2 $(".rt_btn").live("click", function(e){
7 $(".replie_btn").live("click", function(e){
11 $(".favor_btn").live("click", function(e){
15 $(".unfollow_list").live("click",function(e){
18 var id = $this.parent().parent().find(".rank_name").text().substr(1);
19 updateSentTip("Unfollowing lists...", 5000, "ing");
23 data: "action=destory&id=" + id,
24 success: function(msg) {
25 if (msg.indexOf("success") >= 0) {
26 updateSentTip("Successfully unfollowing list " + id, 3000, "success");
27 $this.parent().parent().parent().fadeOut("fast");
29 updateSentTip("Unfollow failed. Please try again.", 3000, "failure");
32 error: function(msg) {
33 updateSentTip("Unfollow failed. Please try again.", 3000, "failure");
39 $(".delete_list").live("click", function(e){
42 var list_slug = $this.parent().parent().find(".rank_name").text().split("/")[1];
43 var confirm = window.confirm("Do you really want to delete " + list_slug + "?");
45 updateSentTip("deleting list " + list_slug + "...", 5000, "ing");
47 url: "ajax/delete.php",
49 data: "list_slug=" + list_slug,
50 success: function(msg) {
51 if (msg.indexOf("success") >= 0) {
52 updateSentTip("Successfully deleting " + list_slug, 3000, "success");
53 $this.parent().parent().parent().fadeOut("fast");
55 updateSentTip("Delete failed. Please try again.", 3000, "failure");
58 error: function(msg) {
59 updateSentTip("Delete failed. Please try again.", 3000, "failure");
65 $("#list_create_btn").live("click", function(e){
67 $("#list_form").toggle("fast");
68 $("#list_name").focus().val("");
69 $("#list_description").val("");
70 $("#list_protect").removeAttr("checked");
71 $("#pre_list_name").val("");
72 $("#list_spanid").val("");
74 $("#list_submit").val("Create");
77 $(".edit_list").live("click", function(e){
79 var parent = $(this).parent().parent();
80 var list_name = parent.find(".rank_name").text().split("/")[1];
81 var list_description = parent.find(".rank_description").text().slice(5);
82 var list_protect = parent.find(".rank_count").text().indexOf("Private") > 0;
84 $("#list_form").show("fast");
85 $("#list_name").focus().val(list_name);
86 $("#list_description").val(list_description);
88 $("#list_protect").attr("checked", "checked");
90 $("#list_protect").removeAttr("checked");
92 $("#list_spanid").val(parent.attr("id"));
94 $("#list_submit").val("Edit");
95 $("#pre_list_name").val(list_name);
98 $("#list_submit").live("click", function(e){
100 var list_name = $("#list_name").val();
101 if (list_name.length == 0) {
102 window.alert("List name cannot be empty!");
105 $('#list_form').slideToggle(300);
106 var list_description = $("#list_description").val();
107 var list_protect = $("#list_protect").attr("checked") == "checked" ? "private" : "public";
108 var pre_list_name = $("#pre_list_name").val();
109 var is_edit = $("#is_edit").val();
110 var postdata = {"name" : list_name,
111 "description" : list_description,
112 "mode" : list_protect};
114 postdata["slug"] = pre_list_name;
115 updateSentTip("editing list " + pre_list_name + "...", 5000, "ing");
116 var spanid = $("#list_spanid").val();
118 updateSentTip("creating list " + list_name + "...", 5000, "ing");
121 url: "ajax/modifyList.php",
125 success: function(msg) {
126 if (msg.result == 'success') {
128 updateSentTip("Successfully modifying list " + pre_list_name, 3000, "success");
129 var rank_content = $("#"+spanid);
130 rank_content.find(".rank_name").html('<a href="list.php?id='+msg.listuri+'"><em>'+msg.username+'/</em>'+list_name+'</a>');
131 var rank_count = rank_content.find(".rank_count");
132 rank_count.html(rank_count.html().replace(/Public|Private/, list_protect == "public" ? "Public" : "Private"));
133 rank_content.find(".rank_description").html("Bio: "+list_description);
136 updateSentTip("Successfully creating list " + list_name, 3000, "success");
137 var html = '<li><span class=\"rank_img\"><img src="'+msg.imgurl+'" /></span>';
138 html += '<div class="rank_content" id="'+msg.contentid+'"><span class="rank_num"><span class="rank_name">';
139 html +='<a href="list.php?id='+msg.listuri+'"><em>'+msg.username+'/</em>'+list_name+'</a>';
140 html += '</span></span><span class="rank_count">Followers: 0 Members: 0 '+(list_protect == "public" ? "Public" : "Private")+'</span>';
141 html += '<span class="rank_description">Bio: '+list_description+'</span>';
142 html += '<span id="list_action"><a id="btn" href="#" class="edit_list">Edit</a> <a id="btn" href="#" class="delete_list">Delete</a> <a id="btn" href="#" class="add_member">Add Members</a></span>';
143 html += "</div></li>";
144 $(html).prependTo($(".rank_list")).fadeIn('fast');
148 updateSentTip("Editing failed. Please try again.", 3000, "failure");
150 updateSentTip("Creating failed. Please try again.", 3000, "failure");
156 $(".add_member").live("click", function(e){
158 $("#member_form").remove();
159 var position = $(this).position();
160 var liPosition = $(this).parent().parent().parent().position();
161 var list_name = $(this).parent().parent().find(".rank_name").text().split("/")[1];
162 var owner_name = $(this).parent().parent().find(".rank_name").text().split("/")[0];
163 var rank_count = $(this).parent().parent().find(".rank_count");
164 owner_name = owner_name.split("@")[1];
165 $('<form method="POST" action="./lists.php?t=1" id="member_form">' +
166 '<span>User ID:(Saperated with comma, e.g. JLHwung,twitter)</span>' +
167 '<span><textarea type="text" name="list_members" id="list_members"></textarea></span>' +
168 '<span><input type="submit" class="btn" id="member_submit" value="Submit" /> <input type="button" class="btn" id="member_cancel" value="Cancel" /></span>' +
169 '</form>').appendTo("#statuses").css("left", liPosition.left + position.left).css("top", liPosition.top + position.top + 30);
171 $("#member_cancel").click(function(){
172 $("#member_form").remove();
175 $("#member_submit").click(function(e){
177 var list_members = $("#list_members").val();
178 if (list_members.length <= 0) {
179 window.alert("User IDs cannot be empty!");
182 $("#member_form").remove();
183 updateSentTip("adding members to list " + list_name + "...", 5000, "ing");
185 url: "ajax/addMembersToList.php",
187 data: { "slug" : list_name,
188 "owner" : owner_name,
189 "add_members" : list_members},
190 success: function(msg) {
191 if (msg.indexOf("error") >= 0) {
192 updateSentTip("Adding failed. Please try again.", 3000, "failure");
194 updateSentTip("Successfully adding members to list " + list_name, 3000, "success");
195 rank_count.html(msg);
198 error: function(msg) {
199 updateSentTip("Adding failed. Please try again.", 3000, "failure");