1function ajaxComt(){ 2 var edit_mode = '0', // åç·¨è¼¯æ¨¡å¼ ( '1'=é; '0'=ä¸é ) 3 ajax_php_url = Theme.comment, // ÃÃÃÃÃÃ对åºä½ç½®æ¹ä¸ºajax phpçè·¯å¾ï¼è¥jså¨ä¸»é¢jsæä»¶å¤¹ä¸ï¼é£ä¹å ../ 4 5 comment = 'comment', // ÃÃà textarea çid ä¸å¸¦# 6 commentlist = 'commentwrap', // ÃÃà è¯è®ºå表ulæolçclassï¼ä¸å¸¦ç¹ 7 8 txt1 = '<div id="loading" class="text-info"><span class="comload"></span></div>', 9 txt2 = '<div id="error">#</div>', 10 txt3 = '"><div class="text-success"> <span class="sub-yes"></span>', 11 txt4 = '<div id="textloading">#</div>', 12 edt1 = ' å·æ°é¡µé¢ä¹åæ¨å¯ä»¥<a rel="nofollow" class="comment-reply-link" href="#edit" onclick=\'return addComment.moveForm("', 13 edt2 = ')\'>忬¡ç¼è¾è¯è®º</a></div>', 14 cancel_edit = 'åæ¶ç¼è¾', 15 edit, num = 1, comm_array=[]; comm_array.push(''); 16 $comments = $('#comments-list-title'); // è¯è®ºè®¡æ°çid 17 $cancel = $('#cancel-comment-reply-link'); 18 cancel_text = $cancel.text(); 19 $submit = $('#commentform #submit'); // ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà æäº¤æé®çidæclass 20 $submit.attr('disabled', false); 21 $('#'+comment).after( txt1 + txt2 + txt4); // ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ è¿æ¯è¯è®ºè¡¨åtextareaçidæclass 22 $('#loading').hide(); 23 $('#error').hide(); 24 $('#textloading').hide(); 25 $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); 26 27 /** è¯è®ºæäº¤ */ 28 $('#commentform').submit(function() { // ÃÃÃÃÃÃÃÃÃà form表åçid 29 $('#loading').slideDown(); 30 $submit.attr('disabled', true).fadeTo('slow', 0.5); 31 if ( edit ) $('#'+comment).after('<input type="text" name="edit_id" id="edit_id" value="' + edit + '" style="display:none;" />'); //ÃÃÃÃÃÃÃà å¨textareaæ ç¾ä¹åæå ¥ 32 33 /** è¯è®ºAjaxæ ¸å¿ */ 34 $.ajax( { 35 url: ajax_php_url, // è¿æ¯ajax.phpçè·¯å¾ 36 data: $(this).serialize()+ "&action=ajax_comment_post",//iowen 37 type: $(this).attr('method'), 38 error: function(request) { 39 $('#loading').slideUp(); 40 $('#error').slideDown().html('<span class="sub-no"></span>' +request.responseText); 41 setTimeout(function() {$submit.attr('disabled', false).fadeTo('slow', 1); $('#error').slideUp();}, 3000); 42 }, 43 success: function (data) { 44 $('#loading').hide(); 45 comm_array.push($('#' + comment).val()); // ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà è¿ä¸ªc-textarea为textareaçid 46 $('textarea').each(function () { this.value = '' }); 47 var t = addComment, 48 cancel = GI('cancel-comment-reply-link'), 49 temp = GI('wp-temp-form-div'), 50 respond = GI(t.respondId), 51 post = GI('comment_post_ID').value, 52 parent = GI('comment_parent').value; 53 //location.reload(true); 54 //$(".entry-content").html(data);//è¦å·æ°çdiv 55 // å¢å è¯è®ºæ° 56 if (!edit && $comments.length) { 57 n = parseInt($comments.text().match(/\d+/)); // æ£åå¹é ææ¬å 容ä¸çæ°å 58 $comments.html($comments.html().replace(n, n + 1)); 59 } 60 // è¯è®ºæ¾ç¤º 61 new_htm = '" id="new_comm_' + num + '"></'; 62 new_htm = (parent == '0') ? ('\n<ol class="' + commentlist + '" ' + new_htm + 'ol>') : ('\n<ul class="children' + new_htm + 'ul>');// ÃÃÃÃÃÃÃè¯è®ºå表çclass 63 ok_htm = '\n<div class="ajax-notice" id="success_' + num + txt3; 64 if (edit_mode == '1') { 65 div_ = (document.body.innerHTML.indexOf('div-comment-') == -1) ? '' : ((document.body.innerHTML.indexOf('li-comment-') == -1) ? 'div-' : ''); 66 ok_htm = ok_htm.concat(edt1, div_, 'comment-', parent, '", "', parent, '", "respond", "', post, '", ', num, edt2); 67 } else { 68 ok_htm += 'è¯è®ºæå'; 69 } 70 ok_htm += '</span><span></span>\n'; 71 72 new_htm = $(new_htm); 73 $('#respond').before(new_htm); 74 75 $('#new_comm_' + num).append(data); 76 $('#new_comm_' + num + ' li').append(ok_htm); 77 $body.animate({ scrollTop: $('#new_comm_' + num).offset().top - 200 }, 900); 78 countdown(); num++; edit = ''; $('*').remove('#edit_id'); 79 cancel.style.display = 'none'; 80 cancel.onclick = null; 81 GI('comment_parent').value = '0'; 82 83 if (new_htm.find('pre').length && $('link#enlighterjs').length) { 84 new_htm.find('pre').enlight({ 85 linenumbers: !0, 86 indent: 2, 87 textOverflow: 'scroll', 88 theme: 'enlighter', 89 title: Theme.pre_c, 90 });
91 } else { 92 highlightJs(); 93 } 94 95 if (temp && respond) { 96 temp.parentNode.insertBefore(respond, temp); 97 temp.parentNode.removeChild(temp) 98 } 99 } 100 }); // end Ajax 101 return false; 102 }); // end submit 103 104 /** ç§»å¨åå¤è¡¨å */ 105 addComment = { 106 moveForm : function(commId, parentId, respondId, postId, num) { 107 //reply(commId); // å夿·»å @ 108 var t = this, 109 div, 110 comm = GI(commId), 111 respond = GI(respondId), 112 cancel = GI('cancel-comment-reply-link'), 113 parent = GI('comment_parent'), 114 post = GI('comment_post_ID'); 115 if ( edit ) exit_prev_edit(); 116 num ? ( 117 GI(comment).value = comm_array[num],// ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃè¿ä¸ªä¸ºtextareaçid 118 edit = GI('new_comm_' + num).innerHTML.match(/(comment-)(\d+)/)[2], 119 $new_sucs = $('#success_' + num ), $new_sucs.hide(), 120 $new_comm = $('#new_comm_' + num ), $new_comm.hide(), 121 $cancel.text(cancel_edit) 122 ) : $cancel.text(cancel_text); 123 124 t.respondId = respondId; 125 postId = postId || false; 126 127 if ( !GI('wp-temp-form-div') ) { 128 div = document.createElement('div'); 129 div.id = 'wp-temp-form-div'; 130 div.style.display = 'none'; 131 respond.parentNode.insertBefore(div, respond); 132 } 133 134 !comm ? ( 135 temp = GI('wp-temp-form-div'), 136 GI('comment_parent').value = '0', 137 temp.parentNode.insertBefore(respond, temp), 138 temp.parentNode.removeChild(temp) 139 ) : comm.parentNode.insertBefore(respond, comm.nextSibling); 140 $body.animate( { scrollTop: $('#respond').offset().top - 180 }, 400); 141 if ( post && postId ) post.value = postId; 142 parent.value = parentId; 143 cancel.style.display = ''; 144 // åæ¶æé®å¨ä½ 145 cancel.onclick = function() { 146 if ( edit ) exit_prev_edit(); 147 var t = addComment, temp = GI('wp-temp-form-div'), respond = GI(t.respondId); 148 149 GI('comment_parent').value = '0'; 150 if ( temp && respond ) { 151 temp.parentNode.insertBefore(respond, temp); 152 temp.parentNode.removeChild(temp); 153 } 154 this.style.display = 'none'; 155 this.onclick = null; 156 $('textarea').val(''); // æ¸ ç©ºtextareaåº 157 return false; 158 }; 159 160 try { GI('comment').focus(); } 161 catch(e) {} 162 163 return false; 164 } 165 } // end addComment 166 167 function GI(e) { 168 return document.getElementById(e); 169 } 170 function exit_prev_edit() { 171 $new_comm.show(); $new_sucs.show(); 172 $('textarea').each(function() {this.value = ''}); 173 edit = ''; 174 } 175 176 /** éç¼è¾çå¾ æ¶é´ 鲿¢å¿«éæäº¤ */ 177 var wait = 8, submit_val = $submit.val(); 178 function countdown() { 179 if ( wait > 0 ) { 180 $submit.val(wait); wait--; setTimeout(countdown, 1000); 181 } else { 182 $submit.val(submit_val).attr('disabled', false).fadeTo('slow', 1); 183 wait = 8; 184 } 185 } 186} 187 188// end Ajaxè¯è®º 189(function ($) { 190 $(document).ready(function () { 191 ajaxComt(); 192 $("#io_emojis").hover(function () { 193 $("#emojis_link").toggle(150); 194 }); 195 }); 196 $(document).on('click', '#io-img-url-btn', function () { 197 var src = $('#io-img-url').val(); 198 if (!src) { 199 return iPopupTips(0, "请è¾å ¥å¾çå°å"); 200 } 201 val = "[img]" + src + "[/img]\n"; 202 insertContent(val); 203 $('#io-img-modal').modal('hide'); 204 }); 205 $(document).on('click', '#io-add-code-btn', function () { 206 var src = $('#io-code-text').val(); 207 if (!src) { 208 return iPopupTips(0, "请è¾å ¥ä»£ç "); 209 } 210 val = "[code]\n" + src + "\n[/code]\n"; 211 insertContent(val); 212 $('#io-code-modal').modal('hide'); 213 }); 214 $(document).on('click', '.add-smily', function () { 215 var tag = $(this).data('smilies'); 216 grin(tag); 217 }); 218 219 $(document).on('change', "#io-img-up-input", function (e) { 220 var files = this.files || e.dataTransfer.files; 221 var ing_key = 'uploading'; 222 223 if (!files[0] || $(this).data(ing_key)){ 224 return false; 225 } 226 var file = files[0]; 227 //æä»¶å¤§å°å¤æ 228 var size_max = Theme.up_img_max || 1024; 229 if (file.size > size_max * 1024 ) { 230 return iPopupTips(0,"æä»¶å¤§å°è¶ è¿" + size_max + "KB"); 231 } 232 233 $('#io-img-modal').modal('hide'); 234 $('#loading').slideDown(); 235 //æ§è¡ä¸ä¼ 236 uploadImg(file, $(this), function (n) { 237 if (n.src) { 238 val = "[img]" + n.src + "[/img]\n"; 239 $('#loading').hide(); 240 insertContent(val); 241 } 242 }); 243 }); 244})(jQuery); 245 246function insertContent(val, fun) { 247 var textarea = $("#comment"); 248 var _val = textarea.val(); 249 textarea.val(_val + val).focus().click(); 250 $.isFunction(fun) && fun(_this, val); 251} 252 253//ä¸ä¼ å¾ç 254function uploadImg(file, _input, success_fun) { 255 var formData = new FormData(); 256 var ing_key = 'uploading'; 257 formData.append('file', file, file.name); 258 formData.append('action', 'edit_file_upload'); 259 formData.append('_wpnonce', Theme.upload_nonce); 260 //showAlert({"status":0,"msg":"æ£å¨ä¸ä¼ 请ç¨å..."}); 261 _input.data(ing_key, true); 262 $.ajax({
263 type: 'POST', 264 url: Theme.ajaxurl, 265 data: formData, 266 processData: false, 267 contentType: false, 268 dataType: 'json', 269 error: function (n) { 270 var _msg = "æä½å¤±è´¥ " + n.status + ' ' + n.statusText + 'ï¼è¯·å·æ°é¡µé¢åéè¯'; 271 if (n.responseText && n.responseText.indexOf("è´å½é误") > -1) { 272 _msg = 'ç½ç«éå°è´å½é误ï¼è¯·æ£æ¥æä»¶å²çªæéè¿é误æ¥å¿æé¤é误'; 273 } 274 iPopupTips(0,_msg); 275 _input.data(ing_key, false); 276 }, 277 success: function (n) { 278 $.isFunction(success_fun) && success_fun(n, _input); 279 _input.data(ing_key, false); 280 } 281 }) 282} 283 284function grin(tag) { 285 var myField; 286 tag = ' ' + tag + ' '; 287 if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') { 288 myField = document.getElementById('comment'); 289 } else { 290 return false; 291 } 292 if (document.selection) { 293 myField.focus(); 294 sel = document.selection.createRange(); 295 sel.text = tag; 296 myField.focus(); 297 } 298 else if (myField.selectionStart || myField.selectionStart == '0') { 299 var startPos = myField.selectionStart; 300 var endPos = myField.selectionEnd; 301 var cursorPos = endPos; 302 myField.value = myField.value.substring(0, startPos) 303 + tag 304 + myField.value.substring(endPos, myField.value.length); 305 cursorPos += tag.length; 306 myField.focus(); 307 myField.selectionStart = cursorPos; 308 myField.selectionEnd = cursorPos; 309 } 310 else { 311 myField.value += tag; 312 myField.focus(); 313 } 314}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.