From 0aa336cce354db2f3320409259dac61f8b015be4 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 3 Feb 2016 17:59:27 +0100 Subject: [PATCH] moved fieldify in a separate repo --- INSTALL.sh | 37 ++++++------ web/fieldify.js | 156 ------------------------------------------------ 2 files changed, 20 insertions(+), 173 deletions(-) delete mode 100644 web/fieldify.js diff --git a/INSTALL.sh b/INSTALL.sh index 36e2f70..83884f6 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -92,7 +92,7 @@ function searchetc() { # # MAIN # -declare -a nam +declare -a nam nam_gz if [ "$1" = "chk" ]; then set -e oldifs="$IFS" @@ -120,35 +120,32 @@ if [ "$1" = "pkg" ]; then else tag="$(git describe)" fi - nam_idx=0 - nam[$nam_idx]="brisk_${tag}.tgz" - nam_idx=$((nam_idx + 1)) - nam[$nam_idx]="brisk-img_${tag}.tgz" + nam=("brisk" "brisk-img" "fieldify") + nam_idx=3 if [ -d ../curl-de-sac ]; then + nam[$nam_idx]="curl-de-sac" nam_idx=$((nam_idx + 1)) - nam[$nam_idx]="curl-de-sac_${tag}.tgz" fi pkg_list="" sep="" - for i in ${nam[@]}; do - pkg_list="${pkg_list}${sep}${i}" + for i in $( seq 0 $((${#nam[@]} - 1)) ); do + echo "$i" + nam_gz[$i]="${nam[$i]}_${tag}.tgz" + pkg_list="${pkg_list}${sep}${nam_gz[$i]}" sep=", " done - echo "Build packages ${pkg_list}." + + echo "Build packages ${pkg_list} ." read -p "Proceed [y/n]: " a if [ "$a" != "y" -a "$a" != "Y" ]; then exit 1 fi - git archive --format=tar --prefix=brisk-${tag}/brisk/ $tag | gzip > ../$nam1 - cd ../brisk-img - git archive --format=tar --prefix=brisk-${tag}/brisk-img/ $tag | gzip > ../$nam2 - cd - - if [ -d ../curl-de-sac ]; then - cd ../curl-de-sac - git archive --format=tar --prefix=brisk-${tag}/curl-de-sac/ $tag | gzip > ../$nam3 + for i in $( seq 0 $((${#nam[@]} - 1)) ); do + cd "../${nam[$i]}" + git archive --format=tar --prefix=brisk-${tag}/${nam[$i]}/ $tag | gzip > ../${nam_gz[$i]} cd - - fi + done exit 0 fi @@ -427,6 +424,12 @@ sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path document_root="$(grep DocumentRoot "${apache_conf}" | grep -v '^[ ]*#' | awk '{ print $2 }')" sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}__/spush/*.ph* +if [ -d ../fieldify ]; then + pw="$PWD" + cd ../fieldify + ./INSTALL.sh -s "$pw" -w ${web_path}__ + cd - >/dev/null 2>&1 +fi if [ -d ../brisk-img ]; then cd ../brisk-img ./INSTALL.sh -w ${web_path}__ diff --git a/web/fieldify.js b/web/fieldify.js deleted file mode 100644 index fdc9795..0000000 --- a/web/fieldify.js +++ /dev/null @@ -1,156 +0,0 @@ -function ends_with(s, suffix) -{ - if (s.indexOf(suffix, s.length - suffix.length) !== -1) { - return true; - } - return false; -} - -function __ffa_nav(obj, ret, name) -{ - var arr; - - arr = obj.className.split(" "); - if (arr.indexOf(name + "_id") != -1) { - ret.push(obj); - return; - } - - // check if the current element is a leaf or a node - // if it is then return - for (var i = 0 ; i < arr.length ; i++) { - if (ends_with(arr[i], "_id")) { - return; - } - } - - for (var i = 0 ; i < obj.children.length ; i++) { - __ffa_nav(obj.children[i], ret, name); - } - return; -} - -function fieldify_get_dom_element(objarr, name) -{ - var obj, ret = []; - - for (var i = 0 ; i < objarr.length ; i++) { - obj = objarr[i]; - for (var e = 0 ; e < obj.children.length ; e++) { - __ffa_nav(obj.children[e], ret, name); - } - } - - if (ret.length > 0) { - return ret; - } - return false; -} - -// fieldsdescr = { name: { type: 'typename' }, ... } -function Fieldify(dom_elements, fieldsdescr) -{ - var item; - - this.dom_elements = dom_elements; - this.field = new Array(); - for (k in fieldsdescr) { - this.field[k] = fieldsdescr[k]; - if (this.field[k].type == 'fields') { - if (item = fieldify_get_dom_element(this.dom_elements, k)) { - this.field[k].obj = new Fieldify(item, this.field[k].fields); - } - } - } -} - -Fieldify.prototype = { - dom_elements: null, - field: null, - - visible: function(is_visible) { - this.dom_elements[0].style.visibility = (is_visible ? "visible" : "hidden" ); - }, - - // { 'name': 'value' } - json2dom: function(field_values) - { - for (k in this.field) { - if (this.field[k].type == 'value') { - this.fld_value_set(k, field_values[k]); - } - else if (this.field[k].type == 'radio') { - this.fld_radio_set(k, field_values[k]); - } - else if (this.field[k].type == 'fields') { - this.field[k].obj.json2dom(field_values[k]); - } - } - }, - - dom2json: function() - { - var ret = {}; - for (k in this.field) { - if (this.field[k].perms == 'ro') - continue; - if (this.field[k].type == 'value') { - ret[k] = this.fld_value_get(k); - } - else if (this.field[k].type == 'radio') { - ret[k] = this.fld_radio_get(k); - } - else if (this.field[k].type == 'fields') { - ret[k] = this.field[k].obj.dom2json(); - } - } - return ret; - }, - - fld_value_set: function(name, value) - { - var item = fieldify_get_dom_element(this.dom_elements, name); - if (item) { - item[0].innerHTML = value; - } - }, - - fld_value_get: function(name) - { - var item = fieldify_get_dom_element(this.dom_elements, name); - if (item) { - return (item[0].innerHTML); - } - return false; - }, - - fld_radio_set: function(name, value) - { - var arr = fieldify_get_dom_element(this.dom_elements, name); - if (arr) { - for (k in arr) { - if (arr[k].value == value) - arr[k].checked = true; - else - arr[k].checked = false; - } - } - }, - - fld_radio_get: function(name) - { - var ret = null; - var arr = fieldify_get_dom_element(this.dom_elements, name); - if (arr) { - for (k in arr) { - if (arr[k].checked == true) { - ret = arr[k].value; - break; - } - } - } - return ret; - }, - - tap: null -} -- 2.17.1