Revue page accueil administrateur site : template wikilerni + optimisation script JS.
This commit is contained in:
parent
f72a7a4824
commit
0cf5a82418
@ -1,79 +1,59 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="Page d'accueil du gestionnaire.">
|
<meta name="description" content="Page d'accueil pour les gestionnaires du site.">
|
||||||
<meta name="robots" content="noindex">
|
<meta name="robots" content="noindex">
|
||||||
<title>WikiLerni - gestion du site</title>
|
<title>Mon WikiLerni</title>
|
||||||
<!-- Version lisible des scripts : https://gitlab.com/lefablab/wikilerni/-/tree/master/front/src -->
|
<!-- Version lisible des scripts : https://gitlab.com/lefablab/wikilerni/-/tree/master/front/src -->
|
||||||
<script src="/JS/polyfill.app.js" defer></script>
|
<script src="/JS/polyfill.app.js" defer></script>
|
||||||
<script src="/JS/homeManager.app.js" defer></script>
|
<script src="/JS/homeManager.app.js" defer></script>
|
||||||
<link rel="shortcut icon" href="/img/favicon.ico">
|
<link rel="shortcut icon" href="/img/favicon.ico">
|
||||||
<link rel="stylesheet" href="/themes/default/CSS/pure-min.css">
|
<link rel="stylesheet" href="/themes/wikilerni/css/style.css">
|
||||||
<link rel="stylesheet" href="/themes/default/CSS/grids-responsive-min.css">
|
</head>
|
||||||
<link rel="stylesheet" href="/themes/default/CSS/wikilerni.css">
|
|
||||||
<link rel="canonical" href="https://www.wililerni.com/gestion.html">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
<body class="cardboard">
|
||||||
|
<!-- En tête -->
|
||||||
<header class="pure-g menu">
|
<header class="cardboard">
|
||||||
<div class="pure-u-1 pure-u-lg-1-8 menu-heading">
|
<a href="/" title="Page d'accueil WikLerni"><img src="/themes/wikilerni/img/wikilerni-purple-2-128.png" alt="WikiLerni (logo)" title="Accéder à la page d'accueil de WikiLerni" /></a>
|
||||||
<a class="pure-menu-heading" href="/">WikiLerni</a>
|
<ul id="headLinks">
|
||||||
</div>
|
<li><a href="/contact.html" rel="nofollow">Contact</a></li>
|
||||||
<div class="pure-u-1 pure-u-lg-7-8">
|
<li><a href="/quizs/" id="indexHeadLink" title="Les derniers quizs">Parcourir</a></li>
|
||||||
<ul class="pure-g">
|
<li><a href="/connexion.html" id="accountHeadLink">Mon compte</a></li>
|
||||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
<li><a href="/a-propos.html">À propos</a></li>
|
||||||
<a class="pure-menu-link" href="/">Accueil</a>
|
<li><a href="/" title="Page d'accueil de WikiLerni">Accueil</a></li>
|
||||||
</li>
|
|
||||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
|
||||||
<a class="pure-menu-link" href="/connexion.html" id="accountHeadLink">Mon compte</a>
|
|
||||||
</li>
|
|
||||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
|
||||||
<a class="pure-menu-link" href="/a-propos.html">À propos</a>
|
|
||||||
</li>
|
|
||||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
|
||||||
<a class="pure-menu-link" href="/contact.html">Contact</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</header>
|
||||||
</header>
|
|
||||||
|
|
||||||
<section id="main-content" class="needJS">
|
|
||||||
|
|
||||||
<div class="pure-menu pure-menu-horizontal">
|
|
||||||
<a href="/gestion.html" class="pure-menu-heading pure-menu-link">Gestion WikiLerni</a>
|
|
||||||
<ul id="classement" class="pure-menu-list">
|
|
||||||
<li class="pure-menu-item"><a href="/gestion-quizs.html" title="Publication des quizs" class="pure-menu-link" >Les quizs</a></li>
|
|
||||||
<li class="pure-menu-item"><a href="/gestion-utilisateurs.html" title="Les comptes utilisateurs" class="pure-menu-link">Les abonné(e)s</a></li>
|
|
||||||
<li class="pure-menu-item"><a href="/sortie.html" title="Sortie des artistes !" class="pure-menu-link">Me déconnecter</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
<div id="crash"></div>
|
||||||
<h2 class="content-head is-center">WikiLerni</h2>
|
|
||||||
<div class="pure-g">
|
<section id="main-content" class="needJS">
|
||||||
<div class="l-box-lrg pure-u-1" id="message"></div>
|
|
||||||
<div class="l-box-lrg pure-u-1" id="questionnaires"></div>
|
<ul id="menu" class="cardboard">
|
||||||
|
<li><a href="/gestion.html">Gestion WikiLerni</a></li>
|
||||||
|
<li><a href="/gestion-quizs.html" title="Publication des quizs">Les quizs</a></li>
|
||||||
|
<li><a href="/gestion-utilisateurs.html" title="Les comptes utilisateurs">Les abonné(e)s</a></li>
|
||||||
|
<li><a href="/sortie.html">Me déconnecter</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div id="home" class="cardboard">
|
||||||
|
<img id="logo" src="/themes/wikilerni/img/wikilerni-purple-2-512.png" alt="Logo WikiLerni" />
|
||||||
|
<div id="message" class="cardboard"></div>
|
||||||
|
<p><a href="#" class="button cardboard" id="wantRegenerate">Régénérer le HTML.</a></p>
|
||||||
|
<div id="questionnaires"></div>
|
||||||
</div>
|
</div>
|
||||||
<p><a href="#" class="pure-button pure-button-primary" id="wantRegenerate">Régénérer le HTML.</a></p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<footer class="footer l-box is-center">
|
</section>
|
||||||
<ul class="pure-g">
|
|
||||||
<li class="pure-u-1 pure-u-lg-1-5">
|
<footer class="cardboard">
|
||||||
<a href="/mentions-legales.html">Crédits</a>
|
<ul id="footLinks">
|
||||||
</li>
|
<li><a href="https://framasphere.org/people/7e54b7a0b53201389eef2a0000053625" title="Blog WikiLerni sur diaspora*">Blog</a></li>
|
||||||
<li class="pure-u-1 pure-u-lg-1-5">
|
<li><a href="/credits.html">Crédits</a></li>
|
||||||
<a href="/mentions-legales.html">Mentions légales</a>
|
<li><a href="/mentions-legales.html" rel="nofollow">Mentions légales</a></li>
|
||||||
</li>
|
<li><a href="/donnees.html">Données personnelles</a></li>
|
||||||
<li class="pure-u-1 pure-u-lg-1-5">
|
<li><a href="/CGV-CGU.html" rel="nofollow">CGV & CGU</a></li>
|
||||||
<a href="/donnees.html">Données personnelles</a>
|
</ul>
|
||||||
</li>
|
</footer>
|
||||||
<li><a href="/CGV-CGU.html">CGV & CGU</a></li>
|
</body>
|
||||||
</ul>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
@ -6,30 +6,41 @@
|
|||||||
/// Un menu permet à l'utilisateur d'accéder aux formulaires permettant de gérer les quizs et les comptes utilisateurs et abonnements
|
/// Un menu permet à l'utilisateur d'accéder aux formulaires permettant de gérer les quizs et les comptes utilisateurs et abonnements
|
||||||
/// Un message venant d'une autre page peut aussi être à afficher lors du premier chargement.
|
/// Un message venant d'une autre page peut aussi être à afficher lors du premier chargement.
|
||||||
|
|
||||||
/// C'est ici aussi que l'on peut régénérer tout le HTML -> à terme dans homeAdmin !
|
/// Temporairement, c'est ici aussi que l'on peut régénérer tout le HTML -> à terme dans homeAdmin !
|
||||||
|
|
||||||
// Fichier de configuration côté client :
|
// Fichier de configuration côté client :
|
||||||
import { apiUrl, availableLangs, theme } from "../../config/instance.js";
|
import { apiUrl, availableLangs, theme } from "../../config/instance.js";
|
||||||
const lang=availableLangs[0];
|
const lang=availableLangs[0];
|
||||||
const configFrontEnd = require("../../views/"+theme+"/config/"+lang+".js");
|
|
||||||
|
import { getAdminStats, userRoutes } from "../../config/users.js";
|
||||||
|
import { getListNextQuestionnaires, questionnaireRoutes, regenerateHTML } from "../../config/questionnaires.js";
|
||||||
|
const configTemplate = require("../../views/"+theme+"/config/"+lang+".js");
|
||||||
|
|
||||||
// Fonctions utiles au script :
|
// Fonctions utiles au script :
|
||||||
import { getLocaly, removeLocaly } from "./tools/clientstorage.js";
|
import { getLocaly, removeLocaly } from "./tools/clientstorage.js";
|
||||||
import { addElement } from "./tools/dom.js";
|
import { addElement } from "./tools/dom.js";
|
||||||
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
|
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
|
||||||
import { dateFormat, isEmpty, replaceAll } from "../../tools/main";
|
import { dateFormat, isEmpty, replaceAll } from "../../tools/main";
|
||||||
import { checkSession, getConfig } from "./tools/users.js";
|
import { checkSession } from "./tools/users.js";
|
||||||
|
|
||||||
// Dictionnaires :
|
// Dictionnaires : revoir pour ne prendre que les variables utilisées
|
||||||
const txt = require("../../lang/"+lang+"/general");
|
const txt = require("../../lang/"+lang+"/general");
|
||||||
const txtUsers = require("../../lang/"+lang+"/user");
|
|
||||||
|
const txtNotAllowed = require("../../lang/"+lang+"/general").notAllowed;
|
||||||
|
const txtServerError = require("../../lang/"+lang+"/general").serverError;
|
||||||
|
const txtStatsAdmin = require("../../lang/"+lang+"/general").statsAdmin;
|
||||||
|
const txtNeedBeCompleted = require("../../lang/"+lang+"/questionnaire").needBeCompleted;
|
||||||
|
const txtNextDateWithoutQuestionnaire = require("../../lang/"+lang+"/questionnaire").nextDateWithoutQuestionnaire;
|
||||||
|
const txtNextQuestionnairesList = require("../../lang/"+lang+"/questionnaire").nextQuestionnairesList;
|
||||||
|
const txtWelcome = require("../../lang/"+lang+"/user").welcomeMessage;
|
||||||
|
|
||||||
const txtQuestionnaire = require("../../lang/"+lang+"/questionnaire");
|
const txtQuestionnaire = require("../../lang/"+lang+"/questionnaire");
|
||||||
|
|
||||||
// Principaux éléments du DOM manipulés :
|
// Principaux éléments du DOM manipulés :
|
||||||
const divMain = document.getElementById("main-content");
|
const divMain = document.getElementById("main-content");
|
||||||
|
const divCrash = document.getElementById("crash");
|
||||||
const divMessage = document.getElementById("message");
|
const divMessage = document.getElementById("message");
|
||||||
const divQuestionnaires = document.getElementById("questionnaires");
|
const divQuestionnaires = document.getElementById("questionnaires");
|
||||||
|
|
||||||
const btnRegenerate = document.getElementById("wantRegenerate");
|
const btnRegenerate = document.getElementById("wantRegenerate");
|
||||||
|
|
||||||
helloDev();
|
helloDev();
|
||||||
@ -38,110 +49,105 @@ const initialise = async () =>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const config = await getConfig();
|
const isConnected=await checkSession(["manager", "admin"], "/"+configTemplate.connectionPage, { message: txtNotAllowed, color:"error" });
|
||||||
if(!config)
|
if(isConnected)
|
||||||
addElement(divResponse, "p", txt.serverError, "", ["error"]);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const isConnected=await checkSession(["manager", "admin"], "/"+configFrontEnd.connectionPage, { message: txt.notAllowed, color:"error" });
|
const user=getLocaly("user", true);
|
||||||
if(isConnected)
|
updateAccountLink(user.status, configTemplate);
|
||||||
|
addElement(divMessage, "h2", txtWelcome.replace("#NAME", user.name));
|
||||||
|
divMain.style.display="block";
|
||||||
|
if(!isEmpty(getLocaly("message")))
|
||||||
{
|
{
|
||||||
const user=getLocaly("user", true);
|
addElement(divMessage, "p", getLocaly("message", true).message, "", [getLocaly("message", true).color], "", false);
|
||||||
updateAccountLink(user.status, configFrontEnd);
|
removeLocaly("message");
|
||||||
addElement(divMessage, "h4", txtUsers.welcomeMessage.replace("#NAME", user.name));
|
|
||||||
divMain.style.display="block";
|
|
||||||
if(!isEmpty(getLocaly("message")))
|
|
||||||
{
|
|
||||||
addElement(divMessage, "p", getLocaly("message", true).message, "", [getLocaly("message", true).color], "", false);
|
|
||||||
removeLocaly("message");
|
|
||||||
}
|
|
||||||
// Les stats :
|
|
||||||
const xhrStats = new XMLHttpRequest();
|
|
||||||
xhrStats.open("GET", apiUrl+config.userRoutes+config.getAdminStats);
|
|
||||||
xhrStats.onreadystatechange = function()
|
|
||||||
{
|
|
||||||
if (this.readyState == XMLHttpRequest.DONE)
|
|
||||||
{
|
|
||||||
let response=JSON.parse(this.responseText);
|
|
||||||
if (this.status === 200)
|
|
||||||
{
|
|
||||||
const mapText =
|
|
||||||
{
|
|
||||||
NB_USERS_24H : response.nbNewUsers24H,
|
|
||||||
NB_SUBSCRIPTIONS_24H : response.Subscriptions.nbSubscriptions24H,
|
|
||||||
NB_USERS_DELETED_24H : response.nbDeletedUsers24H,
|
|
||||||
NB_ANSWERS_24H : response.Answers.nbAnswers24H,
|
|
||||||
NB_USERS_TOT : response.nbNewUsersTot,
|
|
||||||
NB_SUBSCRIPTIONS_TOT : response.Subscriptions.nbSubscriptionsTot,
|
|
||||||
NB_SUBSCRIPTIONS_PREMIUM : response.Subscriptions.nbSubscriptionsPremium,
|
|
||||||
NB_ANSWERS_TOT : response.Answers.nbAnswersTot,
|
|
||||||
NB_USERS_DELETED_TOT : response.nbDeletedUsersTot,
|
|
||||||
NB_USERS_DELETED_VALIDED : response.nbDeletedUsersWasValided,
|
|
||||||
NB_USERS_DELETED_PREMIUM : response.nbDeletedUsersTotWasPremium
|
|
||||||
};
|
|
||||||
addElement(divMessage, "p", replaceAll(txt.statsAdmin, mapText), "", "", "", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhrStats.setRequestHeader("Authorization", "Bearer "+user.token);
|
|
||||||
xhrStats.send();
|
|
||||||
|
|
||||||
// Les questionnaires bientôt publiés :
|
|
||||||
const xhrNextQuestionnaires = new XMLHttpRequest();
|
|
||||||
xhrNextQuestionnaires.open("GET", apiUrl+config.questionnaireRoutes+config.getListNextQuestionnaires);
|
|
||||||
xhrNextQuestionnaires.onreadystatechange = function()
|
|
||||||
{
|
|
||||||
if (this.readyState == XMLHttpRequest.DONE)
|
|
||||||
{
|
|
||||||
let response=JSON.parse(this.responseText);
|
|
||||||
if (this.status === 200 && Array.isArray(response.questionnaires))
|
|
||||||
{
|
|
||||||
let listHTML="", dayStr, optionsDayStr = { weekday: 'long'};
|
|
||||||
for(let i in response.questionnaires)
|
|
||||||
{
|
|
||||||
dayStr=new Intl.DateTimeFormat(lang, optionsDayStr).format(new Date(response.questionnaires[i].datePublishing));
|
|
||||||
listHTML+="<li>"+dayStr+" "+dateFormat(response.questionnaires[i].datePublishing, "fr")+": <a href='"+configFrontEnd.questionnairesManagementPage+"?id="+response.questionnaires[i].id+"'>"+response.questionnaires[i].title+"</a>";
|
|
||||||
if(response.questionnaires[i].isPublishable===false)
|
|
||||||
listHTML+=" <span class='error'>("+txtQuestionnaire.needBeCompleted+")</li>";
|
|
||||||
listHTML+="</li>";
|
|
||||||
}
|
|
||||||
if(response.questionnaires.length!==0)
|
|
||||||
addElement(divQuestionnaires, "h3", txtQuestionnaire.nextQuestionnairesList.replace("#NB", response.questionnaires.length));
|
|
||||||
addElement(divQuestionnaires, "h4", txtQuestionnaire.nextDateWithoutQuestionnaire+dateFormat(response.dateNeeded, "fr"), "", ["information"], "", false);
|
|
||||||
addElement(divQuestionnaires, "ul", listHTML, "", "", "", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhrNextQuestionnaires.setRequestHeader("Authorization", "Bearer "+user.token);
|
|
||||||
xhrNextQuestionnaires.send();
|
|
||||||
|
|
||||||
// Traitement demande régénérer HTML
|
|
||||||
btnRegenerate.addEventListener("click", function(e)
|
|
||||||
{
|
|
||||||
e.preventDefault();
|
|
||||||
const xhrRegenerate = new XMLHttpRequest();
|
|
||||||
xhrRegenerate.open("GET", apiUrl+config.questionnaireRoutes+"/htmlregenerated");
|
|
||||||
xhrRegenerate.onreadystatechange = function()
|
|
||||||
{
|
|
||||||
if (this.readyState == XMLHttpRequest.DONE)
|
|
||||||
{
|
|
||||||
let response=JSON.parse(this.responseText);
|
|
||||||
if (this.status === 200 && response.message!=undefined)
|
|
||||||
addElement(divMessage, "p", response.message, "", ["success"], "", false);
|
|
||||||
else
|
|
||||||
addElement(divMessage, "p", txt.serverError, "", ["error"], "", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhrRegenerate.setRequestHeader("Content-Type", "application/json");
|
|
||||||
xhrRegenerate.setRequestHeader("Authorization", "Bearer "+user.token);
|
|
||||||
xhrRegenerate.send();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
// Les stats sur les comptes utilisateurs :
|
||||||
|
const xhrStats = new XMLHttpRequest();
|
||||||
|
xhrStats.open("GET", apiUrl+userRoutes+getAdminStats);
|
||||||
|
xhrStats.onreadystatechange = function()
|
||||||
|
{
|
||||||
|
if (this.readyState == XMLHttpRequest.DONE)
|
||||||
|
{
|
||||||
|
let response=JSON.parse(this.responseText);
|
||||||
|
if (this.status === 200)
|
||||||
|
{
|
||||||
|
const mapText =
|
||||||
|
{
|
||||||
|
NB_USERS_24H : response.nbNewUsers24H,
|
||||||
|
NB_SUBSCRIPTIONS_24H : response.Subscriptions.nbSubscriptions24H,
|
||||||
|
NB_USERS_DELETED_24H : response.nbDeletedUsers24H,
|
||||||
|
NB_ANSWERS_24H : response.Answers.nbAnswers24H,
|
||||||
|
NB_USERS_TOT : response.nbNewUsersTot,
|
||||||
|
NB_SUBSCRIPTIONS_TOT : response.Subscriptions.nbSubscriptionsTot,
|
||||||
|
NB_SUBSCRIPTIONS_PREMIUM : response.Subscriptions.nbSubscriptionsPremium,
|
||||||
|
NB_ANSWERS_TOT : response.Answers.nbAnswersTot,
|
||||||
|
NB_USERS_DELETED_TOT : response.nbDeletedUsersTot,
|
||||||
|
NB_USERS_DELETED_VALIDED : response.nbDeletedUsersWasValided,
|
||||||
|
NB_USERS_DELETED_PREMIUM : response.nbDeletedUsersTotWasPremium
|
||||||
|
};
|
||||||
|
addElement(divMessage, "p", replaceAll(txtStatsAdmin, mapText), "", "", "", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhrStats.setRequestHeader("Authorization", "Bearer "+user.token);
|
||||||
|
xhrStats.send();
|
||||||
|
|
||||||
|
// Les questionnaires bientôt publiés :
|
||||||
|
const xhrNextQuestionnaires = new XMLHttpRequest();
|
||||||
|
xhrNextQuestionnaires.open("GET", apiUrl+questionnaireRoutes+getListNextQuestionnaires);
|
||||||
|
xhrNextQuestionnaires.onreadystatechange = function()
|
||||||
|
{
|
||||||
|
if (this.readyState == XMLHttpRequest.DONE)
|
||||||
|
{
|
||||||
|
let response=JSON.parse(this.responseText);
|
||||||
|
if (this.status === 200 && Array.isArray(response.questionnaires))
|
||||||
|
{
|
||||||
|
let listHTML="", dayStr, optionsDayStr = { weekday: 'long'};
|
||||||
|
for(let i in response.questionnaires)
|
||||||
|
{
|
||||||
|
dayStr=new Intl.DateTimeFormat(lang, optionsDayStr).format(new Date(response.questionnaires[i].datePublishing));
|
||||||
|
listHTML+="<li>"+dayStr+" "+dateFormat(response.questionnaires[i].datePublishing, availableLangs[0])+": <a href='"+configTemplate.questionnairesManagementPage+"?id="+response.questionnaires[i].id+"'>"+response.questionnaires[i].title+"</a>";
|
||||||
|
if(response.questionnaires[i].isPublishable===false)
|
||||||
|
listHTML+=" <span class='error'>("+txtNeedBeCompleted+")</li>";
|
||||||
|
listHTML+="</li>";
|
||||||
|
}
|
||||||
|
if(response.questionnaires.length!==0)
|
||||||
|
addElement(divQuestionnaires, "h2", txtNextQuestionnairesList.replace("#NB", response.questionnaires.length));
|
||||||
|
addElement(divQuestionnaires, "h4", txtNextDateWithoutQuestionnaire+dateFormat(response.dateNeeded, availableLangs[0]), "", ["info"], "", false);
|
||||||
|
addElement(divQuestionnaires, "ul", listHTML, "", "", "", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhrNextQuestionnaires.setRequestHeader("Authorization", "Bearer "+user.token);
|
||||||
|
xhrNextQuestionnaires.send();
|
||||||
|
|
||||||
|
// Traitement demande régénérer HTML
|
||||||
|
btnRegenerate.addEventListener("click", function(e)
|
||||||
|
{
|
||||||
|
e.preventDefault();
|
||||||
|
const xhrRegenerate = new XMLHttpRequest();
|
||||||
|
xhrRegenerate.open("GET", apiUrl+questionnaireRoutes+regenerateHTML);
|
||||||
|
xhrRegenerate.onreadystatechange = function()
|
||||||
|
{
|
||||||
|
if (this.readyState == XMLHttpRequest.DONE)
|
||||||
|
{
|
||||||
|
let response=JSON.parse(this.responseText);
|
||||||
|
if (this.status === 200 && response.message!=undefined)
|
||||||
|
addElement(divMessage, "p", response.message, "", ["success"], "", false);
|
||||||
|
else
|
||||||
|
addElement(divMessage, "p", txt.serverError, "", ["error"], "", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhrRegenerate.setRequestHeader("Content-Type", "application/json");
|
||||||
|
xhrRegenerate.setRequestHeader("Authorization", "Bearer "+user.token);
|
||||||
|
xhrRegenerate.send();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
{
|
{
|
||||||
addElement(divMessage, "p", txt.serverError, "", ["error"]);
|
addElement(divCrash, "p", txtServerError, "", ["error"]);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user