diff options
author | anekos | 2010-07-31 03:30:44 +0000 |
---|---|---|
committer | anekos | 2010-07-31 03:30:44 +0000 |
commit | abfc600e7d14b0383011da6eb5773bfec6b73cd7 (patch) | |
tree | 611f8772a1ecedf0d3eff78ac80ea18d6380d88f | |
parent | adbcae0f527ea1edeea801d6981f77ab55642390 (diff) | |
download | vimperator-plugins-abfc600e7d14b0383011da6eb5773bfec6b73cd7.tar.bz2 |
JSON.parse を使うように
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38063 d0d07461-0603-4401-acd4-de1884942a52
-rwxr-xr-x | twittperator.js | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/twittperator.js b/twittperator.js index 855f91e..c562772 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1069,9 +1069,6 @@ TwitterOauth.prototype = (function() { // ChirpUserStream let ChirpUserStream = (function () { - - const JSON = Cc['@mozilla.org/dom/json;1'].getService(Ci.nsIJSON); - function getUserInfo () { let host = ['http://twitter.com', 'https://twitter.com']; let loginManager = Cc['@mozilla.org/login-manager;1'].getService(Ci.nsILoginManager); @@ -1079,11 +1076,22 @@ let ChirpUserStream = (function () { return login; } - function extractURL (s) let (m = s.match(/https?:\/\/[\S]+/)) (m && m[0]); + function stop () { + let prev = __context__.prev; + + if (!prev) + return; + + clearInterval(prev.interval); + prev.sos.close(); + prev.sis.close(); + + delete __context__.prev; + } function start () { stop(); @@ -1141,7 +1149,7 @@ let ChirpUserStream = (function () { lines[0] = buf + lines[0]; for (let [, line] in Iterator(lines.slice(0, -1))) { try { - onMsg(JSON.decode(line), line); + onMsg(JSON.parse(line), line); } catch (e) {} } buf = lines.slice(-1)[0]; @@ -1157,21 +1165,6 @@ let ChirpUserStream = (function () { }; } - - function stop () { - let prev = __context__.prev; - - if (!prev) - return; - - clearInterval(prev.interval); - prev.sos.close(); - prev.sis.close(); - - delete __context__.prev; - } - - function onMsg (msg, raw) { if (msg.text) { let talk = msg.user.screen_name + ': ' + msg.text; |