diff options
author | drry | 2008-03-21 02:11:34 +0000 |
---|---|---|
committer | drry | 2008-03-21 02:11:34 +0000 |
commit | cc76a40ad3a001def2f2a9348bad82453d8fd5d6 (patch) | |
tree | d46fb40b49e9f5e3a2a3303fb5943ecfaef2c941 /xpathBlink.js | |
parent | 0d19a1e18f331d8a73a34839947209d1c58949b9 (diff) | |
download | vimperator-plugins-cc76a40ad3a001def2f2a9348bad82453d8fd5d6.tar.bz2 |
lang/javascript/vimperator-plugins/trunk/xpathBlink.js
lang/javascript/vimperator-plugins/trunk/autoIgnoreKey.js
lang/javascript/vimperator-plugins/trunk/copy.js
lang/javascript/vimperator-plugins/trunk/lookupDictionary.js
lang/javascript/vimperator-plugins/trunk/splitBrowser.js
lang/javascript/vimperator-plugins/trunk/gmperator.js:
* 消えたファイルを trunk にコピーしました。
* ほか。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8235 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'xpathBlink.js')
-rw-r--r-- | xpathBlink.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/xpathBlink.js b/xpathBlink.js new file mode 100644 index 0000000..a55c997 --- /dev/null +++ b/xpathBlink.js @@ -0,0 +1,59 @@ +/** + * For vimperator 0.5.3 + * @author teramako teramako@gmail.com + */ +(function(){ +const Cc = Components.classes; +const Ci = Components.interfaces; +var flasher = null; +function getFlasher(){ + if (!flasher){ + flasher = Cc['@mozilla.org/inspector/flasher;1'].createInstance(Ci.inIFlasher); + flasher.color = '#FF0000'; + flasher.thickness = 2; + } + return flasher; +} +/** + * @param {Node} aNode + */ +function blink(aNode){ + if (aNode.nodeType == 3) aNode = aNode.parentNode; + var toggle = true; + var flasher = getFlasher(); + function setOutline(){ + if(toggle){ + flasher.drawElementOutline(aNode); + }else { + flasher.repaintElement(aNode); + } + toggle = !toggle; + } + for (var i=1; i<7; ++i){ + setTimeout(setOutline, i * 100); + } +} +vimperator.commands.add(new vimperator.Command(['xpathb[link]','xb'], + function(expression){ + var result + try { + result = vimperator.buffer.evaluateXPath(expression); + } catch(e) { + vimperator.echoerr('XPath blink: ' + e); + } + if (!result.snapshotLength){ + vimperator.echo('XPath blink: none'); + return; + } + for (var i=0; i<result.snapshotLength; i++){ + blink(result.snapshotItem(i)); + } + },{ + usage: ['xpathb[link] [EXPRESSION]','xb [EXPERSSION]'], + shortHelp: 'XPath blink nodes', + help: 'Search nodes with XPath [EXPRESSION] and blink the nodes' + } +)); +})(); + +// vim: set fdm=marker sw=4 ts=4 et: |