diff options
author | drry | 2008-04-20 16:30:18 +0000 |
---|---|---|
committer | drry | 2008-04-20 16:30:18 +0000 |
commit | 4882dfa0da45968ee447bf87005f40f7b66c884d (patch) | |
tree | a062f2f87d420b1af414a54f476c80fa28c5bacd /direct_bookmark.js | |
parent | 614521bbfff4798942d213afe3856339350fbf9d (diff) | |
download | vimperator-plugins-4882dfa0da45968ee447bf87005f40f7b66c884d.tar.bz2 |
lang/javascript/vimperator-plugins/trunk/direct_bookmark.js:
* `parseHTML()` で `img` も strip から ignore に変更しました。
* ほか。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@10028 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'direct_bookmark.js')
-rw-r--r-- | direct_bookmark.js | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/direct_bookmark.js b/direct_bookmark.js index 125709d..00dc01c 100644 --- a/direct_bookmark.js +++ b/direct_bookmark.js @@ -55,21 +55,21 @@ catch(ex if ex instanceof TypeError){}
- function Deferred () { return (this instanceof Deferred) ? this.init(this) : new Deferred() }
+ function Deferred () this instanceof Deferred ? this.init(this) : new Deferred();
Deferred.prototype = {
init : function () {
this._next = null;
this.callback = {
- ok: function (x) { return x },
+ ok: function (x) x,
ng: function (x) { throw x }
};
return this;
},
- next : function (fun) { return this._post("ok", fun) },
- error : function (fun) { return this._post("ng", fun) },
- call : function (val) { return this._fire("ok", val) },
- fail : function (err) { return this._fire("ng", err) },
+ next : function (fun) this._post("ok", fun),
+ error : function (fun) this._post("ng", fun),
+ call : function (val) this._fire("ok", val),
+ fail : function (err) this._fire("ng", err),
cancel : function () {
(this.canceller || function () {})();
@@ -77,7 +77,7 @@ },
_post : function (okng, fun) {
- this._next = new Deferred();
+ this._next = new Deferred();
this._next.callback[okng] = fun;
return this._next;
},
@@ -92,8 +92,8 @@ }
if (value instanceof Deferred) {
value._next = self._next;
- } else {
- if (self._next) self._next._fire(next, value);
+ } else if (self._next) {
+ self._next._fire(next, value);
}
return this;
}
@@ -188,10 +188,8 @@ if (ignoreTags) {
if (typeof ignoreTags == "string") ignoreTags = [ignoreTags];
var stripTags = [];
- ignoreTags = ignoreTags.filter(function(tag) {
- if (tag[tag.length - 1] == "/") return true;
- stripTags.push(tag);
- }).map(function(tag) tag.replace(/\/$/, ""));
+ ignoreTags = ignoreTags.filter(function(tag) tag[tag.length - 1] == "/" || !stripTags.push(tag))
+ .map(function(tag) tag.replace(/\/$/, ""));
if (stripTags.length > 0) {
stripTags = stripTags.length > 1
? "(?:" + stripTags.join("|") + ")"
@@ -307,7 +305,7 @@ xhr.send(request.toString());
if(xhr.status != 201)
- throw "HatenaBookmark: faild";
+ throw "Hatena Bookmark: faild";
},
tags:function(user,password){
var xhr = new XMLHttpRequest();
@@ -316,13 +314,13 @@ xhr.open("GET","http://b.hatena.ne.jp/my",false);
xhr.send(null);
- var mypage_html = parseHTML(xhr.responseText, ['img', 'script/']);
+ var mypage_html = parseHTML(xhr.responseText, ['img/', 'script/']);
var tags = getElementsByXPath("//ul[@id=\"taglist\"]/li/a",mypage_html);
tags.forEach(function(tag){
hatena_tags.push(tag.innerHTML);
});
- liberator.echo("HatenaBookmark: Tag parsing is finished. Taglist length: " + tags.length);
+ liberator.echo("Hatena Bookmark: Tag parsing is finished. Taglist length: " + tags.length);
return hatena_tags;
},
},
@@ -374,7 +372,7 @@ xhr.send(null);
if(xhr.status != 200)
- throw "LivedoorClip: faild";
+ throw "livedoor clip: faild";
},
tags:function(user,password){
var xhr = new XMLHttpRequest();
@@ -383,13 +381,13 @@ xhr.open("GET","http://clip.livedoor.com/clip/add?link=http://example.example/",false);
xhr.send(null);
- var mypage_html = parseHTML(xhr.responseText, ['img', 'script/']);
+ var mypage_html = parseHTML(xhr.responseText, ['img/', 'script/']);
var tags = getElementsByXPath("id(\"tag_list\")/span",mypage_html);
tags.forEach(function(tag){
ldc_tags.push(tag.textContent);
});
- liberator.echo("LivedoorClip: Tag parsing is finished. Taglist length: " + tags.length);
+ liberator.echo("livedoor clip: Tag parsing is finished. Taglist length: " + tags.length);
return ldc_tags;
},
},
@@ -411,7 +409,7 @@ xhr.send(params);
if(xhr.status != 200)
- throw "GoogleBookmarks: faild";
+ throw "Google Bookmarks: faild";
},
tags:function(user,password) [],
},
|