diff --git a/html/templates/auth/login_modal.html b/html/templates/auth/login_modal.html
deleted file mode 100644
index 37f30ac..0000000
--- a/html/templates/auth/login_modal.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
Login success
-
-
-
-
-
diff --git a/html/templates/auth/reg.html b/html/templates/auth/reg.html
index 4d68dcd..ed9f830 100644
--- a/html/templates/auth/reg.html
+++ b/html/templates/auth/reg.html
@@ -3,10 +3,14 @@
\ No newline at end of file
diff --git a/html/templates/auth/reg_modal.html b/html/templates/auth/reg_modal.html
deleted file mode 100644
index fa72c87..0000000
--- a/html/templates/auth/reg_modal.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
Login success
-
-
-
-
-
-
diff --git a/js/controllers/home.js b/js/controllers/home.js
index ee2ba0c..0ee2624 100644
--- a/js/controllers/home.js
+++ b/js/controllers/home.js
@@ -7,21 +7,21 @@ export default function home(temp_engine) {
temp_engine.after_render(menu_mod);
temp_engine.render("templates/home.html");
- if (My.agent) {
- Ship.list((ships) => {
- ships[0].orbit(
- (response) => console.log(response),
- (err) => console.log(err)
- );
- ships[0].navigate(
- "X1-TN14-A2",
- (response) => {
- console.log(response);
- },
- (err) => {
- console.log(err);
- }
- );
- });
- }
+ // if (My.agent) {
+ // Ship.list((ships) => {
+ // ships[0].orbit(
+ // (response) => console.log(response),
+ // (err) => console.log(err)
+ // );
+ // ships[0].navigate(
+ // "X1-TN14-A2",
+ // (response) => {
+ // console.log(response);
+ // },
+ // (err) => {
+ // console.log(err);
+ // }
+ // );
+ // });
+ // }
}
diff --git a/js/controllers/login.js b/js/controllers/login.js
index 3b4cc9e..a6a3cae 100644
--- a/js/controllers/login.js
+++ b/js/controllers/login.js
@@ -1,51 +1,39 @@
-import { Modal } from "../skama_code/ui/modal.js";
import { Auth } from "../skama_code/auth/auth.js";
import { My } from "../skama_code/api/agent.js";
import home from "./home.js";
import menu_mod from "./menu_mod.js";
export default function login(temp_engine) {
- let auth = new Auth(true);
- let modal = new Modal("login-modal", temp_engine);
+ const auth = new Auth();
- modal.add_class("ext-modal");
temp_engine.after_render((temp_engine) => {
- modal.load("templates/auth/login_modal.html")
menu_mod(temp_engine);
- temp_engine.add_event("#ok", "click", () => {
- home(temp_engine);
- });
-
- temp_engine.add_event("#forget_login", "click", () => {
- My.agent = null;
- auth.unload_token();
- modal.close();
- render_login();
- });
temp_engine.add_event("#val", "click", () => {
- let token = $("#in-token").val();
- auth.login(token);
+ const is_checked = $("#box-remember").is(":checked");
+ const token = $("#in-token").val();
+ auth.store = is_checked;
+ auth.login(token)
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-token").val("");
+ $("#box-remember").prop("checked", false);
});
});
- temp_engine.render(`templates/auth/login.html`);
-
auth.done((agent) => {
- modal.show();
My.agent = agent;
- }).fail((errs) => {
+ if(auth.store) localStorage.setItem("token", agent.token)
+ home(temp_engine);
+ })
+
+ auth.fail((errors) => {
$(".errors").html("");
- errs.forEach(err => {
- $(".errors").append(`
-
${err}
- `);
+ errors.forEach(error => {
+ $(".errors").append(`
${error}
`);
});
- });
+ })
- auth.relog();
+ temp_engine.render(`templates/auth/login.html`);
}
\ No newline at end of file
diff --git a/js/controllers/reg.js b/js/controllers/reg.js
index ade8c69..5ef831b 100644
--- a/js/controllers/reg.js
+++ b/js/controllers/reg.js
@@ -1,61 +1,15 @@
-import { Modal } from "../skama_code/ui/modal.js";
import { Auth } from "../skama_code/auth/auth.js";
import { My } from "../skama_code/api/agent.js";
+import { Faction } from "../skama_code/api/faction.js"
import home from "./home.js";
import menu_mod from "./menu_mod.js";
export default function reg(temp_engine) {
- let active = false;
let auth = new Auth(true);
- let modal = new Modal("reg-modal", temp_engine);
- modal.add_class("ext-modal");
temp_engine.after_render((temp_engine) => {
menu_mod(temp_engine);
- modal.load("templates/auth/reg_modal.html");
- temp_engine.add_event("#ok", "click", () => {
- home(temp_engine);
- });
-
- temp_engine.add_event("#forget_reg", "click", () => {
- My.agent = null;
- auth.unload_token();
- modal.close();
- render_reg();
- });
-
- temp_engine.add_event("#val", "click", () => {
- if (!active) {
- active = true;
- let name = $("#in-name").val();
- let faction = $("#in-faction").val();
- auth.register({
- name: name,
- faction: faction
- });
- }
- });
-
- temp_engine.add_event("#cancel", "click", () => {
- $("#in-name").val("");
- $("#in-faction").val("");
- });
});
temp_engine.render(`templates/auth/reg.html`);
-
- auth.done((agent) => {
- $(".show-token").text(agent.token);
- modal.show();
- My.agent = agent;
- active = false;
- }).fail((errs) => {
- $(".errors").html("");
- errs.forEach(err => {
- $(".errors").append(`
-
${err}
- `);
- });
- active = false;
- });
}
\ No newline at end of file
diff --git a/js/skama_code b/js/skama_code
index 7bbbfc5..7f51628 160000
--- a/js/skama_code
+++ b/js/skama_code
@@ -1 +1 @@
-Subproject commit 7bbbfc565e3e2555d50c4e117311d98e629998c9
+Subproject commit 7f516288452f67f345be6b2eb8f4eb1137a7dd43