5 $("#btn_savesearch").click(function(e){
6 var nowsearch = $("#query").val().trim();
7 if (theAC == null || searches == null || nowsearch == '') {
8 updateSentTip("Error in saving search!", 3000, "failure");
13 $.each(searches, function(){
14 if (nowsearch == this[1]) {
15 updateSentTip("Duplicated search!", 3000, "failure");
22 url: "ajax/savedSearches.php",
23 data: {method: "save", query: nowsearch},
25 success: function(msg) {
26 if (msg.indexOf("[") >= 0) {
27 updateSentTip("Successfully saved search!", 3000, "success");
28 var theData = eval("("+msg+")");
29 searches.push(theData);
31 theAC.setOptions({data:searches});
34 updateSentTip("Error in saving search!", 3000, "failure");
36 error: function(msg) {
37 updateSentTip("Error in saving search!", 3000, "failure");
43 url: "ajax/savedSearches.php",
44 data: {method: "list"},
46 success: function(msg) {
47 searches = eval("("+msg+")");
48 $(".ss_delete_btn").live("click",function(e){
51 if (theAC != null && searches != null) {
52 var selectedId = $(this).attr("id").substr(3);
53 var selectedIndex = -1;
54 $.each(searches, function(ind, ele){
55 if (ele[0] == selectedId)
58 if (selectedIndex != -1) {
59 var cfm = window.confirm("Are you sure to delete the saved search \"" + searches[selectedIndex][1] + "\"?");
62 url: "ajax/savedSearches.php",
63 data: {method: "delete", ssid: selectedId},
65 success: function(m) {
66 if (m.indexOf("success") >= 0)
67 updateSentTip("Successfully deleted saved search!", 3000, "success");
69 updateSentTip("Error in deleting saved search!", 3000, "failure");
70 searches.splice(selectedIndex, 1);
72 theAC.setOptions({data:searches});
75 updateSentTip("Error in deleting saved search!", 3000, "failure");
81 theAC = $("#query").autocomplete(searches, {
83 formatItem:function(data, i, total) {
84 return "<a class=\"ss_delete_btn\" href=\"#\" id=\"sgt" + data[0] + "\" >delete</a>" + data[1];
86 formatMatch:function(data, i, total) {
89 formatResult:function(data) {
94 error: function(msg) {
95 updateSentTip("Failed to fetch the saved searches!", 3000, "failure");
99 formHTML = "<h2>What are you doing?</h2>" + formHTML + "<div class=\"clear\"></div>";
100 $("#allTimeline").click(function(e) {
101 var $this = $(e.target);
102 var type = $this.attr('class');
106 if ($("#textbox").length > 0) {
109 $("#search_form").after(formHTML);
120 if ($("#textbox").length > 0) {
123 $("#search_form").after(formHTML);
146 $("#submit_btn").click(function(e){