reformat js-files, refactor...
This commit is contained in:
parent
95292bd535
commit
fbac0c8d26
|
|
@ -1,81 +0,0 @@
|
||||||
// Set your publishable key: remember to change this to your live publishable key in production
|
|
||||||
// See your keys here: https://dashboard.stripe.com/account/apikeys
|
|
||||||
var stripe = Stripe('pk_test_YkSGqH3Tk9WKK9HrlY63GhAg');
|
|
||||||
var elements = stripe.elements();
|
|
||||||
|
|
||||||
// Set up Stripe.js and Elements to use in checkout form
|
|
||||||
var style = {
|
|
||||||
base: {
|
|
||||||
color: "#32325d",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var card = elements.create("card", { style: style });
|
|
||||||
card.mount("#card-element");
|
|
||||||
|
|
||||||
|
|
||||||
card.addEventListener('change', ({error}) => {
|
|
||||||
const displayError = document.getElementById('card-errors');
|
|
||||||
if (error) {
|
|
||||||
displayError.textContent = error.message;
|
|
||||||
} else {
|
|
||||||
displayError.textContent = '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var submitButton = document.getElementById('submit');
|
|
||||||
|
|
||||||
function GetClientSecret() {
|
|
||||||
var result = "";
|
|
||||||
$.ajax({
|
|
||||||
async: false,
|
|
||||||
url: "getstripepaymentintent",
|
|
||||||
type: "get", //send it through get method
|
|
||||||
dataType: "json",
|
|
||||||
data: {
|
|
||||||
charge_data: $("#charge_data").html()
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
console.log('pay success');
|
|
||||||
console.log(response.stripesessionid);
|
|
||||||
console.log('rc: '+response.rc);
|
|
||||||
if (response.rc == 0) {
|
|
||||||
result = response.stripeclientsecret;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr) {
|
|
||||||
console.log('getstripepaymentintent error');
|
|
||||||
//Do Something to handle error
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
submitButton.addEventListener('click', function(ev) {
|
|
||||||
var clientSecret = GetClientSecret();
|
|
||||||
stripe.confirmCardPayment(clientSecret, {
|
|
||||||
payment_method: {
|
|
||||||
card: card,
|
|
||||||
billing_details: {
|
|
||||||
name: 'Jenny Rosen'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).then(function(result) {
|
|
||||||
if (result.error) {
|
|
||||||
// Show error to your customer (e.g., insufficient funds)
|
|
||||||
console.log(result.error.message);
|
|
||||||
} else {
|
|
||||||
// The payment has been processed!
|
|
||||||
if (result.paymentIntent.status === 'succeeded') {
|
|
||||||
// Show a success message to your customer
|
|
||||||
// There's a risk of the customer closing the window before callback
|
|
||||||
// execution. Set up a webhook or plugin to listen for the
|
|
||||||
// payment_intent.succeeded event that handles any business critical
|
|
||||||
// post-payment actions.
|
|
||||||
alert("Payment succeeded!!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -23,9 +23,9 @@ var woBischIcon2 = L.icon({
|
||||||
popupAnchor: [0, 0]
|
popupAnchor: [0, 0]
|
||||||
});
|
});
|
||||||
var bounds;
|
var bounds;
|
||||||
var boundsSwitzerland = new L.LatLngBounds([[47.826186,10.511814], [45.797054, 5.925007]]);
|
var boundsSwitzerland = new L.LatLngBounds([[47.826186, 10.511814], [45.797054, 5.925007]]);
|
||||||
|
|
||||||
var dstart = moment({hour: 0});
|
var dstart = moment({ hour: 0 });
|
||||||
var start = dstart.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
var start = dstart.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
var dstop = moment();
|
var dstop = moment();
|
||||||
var stop = dstop.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
var stop = dstop.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
|
|
@ -65,7 +65,7 @@ function refreshDatapoints(deveui, start, stop) {
|
||||||
range = range + "&start=" + start;
|
range = range + "&start=" + start;
|
||||||
range = range + "&stop=" + stop;
|
range = range + "&stop=" + stop;
|
||||||
|
|
||||||
$.getJSON('https://wo-bisch.ch/metrics?deveui=' + deveui + range, function(mydata) {
|
$.getJSON('https://wo-bisch.ch/metrics?deveui=' + deveui + range, function (mydata) {
|
||||||
if ("msg" in mydata) {
|
if ("msg" in mydata) {
|
||||||
if (mydata.msg.includes("expired")) {
|
if (mydata.msg.includes("expired")) {
|
||||||
$('#chart').html(`<article class="message is-danger">
|
$('#chart').html(`<article class="message is-danger">
|
||||||
|
|
@ -106,7 +106,7 @@ function refreshDatapoints(deveui, start, stop) {
|
||||||
for (let i of datapoints) {
|
for (let i of datapoints) {
|
||||||
unix_timestamp = i[0];
|
unix_timestamp = i[0];
|
||||||
date = new Date(unix_timestamp * 1000);
|
date = new Date(unix_timestamp * 1000);
|
||||||
markers.push(L.marker([i[1], i[2]], {icon: woBischIcon2}).bindPopup(moment(date).format('DD.MM.YYYY HH:mm')));
|
markers.push(L.marker([i[1], i[2]], { icon: woBischIcon2 }).bindPopup(moment(date).format('DD.MM.YYYY HH:mm')));
|
||||||
}
|
}
|
||||||
allmarkers = L.layerGroup(markers);
|
allmarkers = L.layerGroup(markers);
|
||||||
if (lcontrol != undefined) {
|
if (lcontrol != undefined) {
|
||||||
|
|
@ -114,20 +114,20 @@ function refreshDatapoints(deveui, start, stop) {
|
||||||
lcontrol.remove();
|
lcontrol.remove();
|
||||||
}
|
}
|
||||||
lcontrol = L.control.layers({}).addTo(map);
|
lcontrol = L.control.layers({}).addTo(map);
|
||||||
lcontrol.addOverlay(allmarkers,'alle Positionen anzeigen');
|
lcontrol.addOverlay(allmarkers, 'alle Positionen anzeigen');
|
||||||
bounds = new L.LatLngBounds([[mydata['max_lat'], mydata['max_lon']], [mydata['min_lat'], mydata['min_lon']]]);
|
bounds = new L.LatLngBounds([[mydata['max_lat'], mydata['max_lon']], [mydata['min_lat'], mydata['min_lon']]]);
|
||||||
map.fitBounds(bounds, { padding: [20, 20] });
|
map.fitBounds(bounds, { padding: [20, 20] });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
map = new L.Map('map', {
|
map = new L.Map('map', {
|
||||||
crs: L.CRS.EPSG3857,
|
crs: L.CRS.EPSG3857,
|
||||||
zoomControl: true,
|
zoomControl: true,
|
||||||
maxBounds: boundsSwitzerland,
|
maxBounds: boundsSwitzerland,
|
||||||
doubleClickZoom: false
|
doubleClickZoom: false
|
||||||
});
|
});
|
||||||
map.setMinZoom( map.getBoundsZoom( map.options.maxBounds ) );
|
map.setMinZoom(map.getBoundsZoom(map.options.maxBounds));
|
||||||
|
|
||||||
map.on('dblclick', function (e) {
|
map.on('dblclick', function (e) {
|
||||||
map.fitBounds(bounds, { padding: [20, 20] });
|
map.fitBounds(bounds, { padding: [20, 20] });
|
||||||
|
|
@ -139,15 +139,15 @@ $(document).ready(function() {
|
||||||
map.attributionControl.setPrefix('Source: Swiss Federal Office of Topography')
|
map.attributionControl.setPrefix('Source: Swiss Federal Office of Topography')
|
||||||
map.addLayer(tilelayer);
|
map.addLayer(tilelayer);
|
||||||
map.setView(L.latLng(lat, lon), 10);
|
map.setView(L.latLng(lat, lon), 10);
|
||||||
marker = L.marker([lat, lon],{icon: woBischIcon, zIndexOffset: 1000}).addTo(map);
|
marker = L.marker([lat, lon], { icon: woBischIcon, zIndexOffset: 1000 }).addTo(map);
|
||||||
$('#reportrange span').html(moment(start).locale('de').format('D. MMM YYYY') + ' - ' + moment(stop).locale('de').format('D. MMM YYYY'));
|
$('#reportrange span').html(moment(start).locale('de').format('D. MMM YYYY') + ' - ' + moment(stop).locale('de').format('D. MMM YYYY'));
|
||||||
|
|
||||||
refreshDatapoints(deveui,start,stop);
|
refreshDatapoints(deveui, start, stop);
|
||||||
console.log("End of document ready...");
|
console.log("End of document ready...");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
var start = moment({hour: 0});
|
var start = moment({ hour: 0 });
|
||||||
var end = moment();
|
var end = moment();
|
||||||
var s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
var s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
var s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
var s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
|
|
@ -164,7 +164,7 @@ $(function() {
|
||||||
$('#reportrange').daterangepicker({
|
$('#reportrange').daterangepicker({
|
||||||
startDate: start.local(),
|
startDate: start.local(),
|
||||||
endDate: end.local(),
|
endDate: end.local(),
|
||||||
regional: [ "de" ],
|
regional: ["de"],
|
||||||
"locale": {
|
"locale": {
|
||||||
format: 'DD.MM.YYYY',
|
format: 'DD.MM.YYYY',
|
||||||
"separator": " - ",
|
"separator": " - ",
|
||||||
|
|
@ -211,8 +211,7 @@ $(function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateSliderTooltip(c)
|
function updateSliderTooltip(c) {
|
||||||
{
|
|
||||||
if (datapoints == undefined || datapoints.length == 0) {
|
if (datapoints == undefined || datapoints.length == 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +231,6 @@ function updateSliderTooltip(c)
|
||||||
var lat = datapoints[c.value][1];
|
var lat = datapoints[c.value][1];
|
||||||
var lng = datapoints[c.value][2];
|
var lng = datapoints[c.value][2];
|
||||||
var newLatLng = new L.LatLng(lat, lng);
|
var newLatLng = new L.LatLng(lat, lng);
|
||||||
console.log("Lat: "+lat+", Long: "+lng);
|
console.log("Lat: " + lat + ", Long: " + lng);
|
||||||
marker.setLatLng(newLatLng);
|
marker.setLatLng(newLatLng);
|
||||||
}
|
}
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
function validate(what, text) {
|
function validate(what, text) {
|
||||||
if (what == 'alias') {
|
if (what == 'alias') {
|
||||||
var re = /^[a-zA-Z0-9 ]{1,25}$/;
|
var re = /^[a-zA-Z0-9 ]{1,25}$/;
|
||||||
} else if (what == 'smsnumber') {
|
|
||||||
var re = /^\+[0-9]{11,11}$/;
|
|
||||||
}
|
}
|
||||||
return re.test(text);
|
return re.test(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$(document).ready(function () {
|
||||||
$(".show-modal").click(function() {
|
$(".show-modal").click(function () {
|
||||||
$("#alias_exclamation").hide();
|
$("#alias_exclamation").hide();
|
||||||
$("#smsnumber_exclamation").hide();
|
$("#smsnumber_exclamation").hide();
|
||||||
var alias = $(this).prev().html();
|
var alias = $(this).prev().html();
|
||||||
var deveui = $(this).prev().attr('id').replace("alias_","");
|
var deveui = $(this).prev().attr('id').replace("alias_", "");
|
||||||
$('#deveui').html(deveui);
|
$('#deveui').html(deveui);
|
||||||
var alarmactive = $('#alarmactive_'+deveui).html();
|
var alarmactive = $('#alarmactive_' + deveui).html();
|
||||||
var smsnumber = $('#smsnumber_'+deveui).html();
|
var smsnumber = $('#smsnumber_' + deveui).html();
|
||||||
|
|
||||||
$("#alias").val(alias);
|
$("#alias").val(alias);
|
||||||
console.log(alarmactive);
|
console.log(alarmactive);
|
||||||
|
|
@ -28,16 +26,16 @@ $( document ).ready(function() {
|
||||||
$("#modal").addClass("is-active");
|
$("#modal").addClass("is-active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cart-close").click(function() {
|
$("#cart-close").click(function () {
|
||||||
$("#cart").removeClass("is-active");
|
$("#cart").removeClass("is-active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#payment_notifier_close").click(function() {
|
$("#payment_notifier_close").click(function () {
|
||||||
$("#payment_notifier").removeClass("is-active");
|
$("#payment_notifier").removeClass("is-active");
|
||||||
location.reload(true);
|
location.reload(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".abo_plus").click(function() {
|
$(".abo_plus").click(function () {
|
||||||
console.log("abo_plus");
|
console.log("abo_plus");
|
||||||
el = $(this).parent().find(".abo_add_years");
|
el = $(this).parent().find(".abo_add_years");
|
||||||
el_text = $(this).parent().parent().find(".abo_add_years_text");
|
el_text = $(this).parent().parent().find(".abo_add_years_text");
|
||||||
|
|
@ -53,7 +51,7 @@ $( document ).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".abo_minus").click(function() {
|
$(".abo_minus").click(function () {
|
||||||
console.log("abo_minus");
|
console.log("abo_minus");
|
||||||
el = $(this).parent().find(".abo_add_years");
|
el = $(this).parent().find(".abo_add_years");
|
||||||
el_text = $(this).parent().parent().find(".abo_add_years_text");
|
el_text = $(this).parent().parent().find(".abo_add_years_text");
|
||||||
|
|
@ -71,56 +69,55 @@ $( document ).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function add_years(dt,n)
|
function add_years(dt, n) {
|
||||||
{
|
|
||||||
return new Date(dt.setFullYear(dt.getFullYear() + n));
|
return new Date(dt.setFullYear(dt.getFullYear() + n));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".abo_pay").click(function() {
|
$(".abo_pay").click(function () {
|
||||||
console.log("pay...");
|
console.log("pay...");
|
||||||
loadStripeLibrary();
|
loadStripeLibrary();
|
||||||
counter = 0;
|
counter = 0;
|
||||||
charge_data = '';
|
charge_data = '';
|
||||||
abo_table = '<table class="table is-bordered is-fullwidth" >';
|
abo_table = '<table class="table is-bordered is-fullwidth" >';
|
||||||
abo_table += '<tr><th class="is-2">Alias</th><th>verlängern bis</th><th class="has-text-right">Betrag</th></tr>';
|
abo_table += '<tr><th class="is-2">Alias</th><th>verlängern bis</th><th class="has-text-right">Betrag</th></tr>';
|
||||||
$(".tracker").each(function( index ) {
|
$(".tracker").each(function (index) {
|
||||||
console.log( index + ": " + $( this ).find(".alias").html() );
|
console.log(index + ": " + $(this).find(".alias").html());
|
||||||
this_count = Number($( this ).find(".abo_add_years").html());
|
this_count = Number($(this).find(".abo_add_years").html());
|
||||||
if (this_count > 0) {
|
if (this_count > 0) {
|
||||||
counter += this_count;
|
counter += this_count;
|
||||||
paid_until = $( this ).find(".paid_until").html();
|
paid_until = $(this).find(".paid_until").html();
|
||||||
if (moment(paid_until,'DD.MM.YYYY') < moment()) {
|
if (moment(paid_until, 'DD.MM.YYYY') < moment()) {
|
||||||
this_date = moment().format('DD.MM.YYYY');
|
this_date = moment().format('DD.MM.YYYY');
|
||||||
} else {
|
} else {
|
||||||
this_date = paid_until;
|
this_date = paid_until;
|
||||||
}
|
}
|
||||||
abo_table += '<tr><td>' + $( this ).find('.alias').html() + '</td><td>' + moment(this_date,'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + '</td><td class="has-text-right">' + (this_count * 24).toFixed(2) + '</td></tr>';
|
abo_table += '<tr><td>' + $(this).find('.alias').html() + '</td><td>' + moment(this_date, 'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + '</td><td class="has-text-right">' + (this_count * 24).toFixed(2) + '</td></tr>';
|
||||||
if (charge_data == '') {
|
if (charge_data == '') {
|
||||||
charge_data = $( this ).find("div").first().attr('id') + ":" + this_count;
|
charge_data = $(this).find("div").first().attr('id') + ":" + this_count;
|
||||||
} else {
|
} else {
|
||||||
charge_data += "," + $( this ).find("div").first().attr('id') + ":" + this_count;
|
charge_data += "," + $(this).find("div").first().attr('id') + ":" + this_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log( counter );
|
console.log(counter);
|
||||||
});
|
});
|
||||||
abo_table += '<tr><td>Total CHF</td><td></td><td class="has-text-right">' + (counter * 24).toFixed(2) + '</td></tr>';
|
abo_table += '<tr><td>Total CHF</td><td></td><td class="has-text-right">' + (counter * 24).toFixed(2) + '</td></tr>';
|
||||||
console.log("Counter: "+counter);
|
console.log("Counter: " + counter);
|
||||||
abo_table += "</table>";
|
abo_table += "</table>";
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
console.log(abo_table);
|
console.log(abo_table);
|
||||||
console.log("charge_data: "+charge_data);
|
console.log("charge_data: " + charge_data);
|
||||||
$("#abos_verlaengern").html(abo_table);
|
$("#abos_verlaengern").html(abo_table);
|
||||||
$("#charge_data").html(charge_data);
|
$("#charge_data").html(charge_data);
|
||||||
$("#cart").addClass("is-active");
|
$("#cart").addClass("is-active");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#modal-close").click(function() {
|
$("#modal-close").click(function () {
|
||||||
console.log("blabla");
|
console.log("blabla");
|
||||||
$("#modal").removeClass("is-active");
|
$("#modal").removeClass("is-active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#modal-save").click(function() {
|
$("#modal-save").click(function () {
|
||||||
var alarmactive = "0";
|
var alarmactive = "0";
|
||||||
if ($('#checkbox').prop('checked')) {
|
if ($('#checkbox').prop('checked')) {
|
||||||
alarmactive = "1";
|
alarmactive = "1";
|
||||||
|
|
@ -128,7 +125,7 @@ $( document ).ready(function() {
|
||||||
|
|
||||||
// Validation Code
|
// Validation Code
|
||||||
var is_valid = true;
|
var is_valid = true;
|
||||||
if (!validate('alias',$('#alias').val())) {
|
if (!validate('alias', $('#alias').val())) {
|
||||||
$('#alias_errormsg').html('Ungültige Bezeichnung; erlaubte Zeichen A-Z, 0-9 und Leerschlag');
|
$('#alias_errormsg').html('Ungültige Bezeichnung; erlaubte Zeichen A-Z, 0-9 und Leerschlag');
|
||||||
$("#alias").addClass("is-danger");
|
$("#alias").addClass("is-danger");
|
||||||
$("#alias_exclamation").show();
|
$("#alias_exclamation").show();
|
||||||
|
|
@ -139,17 +136,6 @@ $( document ).ready(function() {
|
||||||
$("#alias_exclamation").hide();
|
$("#alias_exclamation").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validate('smsnumber',$('#smsnumber').val())) {
|
|
||||||
$('#smsnumber_errormsg').html('Beispiel einer gültigen SMS Nummer: +41761234567');
|
|
||||||
$("#smsnumber").addClass("is-danger");
|
|
||||||
$("#smsnumber_exclamation").show();
|
|
||||||
is_valid = false;
|
|
||||||
} else {
|
|
||||||
$('#smsnumber_errormsg').html('');
|
|
||||||
$("#smsnumber").removeClass("is-danger");
|
|
||||||
$("#smsnumber_exclamation").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(is_valid)) {
|
if (!(is_valid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -160,23 +146,15 @@ $( document ).ready(function() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {
|
data: {
|
||||||
deveui: $('#deveui').html(),
|
deveui: $('#deveui').html(),
|
||||||
alias: $('#alias').val(),
|
alias: $('#alias').val()
|
||||||
smsnumber: $("#smsnumber").val(),
|
|
||||||
alarmactive: alarmactive
|
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
console.log('save success');
|
console.log('save success');
|
||||||
if (response.rc == 0) {
|
if (response.rc == 0) {
|
||||||
$('#alias_'+$('#deveui').html()).html($('#alias').val());
|
$('#alias_' + $('#deveui').html()).html($('#alias').val());
|
||||||
var alarmactive = "0";
|
|
||||||
if ($('#checkbox').prop('checked')) {
|
|
||||||
alarmactive = "1";
|
|
||||||
}
|
|
||||||
$('#alarmactive_'+$('#deveui').html()).html(alarmactive);
|
|
||||||
$('#smsnumber_'+$('#deveui').html()).html($('#smsnumber').val());
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function (xhr) {
|
||||||
console.log('save error');
|
console.log('save error');
|
||||||
//Do Something to handle error
|
//Do Something to handle error
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +200,7 @@ function SetupStripe() {
|
||||||
card.mount("#card-element");
|
card.mount("#card-element");
|
||||||
$("#card-errors-article").hide();
|
$("#card-errors-article").hide();
|
||||||
|
|
||||||
card.addEventListener('change', ({error}) => {
|
card.addEventListener('change', ({ error }) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
$("#card-errors").text(error.message);
|
$("#card-errors").text(error.message);
|
||||||
$("#card-errors-article").show();
|
$("#card-errors-article").show();
|
||||||
|
|
@ -241,7 +219,7 @@ function ConfirmPayment(clientSecret) {
|
||||||
name: '{{ .UserName }}'
|
name: '{{ .UserName }}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
// Show error to your customer (e.g., insufficient funds)
|
// Show error to your customer (e.g., insufficient funds)
|
||||||
console.log(result.error.message);
|
console.log(result.error.message);
|
||||||
|
|
@ -286,14 +264,14 @@ function PayMe() {
|
||||||
data: {
|
data: {
|
||||||
charge_data: $("#charge_data").html()
|
charge_data: $("#charge_data").html()
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
console.log('pay success');
|
console.log('pay success');
|
||||||
console.log('rc: '+response.rc);
|
console.log('rc: ' + response.rc);
|
||||||
if (response.rc == 0) {
|
if (response.rc == 0) {
|
||||||
ConfirmPayment(response.stripeclientsecret);
|
ConfirmPayment(response.stripeclientsecret);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function (xhr) {
|
||||||
console.log('getstripepaymentintent error');
|
console.log('getstripepaymentintent error');
|
||||||
//Do Something to handle error
|
//Do Something to handle error
|
||||||
EndPaymentProgress();
|
EndPaymentProgress();
|
||||||
|
|
@ -301,7 +279,7 @@ function PayMe() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#cart-pay').on('click', function(ev) {
|
$('#cart-pay').on('click', function (ev) {
|
||||||
StartPaymentProgress();
|
StartPaymentProgress();
|
||||||
PayMe();
|
PayMe();
|
||||||
});
|
});
|
||||||
|
|
@ -314,8 +292,8 @@ var woBischIcon = L.icon({
|
||||||
});
|
});
|
||||||
|
|
||||||
var maps = [];
|
var maps = [];
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
$(".tracker").each(function(index) {
|
$(".tracker").each(function (index) {
|
||||||
console.log('Draw Map (' + index + "): " + $(this).find(".alias").html());
|
console.log('Draw Map (' + index + "): " + $(this).find(".alias").html());
|
||||||
|
|
||||||
deveui = $(this).find("div").first().attr("id");
|
deveui = $(this).find("div").first().attr("id");
|
||||||
|
|
@ -338,7 +316,7 @@ $(document).ready(function() {
|
||||||
map.addLayer(tilelayer);
|
map.addLayer(tilelayer);
|
||||||
map.setView(L.latLng(lat, lon), 10);
|
map.setView(L.latLng(lat, lon), 10);
|
||||||
|
|
||||||
var marker = L.marker([lat, lon],{icon: woBischIcon}).addTo(map);
|
var marker = L.marker([lat, lon], { icon: woBischIcon }).addTo(map);
|
||||||
|
|
||||||
maps.push(map);
|
maps.push(map);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#email").focus();
|
$("#email").focus();
|
||||||
|
|
||||||
// Check for click events on the navbar burger icon
|
// Check for click events on the navbar burger icon
|
||||||
$(".navbar-burger").click(function() {
|
$(".navbar-burger").click(function () {
|
||||||
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
||||||
$(".navbar-burger").toggleClass("is-active");
|
$(".navbar-burger").toggleClass("is-active");
|
||||||
$(".navbar-menu").toggleClass("is-active");
|
$(".navbar-menu").toggleClass("is-active");
|
||||||
|
|
@ -11,60 +11,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login Button
|
// Login Button
|
||||||
$("#login-button").click(function(e){
|
$("#login-button").click(function (e) {
|
||||||
//alert(true);
|
//alert(true);
|
||||||
$("#login-form").submit();
|
$("#login-form").submit();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
// Login Form
|
|
||||||
$("#login-form-blabla").submit(function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
var formData = {
|
|
||||||
next: $("#email").val(),
|
|
||||||
email: $("#email").val(),
|
|
||||||
password: $("#password").val(),
|
|
||||||
csrf_token: $("#csrf_token").val(),
|
|
||||||
next: $("#next").val()
|
|
||||||
};
|
|
||||||
|
|
||||||
//console.log(formData);
|
|
||||||
// send ajax
|
|
||||||
$.ajax({
|
|
||||||
url: '/login', // url where to submit the request
|
|
||||||
type : "POST", // type of action POST || GET
|
|
||||||
dataType : 'json', // data type
|
|
||||||
contentType: 'application/json',
|
|
||||||
data : JSON.stringify(formData), // post data || get data
|
|
||||||
success : function(result) {
|
|
||||||
// you can see the result from the console
|
|
||||||
// tab of the developer tools
|
|
||||||
console.log('SUCCESS');
|
|
||||||
console.log(result);
|
|
||||||
window.location.replace("/");
|
|
||||||
},
|
|
||||||
error: function(result) {
|
|
||||||
//console.log(xhr, resp, text);
|
|
||||||
console.log('ERROR');
|
|
||||||
console.log(result);
|
|
||||||
var errortext = '<ul style="list-style-type:disc">';
|
|
||||||
a = result.responseJSON.response.errors.email;
|
|
||||||
if (a != undefined) {
|
|
||||||
for (i=0; i < a.length; ++i) {
|
|
||||||
errortext = errortext + "<li>" + a[i] + "</li>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a = result.responseJSON.response.errors.password;
|
|
||||||
if (a != undefined) {
|
|
||||||
for (i=0; i < a.length; ++i) {
|
|
||||||
errortext = errortext + "<li>" + a[i] + "</li>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
errortext = errortext + "</ul>";
|
|
||||||
$('#errorbox').html(errortext);
|
|
||||||
$('#errorbox').show();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue