var show_up_level = 3 ;var header_up_level = 2 ;var is_debug_log_enabled = 0; var sz_is_auto_layout = 1; var sz_high_sibling = 0; var sz_low_sibling = 0; var sz_custom_ratings_text = {1:"it's bad!", 2:"it's so so!", 3:"it's good!", 4:"it's great!", 5:"it rocks!"};
SezWho = {
Version: '1.3.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_global_config_params == null || document.getElementById('cpEmbedPageTableid') || window.sz_comment_config_params == null || window.sz_comment_config_params.comment_number == null) {
return;
}
var post_id = sz_comment_config_params.post_id ;
var sortScore = sz_comment_config_params.sortOrder ;
var isErrorShown = "false" ;
if (sortScore == '') sortScore = 0 ;
if (sz_comment_config_params.comment_number != sz_comment_config_params.sz_comment_data.length) sz_comment_config_params.comment_number = sz_comment_config_params.sz_comment_data.length;
if (!sz_comment_config_params.comment_number) return;
if (sz_comment_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_top_of_first_comment(sz_comment_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);
} 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, ccd;
for (var co2 = 0 ; co2 < sz_comment_config_params.comment_number; co2++) {
if (typeof(sz_comment_config_params.sz_comment_data[co2]) == "undefined") continue;
if (sz_comment_config_params.sz_comment_data[co2].comment_score == 0) continue;
hn = null;
fn = null;
ccd = null;
if (sz_comment_config_params.sz_auto_comment){
try {
var hnode = document.getElementById('szCommentHeaderPlaceHolder:'+co2);
var hnp = hnode;
ccd = get_composite_div(co2);
// 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) ccd.appendChild(hnp.nextSibling);
if (hnp && hnp.parentNode) hnp.parentNode.appendChild(ccd);
// Now handle the header
hn = get_comment_header_div(co2,
sz_comment_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_comment_config_params.sz_comment_data[co2].comment_id);
if (!comment_node) comment_node = SezWho.BlogPlatformCallbackJS.get_comment_node_by_calc(sz_comment_config_params.sz_comment_data[co2].comment_id,1);
if (!comment_node) continue;
try {
hn = get_comment_header_div(co2,
sz_comment_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
ccd = get_composite_div(co2);
while (comment_node.firstChild) ccd.appendChild(comment_node.firstChild);
comment_node.appendChild(ccd);
// Last insert the comment header node.
comment_node.insertBefore(hn,ccd);
} 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);
}
/*
ll = hn.getElementsByTagName("IMG");
for (var i = 0; i < ll.length; i++)
if (ll[i].className == 'cpEmbedImageUserh') {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(); });
}
*/
}
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);
}
if (ccd) {
var n = unescape(sz_comment_config_params.sz_comment_data[co2].comment_author);
var els = ccd.getElementsByTagName("*");
var re = new RegExp("(^\\s*)" + n + "(\\s*$)") ;
for(var i=0,j=els.length; iWhat is this?
" ;
var div = document.createElement("div");
div.innerHTML = iHtml;
return div;
}
function get_comment_footer_div(i) {
var iHtml = "
Was this comment useful to you ?
";
var div = document.createElement("div");
div.innerHTML = iHtml;
return div;
}
function get_composite_div(i) {
SezWho.Utils.log("info" , "get_composite_div called with i = "+i);
var commentCompositeDiv = document.createElement("div") ;
commentCompositeDiv.id = "sz_comment_collapse_div:"+i ;
commentCompositeDiv.className = "cpEmbedPageCommentBodyCollapseDivCustom";
if (sz_comment_config_params.sz_show_commenter_pic==1)
commentCompositeDiv.innerHTML = "
";
return commentCompositeDiv ;
}
}
catch (e)
{
}
};
/* End of SezWho.PluginCore class */
/* Start PopupWindow class */
function PopupWindow() {
if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
if (!window.listenerAttached) {
window.listenerAttached = true;
PopupWindow_attachListener();
}
this.index = popupWindowIndex++;
popupWindowObjects[this.index] = this;
this.divName = null;
this.popupWindow = null;
this.event = new function() {this.type=null,this.ClientX=0,this.ClientY=0;ScreenX=0;ScreenY=0;};
this.visible = false;
this.autoHideEnabled = false;
this.contents = "";
if (arguments.length>0) {
this.type="DIV";
this.divName = arguments[0];
}
this.use_gebi = false;
this.use_css = false;
this.use_layers = false;
if (document.getElementById) { this.use_gebi = true; }
else if (document.all) { this.use_css = true; }
else if (document.layers) { this.use_layers = true; }
else { this.type = "WINDOW"; }
// Method mappings
this.refresh = PopupWindow_refresh;
this.showPopup = PopupWindow_showPopup;
this.hidePopup = PopupWindow_hidePopup;
this.isClicked = PopupWindow_isClicked;
this.autoHide = PopupWindow_autoHide;
this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
this.updateEvent = PopupWindow_updateEvent;
// Refresh the displayed contents of the popup
function PopupWindow_refresh() {
if (this.divName != null) {
// refresh the DIV object
document.getElementById(this.divName).innerHTML = this.contents;
}
}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup() {
this.x = this.event.ScreenX + this.offsetX;
this.y = this.event.ScreenY + this.offsetY;
if (!this.populated && (this.contents != "")) {
this.populated = true;
this.refresh();
}
if (this.divName != null) {
// Show the DIV object
document.getElementById(this.divName).style.left = this.x + "px";
document.getElementById(this.divName).style.top = this.y + "px";
document.getElementById(this.divName).style.visibility = "visible";
}
}
// Hide the popup
function PopupWindow_hidePopup() {
if (this.divName != null) {
SezWho.DivUtils.closediv(this.divName);
}
}
// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e) {
if (this.autoHideEnabled && !this.isClicked(e)) {
this.hidePopup();
}
}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide() {
this.autoHideEnabled = true;
}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupWindow_isClicked(e) {
if (this.divName != null) {
var t = sz_cp_proto.element(e);
while (t && t.parentNode) {
if (t.id==this.divName)
return true;
t = t.parentNode;
}
return false;
}
return false;
}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e) {
for (var i=0; i vp_height - div_height) {
top_viewport_y = vp_height - div_height - 1;
}
if (top_viewport_x < 0) {
top_viewport_x = 1;
}
if (top_viewport_x > vp_width - div_width) {
top_viewport_x = vp_width - div_width - 1;
}
var co_ords = new Object();
co_ords[0] = shift_offset_x + (top_viewport_x - start_top_x);
co_ords[1] = shift_offset_y + (top_viewport_y - start_top_y);
SezWho.Utils.log("info" , "SezWho.PopupPositionUtils.get_offsets returning co-ordinates : x = "+co_ords[0]+" : y = "+co_ords[1]);
return co_ords ;
}
function getViewportHeight() {
var h=-1;
var m=document.compatMode;
if((m || SezWho.Utils.isIE()) && ! SezWho.Utils.isOpera())
{
switch(m)
{
case "CSS1Compat":h=document.documentElement.clientHeight;
break;
default:h=document.body.clientHeight;
}
}
else
{
//h=self.innerHeight;
h=self.innerHeight>document.documentElement.clientHeight ? document.documentElement.clientHeight : self.innerHeight ;
}
return h;
}
function getViewportWidth() {
var w=-1;
var m=document.compatMode;
if(m || SezWho.Utils.isIE())
{
switch(m)
{
case "CSS1Compat":w=document.documentElement.clientWidth;
break;
default:w=document.body.clientWidth;
}
}
else
{
w=self.innerWidth;
}
return w;
}
} ;
/* end PopupPositionUtils class */
/* start SezWho.DivUtils class */
SezWho.DivUtils = new function () {
this.createRatingsDiv = function () {
var ratingDiv = document.createElement("div");
ratingDiv.id = "ratingDiv";
ratingDiv.className = "cpPopupWrapper";
ratingDiv.innerHTML = "
Rate Comment
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.
";
var bodyTag = document.getElementsByTagName("body")[0];
bodyTag.appendChild(ratingDiv);
return ratingDiv;
}
this.createProfileDiv = function () {
var profileDiv = document.createElement("div");
profileDiv.id = "profilepopup";
profileDiv.className = "cpPopupWrapper";
profileDiv.innerHTML = "
Public Profile
";
var bodyTag = document.getElementsByTagName("body")[0];
bodyTag.appendChild(profileDiv);
return profileDiv;
}
this.submitRatingForm = function(form, setcookieflag) {
SezWho.Utils.log("info" , "submitRatingForm called with : cppluginurl = "+sz_global_config_params.cppluginurl);
var req = null;
var ratingIncrement= form.ratingIncrement.value ;
var postID= form.postID.value;
var i= form.commentID.value;
var emailID= form.emailID.value;
var index1 = emailID.indexOf("@");
var index2 = emailID.indexOf(".");
var index3 = emailID.indexOf(" ");
if (index1 <= 0 || index2 <= 0 || index3 > 0 ) {
alert("Please enter a valid email address.");
document.getElementById("ratingDiv").style.display = 'none' ;
return ;
}
//Setup wait state
document.getElementById("sz_comment_score:"+i).innerHTML = "";
// now set cookie
if (setcookieflag) SezWho.Utils.setCookie("SZ_EMAIL_COOKIE" , emailID, 100);
var formParam = 'ratingIncrement='+escape(ratingIncrement)+'&postID='+escape(postID)+'&commentID='+escape(sz_comment_config_params.sz_comment_data[i].comment_id)+'&emailID='+encodeURIComponent(emailID)+'&msec='+SezWho.Utils.getTimeStamp()+'&__mode=cp_comment_rating_submit';
var comment_rating_submit_path = sz_comment_config_params.comment_rating_submit_path ;
if(sz_comment_config_params.use_cross_domain_posting) {
SezWho.Utils.makeJSCall(sz_global_config_params.cppluginurl+comment_rating_submit_path+"?return_js=true&"+formParam);
}
else {
var req = null;
if(window.XMLHttpRequest) req = new XMLHttpRequest();
else if (window.ActiveXObject) req = new ActiveXObject("Microsoft.XMLHTTP");
req.onreadystatechange = function() {
if(req.readyState == 4) {
if(req.status == 200) {
var response = req.responseText;
//alert(response);
SezWho.DivUtils.handleCommentRating(response);
}
}
};
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.handleBadgeData = function(sz_badge_data_params) {
var html_output;
if (navigator.userAgent.match(/msie (5\.5|6)/i)&&navigator.platform=="Win32") //PNG fix
html_output = "