forked from ajmath/Syntaxtic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.coffee
26 lines (20 loc) · 804 Bytes
/
popup.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
settings = chrome.extension.getBackgroundPage().syntaxtic.settings
init = () ->
chrome.tabs.getSelected null, (tab) ->
checkboxes = document.querySelectorAll('.clicker')
for box in checkboxes
blacklist = settings[box.id + "Blacklist"]
box.addEventListener 'click', toggle
box.checked = blacklist.indexOf(tab.url) is -1
toggle = (e) ->
chrome.tabs.getSelected null, (tab) ->
blacklist = settings[e.target.id + "Blacklist"]
if e.target.checked
idx = blacklist.indexOf(tab.url)
blacklist.splice(idx, 1) if idx isnt -1
else
blacklist.push(tab.url)
settings[e.target.id + "Blacklist"] = blacklist
chrome.tabs.executeScript null, {file:"toggle_" + e.target.id + ".js"}
document.addEventListener 'DOMContentLoaded', () ->
init()