var discussionSize = 10; function nofunction(){} function load_topics(forum, condition, pageSize, pageNum) { $.get("/Messages/display_topics_ajax.asp", { forum: forum, page: pageNum, pageSize: pageSize, condition: condition }, function(data) { var datapart = data.split("\<\!--"); $("#topics").html(datapart[0]); var header = datapart[1]; header = header.replace("--\>",""); if($("#dancetalk-top").length){$("#dancetalk-top").html(header);} if($("#forum0").length && forum>0){$("#forum0").val(forum);} }); } function dancetalk_messages(msgID, topicID, forumID, pageNum, pageSize, hint, targetDiv) { load_messages(1, 1, msgID, topicID, "", forumID, pageNum, pageSize, hint, targetDiv); $("#topics").hide(); $("#btn1").hide(); $("#btn2").hide(); $("#bars").hide(); $("#dancetalk-top").hide(); $("#discussion").show(); $("#close_discussion").show(); } function close_discussion() { $("#discussion").hide().html(""); $("#close_discussion").hide(); $("#topics").show(); $("#btn1").show(); $("#btn2").show(); $("#bars").show(); $("#dancetalk-top").show(); } function search_topics(searchSource) { var searchTerm = $(searchSource).val(); setCookie("dancetalkSearchTerm",searchTerm); if (searchTerm!="") { searchTerm = searchTerm.replace(/'/g,"''"); searchTerm = searchTerm.replace(/\./g," "); searchTerm = searchTerm.replace(/\,/g," "); while (searchTerm.indexOf(" ")>-1) {searchTerm = searchTerm.replace(/ /g," ");} searchTerm = searchTerm.trim(); } if (searchTerm!="") { searchTerm = searchTerm.replace(/ /g,"%"); var condition = "Article_Subject + ' ' + Article_Content LIKE '%" + searchTerm + "%'"; load_topics("", condition, discussionSize, 1); } } function add_single_topic(topicID) { $.get("/Messages/display_single_topic_ajax.asp", { topic: topicID }, function(data, status) { if (data!="" && data!=null) { $("#msgBoardHeaderRow").after(data); $(".msgBoardRow").last().remove(); } }); } function load_messages(saveType, viewType, msgID, topicID, refID, forumID, pageNum, pageSize, hint, targetDiv) { $("#loadButton").remove(); $("#noMessages").remove(); $.get("/Messages/messages_ajax.asp", { saveType: saveType, viewType: viewType, id: msgID, topic: topicID, refID: refID, forum: forumID, page: pageNum, pageSize: pageSize, hint: hint }, function(data) { $("#discussion").append(data); }) .done(function() { if (typeof resizeTabContainer == "function") {resizeTabContainer("discussion");} $("#add_messages").click(function() { load_messages(saveType, viewType, msgID, topicID, refID, forumID, pageNum+1, pageSize, targetDiv); }); }); } function reply(msgID) { $("#replyBox"+msgID).slideToggle(500); } function cancel_message(msgID) { $("#replyBox"+msgID).slideUp(500); } function open_new_message() { $("#openNewMsg").hide(); $("#replyBox0").slideDown(500); $("#subject0").focus(); } function save_message(action, msgID, saveType, refID, forumID) { // new message only (new topic or new reply) var subject; var message; if (msgID==0) {action=1;} if (action==3) { message = $("#edit_message"+msgID).val(); }else{ subject = $("#subject"+msgID).val(); message = $("#message"+msgID).val(); } if (msgID==0) { if ($("#forum0").length>0) { if ($("#forum0").val()!=null && $("#forum0").val()!="" && $("#forum0").val()!=undefined) { forumID = $("#forum0").val(); } } } $.post("/Messages/save_message.asp", { subject: subject, message: message, id: msgID, action: action, saveType: saveType, refID: refID, forumID: forumID }, function(data, status) { if (data.substring(0,5)=="ERROR") { alert(data.substring(7)); }else{ if (action==3) { $("#inner_content"+msgID).html(format_text($("#edit_message"+msgID).val())); cancel_edit(msgID); }else{ $("#replyBox"+msgID).parent().after(data).hide(); // parent of the reply box is the container div with class "logged in" $("#message"+msgID).val(""); if (saveType==1) { var dataID = data.split("\-\-\>"); var newID = dataID[0].replace("\<\!\-\-",""); load_topics(forumID, "", discussionSize, 1); // reset to page 1 so that user will see his post on the topic list dancetalk_messages(newID, newID, forumID, 1, 10, "", "#discussion"); } } } }); } function confirm_delete_message(msgID) { $.fancybox({ href:"#delete_message_confirm", padding:'0', closeBtn:false, beforeShow: function() { $("#btnDelete_message").attr("data-msgID",msgID); $(".msgBoardRow").last().remove(); } }); } function delete_message() { var msgID = $("#btnDelete_message").attr("data-msgID"); if (msgID!=''&&msgID!=null&&msgID!="undefined") { $.post("/Messages/delete_message.asp?ID="+msgID, function(data, status) { if (data.substring(0,5)=="ERROR") { popup_message("Uh oh!","There was an error deleting this message. Please contact support for assistance."); }else{ $("#msgBox"+msgID).remove(); if ($(".message_box").length<1){ // User deleted the last message in the visible part of the thread close_discussion(); } var props = data.split("\-\-\>"); var propList = props[0].replace("\<\!\-\-",""); var prop = propList.split(","); if (prop[2]=="1") { $("#rowTopic"+prop[0]).remove(); } else { var msgCount = parseInt($("#rowTopic"+prop[0]+" .clmMsgs").html()); msgCount--; $("#rowTopic"+prop[0]+" .clmMsgs").html(msgCount); } popup_message("Success!","Your message was deleted."); } }); } } function edit_message(msgID) { var cHeight = $("#inner_content"+msgID).height(); cHeight = cHeight * 1.05; if (cHeight<=120){cHeight=120;} $("#edit_message"+msgID).height(cHeight); $("#message_content"+msgID).hide(); $("#message_actions"+msgID).hide(); $("#editContainer"+msgID).show(); $("#msgBox"+msgID).addClass("editColor"); } function cancel_edit(msgID) { $("#editContainer"+msgID).hide(); $("#message_content"+msgID).show(); $("#message_actions"+msgID).show(); $("#msgBox"+msgID).removeClass("editColor"); } function change_forum(forum) { if (forum!="") { $.get("/Messages/change_forum_ajax.asp", { forum: forum, }, function(data) { $("#location-bar #bars #bar1").html(data); load_topics(forum,"",10,1); var newTitle = $("#bar1 a.location-final").html(); if (newTitle!="") { if (forum==0||forum==null||forum=="") { document.title="Dancetalk Message Board"; } else { document.title="Dancetalk Message Board: "+newTitle; } } }); } } function send_pm(refID, refType, recipient) { var subject = $("#subject0").val(); var message = $("#message0").val(); if(subject!=""&&message!="") { $.ajax({ type: "POST", url: "/Messages/save_pm.asp", data: { id: 0, action: 1, subject: subject, message: message, refID: refID, refType: refType, recipient: recipient }, success: function(data){ if (data.substring(0,5)=="ERROR") { popup_message("Uh oh!",data); } else { $("#contact-form").html("

Your message has been sent. To view replies or to continue this conversation, go to the My Messages tab in your user settings.

"); } } }); } else { popup_message("Uh oh!","

Please fill in both the subject and the message before sending.

"); } } function format_text(text) { return text.replace("\n","
"); }