]>
git.wh0rd.org - chrome-ext/wake-on-lan.git/blob - js/theme.js
1 // Written by Mike Frysinger <vapier@gmail.com>.
2 // Released into the public domain.
5 * This code is all very simple/dumb. If we want to ever support more
6 * complicated theme logic, then it should be thrown away entirely.
11 function _set_theme(txt
, fg
, bg
, a
) {
14 b
.style
.backgroundColor
= bg
;
16 // This gets a bit tricky as we want to update the style sheet
17 // to quickly apply to all <a> tags.
18 var s
, sheet
, sheets
, r
, rule
, rules
;
19 sheets
= document
.styleSheets
;
20 for (s
= 0; s
< sheets
.length
; ++s
) {
22 rules
= sheet
.cssRules
;
23 for (r
= 0; r
< rules
.length
; ++r
) {
25 if (rule
.selectorText
== 'a') {
32 // We can't set UTF8 text, or set HTML entities directly. Ugh.
33 var span
= document
.createElement('span');
35 $$('input[name=theme]').value
= span
.innerText
;
38 function set_theme(name
) {
40 'light': ['☀', 'black', 'white', 'black'],
41 'dark': ['☼', 'white', 'black', 'grey']
44 _set_theme
.apply(this, themes
[name
]);
45 chrome
.storage
.local
.set({'theme': curr_theme
});
48 function toggle_theme() {
49 if (curr_theme
== 'light')