Changeset 36076
- Timestamp:
- 12/06/09 03:27:16 (3 years ago)
- Files:
-
- 1 modified
-
websites/twicli/twicli.html (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
websites/twicli/twicli.html
r36024 r36076 27 27 #menu a.new { background-color: #fcc; } 28 28 29 #tw, #tw2 { position: absolute; left: 0px; top: 54px; width: 100%; font-size: small; } 29 .tw { position: absolute; left: 0px; top: 54px; width: 100%; font-size: small; } 30 #re { display: none; } 30 31 #tw2 { background-color: #ffd; display: none; min-height: 448px; } 31 32 #tw > div { border-bottom: 1px solid #777; } 32 #tw > div > div, #tw2c> div > div { padding: 1px; border-bottom: 1px solid #999; }33 .tw-parent > div > div { padding: 1px; border-bottom: 1px solid #999; } 33 34 .dummy { border-bottom: 0; padding: 0; height: 0; clear: both; } 34 35 .uicon { float: left; width: 32px; height: 32px; } … … 50 51 .lock { position: relative; top: 2px; left: 0; } 51 52 .close { color: red; } 52 #get_old, #next { text-align: center; background-color: #999; color: #fec; cursor: pointer; }53 .get-next { text-align: center; background-color: #999; color: #fec; cursor: pointer; } 53 54 #rep { display: none; background-color: #fee; position: absolute; width: 90%; left: 4%; top: 200px; border: 4px solid #666; z-index: 2; padding: 2px; font-size: small; } 54 55 #reps { margin-top: 5px; } … … 71 72 #menu a { padding: 1px 5px; height: 22px; line-height: 22px; } 72 73 #menu a.sel { height: 24px; } 73 #tw, #tw2{ margin-top: 5px; }74 .tw { margin-top: 5px; } 74 75 } 75 76 --></style> … … 83 84 $("menu").style.top = $("counter-div").style.top = h+3+exh*5; 84 85 $("control").style.height = h+23+exh*5; 85 $("tw").style.top = $("tw2").style.top = h+24+exh*4;86 $("tw").style.top = $("tw2").style.top = $("re").style.top = h+24+exh*4; 86 87 } 87 88 // 文字参照をデコード … … 269 270 </div> 270 271 <!--メインタイムライン--> 271 <div id="tw"></div> 272 <!--TL以外のタブ--> 273 <div id="tw2"><div id="tw2h"></div><div id="tw2c"></div></div> 272 <div id="tw" class="tw tw-parent"></div> 273 <!--Reply--> 274 <div id="re" class="tw tw-parent"></div> 275 <!--TL,Re以外のタブ--> 276 <div id="tw2" class="tw"><div id="tw2h"></div><div id="tw2c" class="tw-parent"></div></div> 274 277 <!--返信--> 275 278 <div id="rep"><a href="javascript:closeRep()" class="close"><img alt="×" src="clr.png"></a> … … 301 304 pluginstr = pluginstr.substr(1); 302 305 var plugins = new Array; 303 var nr_limit = parseInt(readCookie('limit')) || 500; // 表示する発言数の上限304 var max_count = (cookieVer>3) && parseInt(readCookie('max_count')) || 50;305 var max_count_u = parseInt(readCookie('max_count_u')) || 50;306 var max_count = Math.min((cookieVer>3) && parseInt(readCookie('max_count')) || 50, 200); 307 var max_count_u = Math.min(parseInt(readCookie('max_count_u')) || 50, 200);; 308 var nr_limit = Math.max(max_count*2.5, parseInt(readCookie('limit')) || 500); // 表示する発言数の上限 306 309 var no_since_id = parseInt(readCookie('no_since_id') || "0"); // since_idを使用しない 307 310 var no_counter = parseInt(readCookie('no_counter') || "0"); // 発言文字数カウンタを無効化 … … 313 316 var nr_tw = 0; // 現在のTLの発言数 314 317 var cur_page = 1; // 現在表示中のページ 315 var nr_page = 0; // 次に取得するページ 318 var nr_page = 0; // 次に取得するページ 319 var nr_page_re = 0; // 次に取得するページ(reply用) 316 320 var get_next_func = getOldTL; // 次ページ取得関数 317 321 var since_id = null; // TLの最終since_id … … 319 323 var in_reply_to_user = null; // 発言の返信先 320 324 var tl_oldest_id = null; // TLの最も古いid 321 var last_replies = []; // 受信した返信322 325 // クロスドメイン通信関連 323 326 var seq = (new Date).getTime(); … … 328 331 var update_ele2 = null; 329 332 var reply_ele = null; 333 var reply_ele2 = null; 330 334 var direct_ele1 = null; 331 335 var direct_ele2 = null; … … 612 616 var ret = document.createElement('div'); 613 617 ret.id = id; 618 ret.className = 'get-next'; 614 619 ret.onclick = function() { getNext(this); }; 615 620 ret.innerHTML = '▽' + (p ? '(' + p + ')' : ''); … … 702 707 } 703 708 // 新着reply受信通知 704 function noticeNewReply( ) {709 function noticeNewReply(replies) { 705 710 if ($("reply").className.indexOf("new") < 0) 706 711 $("reply").className += " new"; 707 callPlugins("noticeNewReply"); 708 if (selected_menu.id == "reply") 709 twShow2(last_replies); 710 } 711 // last_repliesの重複排除・要素数制限 712 function cleanupLastReplies() { 713 var rep_ids = []; 714 for (var i = 0; i < last_replies.length; i++) { 715 if (rep_ids[last_replies[i].id]) { 716 last_replies.splice(i--, 1); 717 } 718 rep_ids[last_replies[i].id] = 1; 719 } 720 last_replies.splice(nr_limit); 712 callPlugins("noticeNewReply", replies); 721 713 } 722 714 // 受信repliesを表示 723 function twReplies(tw ) {715 function twReplies(tw, fromTL) { 724 716 if (tw.error) return alert(tw.error); 725 last_replies = tw.concat(last_replies);726 cleanupLastReplies();727 717 tw.reverse(); 728 718 for (var j in tw) callPlugins("gotNewReply", tw[j]); 729 719 tw.reverse(); 730 var nr = tw.length;731 if (replies_in_tl)732 nr = twShowToNode(tw, $("tw"), false, false, true, false, true);733 if (nr > 0)734 noticeNewReply();735 else if (selected_menu.id == "reply")736 twShow 2(last_replies);737 if ( tw.length > 0) since_id_reply = tw[0].id;720 if (nr_page_re == 0) { 721 nr_page_re = 2; 722 $("re").appendChild(nextButton('get_old_re', nr_page_re)); 723 } 724 twShowToNode(tw, $("re"), false, false, true, false, false, false, fromTL); 725 if (!fromTL && replies_in_tl) 726 twShowToNode(tw, $("tw"), false, false, true, false, true); 727 if (!fromTL && tw.length > 0) since_id_reply = tw[0].id; 738 728 } 739 729 // 受信twitを表示 … … 757 747 twShowToNode(tw, $("tw"), false, false, true, true, true); 758 748 if (tl_oldest_id && update_reply_counter-- <= 0) { 759 update_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) +749 reply_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) + 760 750 '&count=' + (since_id_reply ? 200 : max_count_u) + 761 751 (since_id_reply ? '&since_id='+since_id_reply : '') + 762 752 '&callback=twReplies', 763 update_ele2);753 reply_ele2); 764 754 update_reply_counter = 4; 765 755 } … … 774 764 if (tw.error) return alert(tw.error); 775 765 var tmp = $("tmp"); 766 twShowToNode(tw, $("tw"), false, true, false, false, false, true); 776 767 if (tmp && tmp.parentNode) tmp.parentNode.removeChild(tmp); 777 twShowToNode(tw, $("tw"), false, true, false, false, false, true);778 768 $("tw").appendChild(nextButton('get_old', nr_page)); 769 } 770 function twOldReply(tw) { 771 if (tw.error) return alert(tw.error); 772 var tmp = $("tmp"); 773 twShowToNode(tw, $("re"), false, true, false, false, false, true); 774 if (tmp && tmp.parentNode) tmp.parentNode.removeChild(tmp); 775 $("re").appendChild(nextButton('get_old_re', nr_page_re)); 779 776 } 780 777 function twShow2(tw) { … … 802 799 } 803 800 } 804 function twShowToNode(tw, twNode, no_name, after, animation, check_since, ignore_old, ignore_new ) {801 function twShowToNode(tw, twNode, no_name, after, animation, check_since, ignore_old, ignore_new, weak) { 805 802 $('loading').style.display = 'none'; 806 803 var len = tw.length; … … 810 807 var myname_r = new RegExp("@"+myname+"\\b","i"); 811 808 var nr_show = 0; 812 var need_cleanup_last_replies = false;809 var replies = []; 813 810 for (var i = len-1; i >= 0; i--) { 814 if ($(twNode.id + "-" + tw[i].id)) 815 continue; 811 var duplication = $(twNode.id + "-" + tw[i].id); 812 if (duplication) { 813 if (duplication.weak) 814 duplication.parentNode.removeChild(duplication); 815 else 816 continue; 817 } 816 818 if (ignore_old && tl_oldest_id > tw[i].id) 817 819 continue; … … 824 826 s.screen_name = tw[i].user.screen_name; 825 827 s.tw = tw[i]; // DOMツリーにJSONを記録 828 if (weak) s.weak = true; 826 829 if (tw[i].d_dir == 1 || tw[i].text.match(myname_r)) { 827 830 s.className = "tome"; 828 if (animation) { 829 last_replies.unshift(tw[i]); 830 need_cleanup_last_replies = true; 831 noticeNewReply(); 831 if (animation && !duplication) { 832 replies.push(tw[i]); 832 833 } 833 834 } … … 865 866 if (animation) { 866 867 nr_tw += nr_show; 867 while (nr_tw > nr_limit) { 868 var last_node = twNode.childNodes[twNode.childNodes.length-1]; 869 nr_tw -= last_node.childNodes.length; 870 twNode.removeChild(last_node); 871 } 872 tl_oldest_id = 0; // 最大3ブロックスキャンしてoldest更新(repliesの挿入等により必ずしもID順でない) 873 for (var i = 0; i < 3 && i < twNode.childNodes.length; i++) { 874 var target_block = twNode.childNodes[twNode.childNodes.length-i-1].childNodes; 875 for (var j = 0; j < target_block.length; j++) 876 if (target_block[j].tw && (target_block[j].tw.id < tl_oldest_id || !tl_oldest_id)) 877 tl_oldest_id = target_block[j].tw.id; 868 if (nr_tw > nr_limit) { 869 while (nr_tw > nr_limit) { 870 var last_node = twNode.childNodes[twNode.childNodes.length-1]; 871 nr_tw -= last_node.childNodes.length; 872 twNode.removeChild(last_node); 873 } 874 if (twNode.id == 'TL') { 875 tl_oldest_id = 0; // 最大3ブロックスキャンしてoldest更新(repliesの挿入等により必ずしもID順でない) 876 for (var i = 0; i < 3 && i < twNode.childNodes.length; i++) { 877 var target_block = twNode.childNodes[twNode.childNodes.length-i-1].childNodes; 878 var target_ele = target_block[target_block.length-1]; 879 if (target_ele.tw && (target_ele.tw.id < tl_oldest_id || !tl_oldest_id)) 880 tl_oldest_id = target_ele.tw.id; 881 } 882 } 878 883 } 879 884 } … … 884 889 } 885 890 } 886 if (need_cleanup_last_replies) 887 cleanupLastReplies(); 891 if (replies.length) { 892 if (twNode.id == "tw") 893 twReplies(replies, true); 894 else 895 noticeNewReply(replies); 896 } 888 897 return nr_show; 889 898 } … … 911 920 '&callback=twOld', update_ele2); 912 921 } 922 function getOldReply() { 923 update_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) + 924 '&count=' + max_count_u + '&page=' + (nr_page_re++) + 925 '&callback=twOldReply', update_ele2); 926 } 913 927 function getNextFuncCommon() { 914 928 if (selected_menu.id == "user" && !fav_mode) … … 919 933 update_ele2 = loadXDomainScript(twitterAPI + 'favorites/' + last_user + '.json?seq=' + (seq++) + 920 934 '&page=' + (++cur_page) + '&callback=twShow2', update_ele2); 921 else if (selected_menu.id == "reply")922 update_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) +923 '&count=' + max_count_u + '&page=' + (++cur_page) +924 '&callback=twShow2', update_ele2);925 935 } 926 936 // タイムライン切り替え … … 930 940 selected_menu.className = "sel"; 931 941 $("tw").style.display = id=="TL"?"block":"none"; 942 $("re").style.display = id=="reply"?"block":"none"; 932 943 $("tw2h").innerHTML = ""; 933 944 $("tw2c").innerHTML = ""; 934 $("tw2").style.display = id!="TL" ?"block":"none";945 $("tw2").style.display = id!="TL"&&id!="reply"?"block":"none"; 935 946 $("rep").style.display = "none"; 936 947 scrollTo(0, 1); scrollTo(0, 0); … … 943 954 } 944 955 function switchReply() { 945 if (selected_menu.id == "reply" || last_replies.length == 0) { 956 get_next_func = getOldReply; 957 if (selected_menu.id == "reply") { 946 958 switchTo("reply"); 947 959 $("loading").style.display = "block"; 948 update_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) +949 '&count=' + max_count_u + '&callback=twReplies', update_ele2);960 reply_ele2 = loadXDomainScript(twitterAPI + 'statuses/mentions.json?seq=' + (seq++) + 961 '&count=' + max_count_u + '&callback=twReplies', reply_ele2); 950 962 } else { 951 963 switchTo("reply"); 952 twShow2(last_replies);953 964 } 954 965 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)