PageSourceSearch

https://www.hobbyfarms.com/wp-content/plugins/product-pdf-access/js/pdf-access-new.js?ver=1790223898

js hobbyfarms.com collected 2026-09-24 09:19:28 UTC 3,965 bytes, 163 lines download raw bytes

1jQuery(function ($) {
2  jQuery(".upload_pdf_button").on("click", function (e) {
3    e.preventDefault();
4    var button = $(this);
5    var field = $("#_product_pdf");
6    var uploader = wp
7      .media({
8        title: "Select PDF",
9        button: {
10          text: "Use this PDF",
11        },
12        multiple: false,
13      })
14      .on("select", function () {
15        var attachment = uploader.state().get("selection").first().toJSON();
16        field.val(attachment.url);
17      })
18      .open();
19  });
20});
21
22function viewFreeDigital(el) {
23  var pdfUrl = jQuery(el).data("pdf");
24
25  if (ppa_user.pdf_verified == 1) {
26    // user is logged in, show PDF
27    jQuery("#productPdfFrame").attr("src", pdfUrl);
28    jQuery("#productPdfModal").fadeIn();
29    return;
30  }
31  // show login modal
32  jQuery("#customLoginModal").fadeIn();
33  jQuery("#customProductPdfUrl").val(pdfUrl);
34}
35jQuery(document).ready(function ($) {
36  jQuery(document).on(
37    "click",
38    ".pdf-modal-close, #productPdfModal",
39    function (e) {
40      if (
41        e.target.id === "productPdfModal" ||
42        jQuery(e.target).hasClass("pdf-modal-close")
43      ) {
44        jQuery("#productPdfModal").fadeOut();
45        jQuery("#productPdfFrame").attr("src", "");
46      }
47    },
48  );
49});
50
51jQuery(document).ready(function ($) {
52  jQuery("#customLoginModal").on("click", function (e) {
53    if (e.target.id === "customLoginModal") {
54      jQuery(this).fadeOut();
55
56      jQuery(this).find('input[type="text"], input[type="email"]').val("");
57      jQuery("#err_name, #err_email, #err_phone, #err_otp").text("");
58
59      jQuery("#customLoginModal, #otpModal").hide();
60    }
61  });
62});
63
64// jQuery("#sendOtpBtn").on("click", function () {
65function sendOtp() {
66  var name = jQuery("#user_name").val().trim();
67  var email = jQuery("#user_email").val().trim();
68  var phone = jQuery("#user_phone").val().trim();
69  var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
70
71  jQuery(".input-error").text(""); // reset errors
72
73  var hasError = false;
74
75  if (!name) {
76    jQuery("#err_name").text("Please enter your name");
77    hasError = true;
78  }
79
80  if (!email) {
81    jQuery("#err_email").text("Please enter email");
82    hasError = true;
83  } else if (!emailPattern.test(email)) {
84    jQuery("#err_email").text("Please enter valid email");
85    hasError = true;
86  }
87
88  if (!phone) {
89    jQuery("#err_phone").text("Please enter phone");
90    hasError = true;
91  } else if (phone.length < 10) {
92    jQuery("#err_phone").text("Phone must be at least 10 digits");
93    hasError = true;
94  }
95
96  if (hasError) return;
97
98  jQuery(".loader").show();
99
100  jQuery.post(
101    ppa_ajax_obj.ajax_url,
102    {
103      action: "send_pdf_otp",
104      email: email,
105      name: name,
106      phone: phone,
107    },
108    function (res) {
109      jQuery(".loader").hide();
110
111      if (res.data.logged_in === true) {
112        jQuery("#customLoginModal").hide();
113
114        jQuery("#productPdfFrame").attr(
115          "src",
116          jQuery("#customProductPdfUrl").val(),
117        );
118
119        jQuery("#productPdfModal").fadeIn();
120        return;
121      }
122
123      if (res.data.otp_sent === true) {
124        jQuery("#customLoginModal").hide();
125        jQuery("#otpModal").show();
126        return;
127      }
128    },
129  );
130}
131
132jQuery("#otp_input").on("input", function () {
133  this.value = this.value.replace(/\D/g, "");
134});
135
136// jQuery("#verifyOtpBtn").on("click", function () {
137function verifyOtp() {
138  jQuery(".loader").show();
139
140  jQuery.post(
141    ppa_ajax_obj.ajax_url,
142    {
143      action: "verify_pdf_otp",
144      email: jQuery("#user_email").val(),
145      otp: jQuery("#otp_input").val(),
146    },
147    function (res) {
148      jQuery(".loader").hide();
149      if (!res || !res.success) {
150        jQuery("#err_otp").text("Invalid OTP");
151        return;
152      }
153
154      ppa_user.pdf_verified = "1";
155      jQuery("#otpModal").hide();
156      jQuery("#productPdfFrame").attr(
157        "src",
158        jQuery("#customProductPdfUrl").val(),
159      );
160      jQuery("#productPdfModal").fadeIn();
161    },
162  );
163}

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.