aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/utils.js13
-rw-r--r--vimiumFrontend.js17
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 4c05610c..7fc2a6b9 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -38,4 +38,17 @@ var utils = {
}
return result;
},
+
+ /*
+ * Takes a dot-notation object string and call the function
+ * that it points to with the correct value for 'this'.
+ */
+ invokeCommandString: function(str, argArray) {
+ var components = str.split('.');
+ var obj = window;
+ for (var i = 0; i < components.length - 1; i++)
+ obj = obj[components[i]];
+ var func = obj[components.pop()];
+ return func.apply(obj, argArray);
+ },
};
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index f552fc5a..3ca5f6a2 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -109,27 +109,14 @@ function initializePreDomReady() {
sendResponse({}); // Free up the resources used by this open connection.
});
- /*
- * Takes a dot-notation object string and call the function
- * that it points to with the correct value for 'this'.
- */
- function invokeCommandString(str, argArray) {
- var components = str.split('.');
- var obj = this;
- for (var i = 0; i < components.length - 1; i++)
- obj = obj[components[i]];
- var func = obj[components.pop()];
- return func.apply(obj, argArray);
- }
-
chrome.extension.onConnect.addListener(function(port, name) {
if (port.name == "executePageCommand") {
port.onMessage.addListener(function(args) {
if (frameId == args.frameId) {
if (args.passCountToFunction) {
- invokeCommandString(args.command, [args.count]);
+ utils.invokeCommandString(args.command, [args.count]);
} else {
- for (var i = 0; i < args.count; i++) { invokeCommandString(args.command); }
+ for (var i = 0; i < args.count; i++) { utils.invokeCommandString(args.command); }
}
}