aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorTim Morgan2010-09-03 22:38:45 -0500
committerTim Morgan2010-09-03 22:46:20 -0500
commitf146e5908bd79dcab4d4afa219af79d4a892b099 (patch)
treea00c7189c2352f3a7666fde996215ed48b419808 /vimiumFrontend.js
parentf9f5208f4d88873ee55a4c54062920981ad22eb8 (diff)
downloadvimium-f146e5908bd79dcab4d4afa219af79d4a892b099.tar.bz2
Command to go to next frame.
I remapped toggleViewSource to 'gs' and set 'gf' to nextFrame. Sorry this is such a huge commit. This is really the simplest way I can find to allow the extension to track all available frames as well as the currently-focused frame. If Chrome would allow access to window.frames[i], then this could probably be simpler.
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 829ded5e..685e121f 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -67,6 +67,9 @@ function initializePreDomReady() {
hideHelpDialog();
else
showHelpDialog(request.dialogHtml, request.frameId);
+ else if (request.name == "focusFrame")
+ if(frameId == request.frameId)
+ focusThisFrame();
else if (request.name == "refreshCompletionKeys")
refreshCompletionKeys(request.completionKeys);
sendResponse({}); // Free up the resources used by this open connection.
@@ -135,9 +138,32 @@ function initializeWhenEnabled() {
}
/*
- * Give this frame a unique id.
+ * Give this frame a unique id and register with the backend.
*/
frameId = Math.floor(Math.random()*999999999)
+if(window.top == window.self)
+ chrome.extension.sendRequest({handler: "registerFrame", frameId: frameId, top: true});
+else
+ chrome.extension.sendRequest({handler: "registerFrame", frameId: frameId});
+
+/*
+ * The backend needs to know which frame has focus.
+ */
+window.addEventListener("focus", function(e){
+ chrome.extension.sendRequest({handler: "focusFrame", frameId: frameId});
+});
+
+/*
+ * Called from the backend in order to change frame focus.
+ */
+function focusThisFrame() {
+ window.focus();
+ if(document.body) {
+ var borderWas = document.body.style.border;
+ document.body.style.border = '1px solid red';
+ setTimeout(function(){document.body.style.border = borderWas}, 200);
+ }
+}
/*
* Initialization tasks that must wait for the document to be ready.