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!!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
@ -71,8 +69,7 @@ $( 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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,20 +146,12 @@ $( 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) {
|
||||||
|
|
|
||||||
|
|
@ -15,56 +15,4 @@
|
||||||
//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