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!!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
221
static/js/map.js
221
static/js/map.js
|
|
@ -10,54 +10,54 @@ var markers = [];
|
||||||
var marker;
|
var marker;
|
||||||
var allmarkers = L.layerGroup();
|
var allmarkers = L.layerGroup();
|
||||||
var woBischIcon = L.icon({
|
var woBischIcon = L.icon({
|
||||||
iconUrl: '/static/images/marker.png',
|
iconUrl: '/static/images/marker.png',
|
||||||
iconSize: [64, 64],
|
iconSize: [64, 64],
|
||||||
iconAnchor: [32, 64],
|
iconAnchor: [32, 64],
|
||||||
popupAnchor: [0, -64]
|
popupAnchor: [0, -64]
|
||||||
});
|
});
|
||||||
var datapoints;
|
var datapoints;
|
||||||
var woBischIcon2 = L.icon({
|
var woBischIcon2 = L.icon({
|
||||||
iconUrl: '/static/images/marker-all.png',
|
iconUrl: '/static/images/marker-all.png',
|
||||||
iconSize: [64, 64],
|
iconSize: [64, 64],
|
||||||
iconAnchor: [32, 32],
|
iconAnchor: [32, 32],
|
||||||
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]');
|
||||||
|
|
||||||
function vbat2icon(level) {
|
function vbat2icon(level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 1:
|
case 1:
|
||||||
fa_battery_string = "fa-battery-empty";
|
fa_battery_string = "fa-battery-empty";
|
||||||
icon_color = "has-text-danger";
|
icon_color = "has-text-danger";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fa_battery_string = "fa-battery-quarter";
|
fa_battery_string = "fa-battery-quarter";
|
||||||
icon_color = "has-text-warning";
|
icon_color = "has-text-warning";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fa_battery_string = "fa-battery-half";
|
fa_battery_string = "fa-battery-half";
|
||||||
icon_color = "has-text-info";
|
icon_color = "has-text-info";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
fa_battery_string = "fa-battery-three-quarters";
|
fa_battery_string = "fa-battery-three-quarters";
|
||||||
icon_color = "has-text-link";
|
icon_color = "has-text-link";
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
fa_battery_string = "fa-battery-full";
|
fa_battery_string = "fa-battery-full";
|
||||||
icon_color = "has-text-success";
|
icon_color = "has-text-success";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fa_battery_string = "fa-battery-slash";
|
fa_battery_string = "fa-battery-slash";
|
||||||
icon_color = "has-text-danger";
|
icon_color = "has-text-danger";
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="icon ' + icon_color + '"><i class="fas ' + fa_battery_string + '"></i></span>';
|
return '<span class="icon ' + icon_color + '"><i class="fas ' + fa_battery_string + '"></i></span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshDatapoints(deveui, start, stop) {
|
function refreshDatapoints(deveui, start, stop) {
|
||||||
|
|
@ -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,82 +139,81 @@ $(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]');
|
||||||
|
|
||||||
function cb(start, end) {
|
function cb(start, end) {
|
||||||
$('#reportrange span').html(start.locale('de').format('D. MMM YYYY') + ' - ' + end.locale('de').format('D. MMM YYYY'));
|
$('#reportrange span').html(start.locale('de').format('D. MMM YYYY') + ' - ' + end.locale('de').format('D. MMM YYYY'));
|
||||||
console.log("A new date selection was made: " + start.format() + ' to ' + end.format());
|
console.log("A new date selection was made: " + start.format() + ' to ' + end.format());
|
||||||
s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
||||||
console.log("Start: " + s_start + ' End: ' + s_end);
|
console.log("Start: " + s_start + ' End: ' + s_end);
|
||||||
refreshDatapoints(deveui, s_start, s_end);
|
refreshDatapoints(deveui, s_start, s_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#reportrange').daterangepicker({
|
||||||
|
startDate: start.local(),
|
||||||
|
endDate: end.local(),
|
||||||
|
regional: ["de"],
|
||||||
|
"locale": {
|
||||||
|
format: 'DD.MM.YYYY',
|
||||||
|
"separator": " - ",
|
||||||
|
"applyLabel": "Anwenden",
|
||||||
|
"cancelLabel": "Abbrechen",
|
||||||
|
"fromLabel": "Von",
|
||||||
|
"toLabel": "Bis",
|
||||||
|
customRangeLabel: 'Benutzerdefiniert',
|
||||||
|
"weekLabel": "W",
|
||||||
|
"daysOfWeek": [
|
||||||
|
"So",
|
||||||
|
"Mo",
|
||||||
|
"Di",
|
||||||
|
"Mi",
|
||||||
|
"Do",
|
||||||
|
"Fr",
|
||||||
|
"Sa"
|
||||||
|
],
|
||||||
|
"monthNames": [
|
||||||
|
"Jan",
|
||||||
|
"Feb",
|
||||||
|
"Mär",
|
||||||
|
"Apr",
|
||||||
|
"Mai",
|
||||||
|
"Jun",
|
||||||
|
"Jul",
|
||||||
|
"Aug",
|
||||||
|
"Sep",
|
||||||
|
"Okt",
|
||||||
|
"Nov",
|
||||||
|
"Dez"
|
||||||
|
],
|
||||||
|
"firstDay": 1
|
||||||
|
},
|
||||||
|
ranges: {
|
||||||
|
'Heute': [moment(), moment()],
|
||||||
|
'Gestern': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||||
|
'Letzte 7 Tage': [moment().subtract(6, 'days'), moment()],
|
||||||
|
'Letzte 30 Tage': [moment().subtract(29, 'days'), moment()],
|
||||||
|
'Diesen Monat': [moment().startOf('month'), moment().endOf('month')],
|
||||||
|
'Letzten Monat': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||||
}
|
}
|
||||||
|
}, cb);
|
||||||
$('#reportrange').daterangepicker({
|
|
||||||
startDate: start.local(),
|
|
||||||
endDate: end.local(),
|
|
||||||
regional: [ "de" ],
|
|
||||||
"locale": {
|
|
||||||
format: 'DD.MM.YYYY',
|
|
||||||
"separator": " - ",
|
|
||||||
"applyLabel": "Anwenden",
|
|
||||||
"cancelLabel": "Abbrechen",
|
|
||||||
"fromLabel": "Von",
|
|
||||||
"toLabel": "Bis",
|
|
||||||
customRangeLabel: 'Benutzerdefiniert',
|
|
||||||
"weekLabel": "W",
|
|
||||||
"daysOfWeek": [
|
|
||||||
"So",
|
|
||||||
"Mo",
|
|
||||||
"Di",
|
|
||||||
"Mi",
|
|
||||||
"Do",
|
|
||||||
"Fr",
|
|
||||||
"Sa"
|
|
||||||
],
|
|
||||||
"monthNames": [
|
|
||||||
"Jan",
|
|
||||||
"Feb",
|
|
||||||
"Mär",
|
|
||||||
"Apr",
|
|
||||||
"Mai",
|
|
||||||
"Jun",
|
|
||||||
"Jul",
|
|
||||||
"Aug",
|
|
||||||
"Sep",
|
|
||||||
"Okt",
|
|
||||||
"Nov",
|
|
||||||
"Dez"
|
|
||||||
],
|
|
||||||
"firstDay": 1
|
|
||||||
},
|
|
||||||
ranges: {
|
|
||||||
'Heute': [moment(), moment()],
|
|
||||||
'Gestern': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
||||||
'Letzte 7 Tage': [moment().subtract(6, 'days'), moment()],
|
|
||||||
'Letzte 30 Tage': [moment().subtract(29, 'days'), moment()],
|
|
||||||
'Diesen Monat': [moment().startOf('month'), moment().endOf('month')],
|
|
||||||
'Letzten Monat': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
||||||
}
|
|
||||||
}, cb);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateSliderTooltip(c)
|
function updateSliderTooltip(c) {
|
||||||
{
|
|
||||||
if (datapoints == undefined || datapoints.length == 0) {
|
if (datapoints == undefined || datapoints.length == 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (c.value == last_slider_position) {
|
if (c.value == last_slider_position) {
|
||||||
// we don't do anything if slider position did not change...
|
// we don't do anything if slider position did not change...
|
||||||
|
|
@ -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,99 +26,98 @@ $( 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");
|
||||||
counter = Number(el.html());
|
counter = Number(el.html());
|
||||||
if (counter < 3) {
|
if (counter < 3) {
|
||||||
counter = counter + 1;
|
counter = counter + 1;
|
||||||
el.html(counter);
|
el.html(counter);
|
||||||
if (counter == 1) {
|
if (counter == 1) {
|
||||||
el_text.html("+" + counter + " Jahr");
|
el_text.html("+" + counter + " Jahr");
|
||||||
} else {
|
} else {
|
||||||
el_text.html("+" + counter + " Jahre");
|
el_text.html("+" + counter + " Jahre");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".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");
|
||||||
counter = Number(el.html());
|
counter = Number(el.html());
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
counter = counter - 1;
|
counter = counter - 1;
|
||||||
el.html(counter);
|
el.html(counter);
|
||||||
if (counter == 0) {
|
if (counter == 0) {
|
||||||
el_text.html(" ");
|
el_text.html(" ");
|
||||||
} else if (counter == 1) {
|
} else if (counter == 1) {
|
||||||
el_text.html("+" + counter + " Jahr");
|
el_text.html("+" + counter + " Jahr");
|
||||||
} else {
|
} else {
|
||||||
el_text.html("+" + counter + " Jahre");
|
el_text.html("+" + counter + " Jahre");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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,26 +125,15 @@ $( 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();
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
} else {
|
} else {
|
||||||
$('#alias_errormsg').html('');
|
$('#alias_errormsg').html('');
|
||||||
$("#alias").removeClass("is-danger");
|
$("#alias").removeClass("is-danger");
|
||||||
$("#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)) {
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
@ -189,19 +167,19 @@ $( document ).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadStripeLibrary() {
|
function loadStripeLibrary() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "https://js.stripe.com/v3/",
|
url: "https://js.stripe.com/v3/",
|
||||||
dataType: "script",
|
dataType: "script",
|
||||||
async: false, // <-- This is the key
|
async: false, // <-- This is the key
|
||||||
success: function () {
|
success: function () {
|
||||||
// all good...
|
// all good...
|
||||||
console.log("loadStripeLibrary called...");
|
console.log("loadStripeLibrary called...");
|
||||||
SetupStripe();
|
SetupStripe();
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
throw new Error("Could not load script " + script);
|
throw new Error("Could not load script " + script);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetupStripe() {
|
function SetupStripe() {
|
||||||
|
|
@ -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,21 +279,21 @@ function PayMe() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#cart-pay').on('click', function(ev) {
|
$('#cart-pay').on('click', function (ev) {
|
||||||
StartPaymentProgress();
|
StartPaymentProgress();
|
||||||
PayMe();
|
PayMe();
|
||||||
});
|
});
|
||||||
|
|
||||||
// draw all maps
|
// draw all maps
|
||||||
var woBischIcon = L.icon({
|
var woBischIcon = L.icon({
|
||||||
iconUrl: '/static/images/marker.png',
|
iconUrl: '/static/images/marker.png',
|
||||||
iconSize: [64, 64],
|
iconSize: [64, 64],
|
||||||
iconAnchor: [32, 64]
|
iconAnchor: [32, 64]
|
||||||
});
|
});
|
||||||
|
|
||||||
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,70 +1,18 @@
|
||||||
$(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");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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