var $K2 = jQuery.noConflict();
$K2(document).ready(function(){
console.log('$K2(document).ready');
// Generic function to get URL params passed in .js script include
function getUrlParams(targetScript, varName) {
var scripts = document.getElementsByTagName('script');
var scriptCount = scripts.length;
for (var a = 0; a < scriptCount; a++) {
var scriptSrc = scripts[a].src;
if (scriptSrc.indexOf(targetScript) >= 0) {
varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var re = new RegExp("[\\?&]" + varName + "=([^&#]*)");
var parsedVariables = re.exec(scriptSrc);
if (parsedVariables !== null) {
return parsedVariables[1];
}
}
}
}
// Set the site root path
var K2SitePath = getUrlParams('k2.js', 'sitepath');
// Comments
$K2('#comment-form').submit(function(event){
event.preventDefault();
console.log("$K2('#comment-form').submit");
$K2('#formLog').empty().addClass('formLogLoading');
$K2.ajax({
url: $K2('#comment-form').attr('action'),
type: 'post',
dataType: 'json',
data: $K2('#comment-form').serialize(),
success: function(response){
$K2('#formLog').removeClass('formLogLoading').html(response.message);
if(typeof(Recaptcha) != "undefined"){
Recaptcha.reload();
}
if (response.refresh) {
window.location.reload();
}
}
});
});
console.log("$K2('#comment-form').submit");