-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.html
117 lines (105 loc) · 3.98 KB
/
profile.html
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
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Profile</title>
<meta name="description" content="Test your country, capital and flag knowledge with all the variations of tests in this game.">
<meta name="tags" content="geography, test, quiz, trivia, counties, capital cities, flags">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/common.css?v=16" rel="stylesheet">
</head>
<body>
<form id="login" class="panel">
<h1>Not logged in</h1>
<p>
Enter your details below
</p>
<label for="username">Username:</label>
<input type="username" id="username" placeholder="username" required>
<label for="secret">Secret:</label>
<input type="password" id="secret" placeholder="secret">
<br>
<sub>Leave secret blank for a new account, otherwise, find your secret on the profile page of a device you're signed in on</sub>
<br>
<div class="options">
<input type="submit" class="btn" value="Log in / sign up">
<a href="/" class="btn">Return to menu</a>
</div>
</form>
<div id="profile" class="panel" style="display:none">
<h1 id="usertitle">Logged in</h1>
<p>
<span id="showname">Username: </span>
<br>
<span id="showsecret">Secret: </span>
</p>
<label for="theme">Colour scheme:</label>
<select name="theme" id="theme">
<option value="default">default</option>
</select>
<br>
<sub>Note your secret down somewhere to add your account to a new device</sub>
<br>
<div class="options">
<button class="btn disabled action-save">Save settings</button>
<button class="btn action-logout">Sign out</button>
<a href="/" class="btn">Games</a>
</div>
</d>
<script src="//cdn.yiays.com/jquery-3.7.1.min.js"></script>
<script src="/common.js?v=16"></script>
<script>
let original_theme = theme;
{
// Add options before JQuery so the login process can use them
var themeSelect = document.getElementById('theme');
Object.keys(c_schemes).forEach((c_scheme) => {
if(c_scheme != 'default')
themeSelect.options[themeSelect.options.length] = new Option(c_scheme, c_scheme);
});
}
$().ready(() => {
$('#login').submit((e) => {
e.preventDefault();
let fusername = $('#username').val().toLowerCase();
let fsecret = $('#secret').val();
if(fsecret)
log_in(fusername, fsecret);
else
sign_up(fusername);
});
$('.action-logout').on('click', log_out);
$('#theme').on('change', change_theme);
$('.action-save').on('click', save_prefs);
});
function change_theme(e) {
// Preview theme
theme = e.target.value;
advance_colour();
$('.action-save').removeClass('disabled');
}
function save_prefs() {
if(theme != original_theme) {
$.get(`https://highscore.yiays.com/?secret=${secret}&username=${username}&theme=${theme}`)
.done((data) => {
complete_login(username, data.secret, data.theme, null, true);
toasty("Profile updated successfully! (Note: it can take up to two days for settings to sync)", 10);
original_theme = theme;
$('.action-save').addClass('disabled');
})
.fail((error) => {
if(error.status == 403) {
toasty(error.responseText, 20, true);
log_out();
}
else toasty(error.responseText? error.responseText : "Unable to save settings at this time.", 20, true);
});
}
}
</script>
</body>
</html>