2017-06-21 05:34:56 +00:00
|
|
|
$.urlParam = function(name) {
|
|
|
|
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
|
|
|
return !!results ? decodeURIComponent(results[1]) : null;
|
|
|
|
};
|
|
|
|
|
|
|
|
function displayErrors() {
|
|
|
|
if (!!$.urlParam("error")) {
|
|
|
|
$("#error-message").text($.urlParam("error"));
|
|
|
|
$("#error-alert").removeClass("hidden");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function displaySuccess() {
|
|
|
|
if (!!$.urlParam("success")) {
|
|
|
|
$("#success-message").text($.urlParam("success"));
|
|
|
|
$("#success-alert").removeClass("hidden");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUpCountly() {
|
|
|
|
Countly.init({
|
|
|
|
app_key: "53ec944e2cab9356d3577dd1e260dc113fbf210f",
|
|
|
|
url: "https://stats.openlp.io"
|
|
|
|
});
|
|
|
|
Countly.track_sessions();
|
|
|
|
Countly.track_pageview();
|
|
|
|
Countly.track_errors();
|
|
|
|
console.log("Countly set up");
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUpStripe() {
|
|
|
|
var handler = StripeCheckout.configure({
|
|
|
|
key: "pk_live_GWIWaLW8W53LNTthomxAyO5w",
|
|
|
|
image: "https://openlp.org/assets/images/logo.png",
|
|
|
|
locale: "auto",
|
|
|
|
token: function(token) {
|
|
|
|
$("#token").val(token.id);
|
|
|
|
$("#donate").submit();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#donate-button").on("click", function(event) {
|
|
|
|
console.log("click!");
|
|
|
|
// Open Checkout with further options:
|
|
|
|
var amount = parseInt($("#amount").val()) * 100;
|
|
|
|
handler.open({
|
|
|
|
name: "OpenLP",
|
|
|
|
description: "Donate to OpenLP",
|
|
|
|
amount: amount,
|
|
|
|
panelLabel: "Donate {{amount}}"
|
|
|
|
});
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
// Close Checkout on page navigation:
|
|
|
|
window.addEventListener("popstate", function() {
|
|
|
|
handler.close();
|
|
|
|
});
|
|
|
|
$("#return-url").val(location.protocol + "//" + location.host + location.pathname);
|
|
|
|
}
|
|
|
|
|
2017-11-16 22:53:01 +00:00
|
|
|
function showToastr() {
|
|
|
|
var cookies = document.cookie;
|
|
|
|
if (cookies.search("hasVisitedOpenLPBefore=true") != -1) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-18 06:09:48 +00:00
|
|
|
else if (location.hostname != "localhost") {
|
2017-11-16 22:53:01 +00:00
|
|
|
document.cookie = "hasVisitedOpenLPBefore=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
|
|
|
|
}
|
|
|
|
toastr.options = {
|
|
|
|
closeButton: false,
|
|
|
|
debug: false,
|
|
|
|
newestOnTop: false,
|
|
|
|
progressBar: false,
|
|
|
|
positionClass: "toast-bottom-right",
|
|
|
|
preventDuplicates: false,
|
|
|
|
onclick: null,
|
|
|
|
showDuration: "300",
|
|
|
|
hideDuration: "300",
|
|
|
|
timeOut: "2000",
|
|
|
|
extendedTimeOut: "1000",
|
|
|
|
showEasing: "swing",
|
|
|
|
hideEasing: "linear",
|
|
|
|
showMethod: "fadeIn",
|
|
|
|
hideMethod: "fadeOut"
|
|
|
|
};
|
2017-11-18 06:09:48 +00:00
|
|
|
toastr.info(Transifex.live.translateText("This site may use cookies for anonymous traffic analysis."));
|
2017-11-16 22:53:01 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 05:34:56 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
setUpCountly();
|
2017-11-16 22:53:01 +00:00
|
|
|
showToastr();
|
2017-06-21 05:34:56 +00:00
|
|
|
if (location.pathname.substr(0, 7) == "/donate") {
|
|
|
|
// Online set these up on the donate page
|
|
|
|
displayErrors();
|
|
|
|
displaySuccess();
|
|
|
|
setUpStripe();
|
|
|
|
}
|
|
|
|
});
|