// wp-content/themes/yuewei File //short for document.getElementById function $() { if (arguments.length == 1) return get$(arguments[0]); var elements = []; $c(arguments).each(function(el){ elements.push(get$(el)); }); return elements; } function get$(el){ if (typeof el == 'string') el = document.getElementById(el); return el; } function $c(array){ var nArray = []; for (i=0;el=array[i];i++) nArray.push(el); return nArray; } // get parameters of the comment form function getParams(f){ if(typeof(f)=='string') f = $(f); var p=''; var fi = f.getElementsByTagName('input'); for (i=0; i

"); content = content.replace(/\r\n/g, "
"); content = content.replace(/\n\n/g, "

"); content = content.replace(/\n/g, "
"); var dateObj = new Date(); c.innerHTML = c.innerHTML + "

  • At "+dateObj.toLocaleString()+", "+ author+ " said:

    " + content+ "

    你提交了一条新的留言...
  • "; //the state function of ajax gi.onreadystatechange = function() { if (gi.readyState == 4) { if (gi.status == 200) { $('newComment'+now).innerHTML=gi.responseText; aCookie = document.cookie.split("; "); login("login"); // ajaxStatus("none"); if(gi.responseText.search(/Slow down cowboy/) > -1 || gi.responseText.search(/Duplicate comment detected/) > -1) $('comment').value = temp; } else { $('comment').value = temp; $('submitcomment').innerHTML = '提交失败,请检查是否留言过快或重复提交留言...'; alert('Failed to add your comment. '); } } } //send form by ajax var p=getParams("commentform"); // get parameters of form gi.open('POST', blogurl+"/wp-content/plugins/ajaxcomment/comments-ajax.php", true); gi.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); gi.setRequestHeader("Content-length", p.length); gi.setRequestHeader("Connection", "close"); gi.send(p); //after send form, move the comment form to original position. comment_preview(false); moveForm(0); $('comment').value = ''; return true; } function ajaxPost(u, p, e, s, m){ var g = getXMLInstant(); if ($(e)) e = $(e); g.onreadystatechange = function(){ if (g.readyState == 4) { if (g.status == 200) { if (typeof(m) != "undefined" && m == "delete") { if (e) e.parentNode.removeChild(e); } else { if (e) e.innerHTML = g.responseText; } if (s) eval(s); ajaxStatus("none"); } else { alert('There was a problem with the request.'); } } } g.open('POST', u, true); g.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); g.setRequestHeader("Content-length", p.length); g.setRequestHeader("Connection", "close"); g.send(p); } // Get content by AJAX, u:url; e:element; j:jump; s:alert message; m: method function ajaxShowPost(u, e, j, s, m){ if ("undefined"!=typeof(nowurl) && u==nowurl) { window.location.href="#"+j; return; } if ( u.match(/getpost/) ) nowurl=u; var g = getXMLInstant(); if ($(e)) e = $(e); g.onreadystatechange = function(){ if (g.readyState == 4) { if (g.status == 200) { if (typeof(m) != "undefined" && m == "delete") { if (e) e.parentNode.removeChild(e); } else { if (e) e.innerHTML = g.responseText; } if (j) window.location.href = "#"+j; if (s) eval(s); ajaxStatus("none"); } else { alert('There was a problem with the request.'); } } } g.open('GET', u, true); g.send(null); } // toggle #ajax status function ajaxStatus(s) { if (!$("ajax")) return; $("ajax").style.display = s; } function comment_preview(i) { if (typeof(i)=='undefined' && $('copreview').style.display != 'block' || typeof(i) != 'undefined' && i == true) { if ($('copreview').style.display != 'block') { var p=getParams("commentform"); ajaxPost(blogurl + '/wp-content/plugins/ajaxcomment/preview.php', p, 'copreview', "$('commentdiv').style.display = 'none';$('copreview').style.display = 'block';$('prectr').value = 'Edit';"); } } else { if ($('copreview').style.display != 'none') { $('prectr').value = 'Preview'; $('commentdiv').style.display = 'block'; $('copreview').style.display = 'none'; $('comment').focus(); } } }