From fbac0c8d268c167231eb470300942ab506f1bc3b Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Sat, 20 Mar 2021 17:46:24 +0100 Subject: [PATCH] reformat js-files, refactor... --- static/js/chekout.js | 81 ------------- static/js/map.js | 229 ++++++++++++++++++----------------- static/js/tracker.js | 244 +++++++++++++++++--------------------- static/js/wo-bisch-web.js | 80 +++---------- 4 files changed, 239 insertions(+), 395 deletions(-) delete mode 100644 static/js/chekout.js diff --git a/static/js/chekout.js b/static/js/chekout.js deleted file mode 100644 index af9d3ef..0000000 --- a/static/js/chekout.js +++ /dev/null @@ -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!!!"); - } - } - }); -}); diff --git a/static/js/map.js b/static/js/map.js index ae682d1..c86debd 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -10,54 +10,54 @@ var markers = []; var marker; var allmarkers = L.layerGroup(); var woBischIcon = L.icon({ - iconUrl: '/static/images/marker.png', - iconSize: [64, 64], - iconAnchor: [32, 64], - popupAnchor: [0, -64] + iconUrl: '/static/images/marker.png', + iconSize: [64, 64], + iconAnchor: [32, 64], + popupAnchor: [0, -64] }); var datapoints; var woBischIcon2 = L.icon({ - iconUrl: '/static/images/marker-all.png', - iconSize: [64, 64], - iconAnchor: [32, 32], - popupAnchor: [0, 0] + iconUrl: '/static/images/marker-all.png', + iconSize: [64, 64], + iconAnchor: [32, 32], + popupAnchor: [0, 0] }); 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 dstop = moment(); var stop = dstop.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); function vbat2icon(level) { - switch (level) { - case 1: - fa_battery_string = "fa-battery-empty"; - icon_color = "has-text-danger"; - break; - case 2: - fa_battery_string = "fa-battery-quarter"; - icon_color = "has-text-warning"; - break; - case 3: - fa_battery_string = "fa-battery-half"; - icon_color = "has-text-info"; - break; - case 4: - fa_battery_string = "fa-battery-three-quarters"; - icon_color = "has-text-link"; - break; - case 5: - fa_battery_string = "fa-battery-full"; - icon_color = "has-text-success"; - break; - default: - fa_battery_string = "fa-battery-slash"; - icon_color = "has-text-danger"; - } + switch (level) { + case 1: + fa_battery_string = "fa-battery-empty"; + icon_color = "has-text-danger"; + break; + case 2: + fa_battery_string = "fa-battery-quarter"; + icon_color = "has-text-warning"; + break; + case 3: + fa_battery_string = "fa-battery-half"; + icon_color = "has-text-info"; + break; + case 4: + fa_battery_string = "fa-battery-three-quarters"; + icon_color = "has-text-link"; + break; + case 5: + fa_battery_string = "fa-battery-full"; + icon_color = "has-text-success"; + break; + default: + fa_battery_string = "fa-battery-slash"; + icon_color = "has-text-danger"; + } - return ''; + return ''; } function refreshDatapoints(deveui, start, stop) { @@ -65,7 +65,7 @@ function refreshDatapoints(deveui, start, stop) { range = range + "&start=" + start; 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 (mydata.msg.includes("expired")) { $('#chart').html(`
@@ -92,7 +92,7 @@ function refreshDatapoints(deveui, start, stop) { last_slider_position = datapoints.length - 1; var unix_timestamp = datapoints[datapoints.length - 1][0]; var date = new Date(unix_timestamp * 1000); - + var myhtml = '

' + alias + '
' + moment(date).format('DD.MM.YYYY HH:mm') + '
' + vbat2icon(datapoints[datapoints.length - 1][4]) + '

'; marker.bindPopup(myhtml).openPopup(); @@ -101,12 +101,12 @@ function refreshDatapoints(deveui, start, stop) { } markers = []; - + // we create the layer group with all positions for (let i of datapoints) { unix_timestamp = i[0]; 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); if (lcontrol != undefined) { @@ -114,20 +114,20 @@ function refreshDatapoints(deveui, start, stop) { lcontrol.remove(); } 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']]]); map.fitBounds(bounds, { padding: [20, 20] }); }); } -$(document).ready(function() { +$(document).ready(function () { map = new L.Map('map', { - crs: L.CRS.EPSG3857, - zoomControl: true, - maxBounds: boundsSwitzerland, - doubleClickZoom: false + crs: L.CRS.EPSG3857, + zoomControl: true, + maxBounds: boundsSwitzerland, + doubleClickZoom: false }); - map.setMinZoom( map.getBoundsZoom( map.options.maxBounds ) ); + map.setMinZoom(map.getBoundsZoom(map.options.maxBounds)); map.on('dblclick', function (e) { map.fitBounds(bounds, { padding: [20, 20] }); @@ -139,82 +139,81 @@ $(document).ready(function() { map.attributionControl.setPrefix('Source: Swiss Federal Office of Topography') map.addLayer(tilelayer); 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')); - refreshDatapoints(deveui,start,stop); + refreshDatapoints(deveui, start, stop); console.log("End of document ready..."); }); -$(function() { - var start = moment({hour: 0}); - var end = moment(); - var s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); - var s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); +$(function () { + var start = moment({ hour: 0 }); + var end = moment(); + var s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); + var s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); - function cb(start, end) { - $('#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()); - s_start = start.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); - refreshDatapoints(deveui, s_start, s_end); + function cb(start, end) { + $('#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()); + s_start = start.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); + 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')] } - - $('#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); + }, cb); }); -function updateSliderTooltip(c) -{ +function updateSliderTooltip(c) { if (datapoints == undefined || datapoints.length == 0) { - return + return } if (c.value == last_slider_position) { // 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 lng = datapoints[c.value][2]; var newLatLng = new L.LatLng(lat, lng); - console.log("Lat: "+lat+", Long: "+lng); - marker.setLatLng(newLatLng); -} + console.log("Lat: " + lat + ", Long: " + lng); + marker.setLatLng(newLatLng); +} \ No newline at end of file diff --git a/static/js/tracker.js b/static/js/tracker.js index d9998fe..d2945ec 100644 --- a/static/js/tracker.js +++ b/static/js/tracker.js @@ -1,22 +1,20 @@ function validate(what, text) { if (what == 'alias') { var re = /^[a-zA-Z0-9 ]{1,25}$/; - } else if (what == 'smsnumber') { - var re = /^\+[0-9]{11,11}$/; } return re.test(text); } -$( document ).ready(function() { - $(".show-modal").click(function() { +$(document).ready(function () { + $(".show-modal").click(function () { $("#alias_exclamation").hide(); $("#smsnumber_exclamation").hide(); var alias = $(this).prev().html(); - var deveui = $(this).prev().attr('id').replace("alias_",""); + var deveui = $(this).prev().attr('id').replace("alias_", ""); $('#deveui').html(deveui); - var alarmactive = $('#alarmactive_'+deveui).html(); - var smsnumber = $('#smsnumber_'+deveui).html(); - + var alarmactive = $('#alarmactive_' + deveui).html(); + var smsnumber = $('#smsnumber_' + deveui).html(); + $("#alias").val(alias); console.log(alarmactive); if (alarmactive == "1") { @@ -25,163 +23,143 @@ $( document ).ready(function() { $('#checkbox').prop('checked', false); } $("#smsnumber").val(smsnumber); - $("#modal").addClass("is-active"); + $("#modal").addClass("is-active"); }); - $("#cart-close").click(function() { - $("#cart").removeClass("is-active"); + $("#cart-close").click(function () { + $("#cart").removeClass("is-active"); }); - $("#payment_notifier_close").click(function() { - $("#payment_notifier").removeClass("is-active"); - location.reload(true); + $("#payment_notifier_close").click(function () { + $("#payment_notifier").removeClass("is-active"); + location.reload(true); }); - $(".abo_plus").click(function() { - console.log("abo_plus"); - el = $(this).parent().find(".abo_add_years"); - el_text = $(this).parent().parent().find(".abo_add_years_text"); - counter = Number(el.html()); - if (counter < 3) { - counter = counter + 1; - el.html(counter); - if (counter == 1) { - el_text.html("+" + counter + " Jahr"); - } else { - el_text.html("+" + counter + " Jahre"); - } - } + $(".abo_plus").click(function () { + console.log("abo_plus"); + el = $(this).parent().find(".abo_add_years"); + el_text = $(this).parent().parent().find(".abo_add_years_text"); + counter = Number(el.html()); + if (counter < 3) { + counter = counter + 1; + el.html(counter); + if (counter == 1) { + el_text.html("+" + counter + " Jahr"); + } else { + el_text.html("+" + counter + " Jahre"); + } + } }); - $(".abo_minus").click(function() { - console.log("abo_minus"); - el = $(this).parent().find(".abo_add_years"); - el_text = $(this).parent().parent().find(".abo_add_years_text"); - counter = Number(el.html()); - if (counter > 0) { - counter = counter - 1; - el.html(counter); - if (counter == 0) { - el_text.html(" "); - } else if (counter == 1) { - el_text.html("+" + counter + " Jahr"); - } else { - el_text.html("+" + counter + " Jahre"); - } - } + $(".abo_minus").click(function () { + console.log("abo_minus"); + el = $(this).parent().find(".abo_add_years"); + el_text = $(this).parent().parent().find(".abo_add_years_text"); + counter = Number(el.html()); + if (counter > 0) { + counter = counter - 1; + el.html(counter); + if (counter == 0) { + el_text.html(" "); + } else if (counter == 1) { + el_text.html("+" + counter + " Jahr"); + } else { + el_text.html("+" + counter + " Jahre"); + } + } }); - function add_years(dt,n) - { - return new Date(dt.setFullYear(dt.getFullYear() + n)); + function add_years(dt, n) { + return new Date(dt.setFullYear(dt.getFullYear() + n)); } - $(".abo_pay").click(function() { + $(".abo_pay").click(function () { console.log("pay..."); loadStripeLibrary(); - counter = 0; + counter = 0; charge_data = ''; abo_table = ''; abo_table += ''; - $(".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 += ''; + abo_table += ''; 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 += ''; - console.log("Counter: "+counter); + console.log("Counter: " + counter); abo_table += "
Aliasverlängern bisBetrag
' + $( this ).find('.alias').html() + '' + moment(this_date,'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + '' + (this_count * 24).toFixed(2) + '
' + $(this).find('.alias').html() + '' + moment(this_date, 'DD.MM.YYYY').add('years', this_count).format('DD.MM.YYYY') + '' + (this_count * 24).toFixed(2) + '
Total CHF' + (counter * 24).toFixed(2) + '
"; 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 = '"; - $('#errorbox').html(errortext); - $('#errorbox').show(); - } - }) - }); - - - }); + // Login Button + $("#login-button").click(function (e) { + //alert(true); + $("#login-form").submit(); + }); +});