diff options
Diffstat (limited to 'background_scripts/marks.coffee')
| -rw-r--r-- | background_scripts/marks.coffee | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee new file mode 100644 index 00000000..5b38a381 --- /dev/null +++ b/background_scripts/marks.coffee @@ -0,0 +1,34 @@ +root = window.Marks = {} + +marks = {} + +root.create = (req, sender) -> +  marks[req.markName] = +    tabId: sender.tab.id +    scrollX: req.scrollX +    scrollY: req.scrollY + +chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) -> +  if changeInfo.url? +    removeMarksForTab tabId + +chrome.tabs.onRemoved.addListener (tabId, removeInfo) -> +  # XXX(jez): what about restored tabs? +  removeMarksForTab tabId + +removeMarksForTab = (id) -> +  for markName, mark of marks +    if mark.tabId is id +      delete marks[markName] + +root.goto = (req, sender) -> +  mark = marks[req.markName] +  chrome.tabs.update mark.tabId, selected: true +  chrome.tabs.sendRequest mark.tabId, +    name: "setScrollPosition" +    scrollX: mark.scrollX +    scrollY: mark.scrollY +  chrome.tabs.sendRequest mark.tabId, +    name: "showHUDforDuration", +    text: "Jumped to global mark '#{req.markName}'" +    duration: 1000  | 
