Changeset 25492 for lang/javascript/vimperator-plugins
- Timestamp:
- 12/01/08 07:17:10 (6 weeks ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/toggler.js
r25470 r25492 1 /* 1 /** 2 2 * ==VimperatorPlugin== 3 3 * @name toggler … … 41 41 Toggler.prototype = { 42 42 next: function(notUpdate){ 43 letindex = this.index + 1;43 var index = this.index + 1; 44 44 if (index >= this.cmds.length) index = 0; 45 45 if (!notUpdate) this.index = index; … … 47 47 }, 48 48 previous: function(notUpdate){ 49 letindex = this.index - 1;49 var index = this.index - 1; 50 50 if (index < 0) index = this.cmds.length -1; 51 51 if (!notUpdate) this.index = index; … … 53 53 }, 54 54 list: function(){ 55 var data = []; 56 for (var i = 0; i<this.cmds.length; i++){ 57 data.push([i==this.index ? "*":"", this.cmds[i]]); 58 } 55 var data = this.cmds.map(function(cmd, i){ 56 return [i==this.index ? "*" : "", cmd]; 57 }); 59 58 liberator.echo(template.table(this.name, data), true); 60 59 } … … 76 75 }, 77 76 toggle: function(name, isPrevious){ 78 lettoggler = this.get(name);77 var toggler = this.get(name); 79 78 if (!toggler) return; 80 letcmd = isPrevious ? toggler.previous() : toggler.next();79 var cmd = isPrevious ? toggler.previous() : toggler.next(); 81 80 if (cmd instanceof Array){ 82 cmd.forEach(function(str){ 83 liberator.execute(str); 84 }); 81 cmd.forEach(liberator.execute); 85 82 } else if (typeof cmd == "function"){ 86 83 cmd(); … … 94 91 return; 95 92 } 96 for (let iin settings){97 setting s[i].list();93 for each (let setting in settings){ 94 setting.list(); 98 95 } 99 96 } 100 97 }; 101 98 102 commands.addUserCommand([ 'toggle'],'setting toggler',99 commands.addUserCommand(["toggle"],"setting toggler", 103 100 function(args){ 104 101 if (args["-list"] || args.length == 0){ … … 106 103 liberator.plugins.toggler.list(); 107 104 else 108 args.forEach( function(name) liberator.plugins.toggler.list(name));105 args.forEach(liberator.plugins.toggler.list); 109 106 return; 110 107 } … … 119 116 ], 120 117 completer: function(context,args){ 121 letfilter = context.filter.split(/\s+/).pop();122 let reg = new RegExp(filter ? "^" + flter : ".*", "i");118 var filter = context.filter.split(/\s+/).pop(); 119 var reg = new RegExp(filter ? "^" + flter : ""); 123 120 context.title= ["Name", args.bang ? "Previous" : "Next"]; 124 letlist = [];121 var list = []; 125 122 for (let i in settings){ 126 123 let toggler = settings[i]; 127 if (reg.test(i ) && !args.some(function(arg) arg==i))124 if (reg.test(i.toLowerCase()) && !args.some(function(arg) arg==i)) 128 125 list.push([i, args.bang ? toggler.previous(true) : toggler.next(true)]); 129 126 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)