Var I = 0, got =-1, len = document. getElementsByTagName ('script'). length; While (I <= len & got =-1 ){ Var js_url = document. getElementsByTagName ('script') [I]. src, Got = js_url.indexOf ('comments-ajax. Js'); I ++; } Var edit_mode = '1', // then ?? Mode ('1' = ?; '0' = no? ) Ajax_php_url = js_url.replace ('-ajax. Js','-ajax. Php '), Wp_url = js_url.substr (0, js_url.indexOf ('WP-content ')), Pic_sb = wp_url + 'WP-admin/images/wpspin_dark.gif ', // submit the icon Pic_no = wp_url + 'WP-admin/images/no.png ',//?? Icon Pic_ys = wp_url + 'WP-admin/images/yes.png ', // success icon Txt1 = '<div id = "loading"> submitting ,? Wait... </div> ', Txt2 = '<div id = "error" >#</div> ', Txt3 = '"> submitted successfully ', Edt1 = '. Before refreshing the page, you can <a rel = "nofollow" class = "comment-reply-link" href = "# edit" onclick = 'return addComment. moveForm ("', Edt2 = ')'> edit </a> ', Cancel_edit = 'cancel editation ', Edit, num = 1, comm_array = []; comm_array.push (''); JQuery (document). ready (function ($ ){ $ Comments = $ ('# comments-title ');//??? File ID $ Cancel = $ ('# cancel-comment-reply-link'); cancel_text = $ cancel. text (); $ Submit = $ ('# commentform # submit'); $ submit. attr ('disabled ', false ); $ ('# Comment'). after (txt1 + txt2); $ ('# loading'). hide (); $ ('# error'). hide (); $ Body = (window. opera )? (Document. compatMode = "CSS1Compat "? $ ('HTML '): $ ('body'): $ ('HTML, body '); /** Submit */ $ ('# Commentform'). submit (function (){ $ ('# Loading'). slideDown (); $ Submit. attr ('disabled ', true). fadeTo ('low', 0.5 ); If (edit) $ ('# comment '). after ('<input type = "text" name = "edit_id" id = "edit_id" value = "' + edit + '" style = "display: none; "/> '); /** Ajax */ $. Ajax ({ Url: ajax_php_url, Data: $ (this). serialize (), Type: $ (this). attr ('method '), Error: function (request ){ $ ('# Loading'). slideUp (); Certificate ('{error'{.slidedown().html ('' + request. responseText ); SetTimeout (function () {$ submit. attr ('disabled ', false ). fadeTo ('low', 1); $ ('# error '). slideUp ();}, 3000 ); }, Success: function (data ){ $ ('# Loading'). hide (); Comm_array.push ($ ('# comment'). val ()); $ ('Textarea '). each (function () {this. value = ''}); Var t = addComment, cancel = t. I ('cel-comment-reply-link'), temp = t. I ('WP-temp-form-div '), respond = t. I (t. respondId), post = t. I ('comment _ post_ID '). value, parent = t. I ('comment _ parent '). value; // Comments If (! Edit & $ comments. length ){ N = parseInt ($ comments. text (). match (/d + /)); $ Comments. text ($ comments. text (). replace (n, n + 1 )); } // Show comment New_htm = '"id =" new_comm _' + num + '"> </'; New_htm = (parent = '0 ')? ('N' <ol style = "clear: both;" class = "commentlist '+ new_htm + 'ol> '): ('n' <ul class = "children '+ new_htm + 'Ul> '); OK _htm = 'n' <span id = "success _ '+ num + txt3; If (edit_mode = '1 '){ Div _ = (document. body. innerHTML. indexOf ('div-comment-') =-1 )? '': (Document. body. innerHTML. indexOf ('li-comment-') =-1 )? 'Div -':''); OK _htm = OK _htm.concat (edt1, div _, 'comment-', parent,' "," ', parent,' "," respond "," ', post ,'", ', num, edt2 ); } OK _htm + = '</span> N '; $ ('# Respond'). before (new_htm ); $ ('# New_comm _' + num). hide (). append (data ); $ ('# New_comm _' + num + 'Lil'). append (OK _htm ); $ ('# New_comm _' + num). fadeIn (4000 ); $ Body. animate ({scrollTop: $ ('# new_comm _' + num). offset (). top-200}, 900 ); Countdown (); num ++; edit = ''; $ ('*'). remove ('# edit_id '); Cancel. style. display = 'none '; Cancel. onclick = null; T. I ('comment _ parent'). value = '0 '; If (temp & respond ){ Temp. parentNode. insertBefore (respond, temp ); Temp. parentNode. removeChild (temp) } } }); // End Ajax Return false; }); // End submit /** Comment-reply.dev.js */ AddComment = { MoveForm: function (commId, parentId, respondId, postId, num ){ Var t = this, div, comm = t. I (commId), respond = t. I (respondId), cancel = t. I ('cel-comment-reply-link'), parent = t. I ('comment _ parent'), post = t. I ('comment _ post_ID '); If (edit) exit_prev_edit (); Num? ( T. I ('Comment'). value = comm_array [num], Edit = t. I ('New _ comm _ '+ num). innerHTML. match (/(comment-) (d +)/) [2], $ New_sucs = $ ('# success _' + num), $ new_sucs.hide (), $ New_comm = $ ('# new_comm _' + num), $ new_comm.hide (), $ Cancel. text (cancel_edit) ): $ Cancel. text (cancel_text ); T. respondId = respondId; PostId = postId | false; If (! T. I ('WP-temp-form-div ')){ Div = document. createElement ('div '); Div. id = 'WP-temp-form-div '; Div. style. display = 'none '; Respond. parentNode. insertBefore (div, respond) } ! Comm? ( Temp = t. I ('WP-temp-form-div '), T. I ('comment _ parent'). value = '0 ', Temp. parentNode. insertBefore (respond, temp ), Temp. parentNode. removeChild (temp) ): Comm. parentNode. insertBefore (respond, comm. nextSibling ); $ Body. animate ({scrollTop: $ ('# respond'). offset (). top-180}, 400 ); If (post & postId) post. value = postId; Parent. value = parentId; Cancel. style. display = ''; Cancel. onclick = function (){ If (edit) exit_prev_edit (); Var t = addComment, temp = t. I ('WP-temp-form-div '), respond = t. I (t. respondId ); T. I ('comment _ parent'). value = '0 '; If (temp & respond ){ Temp. parentNode. insertBefore (respond, temp ); Temp. parentNode. removeChild (temp ); } This. style. display = 'none '; This. onclick = null; Return false; }; Try {t. I ('Comment'). focus ();} Catch (e ){} Return false; }, I: function (e ){ Return document. getElementById (e ); } }; // End addComment Function exit_prev_edit (){ $ New_comm.show (); $ new_sucs.show (); $ ('Textarea '). each (function () {this. value = ''}); Edit = ''; } Var wait = 15, submit_val = $ submit. val (); Function countdown (){ If (wait> 0 ){ $ Submit. val (wait); wait --; setTimeout (countdown, 1000 ); } Else { $ Submit. val (submit_val). attr ('disabled ', false). fadeTo ('low', 1 ); Wait = 15; } } }); // End jQ |