Skip to content

Commit

Permalink
fixed bug where content scripts were not initially made aware of used…
Browse files Browse the repository at this point in the history
… hotkeys #98
  • Loading branch information
neocotic committed May 23, 2012
1 parent 4ff233b commit 1a0bee1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/lib/background.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ getBrowserVersion = ->
idx = str.indexOf ' '
if idx is -1 then str else str.substring 0, idx

# Build list of shortcuts used by enabled templates.
getHotkeys = ->
log.trace()
template.shortcut for template in ext.templates when template.enabled

# Derive the path of the image used by `template`.
getImagePathForTemplate = (template, relative) ->
log.trace()
Expand Down Expand Up @@ -368,7 +373,11 @@ onRequest = (request, sender, sendResponse) ->
return sendResponse?()
# Info requests are simple, just send some useful information back. Done!
if request.type in ['info', 'version']
return sendResponse? id: EXTENSION_ID, version: ext.version
return sendResponse?(
hotkeys: getHotkeys()
id: EXTENSION_ID
version: ext.version
)
data = null
editable = no
id = utils.keyGen '', null, 't', no
Expand Down Expand Up @@ -584,10 +593,7 @@ showNotification = ->
# (where valid) of each Chrome window.
updateHotkeys = ->
log.trace()
# Build list of shortcuts used by enabled templates.
hotkeys = (
template.shortcut for template in ext.templates when template.enabled
)
hotkeys = getHotkeys()
# Create a runner to help manage the asynchronous aspect.
runner = new utils.Runner()
runner.push chrome.windows, 'getAll', null, (windows) ->
Expand Down
3 changes: 2 additions & 1 deletion src/lib/content.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ paste = (node, value) ->
# Wrap the function functionality in a request for Template's extension ID and
# current version so that it can be used to detect previous injections.
chrome.extension.sendRequest type: 'info', (data) ->
isMac = navigator.userAgent.toLowerCase().indexOf('mac') isnt -1
hotkeys = data.hotkeys
isMac = navigator.userAgent.toLowerCase().indexOf('mac') isnt -1
# Only add the listeners if a previous injection isn't detected for version
# of Template that is currently running.
return if document.body.getAttribute(data.id) is data.version
Expand Down

0 comments on commit 1a0bee1

Please sign in to comment.