/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ $("#add_camper").click(function () { var copyfrom = $("#camper_list .person-list-item").first(); $.get("parts/template_person.php", { type: "camper", lastname: $("input[name=lastname]", copyfrom).val(), parentname: $("input[name=parentname]", copyfrom).val(), address: $("input[name=address]", copyfrom).val(), zip: $("input[name=zip]", copyfrom).val(), phone1: $("input[name=phone1]", copyfrom).val(), phone2: $("input[name=phone2]", copyfrom).val(), email: $("input[name=email]", copyfrom).val(), unit: $("input[name=unit]", copyfrom).val() }, function (resp) { $("#camper_list").append(resp); updateTotal(); }); }); $("#add_adult").click(function () { var copyfrom = $("#adult_list .person-list-item").first(); $.get("parts/template_person.php", { type: "adult", lastname: $("input[name=lastname]", copyfrom).val(), address: $("input[name=address]", copyfrom).val(), zip: $("input[name=zip]", copyfrom).val(), phone1: $("input[name=phone1]", copyfrom).val(), phone2: $("input[name=phone2]", copyfrom).val(), email: $("input[name=email]", copyfrom).val() }, function (resp) { $("#adult_list").append(resp); updateTotal(); }); }); $("#add_youth").click(function () { var copyfrom = $("#youth_list .person-list-item").first(); $.get("parts/template_person.php", { type: "youth", lastname: $("input[name=lastname]", copyfrom).val(), address: $("input[name=address]", copyfrom).val(), zip: $("input[name=zip]", copyfrom).val(), parentname: $("input[name=parentname]", copyfrom).val(), phone2: $("input[name=phone2]", copyfrom).val(), email: $("input[name=email]", copyfrom).val() }, function (resp) { $("#youth_list").append(resp); updateTotal(); }); }); $("#camper_list").on("change", "input[name=firstname]", function () { updateTotal(); }); $("#adult_list").on("change", "input[name=days]", function () { updateTotal(); }); function updateTotal() { totalcharge = $(".person-list-item[data-persontype=camper] input[name=firstname]").filter(function () { return $(this).val() != ''; }).length * 50.0; totalcharge = totalcharge - $(".person-list-item[data-persontype=adult] input[name=days]:checked").filter(function () { return $(this).val() != ''; }).length * 10.0; totalcharge = Math.max(totalcharge, 0); // The server will refuse to finish the registration if this doesn't match // the backend-calculated amount, don't bother being a haxxor $("#total").text(totalcharge); $("input[name=totalcharge]").val(totalcharge); } // Create a Stripe client. var stripe = Stripe(stripe_pubkey); // Create an instance of Elements. var elements = stripe.elements(); // Create an instance of the card Element. var card = elements.create('card'); // Add an instance of the card Element into the `card-element`