';
abo_table += '| Alias | verlängern bis | Betrag |
';
- $(".tracker").each(function( index ) {
- console.log( index + ": " + $( this ).find(".alias").html() );
- this_count = Number($( this ).find(".abo_add_years").html());
+ $(".tracker").each(function (index) {
+ console.log(index + ": " + $(this).find(".alias").html());
+ this_count = Number($(this).find(".abo_add_years").html());
if (this_count > 0) {
counter += this_count;
- paid_until = $( this ).find(".paid_until").html();
- if (moment(paid_until,'DD.MM.YYYY') < moment()) {
+ paid_until = $(this).find(".paid_until").html();
+ if (moment(paid_until, 'DD.MM.YYYY') < moment()) {
this_date = moment().format('DD.MM.YYYY');
} else {
this_date = paid_until;
}
- abo_table += '| ' + $( this ).find('.alias').html() + ' | ' + moment(this_date,'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + ' | ' + (this_count * 24).toFixed(2) + ' |
';
+ abo_table += '| ' + $(this).find('.alias').html() + ' | ' + moment(this_date, 'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + ' | ' + (this_count * 24).toFixed(2) + ' |
';
if (charge_data == '') {
- charge_data = $( this ).find("div").first().attr('id') + ":" + this_count;
+ charge_data = $(this).find("div").first().attr('id') + ":" + this_count;
} 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 += '| Total CHF | | ' + (counter * 24).toFixed(2) + ' |
';
- console.log("Counter: "+counter);
+ console.log("Counter: " + counter);
abo_table += "
";
if (counter > 0) {
console.log(abo_table);
- console.log("charge_data: "+charge_data);
+ console.log("charge_data: " + charge_data);
$("#abos_verlaengern").html(abo_table);
$("#charge_data").html(charge_data);
- $("#cart").addClass("is-active");
+ $("#cart").addClass("is-active");
}
});
- $("#modal-close").click(function() {
- console.log("blabla");
- $("#modal").removeClass("is-active");
+ $("#modal-close").click(function () {
+ console.log("blabla");
+ $("#modal").removeClass("is-active");
});
-
- $("#modal-save").click(function() {
+
+ $("#modal-save").click(function () {
var alarmactive = "0";
if ($('#checkbox').prop('checked')) {
alarmactive = "1";
}
-
+
// Validation Code
var is_valid = true;
- if (!validate('alias',$('#alias').val())) {
- $('#alias_errormsg').html('Ungültige Bezeichnung; erlaubte Zeichen A-Z, 0-9 und Leerschlag');
- $("#alias").addClass("is-danger");
- $("#alias_exclamation").show();
- is_valid = false;
+ if (!validate('alias', $('#alias').val())) {
+ $('#alias_errormsg').html('Ungültige Bezeichnung; erlaubte Zeichen A-Z, 0-9 und Leerschlag');
+ $("#alias").addClass("is-danger");
+ $("#alias_exclamation").show();
+ is_valid = false;
} else {
- $('#alias_errormsg').html('');
- $("#alias").removeClass("is-danger");
- $("#alias_exclamation").hide();
+ $('#alias_errormsg').html('');
+ $("#alias").removeClass("is-danger");
+ $("#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)) {
return;
}
-
+
$.ajax({
url: "save_scale_settings",
type: "get", //send it through get method
dataType: "json",
- data: {
- deveui: $('#deveui').html(),
- alias: $('#alias').val(),
- smsnumber: $("#smsnumber").val(),
- alarmactive: alarmactive
+ data: {
+ deveui: $('#deveui').html(),
+ alias: $('#alias').val()
},
- success: function(response) {
+ success: function (response) {
console.log('save success');
if (response.rc == 0) {
- $('#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());
+ $('#alias_' + $('#deveui').html()).html($('#alias').val());
}
},
- error: function(xhr) {
+ error: function (xhr) {
console.log('save error');
//Do Something to handle error
}
});
-
+
console.log("save");
$("#modal").removeClass("is-active");
});
@@ -189,19 +167,19 @@ $( document ).ready(function() {
});
function loadStripeLibrary() {
- $.ajax({
- url: "https://js.stripe.com/v3/",
- dataType: "script",
- async: false, // <-- This is the key
- success: function () {
- // all good...
- console.log("loadStripeLibrary called...");
- SetupStripe();
- },
- error: function () {
- throw new Error("Could not load script " + script);
- }
- });
+ $.ajax({
+ url: "https://js.stripe.com/v3/",
+ dataType: "script",
+ async: false, // <-- This is the key
+ success: function () {
+ // all good...
+ console.log("loadStripeLibrary called...");
+ SetupStripe();
+ },
+ error: function () {
+ throw new Error("Could not load script " + script);
+ }
+ });
}
function SetupStripe() {
@@ -210,19 +188,19 @@ function SetupStripe() {
// See your keys here: https://dashboard.stripe.com/account/apikeys
stripe = Stripe('pk_test_YkSGqH3Tk9WKK9HrlY63GhAg');
elements = stripe.elements({ locale: "de" });
-
+
// Set up Stripe.js and Elements to use in checkout form
style = {
base: {
color: "#32325d",
}
};
-
+
card = elements.create("card", { style: style });
card.mount("#card-element");
$("#card-errors-article").hide();
-
- card.addEventListener('change', ({error}) => {
+
+ card.addEventListener('change', ({ error }) => {
if (error) {
$("#card-errors").text(error.message);
$("#card-errors-article").show();
@@ -241,7 +219,7 @@ function ConfirmPayment(clientSecret) {
name: '{{ .UserName }}'
}
}
- }).then(function(result) {
+ }).then(function (result) {
if (result.error) {
// Show error to your customer (e.g., insufficient funds)
console.log(result.error.message);
@@ -283,17 +261,17 @@ function PayMe() {
url: "getstripepaymentintent",
type: "get", //send it through get method
dataType: "json",
- data: {
+ data: {
charge_data: $("#charge_data").html()
},
- success: function(response) {
+ success: function (response) {
console.log('pay success');
- console.log('rc: '+response.rc);
+ console.log('rc: ' + response.rc);
if (response.rc == 0) {
ConfirmPayment(response.stripeclientsecret);
}
},
- error: function(xhr) {
+ error: function (xhr) {
console.log('getstripepaymentintent error');
//Do Something to handle error
EndPaymentProgress();
@@ -301,21 +279,21 @@ function PayMe() {
});
}
-$('#cart-pay').on('click', function(ev) {
+$('#cart-pay').on('click', function (ev) {
StartPaymentProgress();
PayMe();
});
// draw all maps
var woBischIcon = L.icon({
- iconUrl: '/static/images/marker.png',
- iconSize: [64, 64],
- iconAnchor: [32, 64]
+ iconUrl: '/static/images/marker.png',
+ iconSize: [64, 64],
+ iconAnchor: [32, 64]
});
var maps = [];
-$(document).ready(function() {
- $(".tracker").each(function(index) {
+$(document).ready(function () {
+ $(".tracker").each(function (index) {
console.log('Draw Map (' + index + "): " + $(this).find(".alias").html());
deveui = $(this).find("div").first().attr("id");
@@ -338,10 +316,10 @@ $(document).ready(function() {
map.addLayer(tilelayer);
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);
});
-});
+});
\ No newline at end of file
diff --git a/static/js/wo-bisch-web.js b/static/js/wo-bisch-web.js
index 9063c8b..1053381 100644
--- a/static/js/wo-bisch-web.js
+++ b/static/js/wo-bisch-web.js
@@ -1,70 +1,18 @@
- $(document).ready(function() {
+$(document).ready(function () {
- $("#email").focus();
+ $("#email").focus();
- // Check for click events on the navbar burger icon
- $(".navbar-burger").click(function() {
- // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
- $(".navbar-burger").toggleClass("is-active");
- $(".navbar-menu").toggleClass("is-active");
+ // Check for click events on the navbar burger icon
+ $(".navbar-burger").click(function () {
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
+ $(".navbar-burger").toggleClass("is-active");
+ $(".navbar-menu").toggleClass("is-active");
- });
+ });
- // Login Button
- $("#login-button").click(function(e){
- //alert(true);
- $("#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 = '