1jQuery(function ($) { 2 if ($("form.cart").hasClass("grouped_form")) { 3 $("form.cart.grouped_form .single_add_to_cart_button").on( 4 "click", 5 function () { 6 var productData = []; // Array to store product data 7 8 $(".woocommerce-grouped-product-list-item").each(function (i, e) { 9 var productId = $(this).attr("id").replace("product-", ""); 10 var quantity = parseInt($(this).find(".quantity input").val()); 11 12 if (isNaN(quantity) || quantity <= 0) { 13 quantity = 0; // Set quantity to 0 if invalid 14 } 15 16 productData.push({ 17 productId: productId, 18 quantity: quantity, 19 }); 20 }); 21 22 // Send AJAX request to add products to cart 23 $.ajax({ 24 url: wcpd.ajaxurl, // WordPress AJAX endpoint URL 25 type: "POST", 26 data: { 27 action: "add_grouped_products_to_cart", 28 product_data: productData, 29 nonce: wcpd.nonce, 30 }, 31 success: function (response) { 32 // Handle success response 33 if (jQuery(".woocommerce-notices-wrapper").length > 0) { 34 jQuery(".woocommerce-notices-wrapper") 35 .append(`<div class="woocommerce-message" role="alert"> 36 <a href="${wcpd.cart_url}" class="button wc-forward">View cart</a> Product has been added to your cart.</div>`); 37 } else { 38 jQuery("#primary") 39 .prepend(`<div class="woocommerce-message" role="alert"> 40 <a href="${wcpd.cart_url}" class="button wc-forward">View cart</a> Product has been added to your cart.</div>`); 41 } 42 $(document.body).trigger("wc_fragment_refresh"); 43 }, 44 error: function (jqXHR, textStatus, errorThrown) { 45 // Handle error 46 console.error("Error adding products to cart:", errorThrown); 47 }, 48 }); 49 }, 50 ); 51 } 52 53 if (typeof wc_single_product_params === "undefined") { 54 } 55 56 if ("yes" == wcpd.ajax_cart) { 57 //if ajax add to cart on archive page. 58 $(document).ajaxSend(function (event, jqxhr, settings) { 59 if (settings.url.indexOf("?wc-ajax=add_to_cart") != -1) { 60 jqxhr.abort(); 61 } 62 }); 63 } 64 65 $(document).on("click", ".close-wcpd-rest-modal", function (e) { 66 e.preventDefault(); 67 var id = $(this).data("id"); 68 $(`a[data-product_id="${id}"]`).removeClass("loading"); 69 $(".wcpd-error-modal-container").fadeOut("200"); 70 $(".wcpd-modal-container").fadeOut("200"); 71 $("body").removeClass("wcpd-modal-open"); 72 }); 73 74 //sitewide disclaimer 75 var data = { 76 action: wcpd.sitewide_disclaimer, 77 cookie_activation: wcpd.sitewide_cookie_activation, 78 cookie_duration: wcpd.sitewide_cookie_duration, 79 nonce: wcpd.nonce, 80 }; 81 82 $.post(wcpd.ajaxurl, data, function (success) { 83 if ("" != $.trim(success) && "Unauthorized" != $.trim(success)) { 84 $("body").addClass("wcpd-modal-open"); 85 $(".wcpd-modal-container").fadeIn("200").css("display", "flex"); 86 $("#wcpd-modal-content").html(success); 87 } 88 }); 89 90 //Specific Page disclaimer 91 var data = { 92 action: wcpd.specific_page_disclaimer, 93 cookie_activation: wcpd.global_cookie_activation, 94 cookie_duration: wcpd.global_cookie_duration, 95 page_id: wcpd.specific_page_id, 96 nonce: wcpd.nonce, 97 }; 98 99 $.post(wcpd.ajaxurl, data, function (success) { 100 if ("" != $.trim(success) && "Unauthorized" != $.trim(success)) { 101 $("body").addClass("wcpd-modal-open"); 102 $(".wcpd-modal-container").fadeIn("200").css("display", "flex"); 103 $("#wcpd-modal-content").html(success); 104 } 105 }); 106 107 //for single product page 108 $("form.cart").submit(function (e) { 109 if ($("form.cart").hasClass("grouped_form")) { 110 return; 111 } 112 113 e.preventDefault(); 114 115 var form = $(this); 116 var variation_id = ""; 117 var product_id = ""; 118 var quantity = form.find('input[name="quantity"]').val(); 119 120 if (form.hasClass("variations_form")) { 121 product_id = form.find('input[name="add-to-cart"]').val(); 122 variation_id = form.find('input[name="variation_id"]').val(); 123 } else { 124 product_id = form.find('button[name="add-to-cart"]').val(); 125 } 126 if (jQuery("#wc-bookings-booking-form").length > 0) { 127 product_id = document.querySelector('input[name="add-to-cart"]').value; 128 var quantity = "1"; 129 } 130 131 if ("" === product_id || typeof product_id === "undefined") { 132 var action = form.attr("action"); 133 if (action) { 134 var url = new URL(action, window.location.origin); 135 product_id = url.searchParams.get("add-to-cart"); 136 } 137 } 138 139 var data = { 140 action: wcpd.simple_product_disclaimer, 141 cookie_activation: wcpd.global_cookie_activation, 142 cookie_duration: wcpd.global_cookie_duration, 143 product_id: product_id, 144 variation_id: variation_id, 145 quantity: quantity, 146 nonce: wcpd.nonce, 147 }; 148 149 $.post(wcpd.ajaxurl, data, function (success) { 150 //debugger; 151 if ("" != $.trim(success)) {
152 $("body").addClass("wcpd-modal-open"); 153 $(".wcpd-modal-container").fadeIn("200").css("display", "flex"); 154 $("#wcpd-modal-content").html(success); 155 } else { 156 if (variation_id != "") { 157 add_to_cart_simple_product(product_id, variation_id, quantity, form); 158 } else { 159 add_to_cart_simple_product(product_id, "", quantity, form); 160 } 161 } 162 }); 163 }); 164 165 // for simple type products on archive page 166 $(document).on( 167 "click", 168 "a.product_type_bundle, product_type_bundle.product_type_simple.add_to_cart_button, .product_type_simple.ajax_add_to_cart", 169 function (e) { 170 if ( 171 $(".wp-block-button__link").length > 0 && 172 $("body").hasClass("woocommerce") && 173 $("body").hasClass("archive") 174 ) { 175 e.preventDefault(); 176 } 177 178 if ("no" == wcpd.ajax_cart) { 179 e.preventDefault(); 180 } 181 182 var add_to_cart_btn = $(this); 183 var product_id = add_to_cart_btn.data("product_id"); 184 var quantity = 185 typeof add_to_cart_btn.data("quantity") === "undefined" 186 ? 1 187 : add_to_cart_btn.data("quantity"); 188 189 var data = { 190 action: wcpd.simple_product_disclaimer, 191 cookie_activation: wcpd.global_cookie_activation, 192 cookie_duration: wcpd.global_cookie_duration, 193 product_id: product_id, 194 quantity: quantity, 195 nonce: wcpd.nonce, 196 }; 197 198 $.post(wcpd.ajaxurl, data, function (success) { 199 if ("" != $.trim(success)) { 200 // debugger; 201 $("body").addClass("wcpd-modal-open"); 202 $(".wcpd-modal-container").fadeIn("200").css("display", "flex"); 203 $("#wcpd-modal-content").html(success); 204 } else { 205 woo_add_to_cart(product_id, quantity, add_to_cart_btn); 206 } 207 }); 208 }, 209 ); 210 211 $(document).on("click", ".wcpd_accept", function (e) { 212 e.preventDefault(); 213 214 // debugger; 215 var flag_age = false; 216 var flag_terms = false; 217 var current = $(this); 218 var age = ""; 219 var req_age = ""; 220 var age_limit = 150; 221 var parent = current.parents(".wcpd-modal-content"); 222 var type = parent.find("#wcpd_disclaimer_type").val(); 223 var product_id = parent.find("#wcpd_product_id").val(); 224 var disclaimer_id = parent.find("#wcpd_disclaimer_id").val(); 225 var quantity = parent.find("#wcpd_product_quantity").val(); 226 var add_to_cart_btn = $(`a[data-product_id="${product_id}"]`); 227 var form = $("form.cart"); 228 229 if ($(".wcpd_age_verification_wrapper").find(".wcpd-error").length > 0) { 230 $(".wcpd_age_verification_wrapper .wcpd-error").remove(); 231 } 232 233 if ($(".wcpd_terms_condition_wrapper").find(".wcpd-error").length > 0) { 234 $(".wcpd_terms_condition_wrapper .wcpd-error").remove(); 235 } 236 237 if (parent.find("#wcpd_age_verification").length > 0) { 238 age = $.trim(parent.find("#wcpd_age_verification").val()); 239 req_age = parent.find("#wcpd_age_verification").data("min"); 240 if (age >= req_age) { 241 flag_age = true; 242 if (age <= age_limit) { 243 flag_age = true; 244 } else { 245 flag_age = false; 246 $(".wcpd_age_verification_wrapper").append( 247 `<span class="wcpd-error">${wcpd.age_limit_txt}</span>`, 248 ); 249 } 250 } else { 251 flag_age = false; 252 if ( 253 $(".wcpd_age_verification_wrapper").find(".wcpd-error").length <= 0 254 ) { 255 $(".wcpd_age_verification_wrapper").append( 256 `<span class="wcpd-error">${wcpd.age_error_txt}</span>`, 257 ); 258 } 259 } 260 } else { 261 flag_age = true; 262 } 263 264 if (parent.find("#wcpd_terms_condition").length > 0) { 265 if (parent.find("#wcpd_terms_condition").is(":checked")) { 266 flag_terms = true; 267 } else { 268 flag_terms = false; 269 if ( 270 $(".wcpd_terms_condition_wrapper").find(".wcpd-error").length <= 0 271 ) { 272 $(".wcpd_terms_condition_wrapper").append( 273 `<span class="wcpd-error">${wcpd.terms_error_txt}</span>`, 274 ); 275 } 276 } 277 } else { 278 flag_terms = true; 279 } 280 281 if (flag_age && flag_terms) { 282 $(".wcpd-modal-loader").fadeIn("200"); 283 284 // if cookie setting is enable for sitewide 285 if (type == "sitewide" && wcpd.sitewide_cookie_activation == "enabled") { 286 var cookie_data = { 287 action: wcpd.add_cookies, 288 nonce: wcpd.nonce, 289 type: type, 290 cookie_duration: wcpd.sitewide_cookie_duration, 291 }; 292 293 $.post(wcpd.ajaxurl, cookie_data, function (response) {}); 294 } 295 296 // if cookie setting is enable for general or specific 297 if (type != "sitewide" && wcpd.global_cookie_activation == "enabled") { 298 var cookie_data = { 299 action: wcpd.add_cookies, 300 nonce: wcpd.nonce, 301 type: type, 302 product_id: product_id, 303 cookie_duration: wcpd.global_cookie_duration, 304 }; 305 306 if (type == "page") { 307 cookie_data.specific_page_id = wcpd.specific_page_id; 308 } 309 310 $.post(wcpd.ajaxurl, cookie_data, function (response) {}); 311 } 312 313 if (wcpd.logs == "enabled") { 314 var log_data = { 315 action: wcpd.add_logs, 316 disclaimer_id: disclaimer_id, 317 product_id: product_id, 318 permission: "accept", 319 user_age: age, 320 nonce: wcpd.nonce, 321 }; 322 323 if (type == "page") { 324 log_data.specific_page_id = wcpd.specific_page_id; 325 } 326 327 $.post(wcpd.ajaxurl, log_data, function (response) { 328 if (type == "sitewide" || type == "page") { 329 $(".wcpd-error-modal-container").fadeOut("200"); 330 $(".wcpd-modal-container").fadeOut("200");
331 $("body").removeClass("wcpd-modal-open"); 332 return false; 333 } 334 335 if (wcpd.is_product) { 336 if (form.hasClass("variations_form")) { 337 //$('form.cart').unbind().submit(); 338 var variation_id = form.find('input[name="variation_id"]').val(); 339 product_id = form.find('input[name="product_id"]').val(); 340 add_to_cart_simple_product( 341 product_id, 342 variation_id, 343 quantity, 344 form, 345 ); 346 } else { 347 add_to_cart_simple_product(product_id, "", quantity, form, e); 348 } 349 } else { 350 woo_add_to_cart(product_id, quantity, add_to_cart_btn); 351 } 352 }); 353 } else { 354 if (type == "sitewide" || type == "page") { 355 $(".wcpd-error-modal-container").fadeOut("200"); 356 $(".wcpd-modal-container").fadeOut("200"); 357 $("body").removeClass("wcpd-modal-open"); 358 return false; 359 } 360 361 if (wcpd.is_product) { 362 if (form.hasClass("variations_form")) { 363 //$('form.cart').unbind().submit(); 364 var variation_id = form.find('input[name="variation_id"]').val(); 365 add_to_cart_simple_product( 366 product_id, 367 variation_id, 368 quantity, 369 form, 370 ); 371 } else { 372 add_to_cart_simple_product(product_id, "", quantity, form); 373 } 374 } else { 375 woo_add_to_cart(product_id, quantity, add_to_cart_btn); 376 } 377 } 378 379 //$('.wcpd-modal-loader').fadeOut('200'); 380 } 381 }); 382 383 $(document).on("click", ".wcpd_reject", function (e) { 384 e.preventDefault(); 385 //debugger; 386 var current = $(this); 387 var parent = current.parents(".wcpd-modal-content"); 388 var product_id = parent.find("#wcpd_product_id").val(); 389 var disclaimer_id = parent.find("#wcpd_disclaimer_id").val(); 390 var reject_url = current.attr("href"); 391 392 if (wcpd.logs == "enabled") { 393 var log_data = { 394 action: wcpd.add_logs, 395 disclaimer_id: disclaimer_id, 396 product_id: product_id, 397 permission: "reject", 398 nonce: wcpd.nonce, 399 }; 400 401 $.post(wcpd.ajaxurl, log_data, function (response) { 402 if ($.trim(reject_url) != "") { 403 window.location = reject_url; 404 } 405 406 // var obj = $.parseJSON( response ); 407 // if ( obj.status == 'success' ) 408 // console.log('log has been created.'); 409 }); 410 } else { 411 if ($.trim(reject_url) != "") { 412 window.location = reject_url; 413 } 414 } 415 }); 416 417 $(document).on("show_variation", function (e, variation, purchasable) { 418 var data = { 419 action: wcpd.onpage_specific_variation_disclaimer, 420 variation_id: variation.variation_id, 421 nonce: wcpd.nonce, 422 }; 423 424 if ($(".wcpd_onpage_variation_wrapper").length > 0) { 425 $(".wcpd_onpage_variation_wrapper").remove(); 426 } 427 428 $.post(wcpd.ajaxurl, data, function (response) { 429 if ($.trim(response) != "") { 430 $(".quantity").before(response); 431 } 432 }); 433 }); 434 435 function woo_add_to_cart(product_id, quantity, $this = "") { 436 var data = { 437 action: "woocommerce_add_to_cart", 438 product_id: product_id, 439 quantity: quantity, 440 nonce: wcpd.nonce, 441 }; 442 443 // Ajax action 444 $.post(wcpd.ajaxurl, data, function (response) { 445 if (!response) { 446 return; 447 } 448 449 $(".close-wcpd-rest-modal").trigger("click"); 450 451 var this_page = window.location.toString(); 452 453 this_page = this_page.replace("add-to-cart", "added-to-cart"); 454 455 if (response.error && response.product_url) { 456 window.location = response.product_url; 457 return false; 458 } 459 460 // Redirect to cart option 461 if (wcpd.cart_redirect === "yes") { 462 window.location = wcpd.cart_url; 463 return; 464 } else { 465 if ($this == "") { 466 location.reload(); 467 return; 468 } 469 470 $this.removeClass("loading"); 471 fragments = response.fragments; 472 cart_hash = response.cart_hash; 473 // Block fragments class 474 if (fragments) { 475 $.each(fragments, function (key, value) { 476 $(key).addClass("updating"); 477 }); 478 } 479 480 // Changes button classes 481 $this.addClass("added"); 482 // View cart text 483 if ( 484 !wcpd.is_cart && 485 $this.parent().find(".added_to_cart").length === 0 486 ) { 487 $this.after( 488 ' <a href="' + 489 wcpd.cart_url + 490 '" class="added_to_cart wc-forward" title="' + 491 wcpd.i18n_view_cart + 492 '">' + 493 wcpd.i18n_view_cart + 494 "</a>", 495 ); 496 } 497 498 // Replace fragments 499 if (fragments) { 500 $.each(fragments, function (key, value) { 501 $(key).replaceWith(value); 502 }); 503 } 504 // Unblock 505 $(".widget_shopping_cart, .updating") 506 .stop(true) 507 .css("opacity", "1") 508 .unblock(); 509 // Cart page elements 510 $(".shop_table.cart").load( 511 this_page + " .shop_table.cart:eq(0) > *", 512 function () { 513 $( 514 "div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)", 515 ) 516 .addClass("buttons_added") 517 .append( 518 '<input type="button" value="+" id="add1" class="plus" />', 519 ) 520 .prepend( 521 '<input type="button" value="-" id="minus1" class="minus" />', 522 ); 523 $(".shop_table.cart").stop(true).css("opacity", "1").unblock(); 524 $("body").trigger("cart_page_refreshed"); 525 }, 526 ); 527 528 $(".cart_totals").load( 529 this_page + " .cart_totals:eq(0) > *", 530 function () { 531 $(".cart_totals").stop(true).css("opacity", "1").unblock(); 532 }, 533 ); 534 535 //$('.wcpd-modal-loader').fadeOut('200'); 536 537 // Trigger event so themes can refresh other areas 538 $("body").trigger("added_to_cart", [fragments, cart_hash]); 539
540 // CheckoutWC compatibility: open side cart if available 541 // Checkout-for-woocommerce side car compatibility by krestel. 542 var $trigger = jQuery(".cfw-side-cart-open-trigger").first(); 543 if ($trigger.length) { 544 $trigger.trigger("click"); 545 } 546 } 547 }); 548 } 549 550 function add_to_cart_simple_product( 551 product_id = "", 552 variation_id = "", 553 quantity = "", 554 form, 555 e, 556 ) { 557 // console.log('product_addons: ', product_addons); 558 559 var woo_product_bundle = {}; 560 if ($(".cart_group.bundle_form")) { 561 // Iterate over each form element to capture the data 562 $(".cart_group.bundle_form") 563 .find("input, select, textarea") 564 .each(function () { 565 var name = $(this).attr("name"); 566 var value = $(this).val(); 567 568 if (name) { 569 // Add the name-value pair to the formData object 570 woo_product_bundle[name] = value; 571 } 572 }); 573 } 574 575 if (jQuery("#wc-bookings-booking-form").length > 0) { 576 var selectedDateElement = $( 577 "td.selection-start-date.ui-datepicker-current-day", 578 ); 579 var selectedTimeElement = $("li.block .selected"); 580 581 // Extract the date from the td element 582 var year = selectedDateElement.attr("data-year"); 583 var month = parseInt(selectedDateElement.attr("data-month")) + 1; // Add 1 since months are zero-based in JavaScript 584 var day = selectedDateElement.find("a").attr("data-date"); 585 586 // Format the month and day to ensure they are two digits 587 month = month < 10 ? "0" + month : month; 588 day = day < 10 ? "0" + day : day; 589 590 // Extract the time from the li element 591 var timeValue = selectedTimeElement.attr("data-value"); // This contains both date and time in a single string 592 var time = selectedTimeElement.text(); // This gives "7:00 am" or whatever the time is 593 var priceElement = $(".woocommerce-Price-amount.amount"); 594 595 // Extract the price text and remove any non-numeric characters 596 var priceText = priceElement.text(); 597 var price = parseFloat(priceText.replace(/[^0-9.]/g, "")); 598 // Build the booking array dynamically 599 var booking = { 600 _year: year, 601 _month: month, 602 _day: day, 603 _persons: [], // Add persons if applicable 604 _date: year + "-" + month + "-" + day, 605 date: new Date(year, month - 1, day).toLocaleDateString("en-US", { 606 month: "long", 607 day: "numeric", 608 year: "numeric", 609 }), 610 _time: time, // You may need to process this further depending on the format required 611 time: time, 612 _qty: "1", // Use the quantity from your product 613 _start_date: Math.floor(new Date(timeValue).getTime() / 1000), // Convert start time to timestamp 614 _end_date: Math.floor( 615 new Date(new Date(timeValue).getTime() + 3600000).getTime() / 1000, 616 ), // Example for 1 hour duration 617 _all_day: 0, 618 _local_timezone: "", // Add timezone if applicable 619 _cost: price, // Set the cost or fetch dynamically if needed 620 _booking_id: "", // Set the booking ID if you have it 621 }; 622 } else { 623 var booking = {}; 624 } 625 626 // Name Your Price Compatibility 627 if (jQuery(".nyp").length >= 1) { 628 var nyp_price = $('.nyp input[name="nyp"]').val() 629 ? $('.nyp input[name="nyp"]').val() 630 : ""; 631 } 632 633 // Pay Your Price Compatibility 634 if (jQuery(".wc-pyp-price-options").length >= 1) { 635 var pyp_price = $( 636 '.wc-pyp-price-options input[name="custom_price"]', 637 ).val() 638 ? $('.wc-pyp-price-options input[name="custom_price"]').val() 639 : ""; 640 } 641 642 if ($(".wc-pao-addons-container")) { 643 var addonData = get_addon_data(); 644 } 645 646 // Prepare the AJAX request data 647 var data = { 648 action: "wcpd_product_add_to_cart", 649 product_id: product_id, 650 variation_id: variation_id, 651 quantity: quantity, 652 product_bundle_data: woo_product_bundle, 653 nyp: nyp_price, 654 pyp: pyp_price, 655 nonce: wcpd.nonce, 656 booking: booking, // Pass the booking data 657 ...(addonData && Object.keys(addonData).length > 0 ? addonData : {}), 658 }; 659 660 if (variation_id != "") { 661 // debugger; 662 // Collect all selected variation attributes 663 var variation = {}; 664 jQuery("form.variations_form") 665 .find("select[name^=attribute_], input[name^=attribute_]") 666 .each(function () { 667 var name = jQuery(this).attr("name"); 668 var value = jQuery(this).val(); 669 670 if (value.length > 0) { 671 variation[name] = value; 672 } 673 }); 674 675 if (variation) { 676 data.variation = JSON.stringify(variation); 677 } 678 } 679 680 jQuery.post( 681 wcpd.ajaxurl, 682 data, 683 function (response) { 684 if (response.error && response.product_url) { 685 window.location = response.product_url; 686 return false;
687 } 688 689 jQuery(".close-wcpd-rest-modal").trigger("click"); 690 691 if (response.fragments) { 692 if (jQuery(form).find("button.loading").length > 0) { 693 jQuery(form).find("button.loading").removeClass("loading"); 694 } 695 696 jQuery(document.body).trigger("added_to_cart", [ 697 response.fragments, 698 response.cart_hash, 699 ]); 700 701 //added for block theme compatibility 702 jQuery(document.body).trigger("wc_fragment_refresh"); 703 704 // CheckoutWC compatibility: open side cart if available 705 // Checkout-for-woocommerce side car compatibility by krestel. 706 var $trigger = jQuery(".cfw-side-cart-open-trigger").first(); 707 if ($trigger.length) { 708 $trigger.trigger("click"); 709 } 710 711 //jQuery('.wcpd-modal-loader').fadeOut('200'); 712 713 if (wcpd.cart_redirect === "yes") { 714 window.location = wcpd.cart_url; 715 return; 716 } else { 717 if (jQuery(".woocommerce-message").length > 0) { 718 jQuery(".woocommerce-message").remove(); 719 } 720 if (jQuery(".woocommerce-notices-wrapper").length > 0) { 721 jQuery(".woocommerce-notices-wrapper") 722 .append(`<div class="woocommerce-message" role="alert"> 723 <a href="${wcpd.cart_url}" class="button wc-forward">View cart</a> Product has been added to your cart.</div>`); 724 } else { 725 jQuery("#primary") 726 .prepend(`<div class="woocommerce-message" role="alert"> 727 <a href="${wcpd.cart_url}" class="button wc-forward">View cart</a> Product has been added to your cart.</div>`); 728 } 729 } 730 } 731 }, 732 "json", 733 ); 734 } 735 736 function get_addon_data() { 737 var addon_data = {}; 738 739 // Iterate over each addon container 740 $(".wc-pao-addon-container").each(function () { 741 var addonContainer = $(this); 742 743 // Find all input fields within the addon container 744 addonContainer.find(".wc-pao-addon-field").each(function () { 745 var fieldName = $(this).attr("name"); 746 var fieldValue = $(this).val(); 747 748 // If the field is a checkbox and it is not checked, skip it 749 if ($(this).is(":checkbox")) { 750 if ($(this).is(":checked")) { 751 // Remove the '[]' from the field name if it's a checkbox 752 fieldName = fieldName.replace("[]", ""); 753 754 // If the field name already exists and is an array, append the value 755 if (addon_data[fieldName] && Array.isArray(addon_data[fieldName])) { 756 addon_data[fieldName].push(fieldValue); 757 } else { 758 // If it's a checkbox, always store as an array 759 addon_data[fieldName] = [fieldValue]; 760 } 761 } 762 } else { 763 // Handle file input separately to get the file name 764 if ($(this).is(":file")) { 765 fieldValue = 766 $(this)[0].files.length > 0 ? $(this)[0].files[0].name : ""; 767 } 768 769 // For all other field types, store as a single key-value pair 770 if (fieldName) { 771 addon_data[fieldName] = fieldValue; 772 } 773 } 774 }); 775 }); 776 777 return addon_data; 778 } 779});
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.