-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.js
More file actions
108 lines (95 loc) · 2.59 KB
/
account.js
File metadata and controls
108 lines (95 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
The ORIGINAL CODE is the `BRACE WEBSITE` Source Code.
The INITIAL DEVELOPER is Brace Inc., DEntisT.
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 the "License"; you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
Portions created by the Initial Developer are Copyright (c) 2022
the Initial Developer. All Rights Reserved.
*/
let account = {
loggedInKey: function() {
return "brace.guest.account";
},
loggedIn: function(){
return "brace.loggedIn";
},
notLoggedIn: function(){
return "brace.notLoggedIn";
}
};
let Guest = {
Username: function()
{
return "Guest";
},
Password: function()
{
return "";
}
};
/**************************/
let __modalid = 0;
const sucLogin__modalid = 1;
const LoggedOut__modalid = 2;
function ReopenModal()
{
if(__modalid == sucLogin__modalid)
{
openModal('sucLogin');
}
if(__modalid == LoggedOut__modalid)
{
openModal('LoggedOut');
}
}
/**************************/
function handleAccountRequest()
{
user_utils.consoleOutput("`handleAccountRequest` called.");
if(window.localStorage.getItem(account.loggedInKey()) === null)
{
user_utils.consoleOutput("ishere");
window.localStorage.getItem(account.loggedInKey(), account.notLoggedIn());
openModal('AccountPage');
return 1;
}
if(window.localStorage.getItem(account.loggedInKey()) == account.notLoggedIn())
{
openModal('AccountPage');
return 1;
}
if(window.localStorage.getItem(account.loggedInKey()) == account.loggedIn())
{
openModal("AlreadyLoggedIn");
document.getElementById('display_username').textContent = Guest.Username();
return 1;
}
return 1;
}
function AccountLogin()
{
const username = document.getElementById("data_username").value;
const password = document.getElementById("data_password").value;
if(username == Guest.Username() && password == Guest.Password())
{
window.localStorage.setItem(account.loggedInKey(), account.loggedIn());
closeModal();
__modalid = sucLogin__modalid; setTimeout(ReopenModal,1000);
return 1;
}
document.getElementById("account_popup_warntext").textContent = "Wrong username or password.";
return 1;
}
function AccountLogOut()
{
closeModal();
window.localStorage.setItem(account.loggedInKey(), account.notLoggedIn());
__modalid = LoggedOut__modalid; setTimeout(ReopenModal,1000);
}