From c0a4f9294b135db78339531d8c603ee713bab998 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 27 Nov 2009 16:10:07 +0000 Subject: * follow vimperato 2.3 * check DOM Inspector is installed and enabled * fix some format git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36016 d0d07461-0603-4401-acd4-de1884942a52 --- xpathBlink.js | 68 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) (limited to 'xpathBlink.js') diff --git a/xpathBlink.js b/xpathBlink.js index f3c9b3b..2ee15c0 100644 --- a/xpathBlink.js +++ b/xpathBlink.js @@ -1,31 +1,33 @@ -var PLUGIN_INFO = - -{NAME} -blink elements by XPath -teramako -DOM Inspector -MPL 1.1 -1.0.1 -2.3pre -2.3pre -http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js - -; +let INFO = + + teramako + MPL 1.1 + +

+ For test XPath. +

+

CAUTION: This plugin needs "DOM Inspector" addon.

+ + :xpathb :xpathblink + :xpathblink expression + +

+ blink specified elements with XPath expression +

+
+
+
; (function(){ -const Cc = Components.classes; -const Ci = Components.interfaces; -var flasher = null; +let extid = "inspector@mozilla.org"; +if (!Application.extensions.has(extid) || !Application.exntensions.get(extid).enabled){ + liberator.ecomsg("DOM Inspector is not installed or enabled", 2); + return; +} +let flasher = null; function getFlasher(){ if (!flasher){ flasher = Cc['@mozilla.org/inspector/flasher;1'].createInstance(Ci.inIFlasher); @@ -39,23 +41,23 @@ function getFlasher(){ */ function blink(aNode){ if (aNode.nodeType == 3) aNode = aNode.parentNode; - var toggle = true; - var flasher = getFlasher(); + let toggle = true; + let flasher = getFlasher(); function setOutline(){ - if(toggle){ + if (toggle){ flasher.drawElementOutline(aNode); - }else { + } else { flasher.repaintElement(aNode); } toggle = !toggle; } - for (var i=1; i<7; ++i){ + for (let i=1; i<7; ++i){ setTimeout(setOutline, i * 100); } } commands.addUserCommand(['xpathb[link]','xb'],'XPath blink nodes', function(expression){ - var result + let result; try { result = util.evaluateXPath(expression.string); } catch(e) { @@ -65,7 +67,7 @@ commands.addUserCommand(['xpathb[link]','xb'],'XPath blink nodes', liberator.echo('XPath blink: none'); return; } - for (var i=0; i