1(function( $ ) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 33 $(document).ready(function(){ 34 35 $("#basic-information-form").on("submit", function(e) { $("#register_submit").prop('disabled', true).attr("value", "Processsing") }); 36 37 setTimeout(function() { $('[id^="div-gpt-ad"]').each(function(e) { if($(this).height() >= 10) { $(this).prepend("<p class='advertisment-text'>Advertisement</p>"); } }); }, 1500); 38 39 $("#basic-info-submit").click(function(){ 40 var firstName = $("#firstName").val().trim(); 41 var lastName = $("#lastName").val().trim(); 42 var street = $("#street").val().trim(); 43 var city = $("#city").val().trim(); 44 var country = $("#country-select").val().trim(); 45 var state = ""; 46 if(country == "United States") { 47 state = $("#state-select").val().trim(); 48 } 49 50 var zip = $("#zip").val().trim(); 51 var contentPreference = JSON.stringify($('input:checkbox[name=content-preference]:checked').map(function() { return this.value; }).get()); 52 $.ajax({ 53 url:'/wp-json/account-management/v1/update-user-data', 54 type:'post', 55 data:{firstname:firstName,lastname:lastName,street:street,city:city,state:state,zip:zip,contentpreference:contentPreference, _wpnonce: salesforceVars.nonce}, 56 success:function(response){ 57 console.log(response); 58 if(response['status'] == 'success') { 59 $("#basic_info_error_message").html("User Information Updated").css("color","green").show( "slow", function() {}).delay(3000).fadeOut(); 60 } else { 61 $("#basic_info_error_message").html("Failed to update.").css("color","red").show( "slow", function() {}).delay(3000).fadeOut(); 62 } 63 } 64 }); 65 }); 66 67 $(document).on('click', '#unsubfreq-update', function(e) { 68 e.preventDefault(); 69 let frequency = $('input[name=preferenceValue]:checked', '#frequency_form').val() 70 let userId = $(this).attr('emailid'); 71 let preferenceId = $(this).attr('parentpreferenceid'); 72 let frequencyPreferenceId = $(this).attr('frequencypreferenceid'); 73 $.ajax({ 74 url:'/wp-json/account-management/v1/unsubcribe', 75 type:'post', 76 data:{emailuserid:userId,marketingpreferenceid:preferenceId,marketingpreferencevalue:frequency,marketingfrequencyid:frequencyPreferenceId, _wpnonce: salesforceVars.nonce}, 77 success:function(response){ 78 if(response['status'] == 'Success') { 79 $("#frequency_message").html("Preferences Updated Successfully.").css("color","green").show( "slow", function() {}).delay(3000).fadeOut(); 80 81 } else { 82 $("#frequency_message").html("Failed to update preferences.").css("color","red").show( "slow", function() {}).delay(3000).fadeOut(); 83 } 84 } 85 }); 86 }); 87 88 $(document).on('change', '#country-select', function(e) { 89 if($(this).val() != "United States") { 90 $("#state-fieldset").hide(); 91 } else { 92 $("#state-fieldset").show(); 93 } 94 if($(this).val() != "Canada") { 95 $("#province-fieldset").hide(); 96 } else { 97 $("#province-fieldset").show(); 98 } 99 var country = $(this).val().trim(); 100 $.ajax({ 101 url:'/wp-json/account-management/v1/update-user-country', 102 type:'post', 103 data:{country:country, _wpnonce: salesforceVars.nonce}, 104 success:function(response){ 105 console.log("Country Changed successfully"); 106 } 107 }); 108 }); 109 110 111 $(document).on('click', '#auto-renew-toggle', function(e) { 112 e.preventDefault(); 113 var action = $(this).data("action"); 114 if(action === "cancel") { 115 $(this).data("action", "enable"); 116 } else { 117 $(this).data("action", "cancel"); 118 } 119 var subscription = $(this).data("subscription"); 120 $.ajax({ 121 url: '/wp-json/account-management/v1/update-auto-renew', 122 type: 'post', 123 data: {subscription_reference: subscription, action: action, _wpnonce: salesforceVars.nonce}, 124 success:function(response) { 125 if(response.autorenew == true) { 126 $("#auto-renew-toggle").text("Cancel Auto Renew"); 127 $("#auto-renew-field").text("Active"); 128 } else { 129 $("#auto-renew-toggle").text("Enable Auto Renew"); 130 $("#auto-renew-field").text("Inactive"); 131 } 132 } 133 }) 134 }) 135 136 $(document).on('click', '#unsub-btnsubmit', function(e) { 137 e.preventDefault(); 138 let frequency = "N"; 139 let userId = $(this).attr('emailid'); 140 let preferenceId = $(this).attr('preferenceid'); 141 let frequencyPreferenceId = $(this).attr('frequencypreferenceid'); 142 $.ajax({ 143 url:'/wp-json/account-management/v1/unsubcribe', 144 type:'post', 145 data:{emailuserid:userId,marketingpreferenceid:preferenceId,marketingpreferencevalue:frequency,marketingfrequencyid:frequencyPreferenceId}, 146 success:function(response){ 147 if(response['status'] == 'Success') { 148 $("#unsubscribe_message").html("Successfully Unsubscribed.").css("color","green").show( "slow", function() {}).delay(3000).fadeOut(); 149 } else { 150 $("#unsubscribe_message").html("Failed to unsubscribe, please try again later.").css("color","red").show( "slow", function() {}).delay(3000).fadeOut(); 151 } 152 } 153 }); 154 console.log("Unsubscribe") 155 }); 156 157 $(document).on('click', '.interest', function(e) { 158 var interested; 159 var interest = $(this).data('value'); 160 if($(this).hasClass("active")) { 161 $(this).removeClass("active"); 162 interested = false;
163 } else { 164 $(this).addClass("active"); 165 interested = true; 166 } 167 $.ajax({ 168 url:'/wp-json/account-management/v1/updateInterest', 169 type:'post', 170 data:{interest:interest,interestLevel:interested, _wpnonce: salesforceVars.nonce}, 171 success:function(response){ 172 if(response['status'] == 'Success') { 173 console.log(response); 174 } else { 175 console.log("Error"); 176 } 177 } 178 }); 179 }); 180 }); 181 182 $(document).on("click", ".w-filter-opener", function(e) { 183 $(".w-filter-list").append('<a class="w-filter-list-closer w-btn us-btn-style_1" style="width:100px;" id="filter-submit-button" href="javascript:void(0);"><span>Submit</span></a>'); 184 }); 185 186 $(document).on("click", ".w-filter-list-closer", function(e) { 187 $("#filter-submit-button").remove(); 188 }); 189 190 $(document).on("click", "#email-register-submit", function(e) { 191 e.preventDefault(); 192 var email = $("#cta-register-email").val().trim(); 193 $.ajax({ 194 url: '/wp-json/account-management/v1/register-ems', 195 type: 'post', 196 data:{email:email,source:"RV Magazine Web eNewsletter Signup", _wpnonce: salesforceVars.nonce}, 197 success:function(response){ 198 if(response['status'] == "success") { 199 $("#ems-subscribe-form").html("<p>Thank you for subscribing to RV.com and RV Magazine.</p>"); 200 } 201 } 202 }); 203 }); 204 205 $(window).resize(function() { 206 if(this.resizeTO) clearTimeout(this.resizeTO); 207 this.resizeTO = setTimeout(function() { 208 $(this).trigger('resizeEnd'); 209 }, 1000); 210 }); 211 212 $(window).bind('resizeEnd', function() { 213 googletag.cmd.push(function() { 214 setTimeout(function() { $('[id^="div-gpt-ad"]').each(function(e) { if($(this).height() >= 10) { 215 if($(this).parent().find('.advertisment-text').length != 1) { 216 $(this).prepend("<p class='advertisment-text'>Advertisement</p>"); 217 } 218 }}); }, 1500); 219 }); 220 }); 221 222 223})( jQuery ); 224 225Login = function() { 226} 227 228Login.submitLoginRequest = function() { 229 var username = $("#username").val(); 230 var password = $("#password").val(); 231 var errors = ''; 232 var formErrors = $("#error_message"); 233 formErrors.html(errors); 234 if (!username) { 235 errors = 'Please enter your username.'; 236 formErrors.html(errors); 237 return false; 238 } 239 if (!password) 240 { 241 errors = 'Please enter your password.'; 242 formErrors.html(errors); 243 return false; 244 } 245 var dataArray = { 246 username: username, 247 password: password 248 } 249 $.ajax({ 250 type: 'POST', 251 url: salesforceVars.api_url + '/oAuth/login/check', 252 data: dataArray, 253 dataType: 'json' 254 }).done(function (data) { 255 console.log(data.status); 256 if(data.status !== "valid") { 257 errors = data.error_message; 258 formErrors.html(errors); 259 return false; 260 } else { 261 $('#signInForm').submit(); 262 } 263 }).fail(function(jqXHR){ 264 if(jqXHR.status === 401) { 265 var json = JSON.parse(jqXHR.responseText); 266 errors = json.error_message; 267 } else {
268 errors = 'Error communicating with oAuth Provider'; 269 } 270 formErrors.html(errors); 271 return false; 272 }) 273 274}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.