From cc76a40ad3a001def2f2a9348bad82453d8fd5d6 Mon Sep 17 00:00:00 2001 From: drry Date: Fri, 21 Mar 2008 02:11:34 +0000 Subject: 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 --- xpathBlink.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 xpathBlink.js (limited to 'xpathBlink.js') 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