::Stack::Stop() {
this->is_running = false;
this->thread->join();
-
delete this->thread;
+
+ for(auto client : this->clients)
+ delete client;
+
this->is_open = false;
}
}
diff --git a/src/web/index.html b/src/web/index.html
index 3edcf21..6e08ffe 100644
--- a/src/web/index.html
+++ b/src/web/index.html
@@ -12,9 +12,7 @@
diff --git a/src/web/script.js b/src/web/script.js
index b934f11..a3766ed 100644
--- a/src/web/script.js
+++ b/src/web/script.js
@@ -21,19 +21,27 @@ let receive_callbacks = {};
function attempt_login() {
let section = document.getElementById("login");
let error = section.getElementsByClassName("error");
- let buttons = filter(
+ let lock_fields = filter(
to_array(section.getElementsByTagName("input")),
- x => (x.type === "button" || x.type === "submit")
+ x => ["submit", "button", "text", "password"].indexOf(x.type) !== -1
);
- for(let i in buttons)
- buttons[i].disabled = true;
+ for_each(lock_fields, x => x.disabled = true);
+ ws.send(pack(
+ kClientToMaster.LoginRequest, [
+ document.getElementById("login-user").value,
+ document.getElementById("login-pwd").value
+ ]
+ ));
- receive_callbacks[kMasterToClient.LoginResponse] = (pck) => {
+ receive_callbacks[kMasterToClient.LoginResponse] = pck => {
+ if(pck.regions[0][0] === 0) {
+ error.innerHTML = "Username or password was incorrect."
+ } else {
+ alert("allo");
+ }
-
- for(let i in buttons)
- buttons[i].disabled = false;
+ for_each(lock_fields, x => x.disabled = false);
};
}
@@ -578,4 +586,8 @@ function filter(x, f) {
function to_array(x) {
return Array.prototype.slice.call(x);
+}
+
+function concat(x, y) {
+ return Array.prototype.concat.call(x, y);
}
\ No newline at end of file