Skip to content

Instantly share code, notes, and snippets.

@tkawa
Created January 16, 2011 03:27
Show Gist options
  • Save tkawa/781522 to your computer and use it in GitHub Desktop.
Save tkawa/781522 to your computer and use it in GitHub Desktop.
search.js の検索タブでリプライ表示を使えるようにする twicli プラグイン
(function () {
var load_for_tab_original = xds.load_for_tab;
xds.load_for_tab = function (url, callback, callback_key) {
re = /http:\/\/search\.twitter\.com\/search\.json/;
if (re.test(url)) {
url = url.replace(re, 'http://twitter.com/phoenix_search.phoenix');
// できるだけsearch.jsの関数を書き換えないように…と思ったけど断念
/*
var callback_original;
url = url.replace(/callback=(\w+)/, function (match, sub1, offset, s) {
callback_original = sub1;
return 'callback=' + sub1 + 'ViaPhoenix';
});
window[callback_original+'ViaPhoenix'] = function (res) {
res.results = res.statuses;
return window[callback_original].apply(window, arguments);
};
*/
}
return load_for_tab_original.call(this, url, callback, callback_key);
};
})();
// ほとんどコピペ
function twsSearchShow(res, update) {
var tmp = $("tmp");
if (tmp) tmp.parentNode.removeChild(tmp);
if (!update) tws_page++;
var result = res.statuses; // results -> statuses
if (!update && tws_page == 1) {
$('tw2c').innerHTML = '';
}
twShowToNode(result, $("tw2c"), false, !update && tws_page > 1, update, false, update);
if (!update && res.next_page) {
var next = nextButton('next-search');
$("tw2c").appendChild(next);
get_next_func = function(){
var q = res.next_page.match(/(q=[^\&]*)\+exclude%3Anativeretweets/)[1];
xds.load_for_tab('http://twitter.com/phoenix_search.phoenix?'
+ q + '&page=' + encodeURIComponent(res.next_page) // phoenixのパラメータは変な仕様
/* + '&seq=' + (seq++) + '&rpp=' + tws_rpp */
, twsSearchShow);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment