aboutsummaryrefslogtreecommitdiffstats
path: root/xpathBlink.js
diff options
context:
space:
mode:
authorteramako2009-11-27 16:10:07 +0000
committerteramako2009-11-27 16:10:07 +0000
commitc0a4f9294b135db78339531d8c603ee713bab998 (patch)
tree9669558cdc9a4e2871949b59abb21ad74fc4a5b9 /xpathBlink.js
parent4311f86991555f397d2075d3131b87d9f14282f6 (diff)
downloadvimperator-plugins-c0a4f9294b135db78339531d8c603ee713bab998.tar.bz2
* 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
Diffstat (limited to 'xpathBlink.js')
-rw-r--r--xpathBlink.js68
1 files changed, 35 insertions, 33 deletions
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 =
-<VimperatorPlugin>
-<name>{NAME}</name>
-<description>blink elements by XPath</description>
-<author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author>
-<require type="extension" id="inspector@mozilla.org">DOM Inspector</require>
-<license>MPL 1.1</license>
-<version>1.0.1</version>
-<minVersion>2.3pre</minVersion>
-<maxVersion>2.3pre</maxVersion>
-<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js</updateURL>
-<detail><![CDATA[
-for test xpath
-
-== Usage==
-:xpathb[link] {expression}:
-:xb {expression}
- blink specified elements with XPath {expression}
-
-== Caution ==
-It's need "DOM Inspector" addon
-]]></detail>
-</VimperatorPlugin>;
+let INFO =
+<plugin name="xpathBlink" version="1.1"
+ href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js"
+ summary="blink elements by XPath"
+ xmlns="http://vimperator.org/namespaces/liberator">
+ <author email="teramako@gmail.com">teramako</author>
+ <license href="http://www.mozilla.org/MPL/MPL-1.1.txt">MPL 1.1</license>
+ <project name="Vimperator" minVersion="2.2"/>
+ <p>
+ For test XPath.
+ </p>
+ <p>CAUTION: This plugin needs "DOM Inspector" addon.</p>
+ <item>
+ <tags>:xpathb :xpathblink</tags>
+ <spec>:xpathb<oa>link</oa> <a>expression</a></spec>
+ <description>
+ <p>
+ blink specified elements with XPath <a>expression</a>
+ </p>
+ </description>
+ </item>
+</plugin>;
(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<result.snapshotLength; i++){
+ for (let i=0; i<result.snapshotLength; i++){
blink(result.snapshotItem(i));
}
},{}