diff options
-rw-r--r-- | exopen.js | 41 | ||||
-rw-r--r-- | hash.js | 18 | ||||
-rw-r--r--[-rwxr-xr-x] | nextlink.js | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pluginManager.js | 0 |
4 files changed, 29 insertions, 30 deletions
@@ -77,11 +77,10 @@ escape: ]]></detail> </VimperatorPlugin>; -liberator.plugins.exOpen = (function(){ +liberator.plugins.exOpen = (function() { var global = liberator.globalVariables.exopen_templates; if (!global) { - global = [ - { + global = [{ label: 'vimpnightly', value: 'http://download.vimperator.org/vimperator/nightly/', description: 'open vimperator nightly xpi page', @@ -109,7 +108,7 @@ liberator.plugins.exOpen = (function(){ function openTabOrSwitch(url) { var tabs = gBrowser.mTabs; - for (var i=0, l=tabs.length; i<l ;i++) + for (let i=0, l=tabs.length; i<l; i++) if (tabs[i].linkedBrowser.contentDocument.location.href == url) return (gBrowser.tabContainer.selectedIndex = i); return liberator.open(url, liberator.NEW_TAB); } @@ -117,9 +116,9 @@ liberator.plugins.exOpen = (function(){ function replacer(str, isEscape) { if (!str) return ''; var win = new XPCNativeWrapper(window.content.window); - var sel = '',htmlsel = ''; - var selection = win.getSelection(); - function __replacer(val){ + var sel = '', htmlsel = ''; + var selection = win.getSelection(); + function __replacer(val) { switch (val) { case '%TITLE%': return buffer.title; @@ -128,18 +127,18 @@ liberator.plugins.exOpen = (function(){ case '%SEL%': if (sel) return sel; else if (selection.rangeCount < 1) return ''; - for (var i=0, c=selection.rangeCount; i<c; i++){ - sel += selection.getRangeAt(i).toString(); - } + for (let i=0, c=selection.rangeCount; i<c; (function(r) { + sel += r.toString(); + })(selection.getRangeAt(i++))); return sel; case '%HTMLSEL%': if (htmlsel) return sel; - else if (selection.rangeCount < 1) return ''; + if (selection.rangeCount < 1) return ''; - var serializer = new XMLSerializer(); - for (var i=0, c=selection.rangeCount; i<c; i++){ - htmlsel += serializer.serializeToString(selection.getRangeAt(i).cloneContents()); - } + let serializer = new XMLSerializer(); + for (let i=0, c=selection.rangeCount; i<c; (function(r) { + htmlsel += serializer.serializeToString(r.cloneContents()); + })(selection.getRangeAt(i++))); return htmlsel; } return ''; @@ -152,18 +151,18 @@ liberator.plugins.exOpen = (function(){ var ExOpen = function() this.initialize.apply(this, arguments); ExOpen.prototype = { - initialize: function(){ + initialize: function() { this.createCompleter(); this.registerCommand(); }, - createCompleter: function(){ + createCompleter: function() { this.completer = global.map( function(t) [t.label, util.escapeString((t.description ? t.description + ' - ' : '') + t.value)] ); }, - registerCommand: function(){ + registerCommand: function() { var self = this; - commands.addUserCommand(['exopen'], 'Open byextension url', + commands.addUserCommand(['exopen'], 'Open byextension URL', function(args) self.open(args.string, args.bang), { completer: function(context, args) { context.title = ['Template', 'Description - Value']; @@ -171,7 +170,7 @@ liberator.plugins.exOpen = (function(){ context.completions = self.completer; return; } - let filter = context.filter.toLowerCase(); + var filter = context.filter.toLowerCase(); context.completions = self.completer.filter( function( t ) t[0].toLowerCase().indexOf(filter) == 0 ); } }); @@ -187,7 +186,7 @@ liberator.plugins.exOpen = (function(){ var template = this.find(arg) || {value: arg}; if (typeof template.custom == 'function') { url = template.custom.call(this, template.value); - } else if (template.custom instanceof Array){ + } else if (template.custom instanceof Array) { url = replacer(template.value).replace(template.custom[0], template.custom[1], template.escape); } else { url = replacer(template.value, template.escape); @@ -24,10 +24,10 @@ hash: let Algos = [ ["md2", "MD2 Algorithm"], ["md5", "MD5 Algorithm"], - ["sha1", "SHA1 Algorithm"], - ["sha256", "SHA256 Algorithm"], - ["sha384", "SHA385 Algorithm"], - ["sha512", "SHA512 Algorithm"], + ["sha1", "SHA-1 Algorithm"], + ["sha256", "SHA-256 Algorithm"], + ["sha384", "SHA-385 Algorithm"], + ["sha512", "SHA-512 Algorithm"], ]; function getStream(path) @@ -47,9 +47,9 @@ hash: commands.addUserCommand(["hash"], "hash of file", - function(args){ + function(args) { if (args.length!=2) { - + liberator.echo("usage \":hash md2|md5|sha1|sha256|sha384|sha512 file-path\""); return false; } @@ -67,13 +67,13 @@ hash: let hash = Crypt.finish(false); // convert the binary hash data to a hex string. - let str = [toHexString(hash.charCodeAt(i)) for(i in hash)].join(""); + let str = [toHexString(hash.charCodeAt(i)) for (i in hash)].join(""); util.copyToClipboard(str, true); }, { bang: true, - completer: function (context){ - let args = context.value.split(/\s/); + completer: function (context) { + let args = context.value.split(/\s+/); if (args.length<=2) { context.title = "hash algorithm"; context.completions = Algos; diff --git a/nextlink.js b/nextlink.js index 17a9981..17a9981 100755..100644 --- a/nextlink.js +++ b/nextlink.js diff --git a/pluginManager.js b/pluginManager.js index 20d5ed6..20d5ed6 100755..100644 --- a/pluginManager.js +++ b/pluginManager.js |