PageSourceSearch

https://sanskritlibrary.org/js/sl.donations.js?v=1

js sanskritlibrary.org collected 2026-10-02 10:20:08 UTC 1,904 bytes, 67 lines download raw bytes

1"use strict";
2
3const fieldsToFormNames = {
4  email: "email",
5  name: "first_name",
6  street1: "address1",
7  street2: "address2",
8  city: "city",
9  state: "state",
10  country: "country",
11  zip: "zip",
12};
13
14$(function() {
15  // For registered users:
16  // - Show PayPal link instead of donate options
17  const registered = localStorage.getItem("registered");
18  const address = localStorage.getItem("address");
19  if (registered) {
20    $("button#donate").hide();
21    $("form#payPal").show();
22  }
23  // - Prepopulate form with their address
24  if (address) {
25    const addressObj = JSON.parse(address);
26    Object.keys(fieldsToFormNames).forEach(field => {
27      if (field === "name") {
28        const fullName = addressObj[field];
29        const tokens = fullName.split(' ');
30        const firstName = tokens.shift();
31        const lastName = tokens.join(' ');
32        $("<input>").attr({
33          type: "hidden",
34          name: "first_name",
35          value: firstName,
36        }).appendTo("form#payPal");
37        $("<input>").attr({
38          type: "hidden",
39          name: "last_name",
40          value: lastName,
41        }).appendTo("form#payPal");
42      } else {
43        $("<input>").attr({
44          type: "hidden",
45          name: fieldsToFormNames[field],
46          value: addressObj[field],
47        }).appendTo("form#payPal");
48      }
49    });
50  }
51
52  // On click to `Donate`, show donate options
53  $("button#donate").click(function() {
54    $("button#donate").hide();
55    $("div#donateOptions").css("display", "flex");
56  });
57
58  // On click to `Register`, redirect to registration agreement
59  $("button#register").click(() => window.location.href = "agreement.html?redirect=donate");
60
61  // On click to `Donate Anonymously`, show PayPal button
62  $("button#donateAnonymously").click(function() {
63    $("div#donateOptions").hide();
64    $("button#donateAnonymously").hide();
65    $("form#payPal").show();
66  });
67})

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.