function refresh_user_page(adID, adTabID) { showLoad(); $.ajax({ url: "/Users/Shared/user_page.asp" }).done(function(data) { hideLoad(); $("#user_default_page").html(data); refresh_user_tabs(); if(opentab>0&&opentab<6) {$("#tab"+opentab).click();} if (adTabID!=undefined&&adTabID!=undefined) { // open and load appropriate adTab if (adTabID==2) { var adInfo = adID.split("-"); load_ad_photos(adInfo[0], adInfo[1]); $("#"+adID+" .adblocksub-2").show(); } // possibly later add option for dealing with messages tab (3) } $('.tooltip').tooltipster({ contentAsHTML: true, delay: 200, interactive: true, maxWidth: 300, touchDevices: false, theme: 'tooltipster-borderless' }); $("#btn_changepw").fancybox({ padding: '0', closeBtn: false, beforeShow: function() { $("#old_password,#new_password,#retype_password").val(""); $("#changepw_message").html(""); }, afterShow: function() { $("#old_password").focus(); } }); $("#btn_changeprivacy").fancybox({ padding: '0', closeBtn: false, autoSize: false, width: "600", height: "450", beforeShow: function() { $("#change_privacy").load("/Users/Shared/privacy.asp", function() { //$.fancybox.resize(); }); } }); $(".photocaption").bind("click",function(event){ event.stopPropagation(); var pcid = $(this).attr("id"); pcid = pcid.replace("photocaption-",""); $(".photorename").hide(); $(".photocaption").show(); $(this).hide(); $("#photorename-"+pcid).show().select(); $("#photorename-"+pcid).bind("click",function(event){ event.stopPropagation(); }); $("#photorename-"+pcid).on("keyup",function(event){ if(event.keyCode==13) { var caption = $(this).val(); $.ajax({ url: "/Users/Shared/rename_photo.asp", data: {id:pcid,caption:caption} }).done(function(data) { if (data=="Success") { $("#photocaption-"+pcid).html(caption); } else { $("#photorename-"+pcid).val($("#photocaption-"+pcid).html()); } $("#photorename-"+pcid).hide(); $("#photocaption-"+pcid).show(); }); } }); }); }); } function change_privacy_tab(tabid) { $("#privacy a").removeClass("selected"); $("#privtab"+tabid).addClass("selected"); $(".privacyP").hide(); $("#priv"+tabid).show(); } function update_privacy(priv) { var pdesc = ["","Low","Medium","High"]; $.ajax({ url: "/Users/Shared/change_privacy.asp", data: {privacy:priv} }).done(function(data) { if (data=="Success") { popup_message("Success", "Your privacy setting has been changed to "+pdesc[priv]+"."); $("#tdpriv").html(pdesc[priv]); }else{ popup_message("Error", data); } }); } function refresh_user_tabs() { // TABS $(".tabs ul li").click(function(e) { e.preventDefault; $(".tabcontent").hide(); var tabtarget = $(this).attr("tabtarget"); switch(tabtarget) { case "mymessages": if ($("#mymessages .pmTopics").html()=="") { load_ad_topics("user", 0); } clear_unread(); break; } $(".tabs ul li").removeClass("selected_tab"); $(this).addClass("selected_tab"); opentab = $(this).find("a").attr("id").replace("tab",""); $("#"+tabtarget).show(); }); } function change_password() { var oldPW = $("#old_password").val(); var newPW = $("#new_password").val(); var retypePW = $("#retype_password").val(); if (oldPW==""||newPW==""||retypePW=="") { $("#changepw_message").html("Error: Missing information. Please fill in all required fields."); if (oldPW==""){$("#old_password").focus();} else if (newPW==""){$("#new_password").focus();} else if (retypePW==""){$("#retype_password").focus();} } else if (oldPW==newPW) { $("#changepw_message").html("Error: You didn't change your password. The new password must be different."); $("#retype_password").val(""); $("#new_password").val("").focus(); } else if (newPW!=retypePW) { $("#changepw_message").html("Error: New password and retyped password didn't match. Please check your typing carefully and try again."); $("#retype_password").focus().select(); } else { $.ajax({ url: "/Users/Shared/change_password.php", data: {oldPW:oldPW, newPW:newPW} }).done(function(data) { if (data=="Success") { popup_message("Success!","Your password was successfully updated."); } else { $("#changepw_message").html(data); } }); } } function change_country() { var country = $("#country").val(); var state = $("#statelist").val(); $.ajax({ url: "/Shared/change_country.asp", data: {country:country,state:state} }).done(function(data) { if (data==""||data===null) { $("#statelist, #statelist-container").hide(); $("#state").show(); } else { $("#state").hide(); $("#statelist, #statelist-container").show(); $("#statelist").html(data); } $("#lblState").html(state_type(country)+":"); }); } function edit_userinfo() { $("#user-info").hide(); $("#edit-user-info").show(); $("#fname").focus().select(); $("#fname, #lname, #address1, #address2, #city, #state, #statelist, #zip, #country, #telephone").keyup(function(e) { var code = e.keyCode || e.which; if (code==13) { var tabindex = parseInt($(this).attr("tabindex"))+1; $("[tabindex="+tabindex+"]").focus().select(); } }); $("#email").keyup(function(e) { var code = e.keyCode || e.which; if (code==13) { save_userinfo(); } }); } function cancel_edituserinfo() { refresh_user_page(); } function save_userinfo() { var errors = []; var errFields = []; $(".errMsg").hide(); $(".formfield").removeClass("input_error"); var fname = $("#fname").val(); var lname = $("#lname").val(); var address1 = $("#address1").val(); var address2 = $("#address2").val(); var city = $("#city").val(); var state = $("#state").val(); var statelist = $("#statelist").val(); var zip = $("#zip").val(); var country = $("#country").val(); var telephone = $("#telephone").val(); var email = $("#email").val(); if (fname==''||fname===null) {errors.push("First name is a required field");errFields.push("fname");} if (lname==''||lname===null) {errors.push("Last name is a required field");errFields.push("lname");} if (city==''||city===null) {errors.push("City is a required field");errFields.push("city");} if (country=='United States'||country=='Canada'||country=='Australia') { if (zip==''||zip===null) { errors.push("Zip/postal code is a required field for USA, Canada and Australia");errFields.push("zip"); } } if (email==''||email===null) { errors.push("Email address is a required field");errFields.push("email"); } else if (isEmail(email)==false) { errors.push("This does not appear to be a valid email address");errFields.push("email"); } if (errors.length>0) { for (i=0;iError: "+err[1]).show(); } else if (err[0]=="Error 01") { $("#email").addClass("input_error"); $("#err-email").html(err[1]).show(); } else { returnval = false; } return returnval; } function enter_email_code() { $("#email_code").val(""); $("#change_email_code_message").html(""); $.fancybox({ href:"#enter_email_code", padding:'0', closeBtn:false, beforeShow:function() { setCookie("cec","1"); $(window).on("focus", function() { if(getCookie("cec")!="1") { refresh_user_page(); $.fancybox.close(); } }); }, afterShow:function() { $("#email_code").focus(); } }); } function change_email_code() { var errMsg = ""; var email_code = $("#email_code").val(); if (email_code==""||email_code===null) { errMsg = "Error: No code was entered. Please enter the email code and try again."; } else if (email_code.length!=16) { errMsg = "Error: Invalid code. Please make sure you have copied the entire code and try again."; } if (errMsg!="") { $("#change_email_code_message").html(errMsg); } else { showLoad(); $.ajax({ url: "/Users/verify.asp", data: {code: email_code, ajax:"1"} }).done(function(data) { hideLoad(); if (data=="Success") { popup_message("Success!","Your email address was successfully updated."); refresh_user_page(); } else { $("#change_email_code_message").html(data); } }); } } function cancel_email_code() { $.ajax({ url: "/Users/Shared/cancel_code.asp" }).done(function(data) { if (data=="Success") { popup_message("Canceled","Your original request for a change of email address has been canceled."); } refresh_user_page(); }); } function popup_photo(photoID,showExtras) { $.fancybox({ href:"#photo_info", padding:'0', closeBtn:true, scrolling:'no', autoPlay:false, cyclic:true, beforeShow: function() { var pURL = $("#userphoto-"+photoID).css("background-image"); pURL = pURL.replace(/.*\s?url\([\'\"]?/, '').replace(/[\'\"]?\).*/, ''); // remove the url('') wrapper $("#img_container").attr("src",pURL); $("#img_container").click(function(){$("#img_stats_container").toggle();}); $("#img_stats_container").show(); $.ajax({ url: "/Users/Shared/photo.asp", method: "GET", data: {id:photoID,attachments:"yes"} }).done(function(data){ var line = data.split("\r"); if(Number(line[5])<475) { $("#img_container").addClass("zoomed_in"); } var imgstats = "" + line[6] + "
" + line[3] + " " + line[1] + " image
Width: " + line[4] + " px
Height: " + line[5] + " px"; $("#img_stats").html(imgstats); $("#btnAttach").tooltipster({ trigger: 'click', theme: 'tooltipster-shadow', interactive: true, content: $(line[7]) }); $("#btnDetach").tooltipster({ trigger: 'click', theme: 'tooltipster-shadow', interactive: true, content: $(line[8]) }); }); $("#img_buttons a:first-child").unbind("click").click(function(){set_profile(photoID);}); $("#img_buttons a:nth-child(4)").unbind("click").click(function(){confirm_delete_photo(photoID);}); if (showExtras==true) { $("#img_buttons").show(); } else { $("#img_buttons").hide(); } }, afterClose: function() { $("#btnAttach").tooltipster("destroy"); $("#btnDetach").tooltipster("destroy"); $("#img_container").removeClass("zoomed_in"); } }); } function upload_photo(adID) { $("#uploadframe").contents().find("#adID").val(adID); var formaction = $("#uploadframe").contents().find("#uploadform").attr("action"); var url = formaction.split("?"); var baseurl = url[0]; url = formaction.split("pid="); var pid = url[1]; formaction = baseurl + "?attach=" + adID + "&pid=" + pid; $("#uploadframe").contents().find("#uploadform").attr("action",formaction); $("#uploadframe").contents().find("#uploadfile").click(); } function start_progress(progressID,adID) { $("#uploadZone").removeAttr("onclick"); $(".photoupload").html("Uploading..."); $(".upload").removeAttr("onclick"); $("#"+adID+" .upload p").html("Uploading..."); show_progress(progressID,adID); uploadprogress = setInterval(function(){ show_progress(progressID,adID) }, 1000); } function show_progress(progressID,adID) { $.ajax({ url: "/Users/Shared/upload_progress.asp", method: "GET", data: { to: 10, pid: progressID } }).done(function(data){ if(data=="") { // upload complete or upload not yet started }else{ var progHtml = "
"; progHtml = progHtml + "
"+data+"% Complete
"; $("#uploadprogress").html(progHtml); $("#"+adID+" .uploadprogress").html(progHtml); if (parseInt(data)<100) { // upload in progress } else { // upload complete cancel_progress(); } } }); } function cancel_progress() { clearInterval(uploadprogress); $(".uploadprogress").html(""); $("#uploadprogress").html(""); $(".photoupload").html("Upload a Photo"); $(".upload p").html("Upload a Photo"); $("#uploadZone").on("click",function(){ upload_photo(); }); $(".upload").each(function(){ var divID = $(this).parent().parent().parent().parent().parent().attr("id"); $("#"+divID+" .upload").on("click",function(){ upload_photo(divID); }); }); } function set_profile(photoID) { if (photoID==""||photoID==null) {photoID=0;} $.get("/Users/Shared/set_profile_img.asp?id="+photoID, function(data){ if (data=="") { $("#myuserphoto").attr("src", "/images/camera_shy.jpg"); popup_message("Success!","
Your profile photo has been removed.
"); } else { $("#userImgContainer").find("a").find("img").attr("src", data); $("#myuserphoto").attr("src", data); popup_message("Success!","
You have updated your profile photo.

"); } }); } function attach_photo(photoID, action, adtype, adid) { // action: 1 = attach; anything else = detach switch (adtype) { case 1: adtype = "Partner"; break; case 2: adtype = "Costume"; break; case 3: adtype = "Teacher"; break; case 4: adtype = "Studio"; break; } $.ajax({ url: "/Users/Shared/attach_photo.asp", method: "GET", data: { id: photoID, action: action, type: adtype, adid: adid } }).done(function(data){ if (data=="") { popup_message("Uh Oh!","There seems to have been a problem attaching or detaching this photo."); } else { var photoStats = data.split("\n"); popup_message("Success!",photoStats[0]); var targetImg = "#adblock-img-"+adtype.toLowerCase()+"-"+adid; load_ad_photos(adtype,adid); if (action==1) { // attach $(targetImg).html(""); } else { // detach if (photoStats[1].indexOf("data-type='none'")>-1) { $(targetImg).html(""); } else { $(targetImg).html(""); } } } }); } function confirm_delete_photo(photoID) { $.fancybox({ href:"#delete_photo_confirm", padding: '0', closeBtn: false, autoSize: false, width: '400', height: '200', beforeShow: function() { $("#btnDelete_photo").unbind("click").click(function(){delete_photo(photoID);}); } }); } function delete_photo(photoID) { $.get("/Users/Shared/delete_photo_ajax.asp?id="+photoID, function(data){ if (data=="Success") { popup_message("Photo Deleted","This photo has been permanently deleted from your collection."); refresh_userdata(true); refresh_user_page(); } else {$.fancybox.close();} }); } function change_adblock_tab(blockID, tabID) { var thisTab = $("#"+blockID+" .adblock_tabs ul li.adblock-tab"+tabID); if ($("#"+blockID+" .adblock_tabs ul li").hasClass("selectedTab")==true) { if (thisTab.hasClass("selectedTab")==true) { $("#"+blockID+" .adblocksub-"+tabID).slideUp(function() { $("#"+blockID+" .adblock_tabs ul li").removeClass("selectedTab"); }); } else { $("#"+blockID+" .adblock_tabs ul li").removeClass("selectedTab"); thisTab.addClass("selectedTab"); $("#"+blockID+" .adblocksub-1").hide(); $("#"+blockID+" .adblocksub-2").hide(); $("#"+blockID+" .adblocksub-3").hide(); $("#"+blockID+" .adblocksub-"+tabID).show(); } } else { $("#"+blockID+" .adblocksub-"+tabID).slideDown(); $("#"+blockID+" .adblock_tabs ul li").removeClass("selectedTab"); thisTab.addClass("selectedTab"); } var tabContent = $("#"+blockID+" .adblocksub-"+tabID); var blockSplit = blockID.split("-"); var adType = blockSplit[0]; var adID = blockSplit[1]; var loadingDiv = "
Loading...
"; if (tabID==1) { if (tabContent.html()=="") { tabContent.html(loadingDiv); load_adblock_editinfo(adType, adID); } } else if (tabID==2) { if (tabContent.html()=="") { tabContent.html(loadingDiv); load_ad_photos(adType, adID); } } else if (tabID==3) { if ($("#"+blockID+" .adblocksub-"+tabID+" .pmTopics").html()=="") { $("#"+blockID+" .adblocksub-"+tabID+" .pmTopics").html(loadingDiv); load_ad_topics(adType, adID); } } } function load_adblock_editinfo(adType, adID) { $.get("/Users/Edit/"+adType+".asp?id="+adID, function(data) { var targetDiv; var targetTextarea; if (adID==0) { targetDiv = "#new-ad-edit"; targetTextarea = "#new-ad-edit textarea"; $(targetDiv).html(data); $(".ab-new").css("height","auto"); $(targetDiv).slideDown(); } else { targetDiv = "#"+adType+"-"+adID+" .adblocksub-1"; targetTextarea = "#"+adType+"-"+adID+" textarea"; $(targetDiv).html(data); } $(targetTextarea).each(function() { var maxlen = $(this).attr("maxlen"); $(this).keypress(function(e) {var tval = $(this).val();if (tval.length>(maxlen-1)) {$(this).val(tval.substring(0, maxlen));$(this).blur();}}); $(this).blur(function(e) {var tval = $(this).val();if (tval.length>(maxlen-1)) {$(this).val(tval.substring(0, maxlen));}}); }); }); } function close_adblock_editinfo(adType,adID) { if (adID==0) { $("#new-ad-edit").slideUp(function(){ $(".ab-new").css("height","100px"); $("#new-ad-edit").html(); $("#new-adcontainer").css("width","auto"); for(i=0;i<=10;i++) { $("#new-ad-"+i).show().css("cursor","pointer"); } }); } else { $("#"+adType+"-"+adID+" .adblock-tab1").click(); } } function toggle_ad(adID,table) { $.ajax({ url: "/Users/Shared/toggle_ad.asp", method: "GET", data: { id: adID, table: table } }).done(function(data){ if (data=="0") { $("#"+adID+" table").addClass("adblock_disabled"); $("#"+adID+" h1").show(); $("#adblock-toggle-"+adID).html(" Show Ad"); } else if (data=="1") { $("#"+adID+" table").removeClass("adblock_disabled"); $("#"+adID+" h1").hide(); $("#adblock-toggle-"+adID).html(" Hide Ad"); } else { popup_message("Uh oh!","There seems to be a problem. Please log out of your user account and log back in again."+data); } }); } function confirm_delete_ad(adID, table) { $.fancybox({ href:"#delete_ad_confirm", padding: '0', closeBtn: false, autoSize: false, width: '400', height: '200', beforeShow: function() { $("#btnDelete_ad").unbind("click").click(function(){delete_ad(adID, table);}); } }); } function delete_ad(adID,table) { $.get("/Users/Shared/delete_ad_ajax.asp?id="+adID+"&table="+table, function(data) { if (data=="Success") { popup_message("Ad Deleted","This ad has been permanently deleted."); refresh_userdata(true); refresh_user_page(); } else {$.fancybox.close();} }); } function save_ad(adType, adID) { $.ajax({ url: "/Users/Edit/"+adType+"2.asp", method: "POST", data: $("#form-"+adType+"-"+adID).serialize() }).done(function(data){ if (data.substring(0,7)=="Success") { if (adID==0) { popup_message("Success!","You have created a new "+adType+" ad."); refresh_user_page(); } else { popup_message("Success!","Your "+adType+" ad has been updated."); var adinfo = data.split("\n"); $("#"+adType+"-"+adID+"-title").html(adinfo[1]); $("#"+adType+"-"+adID+"-subtitle").html(adinfo[2]); $("#"+adType+"-"+adID+"-pageviews").html(adinfo[3]); $("#"+adType+"-"+adID+"-last-update").html("Last Update: Just Now"); tooltip (adType, adID); $("#"+adType+"-"+adID+" .adblock-tab1").click(); } } else { popup_message("Uh Oh!",data); } }); } function open_new_ad(type, div) { load_adblock_editinfo(type, 0); for (i=0;i<=10;i++) { if ("new-ad-"+i!=div) {$("#new-ad-"+i).hide();} } $("#new-adcontainer").animate({ left: "0px", width: "160px" }, 500, function() { $("#"+div).unbind("click").css("cursor","default"); }); } function load_ad_photos(adType, adID) { $.ajax({ url: "/Users/Shared/ad_photos.asp", method: "GET", data: { type: adType, id: adID } }).done(function(data) { var targetDiv = "#"+adType.toLowerCase()+"-"+adID+" .adblocksub-2"; $(targetDiv).html(data); }); } function load_ad_topics(adType, adID, pageNum) { $.ajax({ url: "/Messages/private_topics.asp", method: "GET", data: { type: adType, id: adID, page: pageNum } }).done(function(data) { var targetDiv = "#"+adType.toLowerCase()+"-"+adID+" .adblocksub-3"; if (adType=="user") {targetDiv="#user-0";} if (pageNum==undefined) { $(targetDiv+" .pmTopics").html(data); if (data.includes("empty-adblock")==true) { $(targetDiv+" .pmReplyBox").hide(); } else { if (typeof loadmsg !== 'undefined') { $("#user-0 #topic-"+loadmsg).click(); } else { $(targetDiv+" .pmTopics ul li:first").click(); } } } else { $(targetDiv+" .pmTopics .more-topics").remove(); $(targetDiv+" .pmTopics").append(data); } }); } function load_ad_messages(adType, adID, topicID, cutoff) { $.ajax({ url: "/Messages/private_messages.asp", method: "GET", data: { type: adType, id: adID, topic: topicID, cutoff: cutoff } }).done(function(data) { var targetDiv = "#"+adType.toLowerCase()+"-"+adID+" .adblocksub-3"; if (adType=="user") {targetDiv="#user-0";} if (cutoff==undefined) { $(targetDiv+" .pmMessages").html(data); $("#msgBlock-"+adType.toLowerCase()+"-"+adID).scrollTop($("#msgBlock-"+adType.toLowerCase()+"-"+adID).prop("scrollHeight")); } else { $(targetDiv+" .pmMessages .older-messages").remove(); $(targetDiv+" .pmMessages").prepend(data); } $(targetDiv+" .pmTopics ul li").removeClass("selected"); $(targetDiv+" #topic-"+topicID).addClass("selected"); $("#replyID-"+adType.toLowerCase()+"-"+adID).val(topicID); var msgSubject = $(targetDiv + " #topic-" + topicID).attr("data-subject"); if (msgSubject.substring(0,4)!="Re: ") {msgSubject="Re: "+msgSubject;} $("#replySubject-"+adType.toLowerCase()+"-"+adID).val(msgSubject); $("#replyMessage-"+adType.toLowerCase()+"-"+adID).val(""); }); } function enable_reply() { $(".pmReplyBox textarea").show(); $(".pmReplyBox .redglass").show(); $(".reply-disabled").hide(); } function disable_reply() { $(".pmReplyBox textarea").hide(); $(".pmReplyBox .redglass").hide(); $(".reply-disabled").show(); } function save_pm_reply(adType, adID) { var topicID = $("#replyID-"+adType.toLowerCase()+"-"+adID).val(); var subject = $("#replySubject-"+adType.toLowerCase()+"-"+adID).val(); var message = $("#replyMessage-"+adType.toLowerCase()+"-"+adID).val(); $.ajax({ url: "/Messages/save_pm.asp", method: "POST", data: { id: topicID, action: 2, refID: adID, subject: subject, message: message }, error: function (xhr, ajaxOptions, thrownError) { console.log("status="+xhr.status); console.log("error="+thrownError); console.log("error message="+xhr.responseText); } }).done(function(data) { if (data.substring(0,7)=="ERROR: ") { popup_message("Uh oh!",data); } else { load_ad_messages(adType, adID, topicID); } }); } function remove_favorite(favID) { $.get("/Shared/remove_favorite.asp", {favID: favID}) .done(function(data) { if(data=="success") { $("#user-favorite-"+favID).remove(); popup_message("Success","This favorite has been removed."); } else { popup_message("Uh oh!","There was a problem, and this favorite could not be removed. Please contact support for assistance."+data); } }); } function change_color(parentID, colorID, which) { colorID = parseInt(colorID); $("#"+parentID+" #costume-color"+which).val(colorID); $("#"+parentID+" #color-container"+which+" .colordot").removeClass("selected"); $("#"+parentID+" #color-container"+which+" .colordot:nth-child("+(colorID+1)+")").addClass("selected"); } function clear_unread() { $.get( "/Users/Shared/clear_unread.asp", function(data) { $(".msgBadge").hide(); }); } function reset_views(adtype, adid) { $.get("/Users/Shared/reset_views.asp", {adtype: adtype, adid: adid}) .done(function(data) { if (data=="Success!") { $("#"+adtype.toLowerCase()+"-"+adid+"-pageviews").html("Views: 0"); $("#"+adtype.toLowerCase()+"-"+adid+"-viewssince a").hide(); } }); } function load_account_cancellation() { $("#user_default_page").load("/Users/Shared/cancel_account.asp"); } function delete_user() { var rating = $("#cancel-rating").val(); var reason = $("#cancel-reason").val(); var comments = $("#cancel-comments").val(); var token = $("#user-delete-token").val(); showLoad(); $.ajax({ url: "/Users/Shared/delete_user.asp", method: "POST", data: { token: token, rating: rating, reason: reason, comments: comments }, error: function (xhr, ajaxOptions, thrownError) { hideLoad(); console.log("status="+xhr.status); console.log("error="+thrownError); console.log("error message="+xhr.responseText); } }).done(function(data) { hideLoad(); if (data=="Success!") { $("#cancel_account_warning").hide(); $("#cancel_account_confirmation").show(); $("#userinfo").html(""); $(".logged-in").hide(); $(".logged-out").show(); } else { popup_message("Uh Oh!",data); } }); }