'); alert("Please fill all the fields") return false; } }); jQuery(document).on('click', '.forgotPassword', function(e){ e.preventDefault(); e.stopPropagation(); var url = site_url + '/forgetPassword'; window.open(url,'_self'); }) jQuery(document).on('click', '.openLogin', function(e){ e.preventDefault(); e.stopPropagation(); setModalforSignup("login"); trackOpenLogin("LOGIN") }) jQuery(document).on('click', '.openSignup', function(e){ e.preventDefault(); e.stopPropagation(); setModalforSignup("signup"); trackOpenLogin("SIGNUP") }) function trackOpenLogin(side){ var source = "SIGNUP MODAL" var main_source = ""; var widget = ""; if(side == "LOGIN"){ source = "LOGIN MODAL" }else{ source = "SIGNUP MODAl" } //mixpanel.track('BLOG-CLICK', { 'itemType' : widget, 'itemName' : "Login-Modal", 'iteamMedium': main_source, "itemAction" : 'Login-Modal-switchedto-'+source } ) } jQuery(document).on('click', '.login-modal-button', function(){ modalLogin(); })	function modalLogin(){ var uname = jQuery(".login-username").val(); var pswd = jQuery(".login-password").val(); if(uname != "" && pswd != "" ){ var loginUrl = 'https://yourdost.com/zion/v2/users/login'; jQuery(".progress").show(); jQuery(".login-button").hide(); jQuery.ajax({ type: "POST", dataType: "JSON", contentType: "application/json; charset=utf-8", url: loginUrl , xhrFields: { withCredentials: true }, beforeSend :function(xhr){ xhr.setRequestHeader( "Authorization", "Basic "+ btoa(uname + ":" + pswd) ); }, statusCode:{ 401 : function(response){ var responseText = response.responseText; var responseJson = JSON.parse(responseText) ; var errorMessage = responseJson.message ; var errorType = responseJson.type ; if(errorType == "BLOCKED"){ jQuery(".signup-error").html("We have noticed some unusual activites from this account. Please contact us to learn more. "); }else{ jQuery(".signup-error").html("The username and password do not match"); } jQuery(".progress").hide(); jQuery(".login-button").show(); }, }, data:JSON.stringify({"shouldGenerateCookie": true,"ipSession": false}) }).done(function( data, status, xhr ) { jQuery(".signup-error").html("") ; jQuery(".progress").show(); jQuery(".login-button").hide(); if ( ( typeof mixpanel != 'undefined' ) && (typeof mixpanel.register === "function") ){ mixpanel.register({ userInfo : data , }); var distinct_id = mixpanel.get_distinct_id(); mixpanel.identify(data.id); mixpanel.people.set({ 'username': data.username, 'name' : data.username , '$email': data.email, 'id' : data.id, 'userType' : data["loggableUser"]["userType"] }); mixpanel.name_tag({ nameTag: data.username }); var main_source = ''; var width = ''; mixpanel.track('LOGIN', {'type' : 'NORMAL', 'mediumSource' : 'forum', 'itemName' : "click Forum Chat Now", 'itemMedium' : 'NORMAL' }); } jQuery.cookie("DCU", JSON.stringify(data), {domain: ".yourdost.com"}); jQuery('#myModal').modal('hide') location.href = "https://yourdost.com/chatSession/?workgroup=demo@workgroup.chat.yourdost.com&noUI=true&username=" + data.username; }).error(function(error){ console.log(error) ; jQuery(".progress").hide(); jQuery(".login-button").show(); jQuery('.signup-error').html("Something went wrong. Please try again later") }); }else{ jQuery('.signup-error').html("Please enter username and password") } }	/* ------------------------ */ $('#backTop').backTop({ 'position' : 1400, 'speed' : 500, 'color' : 'green', }); var url = window.location.href ; $(document).mouseup(function (e) { var container = $(".explore-menu"); if (!container.is(e.target) // if the target of the click isn't the container... && container.has(e.target).length === 0) // ... nor a descendant of the container { container.hide(); } }); $(document).mouseup(function (e) { var container = $(".dropdown-content"); if (!container.is(e.target) // if the target of the click isn't the container... && container.has(e.target).length === 0) // ... nor a descendant of the container { container.hide(); } }); // $("body").click(function(e){ // e.stopPropagation() ; // //var user_header = $(".user-section-header").children() ; // if($("#dost-user-dropdown").css("display") == 'block' && $.inArray(e.target) == -1 ){ // $("#dost-user-dropdown").hide(); // } // }); $(".menu-explore").click(function(){ $(".explore-menu").toggle(); var top = 60; var left = jQuery(".menu-explore").offset().left - 90; jQuery('.explore-menu').css({ top:top, left:left, "width":'auto !important' }); }); $("#current-user-header").click(function(){ $(".dropdown-content").toggle() ; var top = 60; var left = jQuery("#current-user-header").offset().left - 60; jQuery('.user-drop-listitems').css({ top:top, left:left, "width":'auto !important' }); }); $(window).scroll(function(){ console.log("Scrolled Top: "+ $(window).scrollTop()) if($(window).scrollTop() > 50 && $(".ember-view.regular").length > 0){ if($(".left.nav-items").is(":visible")){ $(".nav-items").hide() ; } if($.cookie("DCU") == null || $.cookie("DCU") == "null" || typeof $.cookie("DCU") == "undefined"){ if($(".header-rlogoight-section").is(":visible")){ $(".header-rlogoight-section").show(); } $(".header-right-section").fadeIn('fast'); $(".login-button").html(' Log In to Reply'); if(sessionStorage.getItem("promptClose") != 1 && url.search("commonmanstories-share-your-story-win-exciting-prizes") == -1){ setTimeout(function(){ console.log("opening chat...") $( ".chat-prompt" ).slideDown( "slow", function() {}); }, 1000); } if(url.search("commonmanstories-share-your-story-win-exciting-prizes") > -1 && sessionStorage.getItem("campaingPrompt") !=1){ console.log("opening campaign...") $('#campus-campaign').animate({right: "0"}); } } }else{ $(".login-button").html(' Log In'); $(".nav-items").show() ; } }); //$(window).scroll(function(){ // console.log("Scrolled Top: "+ $(window).scrollTop()) //if($(window).scrollTop() > 50 && $(".ember-view.regular").length > 0){ // $(".nav-items").hide() ; //console.log("Finally Inside the Nav hide:") //}else{ // $(".nav-items").show() ; //} //}); $(".my-profile-link").click(function(e){ e.preventDefault(); e.stopPropagation(); if($.cookie("DCU") != null && $.cookie("DCU") != "null" && typeof $.cookie("DCU") != "undefined"){ var userObj = JSON.parse($.cookie("DCU")); var userType = userObj["loggableUser"]["userType"] ; if(userType=="VICTIM"){ window.open("https://yourdost.com/users/profile", "_self") }else{ window.open("https://yourdost.com/counselor/profile", "_self") } } }) if($.cookie("DCU") != null && $.cookie("DCU") != "null" && typeof $.cookie("DCU") != "undefined"){ var userObj = JSON.parse($.cookie("DCU")); var userName = userObj.username ; var userAvatar = userObj.avatar ; var picUrl = userObj.picUrl ; var firstName = userObj.firstName ; if(firstName !="" && firstName != null ){ userName = firstName ; } $.ajaxSetup({ xhrFields: { withCredentials: true } }); $.ajax({ method: "GET", url:'https://yourdost.com/zion/v1/users/'+userObj.id+'/messages/count?type=unread' }).done(function(response){ $(".iheader-msg-badge,.mobile-msg-badge").text( response.count ); if( response.count > 0 ){ $(".iheader-msg-badge,.mobile-msg-badge").removeClass("hide"); } }).fail(function(error){}); $(".user-name-header").html(userName) ; if(userAvatar == null){ userAvatar = "avatar1" ; } if(picUrl){ userAvatar = picUrl }else{ userAvatar = images[userAvatar] ; } var addedAvatar = $(".user-section-header img").attr("src",userAvatar) ; var userType = userObj["loggableUser"]["userType"] ; if(userType != "VICTIM"){ $(".iheader-msg a").attr("href", "https://yourdost.com/friend/messages?yd_source=FORUM&yd_medium=web&yd_campaign=header"); $("#talkitout-url").hide(); $("#client-history-url").show() ; $(".profile_link").attr("href", "#counselor/profile?yd_source=FORUM&yd_medium=web&yd_campaign=header") } } });