103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
},
listen: function () {
document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect(); });
},
connect: function () {
let xForm = new FormData(document.getElementById('connect_form'));
for (let [k, v] of xForm.entries()) {
console.log("* ", k, v);
}
oMessage.show("TEST");
fetch("http://localhost/connect/", {
method: "POST", // *GET, POST, PUT, DELETE, etc.
//mode: "cors", // no-cors, cors, *same-origin
//cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
/*headers: {
"Content-Type": "multipart/form-data", // text/plain, application/json
},*/
credentials: "omit", // include, *same-origin, omit
body: xForm
})
.then((response) => {
if (response.ok) {
for (let param in response) {
console.log(param, response[param]);
}
console.log(response.body);
return response.json();
} else {
for (let param in response) {
console.log(param, response[param]);
}
return null;
}
})
.then((response) => {
if (response) {
console.log(response);
} else {
console.log(response);
}
})
.catch((e) => {
showError(e);
});
}
}
class Table {
constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {
|
>
>
>
>
<
|
>
|
|
>
>
>
>
|
<
<
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
},
listen: function () {
document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect(); });
},
connect: function () {
if (!this.checkValues()) {
oMessage.show("Les valeurs des champs du formulaire ne sont pas conformes.");
return;
}
let xForm = new FormData(document.getElementById('connect_form'));
for (let [k, v] of xForm.entries()) {
console.log("* ", k, v);
}
fetch("http://localhost/connect/", {
method: "POST", // *GET, POST, PUT, DELETE, etc.
//mode: "cors", // no-cors, cors, *same-origin
//cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
headers: {
"Accept-Charset": "utf-8"
//"Content-Type": "multipart/form-data", // text/plain, application/json
},
credentials: "omit", // include, *same-origin, omit
body: xForm
})
.then((response) => {
if (response.ok) {
if (response.status == 204) {
oMessage.show("Échec d’identification. Vérifiez l’e-mail et le mot de passe envoyés…");
return null;
}
for (let param in response) {
console.log(param, response[param]);
}
console.log(response.body);
return response.json();
} else {
oMessage.show("Erreur. Le serveur ne semble pas en état de répondre. Veuillez réessayer ultérieurement.");
return null;
}
})
.then((response) => {
if (response) {
console.log("response: ", response);
}
})
.catch((e) => {
showError(e);
});
},
checkValues () {
if (document.getElementById("email").value === "") {
return false;
}
let sEmail = document.getElementById("email").value;
if (sEmail.search(/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/) === -1) {
return false;
}
return true;
},
showId (sLogin, sEmail) {
document.getElementById("login_label").textContent = sLogin;
document.getElementById("email_label").textContent = sEmail;
hideElement("connect_form");
showElement("connect_info");
}
}
class Table {
constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {
|