diff options
author | anekos | 2011-09-07 21:46:18 +0900 |
---|---|---|
committer | anekos | 2011-09-07 21:46:18 +0900 |
commit | 498bb2abfc44bfcfdfabb0006b5b18bef9cec40d (patch) | |
tree | 45356740a153fe29711574711004b5e0b7fc17c3 | |
parent | 18658cabbe0f717c08dcadc55a329b5cd31ffea9 (diff) | |
download | vimperator-plugins-498bb2abfc44bfcfdfabb0006b5b18bef9cec40d.tar.bz2 |
一応保存できるようにした
-rw-r--r-- | my-style.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/my-style.js b/my-style.js index 7a761d4..9452d1f 100644 --- a/my-style.js +++ b/my-style.js @@ -165,7 +165,9 @@ EOM ); } - const Currents = {}; + let Currents = {}; + + const store = storage.newMap(__context__.NAME, {store: true}); function expand (css) css.replace(/\w+/g, function (n) (DefinedStyles.hasOwnProperty(n) ? DefinedStyles[n] : n)); @@ -220,15 +222,17 @@ EOM ]; } + function set (url, css) { + Currents[url] = css; + styles.addSheet(false, StyleNamePrefix + url, url, expand(css)); + } const SubCommands = [ new Command( ['s[et]'], 'Set style', function (args) { - let m = args[0]; - Currents[m] = args.literalArg; - styles.addSheet(false, StyleNamePrefix + m, m, expand(args.literalArg)); + set(args[0], args.literalArg); }, { literal: 1, @@ -257,6 +261,19 @@ EOM literal: 1, completer: styleNameCompleter } + ), + + new Command( + ['p[ermanent]'], + 'Permanent current styles', + function (args) { + store.set('permanent', Currents); + store.save(); + liberator.echo('Permanent current styles'); + }, + { + argCount: '0', + } ) ]; @@ -274,6 +291,11 @@ EOM true ); + Currents = store.get('permanent', {}); + for (let [url, css] in Iterator(Currents)) { + set(url, css); + } + })(); // vim:sw=2 ts=2 et si fdm=marker: |