From f146e5908bd79dcab4d4afa219af79d4a892b099 Mon Sep 17 00:00:00 2001 From: Tim Morgan Date: Fri, 3 Sep 2010 22:38:45 -0500 Subject: 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. --- background_page.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index 8abe2f9e..6014d4c8 100644 --- a/background_page.html +++ b/background_page.html @@ -68,6 +68,8 @@ getLinkHintCss: getLinkHintCss, openUrlInCurrentTab: openUrlInCurrentTab, openOptionsPageInNewTab: openOptionsPageInNewTab, + registerFrame: registerFrame, + focusFrame: focusFrame, upgradeNotificationClosed: upgradeNotificationClosed, updateScrollPosition: handleUpdateScrollPosition }; @@ -593,6 +595,35 @@ }); } + var framesForTab = {}; + + function registerFrame(request, sender) { + if(request.top) + framesForTab[sender.tab.id] = []; + framesForTab[sender.tab.id].push(request.frameId); + } + + var focusedFrame = null; + function focusFrame(request, sender) { + focusedFrame = request.frameId; + } + + function nextFrame(callback, frameId) { + chrome.tabs.getSelected(null, function(tab) { + //chrome.tabs.sendRequest(tab.id, { name: "showHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }); + var index; + var frames = framesForTab[tab.id]; + for(index=0; index= frames.length-1) + index = 0; + else + index++; + chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[index] }); + }); + } + function init() { clearKeyMappingsAndSetDefaults(); -- cgit v1.2.3