From bc6c54059d38256b4e05008915f670b4011f1d73 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 22 Mar 2013 17:45:35 +0100 Subject: [PATCH] debug helper fun unfold.debug_dom + various --- plugins/hazelnut/hazelnut.js | 2 +- unfold/js/unfold-helper.js | 23 +++++++++++++++++++++++ unfold/templates/plugin.html | 6 ++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/plugins/hazelnut/hazelnut.js b/plugins/hazelnut/hazelnut.js index 2709af92..5152bc4c 100644 --- a/plugins/hazelnut/hazelnut.js +++ b/plugins/hazelnut/hazelnut.js @@ -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 diff --git a/unfold/js/unfold-helper.js b/unfold/js/unfold-helper.js index 71c5111d..3a76049a 100644 --- a/unfold/js/unfold-helper.js +++ b/unfold/js/unfold-helper.js @@ -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 ""; }, error : function(text){ return ""; }, + + errorDisplay : function (error) { + return '
Notice
  • ' + error + '
'; + return out; + }, + } // global unfold + +// xxx tmp - until all plugins are ported +errorDisplay = unfold.errorDisplay; diff --git a/unfold/templates/plugin.html b/unfold/templates/plugin.html index 56ec1660..7dfbfe20 100644 --- a/unfold/templates/plugin.html +++ b/unfold/templates/plugin.html @@ -1,4 +1,3 @@ -{##} {% if visible %}
{% if togglable %} @@ -11,9 +10,8 @@ +
{# plugin #} {% if visible %} - +{# plugin-toggle #} {% endif %}{# visible #} -{##} -- 2.43.0