diff options
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/background_page.html b/background_page.html index 4763c0d6..5849bde3 100644 --- a/background_page.html +++ b/background_page.html @@ -369,6 +369,8 @@ function updateOpenTabs(tab) { openTabs[tab.id] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId }; + // Frames are recreated on refresh + delete framesForTab[tab.id]; } function handleUpdateScrollPosition(request, sender) { @@ -575,7 +577,11 @@ refreshedCompletionKeys = true; } else { - repeatFunction(this[registryEntry.command], count, 0, frameId); + if(registryEntry.passCountToFunction){ + this[registryEntry.command](count); + } else { + repeatFunction(this[registryEntry.command], count, 0, frameId); + } } newKeyQueue = ""; @@ -647,7 +653,7 @@ if (!framesForTab[sender.tab.id]) framesForTab[sender.tab.id] = { frames: [] }; - if (request.top) { + if (request.is_top) { focusedFrame = request.frameId; framesForTab[sender.tab.id].total = request.total; } @@ -680,25 +686,29 @@ focusedFrame = request.frameId; } - function nextFrame(callback, frameId) { + function nextFrame(count) { chrome.tabs.getSelected(null, function(tab) { - var index; var frames = framesForTab[tab.id].frames; + var curr_index = getCurrFrameIndex(frames); - for (index=0; index < frames.length; index++) { - if (frames[index].id == focusedFrame) - break; - } + // TODO: Skip the "top" frame (which doesn't actually have a <frame> tag), + // since it exists only to contain the other frames. + var new_index = (curr_index + count) % frames.length; - if (index >= frames.length-1) - index = 0; - else - index++; - - chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[index].id, highlight: true }); + chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[new_index].id, highlight: true }); }); } + function getCurrFrameIndex(frames) { + var index; + for (index=0; index < frames.length; index++) { + if (frames[index].id == focusedFrame) + break; + } + return index; + } + + function init() { clearKeyMappingsAndSetDefaults(); |
