/
skin.coffee
36 lines (33 loc) · 1.08 KB
/
skin.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# skin.js
port = null
connect = ->
port = chrome.extension.connect()
port.onMessage.addListener (data) ->
{method, url, statusLine, responseHeaders} = data
#console.log "#{method} <#{url}> #{statusLine}"
#for {name, value} in data.responseHeaders when name is 'Location'
# console.log "#{name}: #{value}"
port.onDisconnect.addListener ->
setTimeout(connect, 1000)
connect()
load = (uri) ->
window.document.title = uri
chrome.tabs.getCurrent (tab) ->
chrome.pageAction.setPopup
popup: 'popup.html?uri='+encodeURIComponent(uri)
tabId: tab.id
chrome.pageAction.show tab.id
kb = tabulator.kb
subject = kb.sym(uri)
tabulator.outline.GotoSubject(subject, true, undefined, true, undefined)
jQuery ->
qs = do ->
r = {}
for elt in window.location.search.substr(1).split('&')
p = elt.split '='
unless p.length is 2
continue
r[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "))
return r
if qs.uri
load qs.uri