diff options
author | drry | 2008-09-26 07:01:40 +0000 |
---|---|---|
committer | drry | 2008-09-26 07:01:40 +0000 |
commit | f1d9bb37870a3be5421a618e61e59246b4601437 (patch) | |
tree | a581f11b8003e11eac39e6c857cefcd17b371d31 | |
parent | fd8b3c8fa639211a6e949aa5d67493d0d1daba32 (diff) | |
download | vimperator-plugins-f1d9bb37870a3be5421a618e61e59246b4601437.tar.bz2 |
* 正規表現を削減しました。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19952 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | nico_related_videos.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/nico_related_videos.js b/nico_related_videos.js index 7ce3668..197a67e 100644 --- a/nico_related_videos.js +++ b/nico_related_videos.js @@ -29,15 +29,15 @@ function httpRequest (uri, onComplete) { var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function(){ - if(xhr.readyState == 4){ - if(xhr.status == 200) + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + if (xhr.status == 200) onComplete(xhr.responseXML); else throw new Error(xhr.statusText) } }; - xhr.open("GET", uri, true); + xhr.open('GET', uri, true); xhr.send(null); } @@ -48,7 +48,7 @@ let videos = []; let uri = 'http://www.nicovideo.jp/api/getrelation?sort=p&order=d&video=' + videoId; let xhr = new XMLHttpRequest(); - xhr.open("GET", uri, false); + xhr.open('GET', uri, false); xhr.send(null); let xml = xhr.responseXML; let v, vs = xml.evaluate('//video', xml, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE , null); @@ -71,11 +71,11 @@ 'niconico related videos', function (url) { url = (function () { - if (url == nothing) + if (url == nothing) return 'http://www.nicovideo.jp/'; if (url.match(/^[a-z]{2}\d+$/)) return 'http://www.nicovideo.jp/watch/' + url; - if (!url.match(/http:\/\//)) + if (url.indexOf('http://') == -1) return 'http://www.nicovideo.jp/search/' + encodeURIComponent(url); })() || url; liberator.open(url); |