Browse Source

working on javascript compatibility for old browsers

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
sqlite
Stephan Richter 3 months ago
parent
commit
522ee26e88
  1. 2
      de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js
  2. 17
      de.srsoftware.oidc.web/src/main/resources/en/scripts/reset.js
  3. 53
      de.srsoftware.oidc.web/src/main/resources/en/scripts/settings.js

2
de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js

@ -31,7 +31,7 @@ function handleRemove(response){ @@ -31,7 +31,7 @@ function handleRemove(response){
function remove(clientId){
var message = document.getElementById('message').innerHTML;
if (confirm(message.replace("{}",clientId))) {
fetch(client_controller+"/delete",{
fetch(client_controller,{
method: 'DELETE',
body : JSON.stringify({ client_id : clientId }),
credentials:'include'

17
de.srsoftware.oidc.web/src/main/resources/en/scripts/reset.js

@ -1,20 +1,20 @@ @@ -1,20 +1,20 @@
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
async function handlePasswordResponse(response){
function handlePasswordResponse(response){
if (response.ok){
console.log(response);
setText('passBtn', 'saved.');
if (response.redirected){
redirect(response.url);
}
} else {
setText('passBtn', 'Update failed!');
var text = await response.text();
if (text == 'invalid token') show('invalid_token');
if (text == 'token missing') show('missing_token');
if (text == 'password mismatch') show('password_mismatch');
if (text == 'weak password') show('weak_password');
response.text().then(text => {
if (text == 'invalid token') show('invalid_token');
if (text == 'token missing') show('missing_token');
if (text == 'password mismatch') show('password_mismatch');
if (text == 'weak password') show('weak_password');
});
}
enable('passBtn');
setTimeout(function(){
@ -41,7 +41,8 @@ function updatePass(){ @@ -41,7 +41,8 @@ function updatePass(){
headers : {
'Content-Type': 'application/json'
},
body : JSON.stringify(newData)
body : JSON.stringify(newData),
credentials:'include'
}).then(handlePasswordResponse);
setText('passBtn','sent…');
}

53
de.srsoftware.oidc.web/src/main/resources/en/scripts/settings.js

@ -14,18 +14,17 @@ function fillForm(){ @@ -14,18 +14,17 @@ function fillForm(){
}
}
async function handlePasswordResponse(response){
function handlePasswordResponse(response){
if (response.ok){
hide('wrong_password');
hide('password_mismatch');
setText('passBtn', 'saved.');
} else {
setText('passBtn', 'Update failed!');
var text = await response.text();
if (text == 'wrong password') show('wrong_password');
if (text == 'password mismatch') show('password_mismatch');
response.text().then(text => {
if (text == 'wrong password') show('wrong_password');
if (text == 'password mismatch') show('password_mismatch');
});
}
enable('passBtn');
setTimeout(function(){
@ -33,16 +32,17 @@ async function handlePasswordResponse(response){ @@ -33,16 +32,17 @@ async function handlePasswordResponse(response){
},10000);
}
async function handleSmtpResponse(response){
function handleSmtpResponse(response){
if (response.ok){
hide('wrong_password');
hide('password_mismatch');
setText('smtpBtn', 'saved.');
} else {
setText('smtpBtn', 'Update failed!');
var text = await response.text();
if (text == 'wrong password') show('wrong_password');
if (text == 'password mismatch') show('password_mismatch');
response.text().then(text => {
if (text == 'wrong password') show('wrong_password');
if (text == 'password mismatch') show('password_mismatch');
});
}
setTimeout(function(){
@ -65,17 +65,15 @@ function handleResponse(response){ @@ -65,17 +65,15 @@ function handleResponse(response){
},10000);
}
async function handleSettings(response){
function handleSettings(response){
console.log('handleSettings(…)',response);
if (response.ok){
var json = await response.json();
console.log("json: ",json);
for (var key in json){
setValue(key,json[key]);
}
get('start_tls').checked = json.start_tls;
get('smtp_auth').checked = json.smtp_auth;
show('mail_settings');
response.json().then(json => {
for (var key in json) setValue(key,json[key]);
get('start_tls').checked = json.start_tls;
get('smtp_auth').checked = json.smtp_auth;
show('mail_settings');
});
} else {
hide('mail_settings');
}
@ -100,7 +98,8 @@ function updateSmtp(){ @@ -100,7 +98,8 @@ function updateSmtp(){
headers : {
'Content-Type': 'application/json'
},
body : JSON.stringify(newData)
body : JSON.stringify(newData),
credentials:'include'
}).then(handleSmtpResponse);
setText('smtpBtn','sent…');
}
@ -118,7 +117,8 @@ function updatePass(){ @@ -118,7 +117,8 @@ function updatePass(){
headers : {
'Content-Type': 'application/json'
},
body : JSON.stringify(newData)
body : JSON.stringify(newData),
credentials:'include'
}).then(handlePasswordResponse);
setText('passBtn','sent…');
}
@ -139,7 +139,8 @@ function update(){ @@ -139,7 +139,8 @@ function update(){
headers : {
'Content-Type': 'application/json'
},
body : JSON.stringify(newData)
body : JSON.stringify(newData),
credentials:'include'
}).then(handleResponse)
setText('updateBtn','sent…');
}
@ -176,5 +177,9 @@ function durationUpdate(){ @@ -176,5 +177,9 @@ function durationUpdate(){
displayDuration();
}
setTimeout(fillForm,100);
fetch("/api/email/settings").then(handleSettings);
document.addEventListener("DOMContentLoaded", function(event) { // wait until page loaded
alert('loaded settings.js');
fillForm();
fetch("/api/email/settings",{credentials:'include'}).then(handleSettings);
});
Loading…
Cancel
Save