2 var PAUSE_UPDATE = false;
\r
3 var PAUSE_TIMELINE = false;
\r
4 function register() {
\r
5 window.open("signup/index.php", "registerwindow", "height=450, width=550, toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=yes, status=yes")
\r
8 var wtfgfw = window.confirm("Please make sure your proxy is ready to visit Twitter.com before authenticating.");
\r
10 window.location.href = "oauth.php"
\r
13 function leaveWord(num) {
\r
17 var leave = num-$("#textbox").val().length;
\r
19 $("#tip").css("color","#CC0000");
\r
20 $("#tip b").css("color","#CC0000");
\r
21 $("#tip").html("<b>-" + (-leave) + "</b>");
\r
22 $("#tweeting_button").addClass('btn-disabled');
\r
24 $("#tip").css("color","#CCCCCC");
\r
25 $("#tip b").css("color","#CCCCCC");
\r
26 $("#tip").html("<b>" + leave + "</b>");
\r
27 $("#tweeting_button").removeClass('btn-disabled');
\r
30 $("#in_reply_to").val("");
\r
31 $("#tweeting_button").addClass('btn-disabled');
\r
34 var formHTML = '<span id="tip"><b>140</b></span><form action="index.php" method="post">';
\r
35 formHTML += '<textarea name="status" id="textbox"></textarea>';
\r
36 formHTML += '<input type="hidden" id="in_reply_to" name="in_reply_to" value="0" />';
\r
37 formHTML += '<input type="submit" id="submit_btn" value="update" /></form>';
\r
38 function rabrTweet(objs) {
\r
39 if(typeof objs === 'undefined'){
\r
40 var objs = $('#statuses .timeline .source a');
\r
42 var objs = objs.find('.source a');
\r
44 for (i = 0; i < objs.length; i++) {
\r
45 if (/rabr/i.test($(objs[i]).text())) {
\r
46 $(objs[i]).css("color", "#33CCFF");
\r
50 var getConversation = function (obj) {
\r
51 var url = $(obj).attr("href");
\r
52 var target = $(obj).parent().parent().parent().parent();
\r
57 success: function(msg){
\r
58 if ($.trim(msg).indexOf("</li>") > 0) {
\r
59 $(msg).appendTo(target);
\r
61 updateSentTip('Get thread failed.', 5000, 'failure');
\r
63 target.removeClass("loading");
\r
65 error: function(msg){
\r
66 updateSentTip('Get thread failed.', 5000, 'failure');
\r
67 target.removeClass("loading");
\r
72 $(".ajax_reply").live("click", function (e) {
\r
73 var obj = $(this).parent().parent().parent().parent();
\r
74 var thread = obj.find(".ajax_form");
\r
75 if (thread.size() > 0) {
\r
76 thread.slideToggle("fast");
\r
78 obj.addClass("loading");
\r
79 getConversation($(this));
\r
85 $("#statuses .trans_btn").live("click", function(){
\r
86 var tBody = $(this).parent().parent();
\r
87 if(tBody.find(".trans_body").size() !== 0){
\r
90 var id = $.trim(tBody.find('.status_id').text());
\r
91 var text = $.trim(tBody.find('.tweet').text());
\r
92 var lang = $.cookie('transLang');
\r
96 tBody.parent().addClass('loading');
\r
97 translate(text, id, lang, 'transCallback');
\r
99 $("#statuses .trans_close").live("click", function(){
\r
100 $(this).parent().parent().parent().parent().find(".translated").remove();
\r
102 $("#translateMy").live("click", function(){
\r
103 var orig = $("#textbox").val();
\r
105 var lang = $.cookie('myLangs')
\r
109 $('#tip').addClass('loading');
\r
110 translate(orig, '', lang, 'transMyCallback');
\r
112 $("#transRecover").live("click", function(){
\r
113 $("#textbox").val(ORIG_TEXT);
\r
114 $("#transRecover").fadeOut('fast');
\r
117 var translate = function(text, context, lang, callback) {
\r
118 var a = "http://www.google.com/uds/Gtranslate";
\r
119 a += "?callback=" + callback;
\r
120 a += "&context=" + context;
\r
121 a += "&q=" + encodeURIComponent(text);
\r
122 a += "&key=notsupplied";
\r
124 a += "&nocache=1240207680396";
\r
125 a += "&langpair=%7C" + lang;
\r
128 var transMyCallback = function(content, translation){
\r
129 if(translation.translatedText !== null){
\r
130 $('#tip').removeClass('loading');
\r
131 $("#transArea").hide();
\r
132 $("#textbox").val(translation.translatedText);
\r
133 $("#transRecover").fadeIn('fast');
\r
136 var transCallback = function(content, translation){
\r
137 if(translation.translatedText !== null){
\r
138 var lang = $.cookie('transLang')
\r
142 var langTxt = $.cookie('fullLang');
\r
143 if(langTxt === null){
\r
144 langTxt = $('#transArea select[name=langs] option[value=' + lang + ']').text();
\r
146 var html = '<div class="translated"><a href="javascript:void(0);" title="Hide Translation" class="trans_close">(Hide)</a><span class="trans_header"><strong>Translation <small>(from ' + translation.detectedSourceLanguage;
\r
147 html += ' to ' + langTxt + ')</small> : </strong></span>';
\r
148 html += '<span class="trans_body">' + translation.translatedText + '</span></div>';
\r
150 if(typeof INTERVAL_COOKIE !== 'undefined'){
\r
151 li = $("#statuses ol:visible li:has(.status_id)").filter(":contains(" + content + ")");
\r
152 target = li.find(".status_word:first");
\r
154 li = $("#statuses li:has(.status_id)").filter(":contains(" + content + ")");
\r
155 target = li.find(".status_word:first");
\r
157 $(html).appendTo(target);
\r
158 li.removeClass("loading");
\r
161 $(window).load(function(){
\r
162 var scrollTo = function (top, duration, callback) {
\r
165 var currentTop = w.scrollTop();
\r
166 var offset = (currentTop - top) / (duration * FPS / 1000);
\r
168 var prevTop = currentTop;
\r
169 var t = setInterval(function () {
\r
170 if ((prevTop - top) * (currentTop - top) <= 0) {
\r
172 currentTop = prevTop = top;
\r
174 if (callback) callback();
\r
176 prevTop = currentTop;
\r
177 w.scrollTop(currentTop -= offset);
\r
181 var scrollToTop = function(){
\r
182 scrollTo(0, 200, function () {
\r
183 scrollTo(30, 50, function () {
\r
188 var scrollToBottom = function(){
\r
189 var height = document.body.clientHeight;
\r
190 scrollTo(height, 200, function () {
\r
191 scrollTo(height + 30, 50, function () {
\r
192 scrollTo(height, 50);
\r
197 $('body').dblclick(function () {
\r
199 $("#textbox").focus();
\r
201 $('#content').dblclick(function (e) {
\r
202 e.stopPropagation();
\r
204 var hkFadeIn = function(text){
\r
205 $("#shortcutTip").fadeIn("fast").html(text);
\r
207 var hkFadeOut = function(){
\r
208 setTimeout(function () {$("#shortcutTip").fadeOut("fast");}, 2000);
\r
211 var hotkeyHandler = function(code){
\r
213 case 82: // R - refresh
\r
214 hkFadeIn("Refresh");
\r
218 case 67: // C - focus textbox
\r
220 hkFadeIn("Compose");
\r
221 scrollTo(0, 1, function () {
\r
222 $("#textbox").focus();
\r
226 case 66: // B - scroll to bottom
\r
231 case 84: // T - scroll to top
\r
236 case 83: // S - search
\r
237 hkFadeIn("Search");
\r
238 $("#sidepost").animate({backgroundColor: "#FF6347"}, 500, function(){
\r
239 $("#header_search_query").focus();
\r
240 $("#sidepost").animate({backgroundColor: $("#side_base").css("background-color")}, 1000);
\r
246 $(document).keydown(function(e){
\r
247 var tag = e.target.tagName;
\r
248 if(tag === "BODY" || tag === "HTML"){
\r
249 if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
\r
250 hotkeyHandler(e.keyCode);
\r
255 $(document).ready(function () {
\r
256 $("<div id='sentTip' style='display:none;' />").prependTo("#header .wrapper");
\r
258 var updateSentTip = function(message, duration, className){
\r
259 var sentTip = $("#sentTip");
\r
260 var bgColor = $("body").css("background-color");
\r
261 sentTip.html(message).removeClass().addClass(className);
\r
263 "border-style": "solid",
\r
264 "border-width": "1px",
\r
265 "border-color": bgColor
\r
267 sentTip.slideDown("fast");
\r
268 window.setTimeout(function () {
\r
269 sentTip.slideUp('fast');
\r
273 var formFunc = function(){
\r
275 $("#textbox").keyup(function () {
\r
277 }).bind("keyup", "keydown", function(event){
\r
278 if (event.ctrlKey && event.keyCode == 13) {
\r
279 if (PAUSE_UPDATE !== true) {
\r
287 //update button core
\r
289 $("#tweeting_button").click(function (e) {
\r
290 e.preventDefault();
\r
291 if ($("#textbox").val().length >0 ) {
\r
296 var updateStatus = function(){
\r
297 $('#tip').addClass('loading');
\r
298 PAUSE_UPDATE = true;
\r
299 var text = $("#textbox").val();
\r
300 var wordsCount = $("#textbox").val().length;
\r
301 if (wordsCount > 140) {
\r
302 updateSentTip("Your tweet is more than 140 words!", 3000, "failure");
\r
304 } else if (wordsCount = 0) {
\r
305 updateSentTip("Your cannot send an empty tweet!", 3000, "failure");
\r
309 url: "ajax/update.php",
\r
313 "in_reply_to": $("#in_reply_to").val()
\r
315 success: function (msg) {
\r
316 if ($.trim(msg).indexOf("</li>") > 0) {
\r
317 $.cookie('recover', text, {'expire': 30});
\r
318 $('#tip').removeClass('loading');
\r
319 updateSentTip("Your status has been updated!", 3000, "success");
\r
320 $("#textbox").val("");
\r
321 $("#tip").html("<b>140</b>");
\r
323 if(typeof INTERVAL_COOKIE !== "undefined"){
\r
324 var source = $(msg).prependTo($("#allTimeline"));
\r
325 source.hide().slideDown('fast');
\r
326 var statusid = $.trim($(msg).find('.status_id').text());
\r
327 var statusText = $.trim($(msg).find('.tweet').html());
\r
329 $(".mine").slideDown("fast");
\r
330 $("#full_status").fadeIn("fast");
\r
331 $("#currently .status-text").hide().text(limitation(text)).fadeIn("fast");
\r
332 $("#latest_meta").hide().html("<a target=\"_blank\" href=\"status.php?id=" + statusid + "\">less than 5 seconds ago</a>").fadeIn("fast");
\r
333 $("#currently .full-text").hide().html(statusText);
\r
334 $("#full_meta").hide().html("<a target=\"_blank\" href=\"status.php?id=" + statusid + "\">less than 5 seconds ago</a>");
\r
335 $("#full_meta a, .full-text a").click(function (e) {e.stopPropagation();});
\r
336 previewMedia(source);
\r
340 $.cookie('recover', text, {'expire': 30});
\r
341 $('#tip').removeClass('loading');
\r
342 updateSentTip("Update failed. Please try again.", 3000, "failure");
\r
343 $('#tweeting_button').removeClass('btn-disabled');
\r
345 PAUSE_UPDATE = false;
\r
347 error: function (msg) {
\r
348 $.cookie('recover', text, {'expire': 30});
\r
349 $('#tip').removeClass('loading');
\r
350 updateSentTip("Update failed. Please try again.", 3000, "failure");
\r
351 $('#tweeting_button').removeClass('btn-disabled');
\r
352 PAUSE_UPDATE = false;
\r
357 function onFavor($this) {
\r
358 var status_id = $.trim($this.parent().parent().find(".status_id").text());
\r
359 updateSentTip("Adding this tweet to your favorites...", 5000, "ing");
\r
361 url: "ajax/addfavor.php",
\r
363 data: "status_id=" + status_id,
\r
364 success: function (msg) {
\r
365 if (msg.indexOf("success") >= 0) {
\r
366 updateSentTip("Favorite added successfully.", 3000, "success");
\r
367 $this.parent().parent().parent().addClass('faved');
\r
369 updateSentTip("Add failed. Please try again.", 3000, "failure");
\r
372 error: function (msg) {
\r
373 updateSentTip("Add failed. Please try again.", 3000, "failure");
\r
377 function onReplie($this, e) {
\r
378 var replie_id = $this.parent().parent().find(".status_word").find(".user_name").text();
\r
379 var in_reply_id = $this.parent().parent().find(".status_id").text();
\r
380 var text = "@" + replie_id;
\r
381 var mode = "In reply to ";
\r
383 mode = "Reply to all: ";
\r
387 var mentionArray = [text];
\r
388 var mentions = $this.parent().parent().find('a[href^="user.php"][innerHTML^=@]');
\r
389 $.each(mentions, function () {
\r
390 var t = $(this).text();
\r
391 if (!(t in temp)) {
\r
393 mentionArray.push(t);
\r
395 text = mentionArray.join(' ');
\r
399 mode = "Non-conversational reply to ";
\r
403 $("#textbox").focus();
\r
404 $("#textbox").val($("#textbox").val() + text + ' ');
\r
405 $("#in_reply_to").val(in_reply_id);
\r
406 $("#full_status").hide();
\r
407 $("#latest_meta").html("").hide();
\r
408 $("#full_meta").hide();
\r
409 $("#currently .full-text").hide();
\r
410 $("#latest_meta").hide();
\r
411 $("#currently .status-text").html(mode + text);
\r
414 function onRT($this) {
\r
415 var replie_id = $this.parent().parent().find(".status_word").find(".user_name").text();
\r
417 $("#textbox").focus();
\r
418 $("#textbox").val("RT @" + replie_id + ":" + $this.parent().parent().find(".status_word").text().replace(replie_id, ""));
\r
419 $("#full_status").hide();
\r
420 $("#latest_meta").hide();
\r
421 $("#full_meta").hide();
\r
422 $("#currently .full-text").hide();
\r
423 $("#latest_meta").hide();
\r
424 $("#currently .status-text").html("Retweet @" + replie_id + "'s tweet with comment.");
\r
427 function onReplieDM($this, e) {
\r
428 var replie_id = $this.parent().parent().find(".status_word").find(".user_name").text();
\r
429 var text = "D " + replie_id;
\r
431 $("#textbox").focus();
\r
432 $("#textbox").val($("#textbox").val() + text + ' ');
\r
433 $("#in_reply_to").val($this.parent().parent().find(".status_id").text());
\r
434 $("#full_status").hide();
\r
435 $("#latest_meta").hide();
\r
436 $("#full_meta").hide();
\r
437 $("#currently .full-text").hide();
\r
438 $("#latest_meta").hide();
\r
439 $("#currently .status-text").html("Reply direct message to @" + replie_id);
\r
442 function onNwRT($this) {
\r
443 var statusBody = $this.parent().parent();
\r
444 var status_id = statusBody.find(".status_id").text();
\r
445 var div = "#" + statusBody.parent().parent().attr('id');
\r
446 var btnDiv = div + "Btn";
\r
447 if (confirm("Are you sure to retweet this?")) {
\r
448 updateSentTip("Retweeting tweet...", 5000, "ing");
\r
450 url: "ajax/retweet.php",
\r
452 data: "status_id=" + status_id,
\r
453 success: function (msg) {
\r
454 if (msg.length >= 0) {
\r
455 statusBody.parent().addClass("retweet");
\r
456 statusBody.find(".source").hide();
\r
457 statusBody.find(".status_info").append("<span class=\"rt_source\">Retweeted by you from <a rel=\"nofollow\" href=\"http://code.google.com/p/rabr/\">rabr</a></span>").fadeIn("fast");
\r
458 statusBody.find(".date").hide();
\r
459 statusBody.find(".status_info").append("<span class=\"rt_undo\" title=\"Your followers will no longer see the tweet as retweeted by you.\"> <a href=\"javascript:void(0);\">(Undo)</a><span class=\"rt_id\" style=\"display: none;\">" + msg + "</span></span>").fadeIn("fast");
\r
460 updateSentTip("This tweet has been retweeted!", 3000, "success");
\r
461 $(".rt_undo").tipsy({
\r
465 if (msg === "duplicated") {
\r
466 updateSentTip("You have retweeted this tweet!", 3000, "failure");
\r
468 updateSentTip("Failed to retweet!", 3000, "failure");
\r
472 error: function (msg) {
\r
473 updateSentTip("Retweet failed. Please try again.", 3000, "failure");
\r
478 function onDelete($this, type) {
\r
479 var status_id = $.trim($this.parent().parent().find(".status_id").text());
\r
480 $this.parent().parent().parent().css("background-color", "#FF3300");
\r
481 var confirm = window.confirm("Are you sure to delete this tweet?");
\r
483 updateSentTip("Deleting tweet...", 5000, "ing");
\r
484 var postData = (type == "Tweet") ? "status_id=" : "favor_id=";
\r
486 url: "ajax/delete.php",
\r
488 data: postData + status_id,
\r
489 success: function (msg) {
\r
490 if (msg.indexOf("success") >= 0) {
\r
491 $this.parent().parent().parent().css("background-color", "#FF3300");
\r
492 $this.parent().parent().parent().fadeOut("fast");
\r
493 updateSentTip("Your tweet has been destroyed!", 3000, "success");
\r
495 $this.parent().parent().parent().css("background-color", "");
\r
496 updateSentTip("Delete failed. Please try again.", 3000, "failure");
\r
499 error: function (msg) {
\r
500 $this.parent().parent().parent().css("background-color", "");
\r
501 updateSentTip("Delete failed. Please try again.", 3000, "failure");
\r
505 $this.parent().parent().parent().css("background-color", "");
\r
507 function onUndoRt($this) {
\r
508 var status_id = $.trim($this.parent().find(".rt_id").text());
\r
509 var statusBody = $this.parent().parent().parent();
\r
510 statusBody.css("background-color", "#FF3300");
\r
511 var confirm = window.confirm("Are you sure to undo this retweet?");
\r
513 updateSentTip("Undoing retweet...", 5000, "ing");
\r
515 url: "ajax/delete.php",
\r
517 data: "status_id=" + status_id,
\r
518 success: function (msg) {
\r
519 if (msg.indexOf("success") >= 0) {
\r
520 statusBody.css("background-color", "#FF3300");
\r
521 statusInfo = $this.parent().parent();
\r
522 if (statusInfo.find(".rt_source").size() === 1) {
\r
523 statusInfo.find(".source").show();
\r
524 statusInfo.find(".date").show();
\r
525 statusInfo.find(".rt_source").remove();
\r
526 statusInfo.find(".rt_undo").remove();
\r
527 statusBody.removeClass("retweet");
\r
528 statusBody.css("background-color", "");
\r
530 statusBody.fadeOut("fast");
\r
532 updateSentTip("Your retweet has been undo!", 3000, "success");
\r
534 statusBody.css("background-color", "");
\r
535 updateSentTip("Undo failed. Please try again.", 3000, "failure");
\r
538 error: function (msg) {
\r
539 statusBody.css("background-color", "");
\r
540 updateSentTip("Undo failed. Please try again.", 3000, "failure");
\r
544 statusBody.css("background-color", "");
\r
546 function onDeleteMsg($this) {
\r
547 var message_id = $.trim($this.parent().parent().find(".status_id").text());
\r
548 $this.parent().parent().parent().css("background-color", "#FF3300");
\r
549 var confirm = window.confirm("Are you sure to delete this message?");
\r
551 updateSentTip("Deleting message...", 5000, "ing");
\r
553 url: "ajax/delete.php",
\r
555 data: "message_id=" + message_id,
\r
556 success: function (msg) {
\r
557 if (msg.indexOf("success") >= 0) {
\r
558 $this.parent().parent().parent().css("background-color", "#FF3300");
\r
559 $this.parent().parent().parent().fadeOut("fast");
\r
560 updateSentTip("Message deleted.", 3000, "success");
\r
562 $this.parent().parent().parent().css("background-color", "");
\r
563 updateSentTip("Failed to delete this message!", 3000, "failure");
\r
566 error: function (msg) {
\r
567 $this.parent().parent().parent().css("background-color", "");
\r
568 updateSentTip("Failed to delete this message!", 3000, "failure");
\r
572 $this.parent().parent().parent().css("background-color", "");
\r
574 function shortUrlDisplay() {
\r
575 var stringVar = "";
\r
576 stringVar = document.getElementById("textbox").value;
\r
577 if (stringVar.length === 0) {
\r
578 updateSentTip("There's no URL in your tweet to shorten!", 3000, "failure");
\r
581 var regexp = /http(s)?:\/\/([\w\-]+\.)+[\w\-]+(\/[\w\-\.\/?\%\!\&=\+\~\:\#\;\,]*)?/ig;
\r
583 str = stringVar.match(regexp);
\r
584 if (str !== null) {
\r
585 for (idx = 0; idx < str.length; idx++) {
\r
586 regexp2 = /(http:\/\/j.mp\/[\S]+)|(http:\/\/bit.ly\/[\S]+)|(http:\/\/zi.mu\/[\S]+)|(http:\/\/orz.se\/[\S]+)/gi;
\r
587 match_short = str[idx].match(regexp2);
\r
588 if (!match_short) {
\r
589 l_urls += str[idx] + "|"
\r
591 match_short = null;
\r
592 updateSentTip("No valid URLs!", 3000, "failure");
\r
594 if (l_urls != "") {
\r
595 $('#tip').addClass('loading');
\r
596 $.post("ajax/shorturl.php", {
\r
598 }, function (data) {
\r
605 function getShortUrl(res) {
\r
607 target_layer = 'textbox';
\r
608 var url_arry, s_url, l_url, part;
\r
610 url_arry = retstr.split('^');
\r
611 for (i = 0; i < url_arry.length; i++) {
\r
612 part = url_arry[i].split('|');
\r
613 if (part.length == 2) {
\r
617 if (s_url.indexOf('http://zi.mu') > -1) {
\r
618 stringVar = document.getElementById(target_layer).value;
\r
619 stringVar = stringVar.replace(l_url, s_url);
\r
620 document.getElementById(target_layer).value = stringVar + "";
\r
622 $('#tip').removeClass('loading');
\r
623 updateSentTip("Successfully shortened your URLs!", 3000, "success");
\r
625 else if (s_url.length > 0) {
\r
630 updateSentTip("Failed to shorten URLs, please try again.", 3000, "failure");
\r
634 function shortenTweet() {
\r
635 var tweet = $.trim($("#textbox").val());
\r
636 if (tweet.length === 0) {
\r
637 updateSentTip("There's nothing to shorten!", 3000, "failure");
\r
639 $('#tip').addClass('loading');
\r
641 url: "ajax/shortenTweet.php",
\r
643 data: "text=" + tweet,
\r
644 success: function(msg){
\r
645 if(msg !== 'error'){
\r
646 $("#textbox").val(msg);
\r
648 $('#tip').removeClass('loading');
\r
649 updateSentTip("Your tweet has been shortened!", 5000, "success");
\r
651 updateSentTip("Failed to shorten your tweet.", 5000, "failure");
\r
654 error: function(msg){
\r
655 updateSentTip("Failed to shorten your tweet.", 5000, "failure");
\r
659 $.getJSON("http://tweetshrink.com/shrink?text=" + tweet, function(data){
\r
660 $("#textbox").val(data.text);
\r
662 updateSentTip("Reduced " + data.difference + " letters!" , 5000, "success");
\r
668 $("#latest_status").toggle(
\r
670 $("#currently .status-text, #latest_meta").css("display", "none");
\r
671 $("#currently .full-text, #full_meta").css("display", "inline");
\r
673 $("#currently .status-text, #latest_meta").css("display", "inline");
\r
674 $("#currently .full-text, #full_meta").css("display", "none");
\r
676 $("#full_meta a, .full-text a").click(function (e) {
\r
677 e.stopPropagation();
\r
680 var limitation = function (text) {
\r
681 if (text.length > 60) {
\r
682 text = text.substr(0, 60) + " ...";
\r
687 if (document.location.href.indexOf("index") > 0 || document.location.href.indexOf("all") > 0) {
\r
688 var temp = $("#currently .status-text").text();
\r
689 if (temp.length > 60) {
\r
690 temp = temp.substr(0, 60) + " ...";
\r
692 $("#currently .status-text").text(temp);
\r
695 function updateTrends() {
\r
697 url: "ajax/updateTrends.php",
\r
699 success: function (msg) {
\r
700 if ($.trim(msg).indexOf("</ul>" > 0)) {
\r
701 $("#trend_entries").html(msg);
\r
703 $("#trends_title").removeClass().addClass("open");
\r
704 $("#trend_entries").slideDown("fast");
\r
709 $("#trends_title").toggle(
\r
711 $("#trends_title").removeClass().addClass("loading");
\r
714 $("#trend_entries").slideUp("fast");
\r
715 $("#trends_title").removeClass();
\r
718 function updateFollowing() {
\r
720 url: "ajax/updateFollowing.php",
\r
722 success: function (msg) {
\r
723 if ($.trim(msg).indexOf("</span>" > 0)) {
\r
724 $("#following_list").html(msg);
\r
726 $("#following_title").removeClass().addClass("open");
\r
727 $("#following_list").slideDown("fast");
\r
732 $("#following_title").toggle(
\r
734 $("#following_title").removeClass().addClass("loading");
\r
737 $("#following_list").slideUp("fast");
\r
738 $("#following_title").removeClass();
\r
742 $("#toolbox_title").toggle(
\r
744 $("#toolbox_title").removeClass().addClass("open");
\r
745 $("#tools_list").slideDown("fast");
\r
747 $("#tools_list").slideUp("fast");
\r
748 $("#toolbox_title").removeClass();
\r
752 $(".status_author img, .rank_img img").live("click", function (e) {
\r
753 $(".right_menu").hide();
\r
754 $(this).parent().parent().find(".right_menu").css("display", "block");
\r
755 e.preventDefault();
\r
757 $('body').click(function () {
\r
758 $(".right_menu").hide();
\r
760 $('.status_author li a').click(function () {
\r
761 $(".right_menu").hide();
\r
763 $(".rm_mention").live("click", function (e) {
\r
764 e.preventDefault();
\r
765 rmmention($(this), e);
\r
767 $(".rm_dm").live("click", function (e) {
\r
768 e.preventDefault();
\r
771 $(".rm_follow").live("click", function (e) {
\r
772 e.preventDefault();
\r
773 var $this = $(this);
\r
774 var id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
775 updateSentTip("Following " + id + "...", 5000, "ing");
\r
777 url: "ajax/relation.php",
\r
779 data: "action=create&id=" + id,
\r
780 success: function (msg) {
\r
781 if (msg.indexOf("success") >= 0) {
\r
782 updateSentTip("You have followed " + id + "!", 3000, "success");
\r
784 updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");
\r
787 error: function (msg) {
\r
788 updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");
\r
792 $(".rm_unfollow").live("click", function (e) {
\r
793 e.preventDefault();
\r
794 var $this = $(this);
\r
795 var id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
796 if (confirm("Are you sure to unfollow " + id + " ?")) {
\r
797 updateSentTip("Unfollowing " + id + "...", 5000, "ing");
\r
799 url: "ajax/relation.php",
\r
801 data: "action=destory&id=" + id,
\r
802 success: function (msg) {
\r
803 if (msg.indexOf("success") >= 0) {
\r
804 updateSentTip("You have unfollowed " + id + "!", 3000, "success");
\r
806 updateSentTip("Failed to unfollow " + id + ", please try again.", 3000, "failure");
\r
809 error: function (msg) {
\r
810 updateSentTip("Failed to unfollow " + id + ", please try again.", 3000, "failure");
\r
815 $(".rm_block").live("click", function (e) {
\r
816 e.preventDefault();
\r
817 var $this = $(this);
\r
818 var id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
819 if (confirm("Are you sure to block " + id + " ?")) {
\r
820 updateSentTip("Blocking " + id + "...", 5000, "ing");
\r
822 url: "ajax/relation.php",
\r
824 data: "action=block&id=" + id,
\r
825 success: function (msg) {
\r
826 if (msg.indexOf("success") >= 0) {
\r
827 updateSentTip("You have blocked " + id + "!", 3000, "success");
\r
829 updateSentTip("Failed to block " + id + ", please try again.", 3000, "failure");
\r
832 error: function (msg) {
\r
833 updateSentTip("Failed to block " + id + ", please try again.", 3000, "failure");
\r
839 $(".rm_spam").live("click", function (e) {
\r
840 e.preventDefault();
\r
841 var $this = $(this);
\r
842 var id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
843 if (confirm("Are you sure to report " + id + " ?")) {
\r
844 updateSentTip("Reporting " + id + " as a spammer...", 5000, "ing");
\r
846 url: "ajax/reportSpam.php",
\r
848 data: "spammer=" + id,
\r
849 success: function (msg) {
\r
850 if (msg.indexOf("success") >= 0) {
\r
851 updateSentTip("Successfully reported!", 3000, "success");
\r
853 updateSentTip("Failed to report " + id + ", please try again.", 3000, "failure");
\r
856 error: function (msg) {
\r
857 updateSentTip("Failed to report " + id + ", please try again.", 3000, "failure");
\r
862 function rmmention($this, e) {
\r
863 var replie_id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
864 var in_reply_id = $this.parent().parent().parent().find(".status_id").text();
\r
865 var text = "@" + replie_id;
\r
866 var mode = "In reply to ";
\r
868 $("#textbox").focus();
\r
869 $("#textbox").val($("#textbox").val() + text + ' ');
\r
870 $("#in_reply_to").val(in_reply_id);
\r
871 $("#full_status").hide();
\r
872 $("#latest_meta").html("").hide();
\r
873 $("#full_meta").hide();
\r
874 $("#currently .full-text").hide();
\r
875 $("#latest_meta").hide();
\r
876 $("#currently .status-text").html(mode + text);
\r
879 function rmdm($this, e) {
\r
880 var replie_id = $this.parent().parent().parent().find(".status_word").find(".user_name").text();
\r
881 var text = "D " + replie_id;
\r
883 $("#textbox").focus();
\r
884 $("#textbox").val($("#textbox").val() + text + ' ');
\r
885 $("#in_reply_to").val($this.parent().parent().parent().find(".status_id").text());
\r
886 $("#full_status").hide();
\r
887 $("#latest_meta").hide();
\r
888 $("#full_meta").hide();
\r
889 $("#currently .full-text").hide();
\r
890 $("#latest_meta").hide();
\r
891 $("#currently .status-text").html("Reply direct message to @" + replie_id);
\r
894 function sidebarFollow(id) {
\r
895 updateSentTip("Following " + id + "...", 5000, "ing");
\r
897 url: "ajax/relation.php",
\r
899 data: "action=create&id=" + id,
\r
900 success: function (msg) {
\r
901 if (msg.indexOf("success") >= 0) {
\r
902 updateSentTip("You have followed " + id + "!", 3000, "success");
\r
903 $.cookie('followus', 1, {
\r
906 $.cookie('whofollowedus', $("#sideid").html(), {
\r
909 $("#follow_us").fadeOut("fast");
\r
911 updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");
\r
914 error: function (msg) {
\r
915 updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");
\r
920 $('#fl_ds').click(function (e) {
\r
921 e.preventDefault();
\r
922 if (confirm("Are you sure to follow @disinfeqt?")) {
\r
923 sidebarFollow("disinfeqt");
\r
926 $('#fl_ys').click(function (e) {
\r
927 e.preventDefault();
\r
928 if (confirm("Are you sure to follow @Chris_Ys?")) {
\r
929 sidebarFollow("chris_ys");
\r
933 //sidebar shortcuts tips
\r
935 $("#sidebarTip").toggle(
\r
937 $('#sidebarTip_more').slideDown('fast');
\r
938 $('#indicator').html('[-]');
\r
940 $('#sidebarTip_more').slideUp('fast');
\r
941 $('#indicator').html('[+]');
\r
944 //init global functions
\r
945 $(document).ready(function () {
\r
947 $("#statuses .mine").live("mouseout", function (e) {
\r
948 $(this).removeClass("mine").addClass("myTweet");
\r
950 $("#primary_nav li a").bind("click", function () {
\r
951 $("#primary_nav li a").each(function (i, o) {
\r
952 if ($(this).hasClass("active")) {
\r
953 $(this).removeClass()
\r
956 $(this).removeClass().addClass("active").css("background", "transparent url('../img/spinner.gif') no-repeat scroll 173px center")
\r
958 $("#statuses .big-retweet-icon, #func_set .func_btn").tipsy({
\r
961 $('#symbols span').tipsy({
\r
962 gravity: $.fn.tipsy.autoNS
\r
964 if ($.cookie('followus') == 1 && $.cookie('whofollowedus') == $("#sideid").html()) {
\r
965 $("#follow_us").hide();
\r
967 $(".timeline img").lazyload({threshold : 100, effect : "fadeIn"});
\r
969 var freshProfile = function(){
\r
970 $('#update_count').text($.cookie('statuses_count'));
\r
971 $('#user_stats a[href*=friends] span.count').text(parseInt($.cookie('friends_count')));
\r
972 $('#user_stats a[href*=followers] span.count').text(parseInt($.cookie('followers_count')));
\r
973 $('#user_stats a[href*=lists] span.count').text(parseInt($.cookie('listed_count')));
\r
975 var markReply = function(obj){
\r
976 obj.each(function (i, o) {
\r
977 if ($(this).find("> span").find('.tweet').text().toLowerCase().indexOf("@" + $("#sideid").text().toLowerCase()) > -1) {
\r
978 $(this).addClass("reply");
\r