header info, better filter saving/loading

This commit is contained in:
James Campos 2010-04-28 03:29:16 -07:00
parent 6fc4fc9423
commit c4c28f6e73
3 changed files with 20 additions and 14 deletions

View File

@ -202,8 +202,9 @@ save: ->
filters[value]: {} filters[value]: {}
option: tag('option') option: tag('option')
option.textContent: value option.textContent: value
option.selected: true
select.appendChild(option) select.appendChild(option)
option?.selected: true
loadFilters()
GM_setValue('filters', JSON.stringify(filters)) GM_setValue('filters', JSON.stringify(filters))
remove(div) remove(div)
@ -230,11 +231,12 @@ addClass: ->
del: -> del: ->
value: @nextElementSibling.value value: @nextElementSibling.value
delete filters[value] delete filters[value]
saveFilters() GM_setValue('filters', JSON.stringify(filters))
remove @parentNode remove @parentNode
for option in select.options for option in select.options
if option.value is value if option.value is value
remove option remove option
loadFilters()
options: -> options: ->
@ -288,7 +290,7 @@ options: ->
loadFilters: -> loadFilters: ->
filter: filters[@value] filter: filters[select.value]
inputs: $$('input', box) inputs: $$('input', box)
for input in inputs for input in inputs
input.value: filter[input.name] || '' input.value: filter[input.name] || ''
@ -343,7 +345,7 @@ for field in fields
div.appendChild(label) div.appendChild(label)
box.appendChild(div) box.appendChild(div)
loadFilters.call(select) loadFilters()
div: tag('div') div: tag('div')
div.className: 'bottom' div.className: 'bottom'

View File

@ -241,10 +241,11 @@ display: none; \
filters[value] = {}; filters[value] = {};
option = tag('option'); option = tag('option');
option.textContent = value; option.textContent = value;
option.selected = true;
select.appendChild(option); select.appendChild(option);
} }
} }
option == undefined ? undefined : option.selected = true;
loadFilters();
GM_setValue('filters', JSON.stringify(filters)); GM_setValue('filters', JSON.stringify(filters));
return remove(div); return remove(div);
}; };
@ -269,17 +270,17 @@ display: none; \
return input.focus(); return input.focus();
}; };
del = function del() { del = function del() {
var _a, _b, _c, _d, option, value; var _a, _b, _c, option, value;
value = this.nextElementSibling.value; value = this.nextElementSibling.value;
delete filters[value]; delete filters[value];
saveFilters(); GM_setValue('filters', JSON.stringify(filters));
remove(this.parentNode); remove(this.parentNode);
_a = []; _c = select.options; _b = select.options;
for (_b = 0, _d = _c.length; _b < _d; _b++) { for (_a = 0, _c = _b.length; _a < _c; _a++) {
option = _c[_b]; option = _b[_a];
_a.push(option.value === value ? remove(option) : null); option.value === value ? remove(option) : null;
} }
return _a; return loadFilters();
}; };
options = function options() { options = function options() {
var _a, a, bar, div, filter, filters, input, opt; var _a, a, bar, div, filter, filters, input, opt;
@ -332,7 +333,7 @@ display: none; \
}; };
loadFilters = function loadFilters() { loadFilters = function loadFilters() {
var _a, _b, _c, _d, filter, input, inputs; var _a, _b, _c, _d, filter, input, inputs;
filter = filters[this.value]; filter = filters[select.value];
inputs = $$('input', box); inputs = $$('input', box);
_a = []; _c = inputs; _a = []; _c = inputs;
for (_b = 0, _d = _c.length; _b < _d; _b++) { for (_b = 0, _d = _c.length; _b < _d; _b++) {
@ -386,7 +387,7 @@ display: none; \
div.appendChild(label); div.appendChild(label);
box.appendChild(div); box.appendChild(div);
} }
loadFilters.call(select); loadFilters();
div = tag('div'); div = tag('div');
div.className = 'bottom'; div.className = 'bottom';
_f = ['apply', 'reset', 'options', 'autohide']; _f = ['apply', 'reset', 'options', 'autohide'];

View File

@ -2,6 +2,9 @@
// @name foltor // @name foltor
// @namespace aeosynth // @namespace aeosynth
// @description 4chon foltor // @description 4chon foltor
// @version alpha
// @copyright 2010 James Campos
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
// @include http://boards.4chan.org/* // @include http://boards.4chan.org/*
// ==/UserScript== // ==/UserScript==