﻿
var CommentPreview=new Object();CommentPreview.init=function(){jQuery("div.yorumlar").each(function(o){var isCommentsPresent=false;jQuery(".comment").each(function(o){isCommentsPresent=true;});if(isCommentsPresent)return;var postId=jQuery(this).attr("id");var yorumLink=jQuery(".yorumlu",this);var yorumOnProgress=false;var yorumEkleOnProgress=false;var commentsJSON="/comments.aspx?"+postId;var commentsPOST="/comments.aspx?post";if(yorumLink!=null){var yorumUrl="";if(jQuery(yorumLink).attr("href")!=null)yorumUrl=jQuery(yorumLink).attr("href");jQuery(yorumLink).attr("href","javascript:void(0);");jQuery(yorumLink).toggle(function(o){if(yorumOnProgress)return;yorumOnProgress=true;jQuery("InlineComments").each(function(o){jQuery(this).remove();})
var commentsDiv=jQuery(document.createElement("DIV")).attr("id","comments"+postId).attr("class","InlineComments").css("display","none");jQuery.ajax({url:commentsJSON,dataType:'json',success:function(json){jQuery.each(json.comments,function(i,c){jQuery(commentsDiv).append(CommentPreview.createCommentContainer(c));});var addComment=document.getElementById("postComment"+postId);if(addComment)
jQuery(addComment).after(commentsDiv);else
jQuery(document.getElementById("post"+postId)).after(commentsDiv);commentsDiv.slideDown("normal");},error:function(XMLHttpRequest,textStatus,errorThrown){if(textStatus=="parsererror"){alert("Çevirici hatası!\n\nJSON kodunuz hatalı oluşturulmuş, lütfen programcıya bildirin...");}
else
alert(textStatus);}});yorumOnProgress=false;},function(o){if(yorumOnProgress)return;yorumOnProgress=true;var commentsDiv=jQuery(document.getElementById("comments"+postId)).slideUp("normal",function(o){jQuery(this).remove();jQuery(".InlineComments").remove();});yorumOnProgress=false;});var yorumYaz=jQuery(document.createElement("A")).toggle(function(o){if(yorumEkleOnProgress)return;yorumEkleOnProgress=true;jQuery(".InlineAddComment").remove();var addCommentDiv=jQuery(document.createElement("DIV")).attr("id","postComment"+postId).attr("class","InlineAddComment").css("display","none");addCommentDiv.append(jQuery(document.createElement("P")).attr("id","pAdi"+postId).addClass("normal").append(jQuery(document.createElement("LABEL")).attr("for","commentAdi"+postId).text("Adınız: ")).append(jQuery(document.createElement("INPUT")).attr("type","text").attr("id","commentAdi"+postId)).append(jQuery(document.createElement("ABBR")).attr("title","").attr("id","vAdi"+postId).css({"color":"red","display":"none"}).addClass("validation"+postId).text("*"))).append(jQuery(document.createElement("P")).attr("id","pEposta"+postId).addClass("normal").append(jQuery(document.createElement("LABEL")).attr("for","commentEposta"+postId).text("Epostanız: ")).append(jQuery(document.createElement("INPUT")).attr("type","text").attr("id","commentEposta"+postId)).append(jQuery(document.createElement("ABBR")).attr("title","").attr("id","vEposta"+postId).css({"color":"red","display":"none"}).addClass("validation"+postId).text("*"))).append(jQuery(document.createElement("P")).attr("id","pWebsite"+postId).addClass("normal").append(jQuery(document.createElement("LABEL")).attr("for","commentWebSite"+postId).text("Web sitesi: ")).append(jQuery(document.createElement("INPUT")).attr("type","text").attr("id","commentWebSite"+postId).attr("value","http://")).append(jQuery(document.createElement("ABBR")).attr("title","").attr("id","vWebsite"+postId).css({"color":"red","display":"none"}).addClass("validation"+postId).text("*"))).append(jQuery(document.createElement("P")).attr("id","pComment"+postId).addClass("normal").append(jQuery(document.createElement("TEXTAREA")).attr("cols","64").attr("rows","10").attr("id","comment_"+postId))).append(jQuery(document.createElement("P")).append(jQuery(document.createElement("INPUT")).attr("type","button").attr("id","commentPostButton"+postId).attr("value","Gönder").bind("click",function(o){jQuery(this).attr("disabled","true");CommentPreview.SendComment(commentsPOST,postId);jQuery(this).removeAttr("disabled");})).css({"text-align":"right","padding-right":"20px"}));jQuery(document.getElementById("post"+postId)).after(addCommentDiv);addCommentDiv.slideDown("normal");yorumEkleOnProgress=false;},function(o){if(yorumEkleOnProgress)return;yorumEkleOnProgress=true;var addCommentDiv=jQuery(document.getElementById("postComment"+postId)).slideUp("normal",function(o){jQuery(this).remove();jQuery(".InlineAddComment").remove();});yorumEkleOnProgress=false;}).attr("href","javascript:void(0);").attr("rel","nofollow").attr("id","postAddCommentLink"+postId).text("Yorum Yaz")
jQuery(".yorumlu",this).after(yorumYaz).after(jQuery(document.createElement("SPAN")).text(" | "));jQuery(".yorumsuz",this).after(yorumYaz).after(jQuery(document.createElement("SPAN")).text(" | ")).replaceWith("<div class=\"yorumsuz\">Yorumsuz</div>");}});};CommentPreview.createCommentContainer=function(c){var cid=c.id;var author=c.author;var content=c.content;var website=c.website;var gravatar=c.gravatar;var date=c.date;var self=c.self;var comment=jQuery(document.createElement("div"));jQuery(comment).attr("id","id_"+cid).addClass("vcard").addClass("comment");if(self)comment.addClass("self")
jQuery(comment).append(jQuery(document.createElement("P")).addClass("date").text(date.toString()));jQuery(comment).append(jQuery(document.createElement("P")).addClass("gravatar").html(gravatar));jQuery(comment).append(jQuery(document.createElement("P")).addClass("content").html(content.toString()));var oAuthor=jQuery(document.createElement("P")).addClass("author");if(website!=null){oAuthor.append(jQuery(document.createElement("A")).attr("href",website).addClass("url").addClass("fn").text(author));}else{oAuthor.html(author.toString());}
jQuery(comment).append(jQuery(oAuthor));return comment;}
CommentPreview.SendComment=function(postTo,postId,sender){var formValid=true;var formData={"type":"AddCommentOp","adi":jQuery(document.getElementById("commentAdi"+postId)).attr("value"),"eposta":jQuery(document.getElementById("commentEposta"+postId)).attr("value"),"website":jQuery(document.getElementById("commentWebSite"+postId)).attr("value"),"yorum":jQuery(document.getElementById("comment_"+postId)).val(),"id":postId};if(formData.website=="http://")formData.website="";formValid=CommentPreview.SendComment.validateForm(formData);if(!formValid)return;jQuery.ajax({url:postTo,data:formData,type:"POST",success:function(data,code){jQuery(document.getElementById("postAddCommentLink"+postId)).click();},error:function(data){alert("Yorumunuz işlenemedi!\nBir iç hata oluştu, lütfen yorumunuzu kontrol edip, tekrar yollayın!")}});}
CommentPreview.SendComment.validateForm=function(formData){jQuery(".validation"+formData.id).hide().attr("title","");var noErrorBackgroundColor="#ebf8fa"
var errorBackgroundColor="#FFB0B3"
var emailRegEx=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;var urlRegEx=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;var formValid=true;var error;if(formData.adi==""||formData.adi==null){error=" - Lütfen isminizi giriniz!\nİsim gereklidir, site adı girerseniz yorumunuz onaylanmaz!";jQuery(document.getElementById("vAdi"+formData.id)).attr("title",error).show();jQuery(document.getElementById("pAdi"+formData.id)).animate({backgroundColor:errorBackgroundColor},1000);formValid=false;}
else{jQuery(document.getElementById("pAdi"+formData.id)).stop();jQuery(document.getElementById("pAdi"+formData.id)).animate({backgroundColor:noErrorBackgroundColor},1000);}
var badEmail1=false;if(formData.eposta==""||formData.eposta==null){error=" - Lütfen eposta adresinizi giriniz!\nEposta adresiniz, üçüncü sahışlarla paylaşılmayacaktır, yalnızca yeni bir yorum eklendiğinde size haber vermek için kullanılacaktır!";jQuery(document.getElementById("vEposta"+formData.id)).attr("title",error).show();badEmail1=true;formValid=false;}
else
badEmail1=false;var badEmail2=false;if(!emailRegEx.test(formData.eposta)){error=jQuery(document.getElementById("vEposta"+formData.id)).attr("title");error+="\n\n"+" - Geçersiz bir eposta adresi girdiniz, lütfen kontrol ediniz!";jQuery(document.getElementById("vEposta"+formData.id)).attr("title",error).show();badEmail2=true;formValid=false;}
else
badEmail2=false;if(badEmail1||badEmail2)
jQuery(document.getElementById("pEposta"+formData.id)).animate({backgroundColor:errorBackgroundColor},1000);else if(!badEmail1&&!badEmail2)
jQuery(document.getElementById("pEposta"+formData.id)).animate({backgroundColor:noErrorBackgroundColor},1000);if(formData.website!=""){if(!urlRegEx.test(formData.website)){error=" - Web sitesi zorunlu değildir!\nGeçersiz ya da engellenmiş bir adres girdiniz lütfen tekrar kontrol ediniz!";jQuery(document.getElementById("vWebsite"+formData.id)).attr("title",error).show();jQuery(document.getElementById("pWebsite"+formData.id)).animate({backgroundColor:errorBackgroundColor},1000);formValid=false;}
else{jQuery(document.getElementById("pWebsite"+formData.id)).animate({backgroundColor:noErrorBackgroundColor},1000);}}
if(formData.yorum==""||formData.yorum==null){formValid=false;jQuery(document.getElementById("pComment"+formData.id)).animate({backgroundColor:errorBackgroundColor},1000);}
else{jQuery(document.getElementById("pComment"+formData.id)).animate({backgroundColor:noErrorBackgroundColor},1000);}
return formValid;}