-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoptions.coffee
More file actions
30 lines (24 loc) · 972 Bytes
/
options.coffee
File metadata and controls
30 lines (24 loc) · 972 Bytes
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
$ = (id) -> document.getElementById id
document.addEventListener "keyup", (event) ->
if event.ctrlKey and event.keyCode == 13
document.activeElement?.blur?()
url = $("url").value.trim()
url = defaultURL unless 0 < url.length
$("url").value = url
chrome.storage.sync.set { url }
chrome.storage.sync.get "url", (items) ->
$("url").value = if items.url? then items.url else defaultURL
$("url").focus()
# From Vimium.
documentReady = do ->
[isReady, callbacks] = [document.readyState != "loading", []]
unless isReady
window.addEventListener "DOMContentLoaded", onDOMContentLoaded = ->
window.removeEventListener "DOMContentLoaded", onDOMContentLoaded
isReady = true
callback() for callback in callbacks
callbacks = null
(callback) -> if isReady then callback() else callbacks.push callback
documentReady ->
versionNumber = $ "versionNumber"
versionNumber.textContent = chrome.runtime.getManifest().version