var show_up_level = 3 ;var header_up_level = 2 ;var is_debug_log_enabled = 0 ; SezWho = { Version: '1.2.0' } ; SezWho.Utils = {} ; // class for rendering the sezwho UI for each comment SezWho.PluginCore = new function () { try { this.szManageEmbedUI = function () { SezWho.Utils.log("info", "called SezWho.PluginCore.szManageEmbedUI "); if (window.sz_js_config_params == null || sz_js_config_params === 'undefined' || sz_js_config_params == null || document.getElementById('cpEmbedPageTableid') || !sz_js_config_params.comment_number) { return ; } var post_id = sz_js_config_params.post_id ; var sortScore = sz_js_config_params.sortOrder ; var isErrorShown = "false" ; if (sortScore == '') sortScore = 0 ; if (sz_js_config_params.comment_number != sz_js_config_params.sz_comment_data.length) sz_js_config_params.comment_number = sz_js_config_params.sz_comment_data.length; if (sz_js_config_params.sz_auto_option_bar) { var fb = get_show_comment_dropdown_div(); var fbph = document.getElementById('szOptionBarPlaceHolder'); fbph.parentNode.replaceChild(fb, fbph); } else { var cn = SezWho.BlogPlatformCallbackJS.get_comment_node(sz_js_config_params.sz_comment_data[0].comment_id); var showCommentDiv = get_show_comment_dropdown_div(); try { if (cn && cn.parentNode) cn.parentNode.insertBefore(showCommentDiv, cn); else { var tfc = SezWho.BlogPlatformCallbackJS.get_top_of_first_comment(sz_js_config_params.sz_comment_data[0].comment_id); tfc.parentNode.insertBefore(showCommentDiv, tfc); } } catch (e) { if (isErrorShown == "false" ) { SezWho.Utils.log("error", "We could not handle this theme, please use the manual modification of theme as outlined in http://www.SezWho.com/FAQ.php."); isErrorShown = "true" ; return ; } } } // loop over the comment score information passed and populate the comment header and footer var hn, fn; for (var co2 = 0 ; co2 < sz_js_config_params.comment_number; co2++) { if (sz_js_config_params.sz_comment_data[co2].comment_score == 0) continue; hn = null; fn = null; if (sz_js_config_params.sz_auto_comment){ try { var hnode = document.getElementById('szCommentHeaderPlaceHolder:'+co2); var commentCompositeDiv = get_composite_div(co2); var hnp = hnode; // In case there are no siblings where the hnode is (case of a div around comment header) while (!hnp.nextSibling) hnp = hnp.parentNode; while (hnp && hnp.nextSibling) commentCompositeDiv.appendChild(hnp.nextSibling); if (hnp && hnp.parentNode) hnp.parentNode.appendChild(commentCompositeDiv); // Now handle the header hn = get_comment_header_div(co2, sz_js_config_params.sz_comment_data[co2].comment_score, get_commenter_display(co2)); hnode.parentNode.replaceChild(hn, hnode); // Footer var fnode = document.getElementById('szCommentFooterPlaceHolder:'+co2); if (fnode){ fn = get_comment_footer_div(co2); fnode.parentNode.replaceChild(fn, fnode); } } catch (e) { if (isErrorShown == "false") { SezWho.Utils.log("error", "We could not handle this theme, please use the manual modification of theme as outlined in http://www.SezWho.com/FAQ.php ."); isErrorShown = "true" ; return ; } } } else { var comment_node = SezWho.BlogPlatformCallbackJS.get_comment_node(sz_js_config_params.sz_comment_data[co2].comment_id); if (!comment_node) continue; try { hn = get_comment_header_div(co2, sz_js_config_params.sz_comment_data[co2].comment_score, get_commenter_display(co2)); fn = get_comment_footer_div(co2); //first insert the footer elements comment_node.insertBefore(fn, null); //Next create the composite Div and insert it var commentCompositeDiv = get_composite_div(co2); while (comment_node.firstChild) commentCompositeDiv.appendChild(comment_node.firstChild); comment_node.appendChild(commentCompositeDiv); // Last insert the comment header node. comment_node.insertBefore(hn,commentCompositeDiv); } catch (e) { if (isErrorShown == "false") { SezWho.Utils.log("error", "We could not handle this theme, please use the manual modification of theme as outlined in http://www.SezWho.com/FAQ.php ."); isErrorShown = "true" ; return ; } } } // Now setup the event handlers var ll = null; if (hn){ var pl = null; ll = hn.getElementsByTagName("A"); for (var i = 0; i < ll.length; i++) if (ll[i].className == 'cpEmbedPageProfileLinkCustom') {pl = ll[i]; break;} if (pl){ sz_cp_proto.observe(pl,"mouseover", SezWho.Utils.cpProfileEventHandler); sz_cp_proto.observe(pl,"mouseout", function(ev) { SezWho.DivUtils.cancelPopUp(); }); sz_cp_proto.observe(pl,"mousedown", SezWho.Utils.cpProfileEventHandler); } } if (fn) { ll = fn.getElementsByTagName("INPUT"); for (var i = 0; i < ll.length; i++) if (SezWho.Utils.isOpera() || ((/Safari|Konqueror|KHTML/gi).test(navigator.userAgent) && !(/Safari\/5/gi).test(navigator.userAgent))) sz_cp_proto.observe(ll[i],"click", SezWho.Utils.szHandleRatingButtonClicks); else sz_cp_proto.observe(ll[i],"mousedown", SezWho.Utils.szHandleRatingButtonClicks); } } } function get_show_comment_dropdown_div() { iHtml = "
Filter: What is this? | "; if (navigator.userAgent.match(/msie (5\.5|6)/i)&&navigator.platform=="Win32") //PNG fix iHtml = iHtml+""; else iHtml = iHtml+""; iHtml = iHtml+" |
| "+comment_author+" (Profile) | "+SezWho.Utils.get_comment_star_rating(cScore)+" |
Please enter your email address. Your identification helps us score the comment better. Your address will be kept private and will not be shown to other users.
";
// now set cookie
SezWho.Utils.setCookie("SZ_EMAIL_COOKIE" , emailID, 100);
var d = new Date();
var formParam = 'ratingIncrement='+escape(ratingIncrement)+'&postID='+escape(postID)+'&commentID='+escape(sz_js_config_params.sz_comment_data[i].comment_id)+'&emailID='+encodeURIComponent(emailID)+'&msec='+escape(d.getMilliseconds())+'&__mode=cp_comment_rating_submit';
//alert(formParam);
req.onreadystatechange = function() {
if(req.readyState == 4) {
if(req.status == 200) {
var response = req.responseText;
//alert(response);
SezWho.DivUtils.handleCommentRating(response);
}
}
};
var comment_rating_submit_path = sz_js_config_params.comment_rating_submit_path ;
if(sz_js_config_params.use_cross_domain_posting) {
this.submitCommentRating(cppluginurl+comment_rating_submit_path+"?return_js=true&"+formParam);
}
else {
req.open('POST', cppluginurl+comment_rating_submit_path , true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
req.send(formParam);
}
}
this.handleCommentRating = function(response) {
var ratingIncrement= document.getElementById('cpEmailForm').ratingIncrement.value ;
var i= document.getElementById('cpEmailForm').commentID.value;
var responseArr = response.split(',');
var status ;
if (responseArr[0]) status = responseArr[0].split('=')[1];
if (status == 'Failure' || status == 'N') {
var errorMsgCode = responseArr[1].split('=')[1];
var errorMsg = "Failure in processing!";
if (errorMsgCode == "DuplicateRatingInsertion") errorMsg = "You can not rate same comment again!" ;
if (errorMsgCode == "NoSiteKey") errorMsg = "No Site Key found!" ;
if (errorMsgCode == "InvalidSiteKey" || errorMsgCode == "SITEKEYERR") errorMsg = "Invalid Site Key found!" ;
if (errorMsgCode == "EmailInsertionFailure") errorMsg = "Failure inserting your email ID!" ;
if (errorMsgCode == "RatingInsertionFailure") errorMsg = "Failure inserting your rating!" ;
if (errorMsgCode == "NoBlogKey") errorMsg = "No Blog Key found!" ;
if (errorMsgCode == "SelfRating") errorMsg = "You can not rate your own comment!" ;
var button_id ;
if (ratingIncrement == 10) button_id = "sz_rating_button:yes:"+i ;
else button_id = "sz_rating_button:no:"+i;
document.getElementById("sz_comment_score:"+i).innerHTML = SezWho.Utils.get_comment_star_rating(sz_js_config_params.sz_comment_data[i].comment_score);
activateErrorDIV("ratingDiv" , i, button_id, errorMsg );
} else {
var commentScoreDiv = document.getElementById("sz_comment_score:"+i);
var comment_score = responseArr[1].split('=')[1];
commentScoreDiv.innerHTML = SezWho.Utils.get_comment_star_rating(comment_score);
sz_js_config_params.sz_comment_data[i].comment_score = comment_score;
}
}
this.submitCommentRating = function(url) {
var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
}
function activateErrorDIV(divName, i, button_id, errorMsg) {
SezWho.Utils.log("info" , "SezWho.DivUtils.activateErrorDIV called with divName = "+divName+" : i = "+i+" : button_id = "+button_id+" : errorMsg = "+errorMsg);
var post_id = document.getElementById('cpEmailForm').postID.value = sz_js_config_params.post_id;
var comment_id = document.getElementById('cpEmailForm').commentID.value =i;
var rating = document.getElementById('cpEmailForm').ratingIncrement.value ;
// create the popup irrespective of whether the cookie exists or not. This is to display show error messages
var divPopUp = PopupWindow.findPopupWindow(divName);
if (!divPopUp) {
divPopUp= new PopupWindow(divName);
}
divPopUp.autoHide();
var mainDiv = document.getElementById(divName) ;
mainDiv.style.display = 'block' ;
mainDiv.style.visibility = 'visible' ;
var errorDiv = document.getElementById("popuperror") ;
errorDiv.style.visibility = "visible";
errorDiv.style.display = "block";
errorDiv.style.color = "#ff0000";
errorDiv.style.display.verticalAlign="left" ;
errorDiv.style.fontSize = "9px";
errorDiv.innerHTML = errorMsg;
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(i, button_id, divName, divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.showPopup(i);
}
this.activateDIV = function(cppluginurl, divName, i, vote, cpserverurl, ev) {
SezWho.Utils.log("info" , "SezWho.DivUtils.activateDIV called with : cppluginurl = "+cppluginurl+" : divName = "+divName+" : i = "+i+" : vote = "+vote+" : cpserverurl = "+cpserverurl+" : ev = "+ev);
var ratingsDiv = document.getElementById(divName);
if (ratingsDiv == null) {
ratingsDiv = SezWho.DivUtils.createRatingsDiv (cppluginurl, cpserverurl);
}
var post_id = document.getElementById('cpEmailForm').postID.value = sz_js_config_params.post_id;
var comment_id = document.getElementById('cpEmailForm').commentID.value =i;
var button_id = vote+":"+comment_id+":"+post_id ;
if (vote == 'yes') {
document.getElementById('cpEmailForm').ratingIncrement.value = '10' ;
} else if (vote == 'no') {
document.getElementById('cpEmailForm').ratingIncrement.value = '0' ;
}
// create the popup irrespective of whether the cookie exists or not.
var divPopUp = PopupWindow.findPopupWindow(divName);
if (!divPopUp) {
divPopUp= new PopupWindow(divName);
}
divPopUp.updateEvent(ev);
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(i, button_id, divName, divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.autoHide();
if (SezWho.Utils.readCookie("SZ_EMAIL_COOKIE")) {
// if cookie exists set popup visibility to false!
document.getElementById(divName).style.display = 'none' ;
this.submitForm(document.getElementById('cpEmailForm'), cppluginurl);
return;
} else {
document.getElementById(divName).style.display = 'block' ;
document.getElementById(divName).style.visibility = 'visible' ;
divPopUp.showPopup(i);
}
}
this.loadProfileData = function(url) {
var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
// document.body.appendChild(script);
}
this.displayProfileData = function (name,data){
sz_cp_proto.replace(document.getElementById('cpPopupContentloadingId'), data);
if (name != '') document.getElementById('cpPopupHeaderTitleTextId').innerHTML = name;
var divPopUp = PopupWindow.findPopupWindow("profilepopup");
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(null, null, "profilepopup", divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.showPopup(null);
}
this.loadProfilePopUp = function(cpserverurl, cppluginurl, url, divName, author_name)
{
SezWho.Utils.log("info" , "SezWho.DivUtils.loadProfilePopUp called with cpserverurl = "+cpserverurl+" : cppluginurl = "+cppluginurl+" : url = "+url+" : divName = "+divName+" : author_name = "+author_name);
var profileDiv = document.getElementById(divName);
if (profileDiv == null) profileDiv = this.createProfileDiv(cpserverurl);
else {
if (document.getElementById('cpPopupContentBodyID'))
sz_cp_proto.replace(document.getElementById('cpPopupContentBodyID'), "
";
// now set cookie
SezWho.Utils.setCookie("SZ_EMAIL_COOKIE" , emailID, 100);
var d = new Date();
var formParam = 'ratingIncrement='+escape(ratingIncrement)+'&postID='+escape(postID)+'&commentID='+escape(sz_js_config_params.sz_comment_data[i].comment_id)+'&emailID='+encodeURIComponent(emailID)+'&msec='+escape(d.getMilliseconds())+'&__mode=cp_comment_rating_submit';
//alert(formParam);
req.onreadystatechange = function() {
if(req.readyState == 4) {
if(req.status == 200) {
var response = req.responseText;
//alert(response);
SezWho.DivUtils.handleCommentRating(response);
}
}
};
var comment_rating_submit_path = sz_js_config_params.comment_rating_submit_path ;
if(sz_js_config_params.use_cross_domain_posting) {
this.submitCommentRating(cppluginurl+comment_rating_submit_path+"?return_js=true&"+formParam);
}
else {
req.open('POST', cppluginurl+comment_rating_submit_path , true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
req.send(formParam);
}
}
this.handleCommentRating = function(response) {
var ratingIncrement= document.getElementById('cpEmailForm').ratingIncrement.value ;
var i= document.getElementById('cpEmailForm').commentID.value;
var responseArr = response.split(',');
var status ;
if (responseArr[0]) status = responseArr[0].split('=')[1];
if (status == 'Failure' || status == 'N') {
var errorMsgCode = responseArr[1].split('=')[1];
var errorMsg = "Failure in processing!";
if (errorMsgCode == "DuplicateRatingInsertion") errorMsg = "You can not rate same comment again!" ;
if (errorMsgCode == "NoSiteKey") errorMsg = "No Site Key found!" ;
if (errorMsgCode == "InvalidSiteKey" || errorMsgCode == "SITEKEYERR") errorMsg = "Invalid Site Key found!" ;
if (errorMsgCode == "EmailInsertionFailure") errorMsg = "Failure inserting your email ID!" ;
if (errorMsgCode == "RatingInsertionFailure") errorMsg = "Failure inserting your rating!" ;
if (errorMsgCode == "NoBlogKey") errorMsg = "No Blog Key found!" ;
if (errorMsgCode == "SelfRating") errorMsg = "You can not rate your own comment!" ;
var button_id ;
if (ratingIncrement == 10) button_id = "sz_rating_button:yes:"+i ;
else button_id = "sz_rating_button:no:"+i;
document.getElementById("sz_comment_score:"+i).innerHTML = SezWho.Utils.get_comment_star_rating(sz_js_config_params.sz_comment_data[i].comment_score);
activateErrorDIV("ratingDiv" , i, button_id, errorMsg );
} else {
var commentScoreDiv = document.getElementById("sz_comment_score:"+i);
var comment_score = responseArr[1].split('=')[1];
commentScoreDiv.innerHTML = SezWho.Utils.get_comment_star_rating(comment_score);
sz_js_config_params.sz_comment_data[i].comment_score = comment_score;
}
}
this.submitCommentRating = function(url) {
var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
}
function activateErrorDIV(divName, i, button_id, errorMsg) {
SezWho.Utils.log("info" , "SezWho.DivUtils.activateErrorDIV called with divName = "+divName+" : i = "+i+" : button_id = "+button_id+" : errorMsg = "+errorMsg);
var post_id = document.getElementById('cpEmailForm').postID.value = sz_js_config_params.post_id;
var comment_id = document.getElementById('cpEmailForm').commentID.value =i;
var rating = document.getElementById('cpEmailForm').ratingIncrement.value ;
// create the popup irrespective of whether the cookie exists or not. This is to display show error messages
var divPopUp = PopupWindow.findPopupWindow(divName);
if (!divPopUp) {
divPopUp= new PopupWindow(divName);
}
divPopUp.autoHide();
var mainDiv = document.getElementById(divName) ;
mainDiv.style.display = 'block' ;
mainDiv.style.visibility = 'visible' ;
var errorDiv = document.getElementById("popuperror") ;
errorDiv.style.visibility = "visible";
errorDiv.style.display = "block";
errorDiv.style.color = "#ff0000";
errorDiv.style.display.verticalAlign="left" ;
errorDiv.style.fontSize = "9px";
errorDiv.innerHTML = errorMsg;
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(i, button_id, divName, divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.showPopup(i);
}
this.activateDIV = function(cppluginurl, divName, i, vote, cpserverurl, ev) {
SezWho.Utils.log("info" , "SezWho.DivUtils.activateDIV called with : cppluginurl = "+cppluginurl+" : divName = "+divName+" : i = "+i+" : vote = "+vote+" : cpserverurl = "+cpserverurl+" : ev = "+ev);
var ratingsDiv = document.getElementById(divName);
if (ratingsDiv == null) {
ratingsDiv = SezWho.DivUtils.createRatingsDiv (cppluginurl, cpserverurl);
}
var post_id = document.getElementById('cpEmailForm').postID.value = sz_js_config_params.post_id;
var comment_id = document.getElementById('cpEmailForm').commentID.value =i;
var button_id = vote+":"+comment_id+":"+post_id ;
if (vote == 'yes') {
document.getElementById('cpEmailForm').ratingIncrement.value = '10' ;
} else if (vote == 'no') {
document.getElementById('cpEmailForm').ratingIncrement.value = '0' ;
}
// create the popup irrespective of whether the cookie exists or not.
var divPopUp = PopupWindow.findPopupWindow(divName);
if (!divPopUp) {
divPopUp= new PopupWindow(divName);
}
divPopUp.updateEvent(ev);
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(i, button_id, divName, divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.autoHide();
if (SezWho.Utils.readCookie("SZ_EMAIL_COOKIE")) {
// if cookie exists set popup visibility to false!
document.getElementById(divName).style.display = 'none' ;
this.submitForm(document.getElementById('cpEmailForm'), cppluginurl);
return;
} else {
document.getElementById(divName).style.display = 'block' ;
document.getElementById(divName).style.visibility = 'visible' ;
divPopUp.showPopup(i);
}
}
this.loadProfileData = function(url) {
var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
// document.body.appendChild(script);
}
this.displayProfileData = function (name,data){
sz_cp_proto.replace(document.getElementById('cpPopupContentloadingId'), data);
if (name != '') document.getElementById('cpPopupHeaderTitleTextId').innerHTML = name;
var divPopUp = PopupWindow.findPopupWindow("profilepopup");
var co_ordinates = SezWho.PopupPositionUtils.get_offsets(null, null, "profilepopup", divPopUp);
divPopUp.offsetX = co_ordinates[0] ;
divPopUp.offsetY = co_ordinates[1] ;
divPopUp.showPopup(null);
}
this.loadProfilePopUp = function(cpserverurl, cppluginurl, url, divName, author_name)
{
SezWho.Utils.log("info" , "SezWho.DivUtils.loadProfilePopUp called with cpserverurl = "+cpserverurl+" : cppluginurl = "+cppluginurl+" : url = "+url+" : divName = "+divName+" : author_name = "+author_name);
var profileDiv = document.getElementById(divName);
if (profileDiv == null) profileDiv = this.createProfileDiv(cpserverurl);
else {
if (document.getElementById('cpPopupContentBodyID'))
sz_cp_proto.replace(document.getElementById('cpPopupContentBodyID'), "