1 FILTER_COOKIE = 'filKey';
2 FILTER_COUNTER = 'filCnt';
7 $("#photoBtn").click(function (){
8 $("#photoArea").slideToggle(100);
10 $("#imageUploadSubmit").click(function (e){
14 $("#filterBtn").click(function (){
15 $("#filterArea").slideToggle(100);
17 $("#symbolBtn").click(function (){
18 $("#symArea").toggle();
20 $("#symbols span").click(function (){
21 var obj = document.getElementById('textbox');
22 var str = $(this).html();
23 if(document.selection){
25 var sel=document.selection.createRange();
26 document.selection.empty();
29 var prefix, main, suffix;
30 prefix = obj.value.substring(0, obj.selectionStart);
31 main = obj.value.substring(obj.selectionStart, obj.selectionEnd);
32 suffix = obj.value.substring(obj.selectionEnd);
33 obj.value = prefix + str + suffix;
38 $("#restoreBtn").click(function (){
39 $('#textbox').val($.cookie('recover'));
40 updateSentTip("Your previous tweet has been restored!", 3e3, "success");
42 $("#autoBtn").click(function(){
43 if ($("#autoBtn").hasClass("pause")){
44 clearInterval(UPDATE_INTERVAL);
45 $("#autoBtn").removeClass("pause").addClass("start");
46 updateSentTip("Auto refresh deactivated!", 3e3, "success");
49 $("#autoBtn").removeClass("start").addClass("pause");
50 updateSentTip("Auto refresh activated!", 3e3, "success");
54 $("#refreshBtn").click(function (){
56 updateSentTip("Retrieving new tweets...", 3e3, "ing");
58 $("#transBtn").click(function (){
59 $("#transArea").slideToggle(100);
61 $("#filterSubmit").click(function (e){
63 if ($.trim($('#iptFilter').val()).length == 0){
64 updateSentTip("Please enter at least one keyword!", 3e3, "failure");
67 $.cookie(FILTER_COOKIE, null);
68 $.cookie(FILTER_COUNTER, null);
69 updateSentTip("New keyword: " + $.trim($('#iptFilter').val()) + " added!", 3e3, "success");
73 $("#filterReset").click(function (e){
75 $.cookie(FILTER_COOKIE, null);
76 $.cookie(FILTER_COUNTER, null);
77 $('#iptFilter').val("");
78 updateSentTip("Filtered tweets have been restored!", 5e3, "success");
79 $('#statuses .filter').slideDown("fast");
81 $("#filterHide").toggle(
84 $('#statuses .reply').slideUp("fast");
85 $('#filterHide').val("Show @");
87 $('#statuses .reply').slideDown("fast");
88 $('#filterHide').val("Hide @");
90 $("#clearBtn").click(function(e){
92 if (confirm("This will sweep your timeline and remove excess tweets, are you sure?")){
93 $("#statuses .timeline").each(function(){
94 $(this).find("li:gt(19)").remove();
100 function ImageUpload(){
101 updateSentTip("Uploading your image...", 10000, "ing");
103 url: 'ajax/uploadImage.php?do=image',
106 fileElementId: 'imageFile',
108 success: function (data, status){
109 if (typeof(console) !== 'undefined' && console != null){
112 if (data.result != undefined && data.result == "success"){
113 $("#textbox").val($("#textbox").val() + data.url);
114 updateSentTip("Your image has been uploaded!", 3e3, "success");
115 $("#photoArea").slideToggle(100);
118 updateSentTip("Failed to upload, please try again.", 3e3, "failure");
119 $("#photoArea").slideToggle(100);
122 error: function (data, status, e){
123 updateSentTip("Failed to upload, please try again.", 3e3, "failure");
124 $("#photoArea").slideToggle(100);
131 function enableFilter(){
132 if ($.cookie(FILTER_COOKIE) != null && $.cookie(FILTER_COOKIE) != ""){
133 $('#iptFilter').val(recoverKeywords());
134 $.cookie(FILTER_COUNTER, null);
138 function filterEle(){
139 if ($.trim($('#iptFilter').val()).length == 0){
144 var keywords = keywordRegexp();
145 if (keywords === $.cookie(FILTER_COOKIE)){
146 objs = $('#statuses .timeline li:not(.filter:hidden)').find('.status_word');
148 objs = $('#statuses .timeline li').find('.status_word');
150 var reg = new RegExp(keywords, "i");
151 for (i = 0; i < objs.length; i++){
152 if (reg.test($(objs[i]).text())){
153 targets.push(objs[i]);
156 if ($.cookie(FILTER_COUNTER) != null && $.cookie(FILTER_COUNTER) != ''){
157 $.cookie(FILTER_COUNTER, targets.length + parseInt($.cookie(FILTER_COUNTER)));
159 $.cookie(FILTER_COUNTER, targets.length);
161 hideMatched(targets);
162 $.cookie(FILTER_COOKIE, keywords);
166 function hideMatched(obj){
167 $(obj).parent().parent().addClass("filter").hide();
169 function isMatch(txt, keywords){
170 var reg = RegExp(keywords, "i");
171 return reg.test(txt);
173 function keywordRegexp(){
174 if ($.cookie(FILTER_COOKIE) === null){
175 return setFilterCookie();
177 return $.cookie(FILTER_COOKIE);
180 function recoverKeywords(){
181 return $.cookie(FILTER_COOKIE).replace(/\|/g, ',');
183 function setFilterCookie(){
184 var strs = $('#iptFilter').val().split(",");
186 for (i = 0; i < strs.length; i++){
187 if (strs[i] == "") continue;
188 keywords += strs[i] + "|";
190 keywords = keywords.substr(0, keywords.length - 1);
193 var option ={ expire: 30 };
194 $(document).ready(function (){
196 if($.cookie('transLang') === null){
197 $.cookie('transLang', 'en', option);
199 if($.cookie('myLangs') === null){
200 $.cookie('myLangs', 'en', option);
202 var select = $('#transArea select[name=langs]');
203 select.change(function(){
204 var val = $(this).val();
205 $.cookie('transLang', val, option);
206 $.cookie('fullLang', $(this).find('option[value=' + val + ']').text(), option);
208 .find('option').each(function(){
209 var lang = $.cookie('transLang')
213 if($(this).val() === lang){
214 $(this).attr('selected', 'selected');
217 var mylang = $('#transArea select[name=myLangs]');
218 mylang.change(function(){
219 var val = $(this).val();
220 $.cookie('myLangs', val, option);
222 .find('option').each(function(){
223 var lang = $.cookie('myLangs')
227 if($(this).val() === lang){
228 $(this).attr('selected', 'selected');