diff options
author | anekos | 2010-07-31 08:42:15 +0000 |
---|---|---|
committer | anekos | 2010-07-31 08:42:15 +0000 |
commit | e4f8911eb92c937d5df9d9c792d6f8633fc7c86d (patch) | |
tree | 93faa7987043685b088f75e622666dbf29a9f527 | |
parent | f57774b0b7bc6105f232bbed0f6a0499b8f8aab7 (diff) | |
download | vimperator-plugins-e4f8911eb92c937d5df9d9c792d6f8633fc7c86d.tar.bz2 |
g:twittperator_use_chirp 設定を追加。デフォルトでは ChirpUserStream をオフにしました
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38077 d0d07461-0603-4401-acd4-de1884942a52
-rwxr-xr-x | twittperator.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/twittperator.js b/twittperator.js index ce6708c..b496b27 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1204,6 +1204,10 @@ function xmlhttpRequest(options) { // {{{ } // }}} // Variables {{{ +let setting = { + useChirp: liberator.globalVariables.twittperator_use_chirp +}; + let accessor = storage.newMap("twittperator", { store: true }); accessor.set("clientName", "Twittperator"); accessor.set("consumerKey", "GQWob4E5tCHVQnEVPvmorQ"); @@ -1220,7 +1224,7 @@ if (__context__.hasOwnProperty('history')) { let tw = new TwitterOauth(accessor); plugins.twittperator = tw; -let expiredStatus = false; +let expiredStatus = true; let autoStatusUpdate = !!parseInt(liberator.globalVariables.twittperator_auto_status_update || 0); let statusValidDuration = parseInt(liberator.globalVariables.twitperator_status_valid_duration || 90); let statusRefreshTimer; @@ -1284,39 +1288,33 @@ function showTwitterSearchResult(word) { // {{{ }); } // }}} function getFollowersStatus(target, force, onload) { // {{{ - if (target) { - api = "http://api.twitter.com/1/statuses/user_timeline.json"; - query.screen_name = target; - tw.get(api, query, function(text) { - onload(JSON.parse(text)); - }); - } else { - onload(history); - } - return; - - // TODO 両対応に function setRefresher(){ expiredStatus = false; if (statusRefreshTimer) clearTimeout(statusRefreshTimer); statusRefreshTimer = setTimeout(function() expiredStatus = true, statusValidDuration * 1000); } + if (!force && !expiredStatus && history.length > 0) { - onload(); + onload(history); } else { - let api = "http://api.twitter.com/1/statuses/home_timeline.json", - query = {}; + let api = "http://api.twitter.com/1/statuses/home_timeline.json", query = {}; + if (target) { api = "http://api.twitter.com/1/statuses/user_timeline.json"; query.screen_name = target; } else { query = null; + if (setting.useChirp) { + onload(history); + return; + } } + tw.get(api, query, function(text) { setRefresher(); - history = JSON.parse(text); - onload(); + // TODO 履歴をちゃんと "追記" するようにするようにするべき + onload(history = JSON.parse(text)); }); } } // }}} @@ -1487,7 +1485,9 @@ function setup() { // {{{ } } }, true); - ChirpUserStream.start(); + + if (setting.useChirp) + ChirpUserStream.start(); } // }}} // PIN code を取得して AccessToken を得る前 {{{ function preSetup() { |