From 2ca8fe12911bc0cedbf2fd4f504fe5b1814d205b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 19 Nov 2024 17:21:53 +0100 Subject: [PATCH] www/dbq/html/default.js --- .githooks/pre-commit | 70 ++++++++++++++++++------------------- www/dbq/html/default.js | 5 --- www/dbq/html/default.min.js | 2 +- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a953c4c3..9fb0dc40 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -2,41 +2,39 @@ echo "Run $0" -if which minify > /dev/null; then - MINIFY="" - [ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-css ' && MINIFY="ext" - [ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-output ' && MINIFY="out" - [ -z "$MINIFY" ] || git diff --name-only | while read file; do - ext="" - case "$file" in - *.min.*) continue ;; - *.css) ext=css ;; - *.js) ext=js ;; - *) continue; - esac - min="$(echo "$file" | sed -E 's/\.([^\.]+)$/.min.\1/')" - [ -w "$min" ] || continue - - echo " Minify $file" - - if [ "$MINIFY" = "ext" ]; then - #echo "minify --$ext < "$file" > "$min.tmp"" - minify --$ext < "$file" > "$min.tmp" - elif [ "$MINIFY" = "out" ]; then - #echo "minify "$file" --output "$min.tmp"" - minify "$file" --output "$min.tmp" > /dev/null - fi - - if [ "$?" = "0" ]; then - echo "cat "$min.tmp" > "$min"" - cat "$min.tmp" > "$min" - else - echo "minify FAILED!" - fi - - rm "$min.tmp" - - done -fi +which minify > /dev/null || exit +MINIFY="" +[ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-css ' && MINIFY="ext" +[ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-output ' && MINIFY="out" +[ -z "$MINIFY" ] || git diff --name-only | while read file; do + ext="" + case "$file" in + *.min.*) continue ;; + *.css) ext=css ;; + *.js) ext=js ;; + *) continue; + esac + min="$(echo "$file" | sed -E 's/\.([^\.]+)$/.min.\1/')" + [ -w "$min" ] || continue + + echo " Minify $file" + + if [ "$MINIFY" = "ext" ]; then + #echo "minify --$ext < "$file" > "$min.tmp"" + minify --$ext < "$file" > "$min.tmp" + elif [ "$MINIFY" = "out" ]; then + #echo "minify "$file" --output "$min.tmp"" + minify "$file" --output "$min.tmp" > /dev/null + fi + + if [ "$?" = "0" ]; then + echo "cat "$min.tmp" > "$min"" + else + echo " minify FAILED!" + fi + + rm "$min.tmp" + +done true diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index c3c6b2f4..8e5d2a02 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -9,7 +9,6 @@ function dbqLoad(DBQ) { $('.db-rows form.rm').each(function() { }); - //console.log('LOADED'); NodeList.prototype.forEach = Array.prototype.forEach; var ext = ( window._dbq['param.format'] ? '.'+window._dbq['param.format'] : ''); if ( ext == '.'+window._dbq['default.format'] ) ext=''; @@ -56,10 +55,6 @@ function dbqLoad(DBQ) { e.removeAttribute('name'); e.onchange = function() { this.form.setAttribute('action',window._dbq['db.base']+'/'+this.value+ext); - /* - window.location = this.form.getAttribute('action')+'?table='+e.value; - return false; - */ form_clean(this.form); return this.form.onsubmit(); } diff --git a/www/dbq/html/default.min.js b/www/dbq/html/default.min.js index d88c5229..0d1bab8a 100644 --- a/www/dbq/html/default.min.js +++ b/www/dbq/html/default.min.js @@ -1 +1 @@ -function dbqLoad(e){window._dbq=e,$(".db-rows form.rm").each(function(){}),NodeList.prototype.forEach=Array.prototype.forEach;var t,n=window._dbq["param.format"]?"."+window._dbq["param.format"]:"";n=="."+window._dbq["default.format"]&&(n=""),document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;window._dbq.default_limit!="undefined"&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select[name=format]").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){var e="";return e!=window._dbq["default.format"]&&e!="html"&&(e="."+this.value),this.form.setAttribute("action",window._dbq["table.base"]+e),this.form.onsubmit()}}),e.querySelectorAll("form.menu select[name=table]").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+n),form_clean(this.form),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".bottom")&&document.querySelector(".insert-bottom")&&document.querySelector(".insert-bottom").insertAdjacentHTML("beforebegin",""+document.querySelector(".bottom").outerHTML.replace("bottom","top")),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm'+(window._dbq.perm>=window._dbq.perms.write?'':""))}),document.querySelector("th.delete")&&(t=document.createElement("a"),t.setAttribute("href","#"),t.innerHTML=document.querySelector("th.delete").innerHTML,document.querySelector("th.delete").innerHTML="",t.onclick=function(){var e,n,s,o,a,r,t=document.querySelectorAll("form.rm"),c=document.querySelector(".db-rows")?document.querySelector(".db-rows"):"";c.className="loader";for(j=0;j h1 a.title-nav-db, body > h1 a.title-nav-table").forEach(function(e){var t=e.className.replace("title-nav-",""),s=window._dbq[t+".base"].replace(/\/[^/]+$/,""),i=s+"/ls.json",o=t=="db"?["id","id"]:["name","name"];dbqGet(i,function(i){var r,a=i.select(o[0],o[1],window._dbq["param."+t]);a.onchange=function(){window.location=s+"/"+this.value+n},r=document.getElementById(t),r&&(r.parentNode.style.display="none"),a.className=e.className,e.parentNode.replaceChild(a,e)})})}function form_clean(e){var t;for(i=0;i=300&&console.log("dbqGet: Url not found: "+e),n.readyState===4&&n.status<300){var o={rows:JSON.parse(n.responseText),debug:function(){console.log(o.rows)},select:function(e,t,n="undefined"){var s=document.createElement("select");return o.rows.forEach(function(n){var i=Object.keys(n),o=document.createElement("option");o.value=n[e],o.innerHTML=dbqPrettyText(n[t]),s.appendChild(o)}),n!="undefined"&&(s.value=n),s}};if(!t)return window._dbq.dbqGet=o;if(typeof t=="function")return t(o);if(typeof t=="string"&&t in o)return typeof o[t]=="function"?o[t](o):o[t]}},n.send()}function dbqPrettyText(e){return e=e.replace(/(\b\w)/g,function(e){return e.toUpperCase()}),e=e.replace(/[^a-zA-Z0-9]+/g," "),e}function iframe_embed(e){return console.log(e),!1} \ No newline at end of file +function dbqLoad(e){window._dbq=e,$(".db-rows form.rm").each(function(){}),NodeList.prototype.forEach=Array.prototype.forEach;var t,n=window._dbq["param.format"]?"."+window._dbq["param.format"]:"";n=="."+window._dbq["default.format"]&&(n=""),document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;window._dbq.default_limit!="undefined"&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select[name=format]").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){var e="";return e!=window._dbq["default.format"]&&e!="html"&&(e="."+this.value),this.form.setAttribute("action",window._dbq["table.base"]+e),this.form.onsubmit()}}),e.querySelectorAll("form.menu select[name=table]").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+n),form_clean(this.form),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".bottom")&&document.querySelector(".insert-bottom")&&document.querySelector(".insert-bottom").insertAdjacentHTML("beforebegin",""+document.querySelector(".bottom").outerHTML.replace("bottom","top")),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm'+(window._dbq.perm>=window._dbq.perms.write?'':""))}),document.querySelector("th.delete")&&(t=document.createElement("a"),t.setAttribute("href","#"),t.innerHTML=document.querySelector("th.delete").innerHTML,document.querySelector("th.delete").innerHTML="",t.onclick=function(){var e,n,s,o,a,r,t=document.querySelectorAll("form.rm"),c=document.querySelector(".db-rows")?document.querySelector(".db-rows"):"";c.className="loader";for(j=0;j h1 a.title-nav-db, body > h1 a.title-nav-table").forEach(function(e){var t=e.innerHTML,s=e.className.replace("title-nav-",""),o=window._dbq[s+".base"].replace(/\/[^/]+$/,""),a=o+"/ls.json",i=s=="db"?["id","id"]:["name","name"];dbqGet(a,function(a){var c,l,r=a.select(i[0],i[1],window._dbq["param."+s]),d=0;for(const e of r.options){if(console.log(t+" <> "+e.value),e.value!=t&&e.innerHTML!=t)continue;d=1;break}d||(c=document.createElement("option"),c.value=t,c.innerHTML=dbqPrettyText(t)),r.prepend(c),r.onchange=function(){window.location=o+"/"+this.value+n},l=document.getElementById(s),l&&(l.parentNode.style.display="none"),r.className=e.className,e.parentNode.replaceChild(r,e)})})}function form_clean(e){var t;for(i=0;i=300&&console.log("dbqGet: Url not found: "+e),n.readyState===4&&n.status<300){var o={rows:JSON.parse(n.responseText),debug:function(){console.log(o.rows)},select:function(e,t,n="undefined"){var s=document.createElement("select");return o.rows.forEach(function(n){var i=Object.keys(n),o=document.createElement("option");o.value=n[e],o.innerHTML=dbqPrettyText(n[t]),s.appendChild(o)}),n!="undefined"&&(s.value=n),s}};if(!t)return window._dbq.dbqGet=o;if(typeof t=="function")return t(o);if(typeof t=="string"&&t in o)return typeof o[t]=="function"?o[t](o):o[t]}},n.send()}function dbqPrettyText(e){return e=e.replace(/(\b\w)/g,function(e){return e.toUpperCase()}),e=e.replace(/[^a-zA-Z0-9]+/g," "),e}function iframe_embed(e){return console.log(e),!1} \ No newline at end of file -- 2.47.3