var wsDir = '/gdcore-ws/'; $(function() { $('.open').click( function(){ clientLogin(); return false; }); $('.client_login').click( function(){ clientLogin(); return false; }); $('.client_login').live( "click", function(){ clientLogin(); return false; }); $('.client_create').click( function(){ clientCreate(); return false; }); $('.client_create').live( "click", function(){ clientCreate(); return false; }); $('.client_forgot_username').click( function(){ clientForgot(); return false; }); $('.client_forgot_username').live( "click", function(){ clientForgot(); return false; }); $('.client_forgot_password').click( function(){ clientForgot(); return false; }); $('.client_forgot_password').live( "click", function(){ clientForgot(); return false; }); $(".client_logout").click( function() { clientUnLoad() return false; }); $(".client_logout").live("click", function() { clientUnLoad() return false; }); /* ---------- Listing - Engage ---------- */ $('#content_area').delegate('.listing_subscribe', 'click', function() { var listingKey = $(this).closest('.gd-listing').attr('id').replace('listing-', ''); var target = $(this); listingSubscribe(listingKey,target); return false; }); $('#content_area').delegate('.listing_unsubscribe', 'click', function() { var listingKey = $(this).closest('.gd-listing').attr('id').replace('listing-', ''); var target = $(this); listingUnsubscribe(listingKey,target); return false; }); $('#content_area').delegate('.listing_hide', 'click', function() { var listingKey = $(this).closest('.gd-listing').attr('id').replace('listing-', ''); var target = $(this); listingHide(listingKey,target); return false; }); /* ---------- Listing - Functions ---------- */ function listingSubscribe(listingKey,target){ var message; if ($("body").hasClass('loggedin')) { //var ajaxUrl = $(target).attr('href'); var ajaxUrl = '/gdcore-ws/client/listing/' + listingKey + '/subscribe'; $.ajax({ method: "get", url: ajaxUrl, dataType: "json", data:{ listingKey: listingKey }, success: function( data ) { $("#client-listings-count").text(data.clientListingCount); saveButton = $(target).parent(); $(saveButton).attr('class', 'gd-updated active'); $(target).attr('class', 'listing_unsubscribe'); $(target).text('Remove Listing'); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to save listings.'; clientLogin(message); } }; function listingUnsubscribe(listingKey,target){ var message; if ($("body").hasClass('loggedin')) { //var ajaxUrl = $(target).attr('href'); var ajaxUrl = '/gdcore-ws/client/listing/' + listingKey + '/unsubscribe'; $.ajax({ method: "get", url: ajaxUrl, dataType: "json", data:{ listingKey: listingKey }, success: function( data ) { $("#client-listings-count").text(data.clientListingCount); saveButton = $(target).parent(); $(saveButton).attr('class', 'gd-updated inactive'); $(target).attr('class', 'listing_subscribe'); $(target).text('Save Listing'); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to save listings.'; clientLogin(message); } }; function listingHide(listingKey,target){ var message; if ($("body").hasClass('loggedin')) { var ajaxUrl = $(target).attr('href'); $.ajax({ method: "get", url: ajaxUrl, dataType: "html", /* data:{ listingKey: listingKey }, */ success: function( data ) { modal(data, message); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to save listings.'; clientLogin(message); } }; /* ---------- Search - Engage ---------- */ $('.modules').delegate('.search_subscribe', 'click', function() { if ($( 'input[name="gdSearchString"]:first-child', $( this ).parents ( '.module' ) ).attr('value') !== undefined) { var searchString = $( 'input[name="gdSearchString"]:first-child', $( this ).parents ( '.module' ) ).attr('value'); } else { var searchString; } var target = $(this); searchSubscribe(searchString,target); return false; }); /* ---------- Search - Functions ---------- */ function searchSubscribe(searchString,target){ var searchString; var message; if ($("body").hasClass('loggedin')) { //var ajaxUrl = $(target).attr('href'); $.ajax({ method: "get", url: '/gdcore-ws/client/search/subscribe', dataType: "html", data:{ searchString: searchString }, success: function( data ) { modal(data, message); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to save searches.'; clientLogin(message); } }; $("#search_subscribe_form").live("submit", function() { if ($('input[name="gdSearchTitle"]').val().length < 1) { // put a message here return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/search/subscribe', dataType: "html", data : $(this).serializeArray(), success: function(data) { modal(data); $.fancybox.resize(); }, error: function( data ) { alert('error'); } }); return false; }); /* ---------- Report - Engage ---------- */ $('#content_area').delegate('.report_subscribe', 'click', function() { var reportKey = $(this).closest('.gd-report').attr('id').replace('report-', ''); var target = $(this); reportSubscribe(reportKey,target); return false; }); $('#content_area').delegate('.report_unsubscribe', 'click', function() { var reportKey = $(this).closest('.gd-report').attr('id').replace('report-', ''); var target = $(this); reportUnsubscribe(reportKey,target); return false; }); /* ---------- Report - Functions ---------- */ function reportSubscribe(reportKey){ var message; if ($("body").hasClass('loggedin')) { $.ajax({ method: "get", url: '/gdcore-ws/client/report/subscribe', dataType: "html", data:{ reportKey: reportKey }, success: function( data ) { subscribeButtonId = '#report-' + reportKey; $(subscribeButtonId + ' .button-report-subscribe').attr('class', 'gd-updated button-report-subscribe active'); $(subscribeButtonId + ' .button-report-subscribe a').attr('class', 'report_unsubscribe'); $(subscribeButtonId + ' .button-report-subscribe a').text(function(index, text) { return text.replace("Subscribe", "Unsubscribe"); }); modal(data, message); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to subscribe to reports.'; clientLogin(message); } }; function reportUnsubscribe(reportKey){ var message; if ($("body").hasClass('loggedin')) { $.ajax({ method: "get", url: '/gdcore-ws/client/report/unsubscribe', dataType: "html", data:{ reportKey: reportKey }, success: function( data ) { subscribeButtonId = '#report-' + reportKey; $(subscribeButtonId + ' .button-report-subscribe').attr('class', 'gd-updated button-report-subscribe inactive'); $(subscribeButtonId + ' .button-report-subscribe a').attr('class', 'report_subscribe'); $(subscribeButtonId + ' .button-report-subscribe a').text(function(index, text) { return text.replace("Unsubscribe", "Subscribe"); }); modal(data, message); }, error: function( data ) { alert('error'); } }) } else { message = 'You must create an account in order to subscribe to reports.'; clientLogin(message); } }; /* ---------- Client Login Process ---------- */ $("#login_form").live("submit", function() { if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) { $("#login_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/account/process', dataType: "json", data : $(this).serializeArray(), success: function(data) { if( data.status == 1 ) { this_status = data.status; this_message = data.message; this_id = data.id; this_firstname = data.firstname; this_lastname = data.lastname; clientLoad(this_status, this_message, this_id, this_firstname, this_lastname); } else { this_message = data.message; client(this_message); } $.fancybox.hideActivity(); } }); return false; }); /* ---------- Widget Client Login Process ---------- */ $("#widget-client-login-form").live("submit", function() { if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) { $("#login_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/account/process', dataType: "json", data : $(this).serializeArray(), success: function(data) { if( data.status == 1 ) { this_status = data.status; this_message = data.message; this_id = data.id; this_firstname = data.firstname; this_lastname = data.lastname; clientLoad(this_status, this_message, this_id, this_firstname, this_lastname); } else { this_message = data.message; client(this_message); } $.fancybox.hideActivity(); } }); return false; }); /* ---------- Client Create ---------- */ function clientCreate(message){ var message; formKey = 69; $.ajax({ method: "get", url: '/gdcore-ws/client/account/create', dataType: "html", data:{ formKey: 69 }, success: function( data ) { modal(data, message); }, error: function( data ) { alert('error'); } }) return false; }; /* ---------- Client Create Process ---------- */ $("#client_create_form").live("submit", function() { if ($("#reg_firstname").val().length < 1 || $("#reg_lastname").val().length < 1 || $("#reg_username").val().length < 1) { $("#client_create_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/account/create/process', dataType: "json", data : $(this).serializeArray(), success: function(data) { if( data.status == 1 ) { this_status = data.status; this_message = data.message; this_id = data.id; this_firstname = data.firstname; this_lastname = data.lastname; clientLoad(this_status, this_message, this_id, this_firstname, this_lastname); } else { this_message = data.message; clientCreate(this_message); } }, error: function( data ) { alert('error'); } }); return false; }); /* ---------- Client Forgot ---------- */ function clientForgot(message){ var message; formKey = 69; $.ajax({ method: "get", url: '/gdcore-ws/client/account/forgot', dataType: "html", data:{ formKey: 69 }, success: function( data ) { modal(data, message); }, error: function( data ) { alert('error'); } }) return false; }; /* ---------- Client Forgot Username ---------- */ $("#client_forgot_username_form").live("submit", function() { if ($("#client_email").val().length < 1 || $("#client_email").val().length < 1) { $("#client_forgot_username_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/account/forgot', dataType: "html", data : $(this).serializeArray(), success: function(data) { modal(data); } }); return false; }); /* ---------- Client Forgot Password ---------- */ $("#client_forgot_password_form").live("submit", function() { if ($("#client_username").val().length < 1 || $("#client_username").val().length < 1) { $("#client_forgot_password_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/account/forgot', dataType: "html", data : $(this).serializeArray(), success: function(data) { modal(data); } }); return false; }); /* ---------- List Subscribe ---------- */ $(".list_subscribe").live("submit", function() { listHTMLId = '#' + $(this).attr("id"); parentElement = $(listHTMLId).parent(); parentHTMLId = '#' + (parentElement).attr("id"); listToken = $(listHTMLId + ' input:hidden[name=listToken]').val(); if ($(listHTMLId + ' .subscriber_email').val().length < 1 || $(listHTMLId + ' .subscriber_name').val() == 'your name' || $(listHTMLId + ' .subscriber_email').val() == 'your email') { alert('Your Name and Email Address are required to subscribe.') return false; } $.ajax({ type : "get", cache : false, url : '/gdcore-ws/client/list/subscribe', dataType: "html", data : $(this).serializeArray(), success: function(data) { $(listHTMLId).remove(); $(parentHTMLId).prepend(data); } }); return false; }); function modal(data, message){ //alert('modal?!'); var modalMessage = message; var modalContent = data; if (undefined != modalMessage) { modalMessageInsert = '
'; modalContent = modalContent.replace(/