diff options
author | portix <none@none> | 2013-03-05 11:54:41 +0100 |
---|---|---|
committer | portix <none@none> | 2013-03-05 11:54:41 +0100 |
commit | 7762d2b27b0cbc8ad5aa6e7cdf2601f1671321e6 (patch) | |
tree | 4d57ee80239908e03b0902c9fac4aeef61c48a7f | |
parent | 5014ba8e7a6f43feb8a419d747b156df0d5838b4 (diff) | |
download | dwb-7762d2b27b0cbc8ad5aa6e7cdf2601f1671321e6.zip |
Fixing formfiller export functions; shorter implementation of util.[un]camelize
-rw-r--r-- | extensions/formfiller | 36 | ||||
-rw-r--r-- | extensions/perdomainsettings | 3 | ||||
-rw-r--r-- | extensions/requestpolicy | 5 | ||||
-rw-r--r-- | extensions/unique_tabs | 5 | ||||
-rw-r--r-- | extensions/userscripts | 6 | ||||
-rw-r--r-- | m4/Makefile | 2 | ||||
-rw-r--r-- | scripts/lib/util.js | 31 |
7 files changed, 36 insertions, 52 deletions
diff --git a/extensions/formfiller b/extensions/formfiller index 4196d198..a0c611c2 100644 --- a/extensions/formfiller +++ b/extensions/formfiller @@ -144,7 +144,6 @@ keepFormdata : false var config = {}; var passWord = null; var formData = null; -var exports = { }; var injectGetForm = function () //{{{ { @@ -285,10 +284,10 @@ function getFormData(callback) //{{{ var data; if (config.useGPG) { - if (data !== null) - return data; - if ((formData = exports.onRead())) - return JSON.parse(formData.replace(/\\"/g, '"')); + if (formData !== null) + return formData; + if ((data = formfiller.exports.onRead())) + return JSON.parse(data.replace(/\\"/g, '"')); if (!config.GPGAgent) getPassWord(); @@ -319,7 +318,7 @@ function getFormData(callback) //{{{ { try { - if ((data = onRead())) + if ((data = formfiller.exports.onRead())) return JSON.parse(data); else return JSON.parse(io.read(config.formData)); @@ -342,11 +341,10 @@ function onWrite() { return false; } function writeFormData(object) //{{{ { var written = true, ret; - io.print("foo"); if (config.useGPG) { var data = JSON.stringify(object).replace(/"/g, "\\\""); - if (exports.onWrite(data)) + if (formfiller.exports.onWrite(data)) return true; if (!(config.GPGAgent || config.GPGKeyID)) { @@ -371,7 +369,7 @@ function writeFormData(object) //{{{ } else { - if (exports.onWrite(config.formData)) + if (formfiller.exports.onWrite(config.formData)) return true; written = io.write(config.formData, "w", JSON.stringify(object, null, 2)); } @@ -476,19 +474,19 @@ function fillForm() //{{{ io.notify("Executed formfiller"); }//}}} -// init {{{ -return { +var formfiller = { defaultConfig : defaultConfig, - exports : exports, + exports : { + onRead : onRead, + onWrite : onWrite, + getForm : getForm, + fillForm : fillForm + }, init : function (c) { config = c; bind(config.scGetForm, getForm, "formfillerGet"); bind(config.scFillForm, fillForm, "formfillerFill"); - exports.config = config; - exports.onRead = onRead; - exports.onWrite = onWrite; - exports.getForm = getForm; - exports.fillForm = fillForm; + this.exports.config = config; return true; }, end : function () { @@ -496,6 +494,8 @@ return { unbind("formfillerFill"); return true; } -}//}}} +}; + +return formfiller; // vim: set ft=javascript: diff --git a/extensions/perdomainsettings b/extensions/perdomainsettings index 5f0b5ab8..91b7e4cc 100644 --- a/extensions/perdomainsettings +++ b/extensions/perdomainsettings @@ -227,7 +227,7 @@ function getDefaultValue(object) } } -return { +var perdomainsettings = { exports : exports, init : function (config) { @@ -251,5 +251,6 @@ return { signals.disconnect(onNavigation); } }; +return perdomainsettings; // vim: set ft=javascript: diff --git a/extensions/requestpolicy b/extensions/requestpolicy index 62e1d81e..4d0a66f3 100644 --- a/extensions/requestpolicy +++ b/extensions/requestpolicy @@ -84,8 +84,6 @@ Block requests from thirdparty domains permanently or just for a session, whitelisting support INFO>*/ -var me = "requestpolicy"; - var defaultConfig = { //<DEFAULT_CONFIG // path to a whitelist @@ -431,7 +429,7 @@ function disconnect() } }); }//}}} -return { +var requestpolicy = { defaultConfig : defaultConfig, init : function(c) { @@ -464,4 +462,5 @@ return { unbind("requestpolicyUnblockAll"); } }; +return requestpolicy; // vim: set ft=javascript: diff --git a/extensions/unique_tabs b/extensions/unique_tabs index cd52c659..3496a1c3 100644 --- a/extensions/unique_tabs +++ b/extensions/unique_tabs @@ -98,7 +98,7 @@ var toggleAutoFocus = function() } }; -return { +var uniqueTabs = { defaultConfig : defaultConfig, init : function(c) { if (c.shortcutRemoveDuplicates || c.commandRemoveDuplicates) @@ -120,6 +120,7 @@ return { disconnectAutoFocus(); return true; } -} +}; +return uniqueTabs; // vim:set ft=javascript: diff --git a/extensions/userscripts b/extensions/userscripts index 689b07de..76709ec3 100644 --- a/extensions/userscripts +++ b/extensions/userscripts @@ -202,7 +202,7 @@ function matchIncludeExclude(frame, items) //{{{ } catch(e) { - extensions.error(me, e); + script.debug(e); } } return false; @@ -535,7 +535,7 @@ function parseScripts(scripts) //{{{ return userscriptsStart(); }//}}} -return { +var userscripts = { init : function (c) { return parseScripts(c ? c.scripts || [] : []); }, @@ -552,4 +552,6 @@ return { } }; +return userscripts; + // vim: set ft=javascript: diff --git a/m4/Makefile b/m4/Makefile index 059872a6..dae54847 100644 --- a/m4/Makefile +++ b/m4/Makefile @@ -16,6 +16,6 @@ $(SETTINGS): settings.m4 @m4 $(M4FLAGS) $< > $@ clean: - $(RM) $(OUTFILES) settings.in + $(RM) $(OUTFILES) .PHONY: clean diff --git a/scripts/lib/util.js b/scripts/lib/util.js index c4ad60f9..ac539614 100644 --- a/scripts/lib/util.js +++ b/scripts/lib/util.js @@ -38,18 +38,9 @@ { if (! text || text.length === 0) return text; - - var c = text.charAt(0); - var uncamelized = c == c.toUpperCase() ? c.toLowerCase() : c; - for (var i=1, l=text.length; i<l; ++i) - { - c = text.charAt(i); - if (c == "-" || c == "_" || c.toUpperCase() != c) - uncamelized += c; - else - uncamelized += "-" + c.toLowerCase(); - } - return uncamelized; + return text.replace(/(.)?([A-Z])/g, function(x, s, m) { + return s ? s + "-" + m.toLowerCase() : m.toLowerCase(); + }); } }, "camelize" : @@ -58,19 +49,9 @@ { if (! text || text.length === 0) return text; - - var camelized = "", c; - for (var i=0, l=text.length; i<l; ++i) - { - c = text.charAt(i); - if (c == "-" || c == "_") { - i++; - camelized += text.charAt(i).toUpperCase(); - } - else - camelized += c; - } - return camelized; + return text.replace(/[-_]+(.)?/g, function(a, b) { + return b ? b.toUpperCase() : ""; + }); } } }); |