From c4c28f6e73d3ab1ddfd952e51f5623d164fef165 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 28 Apr 2010 03:29:16 -0700 Subject: [PATCH] header info, better filter saving/loading --- foltor/foltor.coffee | 10 ++++++---- foltor/foltor.js | 21 +++++++++++---------- foltor/header | 3 +++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/foltor/foltor.coffee b/foltor/foltor.coffee index f1bdf1cad..878b90674 100644 --- a/foltor/foltor.coffee +++ b/foltor/foltor.coffee @@ -202,8 +202,9 @@ save: -> filters[value]: {} option: tag('option') option.textContent: value - option.selected: true select.appendChild(option) + option?.selected: true + loadFilters() GM_setValue('filters', JSON.stringify(filters)) remove(div) @@ -230,11 +231,12 @@ addClass: -> del: -> value: @nextElementSibling.value delete filters[value] - saveFilters() + GM_setValue('filters', JSON.stringify(filters)) remove @parentNode for option in select.options if option.value is value remove option + loadFilters() options: -> @@ -288,7 +290,7 @@ options: -> loadFilters: -> - filter: filters[@value] + filter: filters[select.value] inputs: $$('input', box) for input in inputs input.value: filter[input.name] || '' @@ -343,7 +345,7 @@ for field in fields div.appendChild(label) box.appendChild(div) -loadFilters.call(select) +loadFilters() div: tag('div') div.className: 'bottom' diff --git a/foltor/foltor.js b/foltor/foltor.js index b58f885da..b8340d194 100644 --- a/foltor/foltor.js +++ b/foltor/foltor.js @@ -241,10 +241,11 @@ display: none; \ filters[value] = {}; option = tag('option'); option.textContent = value; - option.selected = true; select.appendChild(option); } } + option == undefined ? undefined : option.selected = true; + loadFilters(); GM_setValue('filters', JSON.stringify(filters)); return remove(div); }; @@ -269,17 +270,17 @@ display: none; \ return input.focus(); }; del = function del() { - var _a, _b, _c, _d, option, value; + var _a, _b, _c, option, value; value = this.nextElementSibling.value; delete filters[value]; - saveFilters(); + GM_setValue('filters', JSON.stringify(filters)); remove(this.parentNode); - _a = []; _c = select.options; - for (_b = 0, _d = _c.length; _b < _d; _b++) { - option = _c[_b]; - _a.push(option.value === value ? remove(option) : null); + _b = select.options; + for (_a = 0, _c = _b.length; _a < _c; _a++) { + option = _b[_a]; + option.value === value ? remove(option) : null; } - return _a; + return loadFilters(); }; options = function options() { var _a, a, bar, div, filter, filters, input, opt; @@ -332,7 +333,7 @@ display: none; \ }; loadFilters = function loadFilters() { var _a, _b, _c, _d, filter, input, inputs; - filter = filters[this.value]; + filter = filters[select.value]; inputs = $$('input', box); _a = []; _c = inputs; for (_b = 0, _d = _c.length; _b < _d; _b++) { @@ -386,7 +387,7 @@ display: none; \ div.appendChild(label); box.appendChild(div); } - loadFilters.call(select); + loadFilters(); div = tag('div'); div.className = 'bottom'; _f = ['apply', 'reset', 'options', 'autohide']; diff --git a/foltor/header b/foltor/header index acbfbc2bf..c0657fd39 100644 --- a/foltor/header +++ b/foltor/header @@ -2,6 +2,9 @@ // @name foltor // @namespace aeosynth // @description 4chon foltor +// @version alpha +// @copyright 2010 James Campos +// @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* // ==/UserScript==