aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormitsugu oyama2011-02-18 15:37:13 +0900
committermitsugu oyama2011-02-18 15:37:13 +0900
commit2176f8fae5a39fbdcf3f303b74343f921504ea99 (patch)
tree89c35659b694a676df1bf96c73ed58c49d407bc3
parent59345d949b0378daa1cdddd87b2eeb582357243a (diff)
downloadvimperator-plugins-2176f8fae5a39fbdcf3f303b74343f921504ea99.tar.bz2
add XPath Name Suggestion
-rw-r--r--onclick.js53
1 files changed, 41 insertions, 12 deletions
diff --git a/onclick.js b/onclick.js
index d975efc..c5d6259 100644
--- a/onclick.js
+++ b/onclick.js
@@ -1,6 +1,6 @@
// INFO //
var INFO =
-<plugin name="onclick.js" version="0.1"
+<plugin name="onclick.js" version="0.2"
summary="Emulate onClick event."
href="http://github.com/vimpr/vimperator-plugins/blob/master/onclick.js"
xmlns="http://vimperator.org/namespaces/liberator">
@@ -21,7 +21,7 @@ For Exsample,
js <<EOM
liberator.globalVariables.onclickTable={
'github':'//span[@class="toggle"][1]',
- 'pixiv':'//span[@class="trigger"][1]'
+ 'pixiv' :'//span[@class="trigger"][1]'
};
EOM
]]></code>
@@ -29,10 +29,8 @@ For Exsample,
</item>
</plugin>;
-commands.addUserCommand(
- ['onclick'],
- 'Emulate onClick event.',
- function(args){
+(function(){
+ let onclick=function(args){
if(args.length<1){
liberator.echoerr('Usage: onclick {xpath_id}');
return false;
@@ -78,9 +76,40 @@ commands.addUserCommand(
null //relatedTarget
);
elms[0].dispatchEvent(evt);
- },
- {
- literal: false
- },
- true
-);
+ };
+ let tblSuggest;
+ let comp=function(context, args){
+ context.completions=tblSuggest;
+ };
+ let addSuggestTable=function(){
+ if(liberator.globalVariables.onclickTable==undefined){
+ liberator.echoerr('Not Found XPath Table');
+ return false;
+ }
+ tblSuggest=new Array();
+ let item;
+ let i;
+ for(i in liberator.globalVariables.onclickTable){
+ item=new Array(i,liberator.globalVariables.onclickTable[i]);
+ tblSuggest.push(item);
+ }
+ };
+ let initialize=function(){
+ addSuggestTable();
+ commands.addUserCommand(
+ ['onclick'],
+ 'Emulate onClick event.',
+ onclick,
+ {
+ completer : comp,
+ argCount : 0,
+ hereDoc : false,
+ bang : false,
+ count : false,
+ literal : false
+ },
+ true
+ );
+ }
+ initialize();
+})();