1(function ($) { 2 'use strict'; 3 4 let ajax_url = dfc_donations_front.ajaxurl; 5 6 // load a locale 7 numeral.register('locale', 'hivos', { 8 delimiters: { 9 thousands: '.', 10 decimal: ',' 11 }, 12 abbreviations: { 13 thousand: 'k', 14 million: 'm', 15 billion: 'b', 16 trillion: 't' 17 }, 18 ordinal: function (number) { 19 return number === 1 ? 'er' : 'ème'; 20 }, 21 currency: { 22 symbol: 'â¬' 23 } 24 }); 25 26 $(document).on("keyup", "form.js-petition-form [name='email']", function () { 27 $("#field10533").val($(this).val()) 28 $(".js-petition-form loading").removeClass("loading") 29 }); 30 31 $(document).on("keyup", "form.js-petition-form [name='first_name']", function () { 32 $("#field10534").val($(this).val()) 33 $(".js-petition-form loading").removeClass("loading") 34 }); 35 36 $(document).on("keyup", "form.js-petition-form [name='insertion']", function () { 37 $("#field10535").val($(this).val()) 38 $(".js-petition-form loading").removeClass("loading") 39 }); 40 41 $(document).on("keyup", "form.js-petition-form [name='last_name']", function () { 42 $("#field10536").val($(this).val()) 43 $(".js-petition-form loading").removeClass("loading") 44 }); 45 46 47 $(document).on("keyup", "form.js-donate-form [name='email']", function () { 48 $("#field10538").val($(this).val()) 49 $(".js-donate-form loading").removeClass("loading") 50 }); 51 52 $(document).on("keyup", "form.js-donate-form [name='firstname']", function () { 53 $("#field10539").val($(this).val()) 54 $(".js-donate-form loading").removeClass("loading") 55 }); 56 57 $(document).on("keyup", "form.js-donate-form [name='nameinfix']", function () { 58 $("#field10540").val($(this).val()) 59 $(".js-donate-form loading").removeClass("loading") 60 }); 61 62 $(document).on("keyup", "form.js-donate-form [name='lastname']", function () { 63 $("#field10541").val($(this).val()) 64 $(".js-donate-form loading").removeClass("loading") 65 }); 66 67 68 $(document).on("change", "[name='donation_period']", function () { 69 70 let period = $(this).val(); 71 72 if (period === "single") { 73 $('[data-period="monthly"]').addClass("is-hidden"); 74 $('[data-period="single"]').removeClass("is-hidden"); 75 76 $('[data-period="monthly"]').find("input[name='bank']").attr("required", false); 77 $('[data-period="monthly"]').find("input[name='iban']").attr("required", false); 78 79 } else { 80 $('[data-period="monthly"]').removeClass("is-hidden"); 81 $('[data-period="single"]').addClass("is-hidden"); 82 83 $('[data-period="monthly"]').find("input[name='bank']").attr("required", true); 84 $('[data-period="monthly"]').find("input[name='iban']").attr("required", true); 85 } 86 87 }); 88 89 $(document).on("click", "[name='single_amount']", function () { 90 91 let c_value = $(this).val() 92 93 if (c_value === "c") { 94 $("#amountOnceCustom").attr("disabled", false); 95 } else { 96 $("#amountOnceCustom").attr("disabled", true); 97 $("#amountOnceCustom").val("") 98 } 99 100 }); 101 102 $(document).on("click", "[name='monthly_amount']", function () { 103 104 let c_value = $(this).val() 105 106 if (c_value === "c") { 107 $("#amountPeriodicCustom").attr("disabled", false); 108 } else { 109 $("#amountPeriodicCustom").attr("disabled", true); 110 $("#amountPeriodicCustom").val("") 111 } 112 113 }); 114 115 $(document).on("submit", "form.js-petition-form", function (e) { 116 117 e.preventDefault(); 118 119 if ($(this).hasClass("loading")) { 120 return true 121 } 122 123 $(this).addClass("loading") 124 125 let form_container = $(this).closest(".dfc-form-main-container"); 126 127 run_dfc_new_petition(form_container); 128 129 }); 130 131 $(document).on("submit", "form.js-donate-form", function (e) { 132 133 e.preventDefault(); 134 135 let form_container = $(this).closest(".dfc-form-main-container"); 136 137 run_dfc_new_donation(form_container); 138 139 }); 140
141 function run_dfc_new_petition(form_container) { 142 143 let x = getCookie("last_petition"); 144 145 if (typeof (x) === "undefined" || x === "") { 146 console.log("if 1") 147 x = ThemeJS.post_id 148 } else { 149 150 console.log("else 1") 151 let x_array = x.split(','); 152 153 if (x_array.length > 5) { 154 console.log("Max 5") 155 alert("Max petition per day") 156 return true; 157 } 158 159 if (x_array.indexOf(ThemeJS.post_id) === -1) { 160 x_array.push(ThemeJS.post_id); 161 } 162 163 x = x_array.join(","); 164 165 } 166 167 let form_array = form_container.find("form.js-petition-form").serializeArray() 168 let newsletter = form_container.find("[name='newsletter']").prop("checked"); 169 let MC_form = $("#form1502").clone(); 170 171 let data = { 172 action: "dfc_new_petition", 173 form: form_array, 174 post_id: dfc_donations_front.post_id, 175 } 176 177 console.log(form_array) 178 179 $.post(ajax_url, data, function (res) { 180 181 console.log(res) 182 183 if (res.error) { 184 alert(res.error) 185 return true 186 } 187 188 $(".dfc-form-main-container").html(res.new_text); 189 $("html, body").scrollTop(form_container.position().top); 190 191 if (newsletter) { 192 run_mailchimp_petition(form_array, MC_form); 193 } 194 195 setCookie("last_petition", x, 1); 196 197 }, "json"); 198 199 } 200 201 function run_dfc_new_donation(form_container) { 202 203 let form_array = form_container.find("form.js-donate-form").serializeArray() 204 let newsletter = form_container.find("[name='optin']").prop("checked"); 205 let MC_form = $("#form1503").clone(); 206 let payment_mode = form_container.find("[name='donation_period']").val() 207 let period = "one" 208 209 if (payment_mode === "monthly") { 210 period = form_container.find("[name='donationtype']").val() 211 } 212 213 let data = { 214 action: "dfc_new_mollie_donation", 215 form: form_array, 216 post_id: dfc_donations_front.post_id, 217 payment_mode: payment_mode, 218 period: period 219 } 220 221 $.post(ajax_url, data, function (res) { 222 223 console.log(res) 224 225 if (newsletter) { 226 227 console.log("newsletter yes") 228 229 let mailchimp_url = MC_form.attr("action"); 230 231 let email, first_name, last_name, nameinfix = ""; 232 233 $.each(form_array, function (i, val) { 234 235 if (val.name === "email") { 236 email = val.value; 237 } 238 239 if (val.name === "first_name") { 240 first_name = val.value; 241 } 242 243 if (val.name === "last_name") { 244 last_name = val.value; 245 } 246 247 if (val.name === "insertion") { 248 nameinfix = val.value; 249 } 250 251 }); 252 253 let data = { 254 "field10538": email, 255 "field10539": first_name, 256 "field10540": nameinfix, 257 "field10541": last_name, 258 "userId": "70132", 259 "formEncId": "hMVsI4uVUwv6Z3sigRHR", 260 "pagePosition": "1", 261 "viewMode": "STATICINTEGRATION", 262 "redir": "formAdmin2", 263 "formLayout": "N", 264 "errorText": "Dit formulier kon niet verzonden worden om de volgende reden(en):" 265 } 266 267 /* 268 $.post(mailchimp_url, data, function (mailplus_res) { 269 270 document.location = res.checkout_url; 271 272 }); 273 */ 274 275 let jqXHR = jQuery.ajax({ 276 type: 'POST', 277 async: true, 278 cache: false, 279 url: mailchimp_url, 280 //contentType: 'application/json; charset=UTF-8', 281 //crossDomain: true, 282 //dataType: 'jsonp', 283 data: data, 284 timeout: 2000 285 }) 286 .fail(function (jqXHR, textStatus, errorThrown) { 287 console.log('fail was called'); 288 }) 289 .done(function (data, textStatus, jqXHR) { 290 //console.log('Your IP is ' + data.ip); 291 console.log('done was called'); 292 }) 293 .always(function (dataOrjqXHR, textStatus, jqXHR
293orErrorThrown) { 294 document.location = res.checkout_url; 295 }); 296 297 298 } else { 299 300 document.location = res.checkout_url; 301 302 } 303 304 }, "json"); 305 306 } 307 308 function run_mailchimp_petition(form_array, MC_form) { 309 310 let mailchimp_url = MC_form.attr("action"); 311 312 let email, first_name, last_name, nameinfix = ""; 313 314 $.each(form_array, function (i, val) { 315 316 if (val.name === "email") { 317 email = val.value; 318 } 319 320 if (val.name === "first_name") { 321 first_name = val.value; 322 } 323 324 if (val.name === "last_name") { 325 last_name = val.value; 326 } 327 328 if (val.name === "insertion") { 329 nameinfix = val.value; 330 } 331 332 }); 333 334 let data = { 335 "field10533": email, 336 "field10534": first_name, 337 "field10535": nameinfix, 338 "field10536": last_name, 339 "userId": "70132", 340 "formEncId": "WWcd46xAq5VviudLmV7q", 341 "pagePosition": "1", 342 "viewMode": "STATICINTEGRATION", 343 "redir": "formAdmin2", 344 "formLayout": "N", 345 "errorText": "Dit formulier kon niet verzonden worden om de volgende reden(en):" 346 } 347 348 $.post(mailchimp_url, data, function (res) { 349 }); 350 351 } 352 353 function run_mailchimp_donation(form_array, MC_form) { 354 355 } 356 357 function setCookie(cname, cvalue, exdays) { 358 const d = new Date(); 359 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 360 //d.setTime(d.getTime() + 5000); 361 let expires = "expires=" + d.toUTCString(); 362 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 363 } 364 365 function getCookie(cname) { 366 let name = cname + "="; 367 let decodedCookie = decodeURIComponent(document.cookie); 368 let ca = decodedCookie.split(';'); 369 for (let i = 0; i < ca.length; i++) { 370 let c = ca[i]; 371 while (c.charAt(0) == ' ') { 372 c = c.substring(1); 373 } 374 if (c.indexOf(name) == 0) { 375 return c.substring(name.length, c.length); 376 } 377 } 378 return ""; 379 } 380 381 382})(jQuery);
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.