Changeset 36016

Show
Ignore:
Timestamp:
11/28/09 01:10:07 (3 years ago)
Author:
teramako
Message:
  • follow vimperato 2.3
  • check DOM Inspector is installed and enabled
  • fix some format
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/xpathBlink.js

    r35833 r36016  
    1 var PLUGIN_INFO = 
    2 <VimperatorPlugin> 
    3 <name>{NAME}</name> 
    4 <description>blink elements by XPath</description> 
    5 <author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author> 
    6 <require type="extension" id="inspector@mozilla.org">DOM Inspector</require> 
    7 <license>MPL 1.1</license> 
    8 <version>1.0.1</version> 
    9 <minVersion>2.3pre</minVersion> 
    10 <maxVersion>2.3pre</maxVersion> 
    11 <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js</updateURL> 
    12 <detail><![CDATA[ 
    13 for test xpath 
    14  
    15 == Usage== 
    16 :xpathb[link] {expression}: 
    17 :xb {expression} 
    18     blink specified elements with XPath {expression}  
    19  
    20 == Caution == 
    21 It's need "DOM Inspector" addon 
    22 ]]></detail> 
    23 </VimperatorPlugin>; 
     1let INFO = 
     2<plugin name="xpathBlink" version="1.1" 
     3        href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js" 
     4        summary="blink elements by XPath" 
     5        xmlns="http://vimperator.org/namespaces/liberator"> 
     6    <author email="teramako@gmail.com">teramako</author> 
     7    <license href="http://www.mozilla.org/MPL/MPL-1.1.txt">MPL 1.1</license> 
     8    <project name="Vimperator" minVersion="2.2"/> 
     9    <p> 
     10        For test XPath. 
     11    </p> 
     12    <p>CAUTION: This plugin needs "DOM Inspector" addon.</p> 
     13    <item> 
     14        <tags>:xpathb :xpathblink</tags> 
     15        <spec>:xpathb<oa>link</oa> <a>expression</a></spec> 
     16        <description> 
     17            <p> 
     18                blink specified elements with XPath <a>expression</a> 
     19            </p> 
     20        </description> 
     21    </item> 
     22</plugin>; 
    2423 
    2524(function(){ 
    26 const Cc = Components.classes; 
    27 const Ci = Components.interfaces; 
    28 var flasher = null; 
     25let extid = "inspector@mozilla.org"; 
     26if (!Application.extensions.has(extid) || !Application.exntensions.get(extid).enabled){ 
     27    liberator.ecomsg("DOM Inspector is not installed or enabled", 2); 
     28    return; 
     29} 
     30let flasher = null; 
    2931function getFlasher(){ 
    3032        if (!flasher){ 
     
    4042function blink(aNode){ 
    4143        if (aNode.nodeType == 3) aNode = aNode.parentNode; 
    42         var toggle = true; 
    43         var flasher = getFlasher(); 
     44        let toggle = true; 
     45        let flasher = getFlasher(); 
    4446        function setOutline(){ 
    45                 if(toggle){ 
     47                if (toggle){ 
    4648                        flasher.drawElementOutline(aNode); 
    47                 }else { 
     49                } else { 
    4850                        flasher.repaintElement(aNode); 
    4951                } 
    5052                toggle = !toggle; 
    5153        } 
    52         for (var i=1; i<7; ++i){ 
     54        for (let i=1; i<7; ++i){ 
    5355                setTimeout(setOutline, i * 100); 
    5456        } 
     
    5658commands.addUserCommand(['xpathb[link]','xb'],'XPath blink nodes', 
    5759        function(expression){ 
    58                 var result 
     60                let result; 
    5961                try { 
    6062                        result = util.evaluateXPath(expression.string); 
     
    6668                        return; 
    6769                } 
    68                 for (var i=0; i<result.snapshotLength; i++){ 
     70                for (let i=0; i<result.snapshotLength; i++){ 
    6971                        blink(result.snapshotItem(i)); 
    7072                }