-var INTERVAL_COOKIE = 'updatesInterval';\r
-$(function () {\r
- formFunc();\r
- $(".rt_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onRT($(this));\r
- });\r
- $(".retw_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onNwRT($(this));\r
- });\r
- $(".replie_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onReplie($(this), e);\r
- });\r
- $(".favor_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onFavor($(this));\r
- });\r
- $(".delete_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onDelete($(this), "Tweet");\r
- });\r
- $(".msg_replie_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onReplieDM($(this));\r
- });\r
- $(".msg_delete_btn").live("click", function (e) {\r
- e.preventDefault();\r
- onDeleteMsg($(this));\r
- });\r
- $(".rt_undo").live("click", function (e) {\r
- e.preventDefault();\r
- onUndoRt($(this));\r
- });\r
- markReply($("#allTimeline > li"));\r
- $("#submit_btn").click(function (e) {\r
- updateStatus();\r
- e.preventDefault();\r
- });\r
- document.onclick = function () {\r
- document.title = document.title.replace(/(\([0-9]+\))/g, "");\r
- $(".allHighLight").text($(".allHighLight").text().replace(/(\([0-9]+\))/g, ""));\r
- $("#statuses .new").each(function () {\r
- $("#statuses .new").remove();\r
- });\r
- }\r
- $("#allReplies").hide();\r
- $("#allMessage").hide();\r
- $("#allTimelineBtn").click(function () {\r
- $("#allTimeline").show();\r
- $("#allReplies").hide();\r
- $("#allMessage").hide();\r
- $("#allTimelineBtn").addClass("allHighLight");\r
- if ($("#allRepliesBtn").hasClass("allHighLight")) $("#allRepliesBtn").removeClass("allHighLight");\r
- else $("#allMessageBtn").removeClass("allHighLight");\r
- $("#allTimelineBtn").text($("#allTimelineBtn").text().replace(/(\([0-9]+\))/g, ""));\r
- })\r
- $("#allRepliesBtn").click(function () {\r
- $("#allTimeline").hide();\r
- $("#allReplies").show();\r
- $("#allMessage").hide();\r
- $("#allRepliesBtn").addClass("allHighLight");\r
- if ($("#allTimelineBtn").hasClass("allHighLight")) $("#allTimelineBtn").removeClass("allHighLight");\r
- else $("#allMessageBtn").removeClass("allHighLight");\r
- $("#allRepliesBtn").text($("#allRepliesBtn").text().replace(/(\([0-9]+\))/g, ""));\r
- })\r
- $("#allMessageBtn").click(function () {\r
- $("#allTimeline").hide();\r
- $("#allReplies").hide();\r
- $("#allMessage").show();\r
- $("#allMessageBtn").addClass("allHighLight");\r
- if ($("#allRepliesBtn").hasClass("allHighLight")) $("#allRepliesBtn").removeClass("allHighLight");\r
- else $("#allTimelineBtn").removeClass("allHighLight");\r
- $("#allMessageBtn").text($("#allMessageBtn").text().replace(/(\([0-9]+\))/g, ""));\r
- })\r
- $(function () {\r
- setUpdateInterval();\r
- });\r
- });\r
-var setUpdateInterval = function () {\r
- if (!location.href.split("?")[1] || location.href.split("?")[1] == "p=1") {\r
- var interval = parseFloat($.cookie(INTERVAL_COOKIE));\r
- if (interval === 0.0) {\r
- return false;\r
- }\r
- interval = interval > 0 ? interval : 3;\r
- UPDATE_INTERVAL = setInterval(function () {\r
- update();\r
- }, interval * 1000 * 60);\r
- }\r
-};\r
-\r
-function update() {\r
- if (PAUSE_UPDATE === true) {\r
- window.setTimeout(update, 5000);\r
- } else if (PAUSE_TIMELINE === true) {\r
- return 0;\r
- } else {\r
- if($.cookie("intervalChanged") === "true"){\r
- clearInterval(UPDATE_INTERVAL);\r
- $.cookie("intervalChanged", "")\r
- setUpdateInterval();\r
- }\r
- updateSentTip('Retrieving new tweets...', 5000, 'ing');\r
- updateFunc("timeline");\r
- updateFunc("replies");\r
- updateFunc("message");\r
- }\r
-}\r
-\r
-function updateFunc(type, name, pw) {\r
- PAUSE_TIMELINE = true;\r
- var div, url, btnDiv, param;\r
- switch (type) {\r
- case "timeline":\r
- div = "#allTimeline";\r
- btnDiv = "#allTimelineBtn";\r
- url = "ajax/updateTimeline.php";\r
- $(div + " li.mine").removeClass("mine").addClass("myTweet");\r
- break;\r
- case "replies":\r
- div = "#allReplies";\r
- btnDiv = "#allRepliesBtn";\r
- url = "ajax/updateReplies.php";\r
- break;\r
- case "message":\r
- div = "#allMessage";\r
- btnDiv = "#allMessageBtn";\r
- url = "ajax/updateMessage.php";\r
- break;\r
- }\r
- var since_id = 0;\r
- if (div === "#allTimeline") {\r
- since_id = $(div + " li:not(.myTweet):not(#ajax_statuses li):first").find("span.status_id").text();\r
- } else {\r
- since_id = $(div + " li:first-child").find("span.status_id").text();\r
- }\r
- param = "?since_id=" + since_id;\r
- $.ajax({\r
- url: url + param,\r
- type: "GET",\r
- dataType: "text",\r
- data: "since_id=" + since_id,\r
- success: function (msg) {\r
- if ($.trim(msg).indexOf("</li>") > 0) {\r
- var source = $(msg).prependTo(div);\r
- if (div === "#allTimeline") {\r
- $(div + " li.myTweet:not(:first)").removeClass("myTweet");\r
- markReply($('#allTimeline > li'));\r
- }\r
- var num = 0;\r
- var navNum = 0;\r
- if (document.title.match(/\d+/) != null) {\r
- num = parseInt(document.title.match(/\d+/));\r
- }\r
- var len = $(msg).length - 1;\r
- document.title = "(" + (num + len) + ") " + document.title.replace(/(\([0-9]+\))/g, "");\r
- if ($(btnDiv).text().match(/\d+/) != null) {\r
- navNum = parseInt($(btnDiv).text().match(/\d+/));\r
- }\r
- $(btnDiv).text($(btnDiv).text().replace(/(\([0-9]+\))/g, "") + "(" + (navNum + len) + ")");\r
- filterEle();\r
- rabrTweet(source);\r
- $(".new").slideDown("fast");\r
- $(".big-retweet-icon").tipsy({\r
- gravity: 's'\r
- });\r
- previewMedia(source);\r
- }\r
- PAUSE_TIMELINE = false;\r
- },\r
- error: function (msg) {\r
- PAUSE_TIMELINE = false;\r
- }\r
- });\r
-}\r
+var INTERVAL_COOKIE = 'updatesInterval';
+$(function () {
+ formFunc();
+ $("ol.timeline").click(function(e) {
+ var $this = $(e.target);
+ var type = $this.attr('class');
+ switch(type) {
+ case 'rt_btn':
+ e.preventDefault();
+ onRT($this);
+ break;
+ case 'retw_btn':
+ e.preventDefault();
+ onNwRT($this);
+ break;
+ case 'replie_btn':
+ e.preventDefault();
+ onReplie($this,e);
+ break;
+ case 'favor_btn':
+ e.preventDefault();
+ onFavor($this);
+ break;
+ case 'unfav_btn':
+ e.preventDefault();
+ UnFavor($this);
+ break;
+ case 'delete_btn':
+ e.preventDefault();
+ onDelete($this);
+ break;
+ case 'rt_undo':
+ e.preventDefault();
+ onUndoRt($this);
+ break;
+ case 'msg_replie_btn':
+ e.preventDefault();
+ onReplieDM($this);
+ break;
+ case 'msg_delete_btn':
+ e.preventDefault();
+ onDeleteMsg($this);
+ break;
+ }
+ });
+ markReply($("#allTimeline > li"));
+ $("#submit_btn").click(function (e) {
+ updateStatus();
+ e.preventDefault();
+ });
+ document.onclick = function () {
+ document.title = document.title.replace(/(\([0-9]+\))/g, "");
+ $(".allHighLight").text($(".allHighLight").text().replace(/(\([0-9]+\))/g, ""));
+ $("#statuses .new").each(function () {
+ $("#statuses .new").remove();
+ });
+ }
+ $("#allReplies").hide();
+ $("#allMessage").hide();
+ $("#allTimelineBtn").click(function () {
+ $("#allTimeline").show();
+ $("#allTimeline img").lazyload({threshold : 100, effect : "fadeIn", placeholder:'img/blank.gif'});
+ $("#allReplies").hide();
+ $("#allMessage").hide();
+ $("#allTimelineBtn").addClass("allHighLight");
+ if ($("#allRepliesBtn").hasClass("allHighLight")) $("#allRepliesBtn").removeClass("allHighLight");
+ else $("#allMessageBtn").removeClass("allHighLight");
+ $("#allTimelineBtn").text($("#allTimelineBtn").text().replace(/(\([0-9]+\))/g, ""));
+ })
+ $("#allRepliesBtn").click(function () {
+ $("#allTimeline").hide();
+ $("#allReplies").show();
+ $("#allReplies img").lazyload({threshold : 100, effect : "fadeIn",placeholder:'img/blank.gif'});
+ $("#allMessage").hide();
+ $("#allRepliesBtn").addClass("allHighLight");
+ if ($("#allTimelineBtn").hasClass("allHighLight")) $("#allTimelineBtn").removeClass("allHighLight");
+ else $("#allMessageBtn").removeClass("allHighLight");
+ $("#allRepliesBtn").text($("#allRepliesBtn").text().replace(/(\([0-9]+\))/g, ""));
+ })
+ $("#allMessageBtn").click(function () {
+ $("#allTimeline").hide();
+ $("#allReplies").hide();
+ $("#allMessage").show();
+ $("#allMessage img").lazyload({threshold : 100, effect : "fadeIn",placeholder:'img/blank.gif'});
+ $("#allMessageBtn").addClass("allHighLight");
+ if ($("#allRepliesBtn").hasClass("allHighLight")) $("#allRepliesBtn").removeClass("allHighLight");
+ else $("#allTimelineBtn").removeClass("allHighLight");
+ $("#allMessageBtn").text($("#allMessageBtn").text().replace(/(\([0-9]+\))/g, ""));
+ $("#allMessage span.date").timeago();
+ })
+ $(function () {
+ setUpdateInterval();
+ });
+ });
+var setUpdateInterval = function () {
+ if (!location.href.split("?")[1] || location.href.split("?")[1] == "p=1") {
+ var interval = parseFloat($.cookie(INTERVAL_COOKIE));
+ if (interval === 0.0) {
+ return false;
+ }
+ interval = interval > 0 ? interval : 3;
+ UPDATE_INTERVAL = setInterval(function () {
+ update();
+ }, interval * 1000 * 60);
+ }
+};
+
+function update() {
+ if (PAUSE_UPDATE === true) {
+ window.setTimeout(update, 5000);
+ } else if (PAUSE_TIMELINE === true) {
+ return 0;
+ } else {
+ if($.cookie("intervalChanged") === "true"){
+ clearInterval(UPDATE_INTERVAL);
+ $.cookie("intervalChanged", "")
+ setUpdateInterval();
+ }
+ updateSentTip('Retrieving new tweets...', 5000, 'ing');
+ updateFunc("timeline");
+ updateFunc("replies");
+ updateFunc("message");
+ }
+}
+
+function updateFunc(type, name, pw) {
+ PAUSE_TIMELINE = true;
+ var div, url, btnDiv, param;
+ switch (type) {
+ case "timeline":
+ div = "#allTimeline";
+ btnDiv = "#allTimelineBtn";
+ url = "ajax/updateTimeline.php";
+ $(div + " li.mine").removeClass("mine").addClass("myTweet");
+ break;
+ case "replies":
+ div = "#allReplies";
+ btnDiv = "#allRepliesBtn";
+ url = "ajax/updateReplies.php";
+ break;
+ case "message":
+ div = "#allMessage";
+ btnDiv = "#allMessageBtn";
+ url = "ajax/updateMessage.php";
+ break;
+ }
+ var since_id = 0;
+ if (div === "#allTimeline") {
+ since_id = $(div + " li:not(.myTweet):not(#ajax_statuses li):first").find("span.status_id").text();
+ } else {
+ since_id = $(div + " li:first-child").find("span.status_id").text();
+ }
+ $.ajax({
+ url: url,
+ type: "GET",
+ dataType: "text",
+ data: "since_id=" + since_id,
+ success: function (msg) {
+ if ($.trim(msg).indexOf("</li>") > 0) {
+ var source = $(msg).prependTo(div);
+ if (div === "#allTimeline") {
+ $(div + " li.myTweet:not(:first)").removeClass("myTweet");
+ markReply($('#allTimeline > li'));
+ }
+ var num = 0;
+ var navNum = 0;
+ if (document.title.match(/\d+/) != null) {
+ num = parseInt(document.title.match(/\d+/));
+ }
+ var len = $(msg).length - 1;
+ document.title = "(" + (num + len) + ") " + document.title.replace(/(\([0-9]+\))/g, "");
+ if ($(btnDiv).text().match(/\d+/) != null) {
+ navNum = parseInt($(btnDiv).text().match(/\d+/));
+ }
+ $(btnDiv).text($(btnDiv).text().replace(/(\([0-9]+\))/g, "") + "(" + (navNum + len) + ")");
+ filterEle();
+ embrTweet(source);
+ if($("div.new").length == 1) {
+ $("div.new").show().slideDown("fast");
+ } else {
+ $("div.new").filter(":first").remove();
+ $("span.tweetcount").filter(":last").text(navNum + len);
+ }
+ $("span.big-retweet-icon").tipsy({
+ gravity: 's'
+ });
+ previewMedia(source);
+ }
+ PAUSE_TIMELINE = false;
+ },
+ error: function (msg) {
+ PAUSE_TIMELINE = false;
+ }
+ });
+}