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);
117 updateSentTip("Failed to upload, please try again.", 3e3, "failure");
118 $("#photoArea").slideToggle(100);
121 error: function (data, status, e){
122 updateSentTip("Failed to upload, please try again.", 3e3, "failure");
123 $("#photoArea").slideToggle(100);
129 function enableFilter(){
130 if ($.cookie(FILTER_COOKIE) != null && $.cookie(FILTER_COOKIE) != ""){
131 $('#iptFilter').val(recoverKeywords());
132 $.cookie(FILTER_COUNTER, null);
136 function filterEle(){
137 if ($.trim($('#iptFilter').val()).length == 0){
142 var keywords = keywordRegexp();
143 if (keywords === $.cookie(FILTER_COOKIE)){
144 objs = $('#statuses .timeline li:not(.filter:hidden)').find('.status_word');
146 objs = $('#statuses .timeline li').find('.status_word');
148 var reg = new RegExp(keywords, "i");
149 for (i = 0; i < objs.length; i++){
150 if (reg.test($(objs[i]).text())){
151 targets.push(objs[i]);
154 if ($.cookie(FILTER_COUNTER) != null && $.cookie(FILTER_COUNTER) != ''){
155 $.cookie(FILTER_COUNTER, targets.length + parseInt($.cookie(FILTER_COUNTER)));
157 $.cookie(FILTER_COUNTER, targets.length);
159 hideMatched(targets);
160 $.cookie(FILTER_COOKIE, keywords);
164 function hideMatched(obj){
165 $(obj).parent().parent().addClass("filter").hide();
167 function isMatch(txt, keywords){
168 var reg = RegExp(keywords, "i");
169 return reg.test(txt);
171 function keywordRegexp(){
172 if ($.cookie(FILTER_COOKIE) === null){
173 return setFilterCookie();
175 return $.cookie(FILTER_COOKIE);
178 function recoverKeywords(){
179 return $.cookie(FILTER_COOKIE).replace(/\|/g, ',');
181 function setFilterCookie(){
182 var strs = $('#iptFilter').val().split(",");
184 for (i = 0; i < strs.length; i++){
185 if (strs[i] == "") continue;
186 keywords += strs[i] + "|";
188 keywords = keywords.substr(0, keywords.length - 1);
191 var option ={ expire: 30 };
192 $(document).ready(function (){
194 if($.cookie('transLang') === null){
195 $.cookie('transLang', 'en', option);
197 if($.cookie('myLangs') === null){
198 $.cookie('myLangs', 'en', option);
200 var select = $('#transArea select[name=langs]');
201 select.change(function(){
202 var val = $(this).val();
203 $.cookie('transLang', val, option);
204 $.cookie('fullLang', $(this).find('option[value=' + val + ']').text(), option);
206 .find('option').each(function(){
207 var lang = $.cookie('transLang')
211 if($(this).val() === lang){
212 $(this).attr('selected', 'selected');
215 var mylang = $('#transArea select[name=myLangs]');
216 mylang.change(function(){
217 var val = $(this).val();
218 $.cookie('myLangs', val, option);
220 .find('option').each(function(){
221 var lang = $.cookie('myLangs')
225 if($(this).val() === lang){
226 $(this).attr('selected', 'selected');