This commit is contained in:
Zixaphir 2013-08-25 11:16:59 -07:00
parent 82d43423c5
commit 44f83a756a
3 changed files with 74 additions and 40 deletions

View File

@ -14394,7 +14394,7 @@
Settings = { Settings = {
init: function() { init: function() {
var el, settings; var addSection, check, el, key, settings, value, _ref;
el = $.el('a', { el = $.el('a', {
className: 'settings-link', className: 'settings-link',
@ -14431,24 +14431,37 @@
} }
return $.set('previousversion', g.VERSION); return $.set('previousversion', g.VERSION);
}); });
Settings.addSection('Style', Settings.style); addSection = Settings.addSection;
Settings.addSection('Themes', Settings.themes); _ref = {
Settings.addSection('Mascots', Settings.mascots); 'style': 'Style',
Settings.addSection('Script', Settings.main); 'themes': 'Themes',
Settings.addSection('Filter', Settings.filter); 'mascots': 'Mascots',
Settings.addSection('Sauce', Settings.sauce); 'main': 'Script',
Settings.addSection('Advanced', Settings.advanced); 'filter': 'Filter',
Settings.addSection('Keybinds', Settings.keybinds); 'sauce': 'Sauce',
'advanced': 'Advanced',
'keybinds': 'Keybinds'
};
for (key in _ref) {
value = _ref[key];
addSection(value, Settings[key]);
}
$.on(d, 'AddSettingsSection', Settings.addSection); $.on(d, 'AddSettingsSection', Settings.addSection);
$.on(d, 'OpenSettings', function(e) { $.on(d, 'OpenSettings', function(e) {
return Settings.open(e.detail); return Settings.open(e.detail);
}); });
settings = JSON.parse(localStorage.getItem('4chan-settings')) || {}; settings = JSON.parse(localStorage.getItem('4chan-settings')) || {};
if (settings.disableAll) { if (!settings.disableAll) {
return; settings.disableAll = true;
check = true;
}
if (settings.keyBinds) {
settings.keyBinds = false;
check = true;
}
if (check) {
return localStorage.setItem('4chan-settings', JSON.stringify(settings));
} }
settings.disableAll = true;
return localStorage.setItem('4chan-settings', JSON.stringify(settings));
}, },
open: function(openSection) { open: function(openSection) {
var dialog, link, links, overlay, section, sectionToOpen, _i, _len, _ref; var dialog, link, links, overlay, section, sectionToOpen, _i, _len, _ref;

View File

@ -14388,7 +14388,7 @@
Settings = { Settings = {
init: function() { init: function() {
var el, settings; var addSection, check, el, key, settings, value, _ref;
el = $.el('a', { el = $.el('a', {
className: 'settings-link', className: 'settings-link',
@ -14425,24 +14425,37 @@
} }
return $.set('previousversion', g.VERSION); return $.set('previousversion', g.VERSION);
}); });
Settings.addSection('Style', Settings.style); addSection = Settings.addSection;
Settings.addSection('Themes', Settings.themes); _ref = {
Settings.addSection('Mascots', Settings.mascots); 'style': 'Style',
Settings.addSection('Script', Settings.main); 'themes': 'Themes',
Settings.addSection('Filter', Settings.filter); 'mascots': 'Mascots',
Settings.addSection('Sauce', Settings.sauce); 'main': 'Script',
Settings.addSection('Advanced', Settings.advanced); 'filter': 'Filter',
Settings.addSection('Keybinds', Settings.keybinds); 'sauce': 'Sauce',
'advanced': 'Advanced',
'keybinds': 'Keybinds'
};
for (key in _ref) {
value = _ref[key];
addSection(value, Settings[key]);
}
$.on(d, 'AddSettingsSection', Settings.addSection); $.on(d, 'AddSettingsSection', Settings.addSection);
$.on(d, 'OpenSettings', function(e) { $.on(d, 'OpenSettings', function(e) {
return Settings.open(e.detail); return Settings.open(e.detail);
}); });
settings = JSON.parse(localStorage.getItem('4chan-settings')) || {}; settings = JSON.parse(localStorage.getItem('4chan-settings')) || {};
if (settings.disableAll) { if (!settings.disableAll) {
return; settings.disableAll = true;
check = true;
}
if (settings.keyBinds) {
settings.keyBinds = false;
check = true;
}
if (check) {
return localStorage.setItem('4chan-settings', JSON.stringify(settings));
} }
settings.disableAll = true;
return localStorage.setItem('4chan-settings', JSON.stringify(settings));
}, },
open: function(openSection) { open: function(openSection) {
var dialog, link, links, overlay, section, sectionToOpen, _i, _len, _ref; var dialog, link, links, overlay, section, sectionToOpen, _i, _len, _ref;

View File

@ -6,7 +6,7 @@ Settings =
href: 'javascript:;' href: 'javascript:;'
textContent: 'Settings' textContent: 'Settings'
$.on el, 'click', Settings.open $.on el, 'click', Settings.open
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'header' type: 'header'
el: el el: el
@ -30,22 +30,30 @@ Settings =
$.on d, '4chanXInitFinished', Settings.open $.on d, '4chanXInitFinished', Settings.open
$.set 'previousversion', g.VERSION $.set 'previousversion', g.VERSION
Settings.addSection 'Style', Settings.style {addSection} = Settings
Settings.addSection 'Themes', Settings.themes addSection value, Settings[key] for key, value of {
Settings.addSection 'Mascots', Settings.mascots 'style': 'Style'
Settings.addSection 'Script', Settings.main 'themes': 'Themes'
Settings.addSection 'Filter', Settings.filter 'mascots': 'Mascots'
Settings.addSection 'Sauce', Settings.sauce 'main': 'Script'
Settings.addSection 'Advanced', Settings.advanced 'filter': 'Filter'
Settings.addSection 'Keybinds', Settings.keybinds 'sauce': 'Sauce'
'advanced': 'Advanced'
'keybinds': 'Keybinds'
}
$.on d, 'AddSettingsSection', Settings.addSection $.on d, 'AddSettingsSection', Settings.addSection
$.on d, 'OpenSettings', (e) -> Settings.open e.detail $.on d, 'OpenSettings', (e) -> Settings.open e.detail
settings = JSON.parse(localStorage.getItem '4chan-settings') or {} settings = JSON.parse(localStorage.getItem '4chan-settings') or {}
return if settings.disableAll unless settings.disableAll
settings.disableAll = true settings.disableAll = true
localStorage.setItem '4chan-settings', JSON.stringify settings check = true
if settings.keyBinds
# Keybinds persist even with disableAll. Thanks moot.
settings.keyBinds = false
check = true
localStorage.setItem '4chan-settings', JSON.stringify settings if check
open: (openSection) -> open: (openSection) ->
if Conf['editMode'] is "theme" if Conf['editMode'] is "theme"