forked from kakaroto/Beyond20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.pyj
41 lines (36 loc) · 1.32 KB
/
options.pyj
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
37
38
39
40
41
from elementmaker import E
from settings import options_list, createHTMLOption, initializeSettings, saveSettings
def createOptionList():
options = []
for option in options_list:
child = createHTMLOption(option)
if child:
options.append(child)
$("main").prepend(E.ul(class_="list-group beyond20-options", *options))
def save_settings():
cb = def(settings):
if chrome.runtime.lastError:
console.log('Chrome Runtime Error', chrome.runtime.lastError.message)
else:
chrome.runtime.sendMessage({"action": "settings", "type": "general", "settings": settings})
$('.success').toggleClass('show')
setTimeout(def():
$('.success').toggleClass('show')
, 3000)
saveSettings(cb)
def gotSettings(stored_settings):
$("ul").removeClass("disabled")
def setupHTML():
createOptionList()
$("ul").addClass("disabled")
initializeSettings(gotSettings)
$('#save').bind('click', save_settings)
$('.beyond20-option-input').change(save_settings)
$(".beyond20-options").on("markaChanged", save_settings)
$(document).on('click', 'a', def(ev):
href = this.getAttribute('href')
if len(href) > 0 and href != "#":
window.open(this.href)
return False
)
setupHTML()