debug helper fun unfold.debug_dom + various
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 22 Mar 2013 16:45:35 +0000 (17:45 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 22 Mar 2013 16:45:35 +0000 (17:45 +0100)
plugins/hazelnut/hazelnut.js
unfold/js/unfold-helper.js
unfold/templates/plugin.html

index 2709af9..5152bc4 100644 (file)
@@ -56,7 +56,7 @@
                 $.subscribe(query_channel,  function(e, query) { hazelnut.set_query(query); });
                 $.subscribe(update_channel, function(e, resources, instance) { hazelnut.set_resources(resources, instance); });
                 $.subscribe(results_channel, $this, function(e, rows) { hazelnut.update_plugin(e,rows); });
-               if (debug) console.log("hazelnut " + this.id + " subscribed to " + query_channel + " " + update_channel + " " + results_channel);
+               if (debug) console.log("hazelnut '" + this.id + "' subscribed to " + query_channel + " " + update_channel + " " + results_channel);
 
             }); // this.each
         }, // init
index 71c5111..3a76049 100644 (file)
@@ -1,8 +1,31 @@
+// various UI oriented utilities
 var unfold = {
+    debug_dom: function (msg,dom,maxdepth) {
+       if (maxdepth===undefined) maxdepth=5;
+       var up=null, counter=0;
+       while (true) {
+           console.log(counter+" "+msg+" id='"+dom.id+"' ["+dom.classList+"]");
+           up=dom.parentNode;
+           counter += 1;
+           if ( (up == null) || (up === dom)) break;
+           if (counter >= maxdepth) { console.log(counter+" "+msg+" -> ..."); break; }
+           dom=up;
+       }
+    },
+
     warning:function(text){ 
        return "<button class='unfold-warning btn btn-warning'>"+text+"</button>"; 
     },
     error : function(text){ 
        return "<button class='unfold-error btn btn-danger'>"+text+"</button>"; 
     },
+
+    errorDisplay : function (error) {
+       return '<div class="error"><dl id="system-message"><dt class="error">Notice</dt><dd class="error message"><ul><li>' + error + '</li></ul></dd></dl></div>';
+    return out;
+    },
+
 } // global unfold
+
+// xxx tmp - until all plugins are ported
+errorDisplay = unfold.errorDisplay;
index 56ec166..7dfbfe2 100644 (file)
@@ -1,4 +1,3 @@
-{#<!--begin {{ classname }}{{ domid }}-->#}
 {% if visible %}
 <div class='plugin-toggle{% if need_spin %} need-spin{% endif %}' id='complete-{{ domid }}'>
 {% if togglable %}
@@ -11,9 +10,8 @@
 
 <div class='plugin {{ classname }}' id='{{ domid }}'{% if not toggled %} style='display:none;'{% endif %}>
 {{ plugin_content|safe }}
-</div><!--plugin {{ classname }}{{ domid }}-->
+</div>{# plugin #}
 
 {% if visible %}
-</div>
+</div>{# plugin-toggle #}
 {% endif %}{# visible #}
-{#<!--end {{ classname }}{{ domid }}-->#}