"; if(typeof CKEDITOR != "undefined") { if(CKEDITOR.instances['comment']) { CKEDITOR.instances['comment'].setData(message); CKEDITOR.instances['comment'].focus(); } else { $('#comment').val(message); $('#commentSubmit').focus(); } } else { $('#comment').val(message); $('#commentSubmit').focus(); } } function doVote(obj, commentID, vote, first) { var url = "/do/doVote.php"; var token = $('#token').val(); var params = {commentID: commentID, vote: vote, first: first, token: token}; $.post(url, params, function(result) { var message = $.parseJSON(result); var pieces = obj.id.split('_'); if(!vote && $('#commentVotes_'+pieces[1]).html().indexOf('voteUpGrey') == -1) hide = true; else hide = false; $('#commentVotes_'+pieces[1]).html(message['markup'].toString()); if(hide) showHide($('#username'), pieces[1]); } ); } function toSingleQuote(str) { return str.replace(/(
[\s\S]*<\/blockquote>)/gi, ""); //return str.replace(/( )([\s\S]+:<\/div>)()([\s\S]*)([\s\S]*<\/BLOCKQUOTE>)([\s\S]*<\/blockquote>)/g, ""); //return str.replace(/( [\s\S]*)( [\s\S]*<\/BLOCKQUOTE>)([\s\S]*<\/blockquote>)/g, "$1 $3"); } function doStar(obj, commentID) { var url = "/do/doStar.php"; var token = $('#token').val(); var pieces = obj.id.split('_'); var jObj = $('#star_'+pieces[1]).parent(); var vote = (jObj.css('background-image')).toString().match(/star\.png/) == "star.png"; if(vote) jObj.css('background-image', 'url("/images/star_filled.png")'); else jObj.css('background-image', 'url("/images/star.png")'); var params = {commentID: commentID, vote: vote, token: token}; $.post(url, params); } function showHide(obj, commentID) { var jObj = $('#comment_'+commentID); if(!jObj.hasClass("buried")) { jObj.addClass('buried'); obj.html('Show'); } else { jObj.removeClass('buried'); obj.html('Hide'); } $.post("/do/doShowHide.php", {commentID: commentID, hidden: jObj.hasClass("buried") ? 1 : 0, token: $('#token').val()}); } function doComment(obj) { var name = $('#name').val(); var type = ""; var comment; var addBreaks; rows = getContent('comment'); comment = rows['text']; addBreaks = rows['addBreaks']; var id = ""; var dummy = ""; var errors = ""; if(!(name.length > 0) && !(dummy.length > 0)) errors += "Guests must enter a name
"; if(!(comment.length > 0)) errors += "Comments cannot be blank
"; if(errors.length > 0) { error(errors); } else { $('#'+obj.id).attr('disabled', true); $('#'+obj.id).val("Processing..."); var commentID = $('#commentEditID').html(); var token = $('#antixsrf').val(); if(commentID == "") { var url = "/do/doComment.php"; var params = {name: name, comment: comment, id: id, type: type, addBreaks: addBreaks, token: token}; } else { var url = "/do/doEditComment.php"; var params = {comment: comment, commentID: commentID, type: type, addBreaks: addBreaks, token: token}; } var box = $('#errors'); box.html(""); box.css('display', "none"); $.post(url, params, function(result) { if(result.length > 0) { $('#'+obj.id).removeAttr('disabled').get(); $('#'+obj.id).val("Submit"); error(result); } else { $('#'+obj.id).removeAttr('disabled').get(); location.reload(); } } ); } } function strip_tags(html) { var elem = false; var output = ""; var len = html.length; for(var i=0;i') elem = false; } else { if(html.charAt(i) == '<') elem = true; else output += html.charAt(i); } } return output; } function startEditMode(obj, commentID) { $('#commentEditMode').html('Quit Edit Mode'); $('#commentEditID').val(commentID); var message = $('#commentText_'+commentID).html(); if(typeof CKEDITOR != "undefined") { if(CKEDITOR.instances['comment']) CKEDITOR.instances['comment'].setData(message); else { message = str_replace_code(13,-1,message); message = str_replace_code(10,-1,message); $('#comment').val(removeBreaks(message)); } } else { message = str_replace_code(13,-1,message); message = str_replace_code(10,-1,message); $('#comment').val(removeBreaks(message)); } $('#commentSubmit').focus(); } function endEditMode() { $('#commentEditMode').html(''); $('#commentEditID').val(""); } function doDeleteComment(obj, id) { if(confirm('Are you sure you want to delete this comment?')) { var url = "/do/doDeleteComment.php"; var token = $('#token').val(); var params = {commentID: id, token: token}; $.post(url, params, function(result) { location.reload(); } ); } } function previewComment(obj, id) { var comment; var addBreaks; rows = getContent('comment'); comment = rows['text']; addBreaks = rows['addBreaks']; var type = $('#type').val(); var errors = ""; if(!(comment.length > 0)) setError("Comments cannot be blank"); if(messages['errors'].length > 0) { showErrors(messages['errors']); } else { $('#'+obj.id).attr('disabled', true); $('#'+obj.id).val("Processing..."); var url = "/do/doPreview.php"; var params = {comment: comment, type: type, addBreaks: addBreaks}; $.post(url, params, function(result) { $('#'+obj.id).removeAttr('disabled').get(); $('#'+obj.id).val("Preview"); $('#previewContainer').html(result); } ); } } function checkAddBreaks(obj) { return false; if(CKEDITORS.instances['comment']) $('#addBreaks').val("false"); else $('#addBreaks').val('true'); } function processComment(data) { if(data != "") { try { var message = $.parseJSON(data); if(typeof message['errors'] == "undefined") { ajaxReload(); return false; } else return true; } catch(err) { ajaxReload(); return false; } } else ajaxReload(); } function checkNewComments() { var type = $('#type').val(); $.get("/do/doCheckNewComments.php", {type: type}, function(data) { //alert(data); }); } $(document).ready(function() { //setInterval(checkNewComments, 10000); });