[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 var Thread = { 2 init: function() 3 { 4 Thread.qeCache = new Array(); 5 Thread.initMultiQuote(); 6 Thread.initQuickReply(); 7 }, 8 9 initMultiQuote: function() 10 { 11 var quoted = Cookie.get("multiquote"); 12 if(quoted) 13 { 14 var post_ids = quoted.split("|"); 15 post_ids.each(function(post_id) { 16 if($("multiquote_"+post_id)) 17 { 18 element = $("multiquote_"+post_id); 19 element.src = element.src.replace("postbit_multiquote.gif", "postbit_multiquote_on.gif"); 20 } 21 }); 22 if($('quickreply_multiquote')) 23 { 24 $('quickreply_multiquote').show(); 25 } 26 } 27 return true; 28 }, 29 30 multiQuote: function(pid) 31 { 32 var new_post_ids = new Array(); 33 var quoted = Cookie.get("multiquote"); 34 var is_new = true; 35 if(quoted) 36 { 37 var post_ids = quoted.split("|"); 38 post_ids.each(function(post_id) { 39 if(post_id != pid && post_id != '') 40 { 41 new_post_ids[new_post_ids.length] = post_id; 42 } 43 else if(post_id == pid) 44 { 45 is_new = false; 46 } 47 }); 48 } 49 element = $("multiquote_"+pid); 50 if(is_new == true) 51 { 52 element.src = element.src.replace("postbit_multiquote.gif", "postbit_multiquote_on.gif"); 53 new_post_ids[new_post_ids.length] = pid; 54 } 55 else 56 { 57 element.src = element.src.replace("postbit_multiquote_on.gif", "postbit_multiquote.gif"); 58 } 59 if($('quickreply_multiquote')) 60 { 61 if(new_post_ids.length > 0) 62 { 63 $('quickreply_multiquote').show(); 64 } 65 else 66 { 67 $('quickreply_multiquote').hide(); 68 } 69 } 70 Cookie.set("multiquote", new_post_ids.join("|")); 71 }, 72 73 loadMultiQuoted: function() 74 { 75 if(use_xmlhttprequest == 1) 76 { 77 this.spinner = new ActivityIndicator("body", {image: imagepath + "/spinner_big.gif"}); 78 new Ajax.Request('xmlhttp.php?action=get_multiquoted&load_all=1', {method: 'get', onComplete: function(request) {Thread.multiQuotedLoaded(request); }}); 79 return false; 80 } 81 else 82 { 83 return true; 84 } 85 }, 86 87 multiQuotedLoaded: function(request) 88 { 89 if(request.responseText.match(/<error>(.*)<\/error>/)) 90 { 91 message = request.responseText.match(/<error>(.*)<\/error>/); 92 if(!message[1]) 93 { 94 message[1] = "An unknown error occurred."; 95 } 96 if(this.spinner) 97 { 98 this.spinner.destroy(); 99 this.spinner = ''; 100 } 101 alert('There was an error fetching the posts.\n\n'+message[1]); 102 } 103 else if(request.responseText) 104 { 105 var id = 'message'; 106 if(typeof clickableEditor != 'undefined') 107 { 108 id = clickableEditor.textarea; 109 } 110 if($(id).value) 111 { 112 $(id).value += "\n"; 113 } 114 $(id).value += request.responseText; 115 } 116 Thread.clearMultiQuoted(); 117 $('quickreply_multiquote').hide(); 118 $('quoted_ids').value = 'all'; 119 if(this.spinner) 120 { 121 this.spinner.destroy(); 122 this.spinner = ''; 123 } 124 $('message').focus(); 125 }, 126 127 clearMultiQuoted: function() 128 { 129 $('quickreply_multiquote').hide(); 130 var quoted = Cookie.get("multiquote"); 131 if(quoted) 132 { 133 var post_ids = quoted.split("|"); 134 post_ids.each(function(post_id) { 135 if($("multiquote_"+post_id)) 136 { 137 element = $("multiquote_"+post_id); 138 element.src = element.src.replace("postbit_multiquote_on.gif", "postbit_multiquote.gif"); 139 } 140 }); 141 } 142 Cookie.unset('multiquote'); 143 }, 144 145 deletePost: function(pid) 146 { 147 confirmReturn = confirm(quickdelete_confirm); 148 if(confirmReturn == true) 149 { 150 var form = new Element("form", { method: "post", action: "editpost.php?action=deletepost&delete=1", style: "display: none;" }); 151 152 if(my_post_key) 153 { 154 form.insert({ bottom: new Element("input", 155 { 156 name: "my_post_key", 157 type: "hidden", 158 value: my_post_key 159 }) 160 }); 161 } 162 163 form.insert({ bottom: new Element("input", 164 { 165 name: "pid", 166 type: "hidden", 167 value: pid 168 }) 169 }); 170 171 $$("body")[0].insert({ bottom: form }); 172 form.submit(); 173 } 174 }, 175 176 reportPost: function(pid) 177 { 178 MyBB.popupWindow("report.php?pid="+pid, "reportPost", 400, 300) 179 }, 180 181 quickEdit: function(pid) 182 { 183 if(!$("pid_"+pid)) 184 { 185 return false; 186 } 187 188 if(Thread.qeCache[pid]) 189 { 190 return false; 191 } 192 193 Thread.qeCache[pid] = $("pid_"+pid).innerHTML; 194 this.spinner = new ActivityIndicator("body", {image: imagepath + "/spinner_big.gif"}); 195 new Ajax.Request('xmlhttp.php?action=edit_post&do=get_post&pid='+pid, {method: 'get', onComplete: function(request) { Thread.quickEditLoaded(request, pid); }}); 196 return false; 197 }, 198 199 quickEditLoaded: function(request, pid) 200 { 201 if(request.responseText.match(/<error>(.*)<\/error>/)) 202 { 203 message = request.responseText.match(/<error>(.*)<\/error>/); 204 if(!message[1]) 205 { 206 message[1] = "An unknown error occurred."; 207 } 208 if(this.spinner) 209 { 210 this.spinner.destroy(); 211 this.spinner = ''; 212 } 213 alert('There was an error performing the update.\n\n'+message[1]); 214 Thread.qeCache[pid] = ""; 215 } 216 else if(request.responseText) 217 { 218 $("pid_"+pid).innerHTML = request.responseText; 219 element = $("quickedit_"+pid); 220 element.focus(); 221 offsetTop = -60; 222 do 223 { 224 offsetTop += element.offsetTop || 0; 225 element = element.offsetParent; 226 } 227 while(element); 228 229 scrollTo(0, offsetTop); 230 } 231 if(this.spinner) 232 { 233 this.spinner.destroy(); 234 this.spinner = ''; 235 } 236 }, 237 238 quickEditSave: function(pid) 239 { 240 message = $("quickedit_"+pid).value; 241 if(message == "") 242 { 243 return false; 244 } 245 this.spinner = new ActivityIndicator("body", {image: imagepath + "/spinner_big.gif"}); 246 247 postData = "value="+encodeURIComponent(message).replace(/\+/g, "%2B"); 248 new Ajax.Request('xmlhttp.php?action=edit_post&do=update_post&pid='+pid+"&my_post_key="+my_post_key, {method: 'post', postBody: postData, onComplete: function(request) { Thread.quickEditSaved(request, pid); }}); 249 }, 250 251 quickEditCancel: function(pid) 252 { 253 $("pid_"+pid).innerHTML = Thread.qeCache[pid]; 254 Thread.qeCache[pid] = ""; 255 if(this.spinner) 256 { 257 this.spinner.destroy(); 258 this.spinner = ''; 259 } 260 }, 261 262 quickEditSaved: function(request, pid) 263 { 264 if(request.responseText.match(/<error>(.*)<\/error>/)) 265 { 266 message = request.responseText.match(/<error>(.*)<\/error>/); 267 if(!message[1]) 268 { 269 message[1] = "An unknown error occurred."; 270 } 271 if(this.spinner) 272 { 273 this.spinner.destroy(); 274 this.spinner = ''; 275 } 276 alert('There was an error performing the update.\n\n'+message[1]); 277 } 278 else if(request.responseText) 279 { 280 var message = request.responseText; 281 var edited_regex = new RegExp("<editedmsg>(.*)</editedmsg>", "m"); 282 if(request.responseText.match(edited_regex)) 283 { 284 var edited_message = request.responseText.match(edited_regex)[1]; 285 if($('edited_by_'+pid)) 286 { 287 $('edited_by_'+pid).innerHTML = edited_message; 288 } 289 message = message.replace(edited_regex, '') 290 } 291 $("pid_"+pid).innerHTML = message; 292 Thread.qeCache[pid] = ""; 293 } 294 295 if(this.spinner) 296 { 297 this.spinner.destroy(); 298 this.spinner = ''; 299 } 300 }, 301 302 initQuickReply: function() 303 { 304 if($('quick_reply_form') && use_xmlhttprequest == 1) 305 { 306 Event.observe($('quick_reply_submit'), "click", Thread.quickReply.bindAsEventListener(this)); 307 } 308 }, 309 310 quickReply: function(e) 311 { 312 Event.stop(e); 313 314 if(this.quick_replying) 315 { 316 return false; 317 } 318 319 this.quick_replying = 1; 320 var post_body = Form.serialize('quick_reply_form'); 321 this.spinner = new ActivityIndicator("body", {image: imagepath + "/spinner_big.gif"}); 322 new Ajax.Request('newreply.php?ajax=1', {method: 'post', postBody: post_body, onComplete: function(request) { Thread.quickReplyDone(request); }}); 323 return false; 324 }, 325 326 quickReplyDone: function(request) 327 { 328 if($('captcha_trow')) 329 { 330 captcha = request.responseText.match(/^<captcha>([0-9a-zA-Z]+)(\|([0-9a-zA-Z]+)|)<\/captcha>/); 331 if(captcha) 332 { 333 request.responseText = request.responseText.replace(/^<captcha>(.*)<\/captcha>/, ''); 334 335 if(captcha[1] == "reload") 336 { 337 Recaptcha.reload(); 338 } 339 else if($("captcha_img")) 340 { 341 if(captcha[1]) 342 { 343 imghash = captcha[1]; 344 $('imagehash').value = imghash; 345 if(captcha[3]) 346 { 347 $('imagestring').type = "hidden"; 348 $('imagestring').value = captcha[3]; 349 // hide the captcha 350 $('captcha_trow').style.display = "none"; 351 } 352 else 353 { 354 $('captcha_img').src = "captcha.php?action=regimage&imagehash="+imghash; 355 $('imagestring').type = "text"; 356 $('imagestring').value = ""; 357 $('captcha_trow').style.display = ""; 358 } 359 } 360 } 361 } 362 } 363 if(request.responseText.match(/<error>([^<]*)<\/error>/)) 364 { 365 message = request.responseText.match(/<error>([^<]*)<\/error>/); 366 367 if(!message[1]) 368 { 369 message[1] = "An unknown error occurred."; 370 } 371 372 if(this.spinner) 373 { 374 this.spinner.destroy(); 375 this.spinner = ''; 376 } 377 alert('There was an error posting your reply:\n\n'+message[1]); 378 } 379 else if(request.responseText.match(/id="post_([0-9]+)"/)) 380 { 381 var pid = request.responseText.match(/id="post_([0-9]+)"/)[1]; 382 var post = document.createElement("div"); 383 post.innerHTML = request.responseText; 384 $('posts').appendChild(post); 385 request.responseText.evalScripts(); 386 Form.reset('quick_reply_form'); 387 if($('lastpid')) 388 { 389 $('lastpid').value = pid; 390 } 391 } 392 else 393 { 394 request.responseText.evalScripts(); 395 } 396 397 if(this.spinner) 398 { 399 this.spinner.destroy(); 400 this.spinner = ''; 401 } 402 this.quick_replying = 0; 403 }, 404 405 showIgnoredPost: function(pid) 406 { 407 $('ignored_post_'+pid).hide(); 408 $('post_'+pid).show(); 409 } 410 }; 411 Event.observe(document, 'dom:loaded', Thread.init);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |