From b8dcc90196a94aa494aa3b8ea0846a5ccc803c22 Mon Sep 17 00:00:00 2001
From: anekos
Date: Mon, 9 Apr 2012 02:28:02 +0900
Subject: Provides fresh tags!
---
direct_bookmark.js | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/direct_bookmark.js b/direct_bookmark.js
index 293d64d..0a565f0 100644
--- a/direct_bookmark.js
+++ b/direct_bookmark.js
@@ -3,7 +3,7 @@ var PLUGIN_INFO =
{NAME}
Direct Post to Social Bookmarks
Trapezoid
- 0.16.2
+ 0.17.0
GPL
2.0pre
https://github.com/vimpr/vimperator-plugins/raw/master/direct_bookmark.js
@@ -598,7 +598,22 @@ for Migemo search: require XUL/Migemo Extension
},
};
__context__.services = services;
- __context__.tags = [];
+
+ let (_tags = {}, _empty = true) {
+ __context__.tags = {
+ update: function (atags) {
+ _tags = {};
+ _empty = atags.length === 0;
+ for (let [, t] in Iterator(atags))
+ _tags[t] = true;
+ },
+ add: function (newTag) {
+ _tags[newTag] = true;
+ },
+ get list () Object.keys(_tags),
+ get isEmpty () _empty,
+ };
+ }
function getTagsAsync(onComplete){
var d,first;
@@ -616,7 +631,7 @@ for Migemo search: require XUL/Migemo Extension
d.next(function(tags){
tags = tags.filter(function(e,i,a) a.indexOf(e) == i);
tags.sort();
- __context__.tags = tags;
+ __context__.tags.update(tags);
if (onComplete)
onComplete(tags);
}).error(function(e){liberator.echoerr(e, null, "direct_bookmark.js: ")});
@@ -709,6 +724,8 @@ for Migemo search: require XUL/Migemo Extension
comment = text || '';
}
+ tags.forEach(function (t) __context__.tags.add(t));
+
var url = liberator.modules.buffer.URL;
var title = liberator.modules.buffer.title;
@@ -791,11 +808,11 @@ for Migemo search: require XUL/Migemo Extension
context.fork('MyTags', 0, context, function(context, arg){
context.title = ['My Tag','Description'];
- if(__context__.tags.length == 0){
+ if(__context__.tags.isEmpty){
context.incomplete = true;
getTagsAsync(set.bind(null, context)).call([]);
} else {
- set(context, __context__.tags);
+ set(context, __context__.tags.list);
}
});
},
--
cgit v1.2.3