OSDN Git Service

5143132a748aa09f4d1aabf35a060f2769d8404b
[embrj/master.git] / js / userlist.js
1 $(function () {\r
2         $(".rank_img img").tipsy({gravity: 's'});\r
3         $(".rank_img img").live("click", function (e) {\r
4                 $(".right_menu").hide();\r
5                 $(this).parent().parent().parent().find(".right_menu").css("display", "block");\r
6                 e.preventDefault();\r
7         });\r
8         $('body').click(function () {\r
9                 $(".right_menu").hide();\r
10         });\r
11         $('.status_author li a').click(function () {\r
12                 $(".right_menu").hide();\r
13         });\r
14         $(".ul_mention").live("click", function (e) {\r
15                 e.preventDefault();\r
16                 ulmention($(this), e);\r
17         });\r
18         $(".ul_dm").live("click", function (e) {\r
19                 e.preventDefault();\r
20                 uldm($(this), e);\r
21         });\r
22         $(".ul_follow").live("click", function (e) {\r
23                 e.preventDefault();\r
24                 var $this = $(this);\r
25                 var id = $this.parent().parent().parent().find(".rank_screenname").text();\r
26                 updateSentTip("Following " + id + "...", 5000, "ing");\r
27                 $.ajax({\r
28                         url: "ajax/relation.php",\r
29                         type: "POST",\r
30                         data: "action=create&id=" + id,\r
31                         success: function (msg) {\r
32                                 if (msg.indexOf("success") >= 0) {\r
33                                         $this.parent().parent().parent().addClass("reply");\r
34                                         updateSentTip("You have followed " + id + "!", 3000, "success");\r
35                                 } else {\r
36                                         updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");\r
37                                 }\r
38                         },\r
39                         error: function (msg) {\r
40                                 updateSentTip("Failed to follow " + id + ", please try again.", 3000, "failure");\r
41                         }\r
42                 });\r
43         });\r
44         $(".ul_unfollow").live("click", function (e) {\r
45                 e.preventDefault();\r
46                 var $this = $(this);\r
47                 var id = $this.parent().parent().parent().find(".rank_screenname").text();\r
48                 if (confirm("Are you sure to unfollow " + id + " ?")) {\r
49                         updateSentTip("Unfollowing " + id + "...", 5000, "ing");\r
50                         $.ajax({\r
51                                 url: "ajax/relation.php",\r
52                                 type: "POST",\r
53                                 data: "action=destory&id=" + id,\r
54                                 success: function (msg) {\r
55                                         if (msg.indexOf("success") >= 0) {\r
56                                                 $this.parent().parent().parent().addClass("filter");\r
57                                                 updateSentTip("You have unfollowed " + id + "!", 3000, "success");\r
58                                         } else {\r
59                                                 updateSentTip("Failed to unfollow " + id + ", please try again.", 3000, "failure");\r
60                                         }\r
61                                 },\r
62                                 error: function (msg) {\r
63                                         updateSentTip("Failed to unfollow " + id + ", please try again.", 3000, "failure");\r
64                                 }\r
65                         });\r
66                 }\r
67         });\r
68         $(".ul_block").live("click", function (e) {\r
69                 e.preventDefault();\r
70                 var $this = $(this);\r
71                 var id = $this.parent().parent().parent().find(".rank_screenname").text();\r
72                 if (confirm("Are you sure to block " + id + " ?")) {\r
73                         updateSentTip("Blocking " + id + "...", 5000, "ing");\r
74                         $.ajax({\r
75                                 url: "ajax/relation.php",\r
76                                 type: "POST",\r
77                                 data: "action=block&id=" + id,\r
78                                 success: function (msg) {\r
79                                         if (msg.indexOf("success") >= 0) {\r
80                                                 $this.parent().parent().parent().fadeOut("normal");\r
81                                                 updateSentTip("You have blocked " + id + "!", 3000, "success");\r
82                                         } else {\r
83                                                 updateSentTip("Failed to block " + id + ", please try again.", 3000, "failure");\r
84                                         }\r
85                                 },\r
86                                 error: function (msg) {\r
87                                         updateSentTip("Failed to block " + id + ", please try again.", 3000, "failure");\r
88                                 }\r
89                         });\r
90                 }\r
91         });\r
92 })\r
93 $(".ul_spam").live("click", function (e) {\r
94         e.preventDefault();\r
95         var $this = $(this);\r
96         var id = $this.parent().parent().parent().find(".rank_screenname").text();\r
97         if (confirm("Are you sure to report " + id + " ?")) {\r
98                 updateSentTip("Reporting " + id + " as a spammer...", 5000, "ing");\r
99                 $.ajax({\r
100                         url: "ajax/reportSpam.php",\r
101                         type: "POST",\r
102                         data: "spammer=" + id,\r
103                         success: function (msg) {\r
104                                 if (msg.indexOf("success") >= 0) {\r
105                                         $this.parent().parent().parent().fadeOut("normal");\r
106                                         updateSentTip("Successfully reported!", 3000, "success");\r
107                                 } else {\r
108                                         updateSentTip("Failed to report " + id + ", please try again.", 3000, "failure");\r
109                                 }\r
110                         },\r
111                         error: function (msg) {\r
112                                 updateSentTip("Failed to report " + id + ", please try again.", 3000, "failure");\r
113                         }\r
114                 });\r
115         }\r
116 });\r
117 function ulmention($this, e) {\r
118         var replie_id = $this.parent().parent().parent().find(".rank_screenname").text();\r
119         if ($("#textbox").length > 0) {\r
120                         var text = "@" + replie_id;\r
121                         scroll(0, 0);\r
122                         $("#textbox").focus();\r
123                         $("#textbox").val($("#textbox").val() + text + ' ');\r
124                         leaveWord();\r
125                 } else {\r
126                         $("#statuses h2").before('<h2>Mention</h2>' + formHTML);\r
127                         formFunc();\r
128                         var text = "@" + replie_id;\r
129                         scroll(0, 0);\r
130                         $("#textbox").focus();\r
131                         $("#textbox").val($("#textbox").val() + text + ' ');\r
132                         leaveWord();\r
133                 }\r
134 }\r
135 function uldm($this, e) {\r
136         var replie_id = $this.parent().parent().parent().find(".rank_screenname").text();\r
137         if ($("#textbox").length > 0) {\r
138                         var text = "D " + replie_id;\r
139                         scroll(0, 0);\r
140                         $("#textbox").focus();\r
141                         $("#textbox").val($("#textbox").val() + text + ' ');\r
142                         leaveWord();\r
143                 } else {\r
144                         $("#statuses h2").before('<h2>Send direct message</h2>' + formHTML);\r
145                         formFunc();\r
146                         var text = "D " + replie_id;\r
147                         scroll(0, 0);\r
148                         $("#textbox").focus();\r
149                         $("#textbox").val($("#textbox").val() + text + ' ');\r
150                         leaveWord();\r
151                 }\r
152 }