- Timestamp:
- 09/21/08 15:51:39 (2 months ago)
- Files:
-
- 1 modified
-
websites/twicli/twicli.html (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
websites/twicli/twicli.html
r19645 r19669 38 38 #user_info td { font-size: small; } 39 39 --></style> 40 <script >40 <script type="text/javascript"> 41 41 function $(id) { return document.getElementById(id); } 42 42 // クロスドメインJavaScript呼び出し … … 73 73 }; 74 74 var xds = new XDomainScript; 75 // 動的にフレームを生成してPOSTを投げる 76 var postQueue = []; 77 function enqueuePost(url, done, err) { 78 postQueue.push([url, done, err]); 79 if (postQueue.length > 1) // 複数リクエストを同時に投げないようキューイング 80 return; 81 postNext(); 82 } 83 function postNext() { 84 if (postQueue.length) { 85 postInIFrame(postQueue[0][0], postQueue[0][1], postQueue[0][2]); 86 } 87 } 88 var postSeq = 0; 89 function postInIFrame(url, done, err) { 90 var frm = document.createElement("form"); // POST用のフォームを生成 91 frm.action = url; 92 frm.method = "POST"; 93 frm.target = "pfr" + seq; 94 document.body.appendChild(frm); 95 var pfr = document.createElement("iframe"); // formのtargetとなるiframeを生成 96 pfr.name = "pfr" + seq; 97 pfr.src = "about:blank"; 98 pfr.style.display = "block"; 99 pfr.style.position = "absolute"; 100 pfr.style.width = 300; 101 pfr.style.height = 200; 102 pfr.style.top = 100; 103 pfr.style.left = 200; 104 var errTimer = false; 105 if (err) { // 10秒で正常終了しなければエラーとみなす 106 errTimer = setTimeout(function(){ 107 err(); 108 frm.parentNode.removeChild(frm); 109 pfr.parentNode.removeChild(pfr); 110 postQueue.shift(); 111 postNext(); 112 }, 100000); 113 } 114 var cnt = 0; 115 var onload = pfr.onload = function(){ 116 if (cnt++ == 0) { 117 setTimeout(function(){frm.submit();}, 0); 118 } else { 119 clearTimeout(errTimer); 120 done(); 121 setTimeout(function(){ 122 frm.parentNode.removeChild(frm); 123 pfr.parentNode.removeChild(pfr); 124 postQueue.shift(); 125 postNext(); 126 }, 0); 127 } 128 }; 129 document.body.appendChild(pfr); 130 } 75 131 // 要素の位置を取得 76 132 function cumulativeOffset(ele) { … … 118 174 <body onLoad="init()"> 119 175 <div id="control"> 120 <iframe name="tx" ></iframe>176 <iframe name="tx" onload="update()"></iframe> 121 177 <!--発言フォーム--> 122 178 <form name="frm" action="http://twitter.com/statuses/update.xml" method="POST" target="tx"> 123 <textarea id="fst" type="text"name="status" onkeyup="if (this.value.indexOf('\n') >= 0) return press(1)" onkeypress="return press(event)"></textarea>179 <textarea id="fst" name="status" onkeyup="if (this.value.indexOf('\n') >= 0) return press(1)" onkeypress="return press(event)"></textarea> 124 180 <input type="hidden" name="source" value="twicli"> 125 181 <a id="go" href="javascript:void press(1)"><img src="go.png"></a> 126 182 <a id="rst" href="javascript:void resetFrm()"><img src="clr.png"></a> 127 183 <div id="loading"><img src="loading.gif"></div></form> 128 <!--fav/followフォーム-->129 <form name="favf" action="" method="POST" target="tx"></form>130 184 <!--メニュー--> 131 185 <div id="menu"> … … 174 228 var get_next_func; 175 229 176 // ローディング表示ON、twit更新177 function reload(to) {178 $("loading").style.display = "block";179 setTimeout(update, to);180 }181 230 // enterキーで発言 182 231 function press(e) { … … 184 233 document.frm.status.value = document.frm.status.value.replace(/\n/g, ""); 185 234 if (document.frm.status.value == '') { // 空欄であればTimeline更新のみ 186 reload(0); 235 $("loading").style.display = "block"; 236 update(); 187 237 return false; 188 238 } … … 192 242 document.frm.status.select(); 193 243 setTimeout(resetFrm, 10); // twit送信後にフォームをクリア 194 reload(3000); // 送信3秒後にTimelineを更新195 244 document.frm.submit(); 196 245 } … … 216 265 function replyTo(user, id) { 217 266 in_reply_to_user = user; 218 document.frm.status.value += "@" + user + " ";267 document.frm.status.value = "@" + user + " " + document.frm.status.value; 219 268 setReplyId(id); 220 269 document.frm.status.select(); … … 306 355 // favoriteの追加(f=true)/削除(f=false) 307 356 function fav(img, id) { 357 if (img.src.indexOf('throbber') >= 0) return; 308 358 var f = img.src.indexOf('empty') >= 0; 309 document.favf.action = 'http://twitter.com/favourings/' + (f ? 'create' : 'destroy') + '/' + id + '.xml'; 310 document.favf.submit(); 311 img.src = 'http://assets3.twitter.com/images/icon_star_' + (f ? 'full' : 'empty') + '.gif'; 359 img.src = 'http://twitter.com/images/icon_throbber.gif'; 360 enqueuePost('http://twitter.com/favourings/' + (f ? 'create' : 'destroy') + '/' + id + '.xml', 361 function(){ img.src = 'http://assets3.twitter.com/images/icon_star_' + (f ? 'full' : 'empty') + '.gif'; }, 362 function(){ img.src = 'http://assets3.twitter.com/images/icon_star_' + (!f ? 'full' : 'empty') + '.gif'; }); 312 363 } 313 364 // followとremove 314 365 function follow(f) { 315 document.favf.action = 'http://twitter.com/friendships/' + (f ? 'create' : 'destroy') + '/' + last_user + '.xml'; 316 document.favf.submit(); 366 enqueuePost('http://twitter.com/friendships/' + (f ? 'create' : 'destroy') + '/' + last_user + '.xml', switchUser); 317 367 $("loading").style.display = "block"; 318 setTimeout(switchUser, 3000);319 368 } 320 369 // 自分の最新の発言を受信
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)