-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.html
267 lines (251 loc) · 10.3 KB
/
settings.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
* Create your own at http://cspisawesome.com
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/bars.css" />
<link rel="stylesheet" href="./css/css/fontawesome-all.css" />
<link rel="manifest" href="./manifest.json">
<!-- <link rel="stylesheet" type="text/css" href="progress/progress.css" /> -->
<script>
function applyBackgroundTheme(color) {
var css = `
/* --------- Dark Theme --------- */
html{background-color: #27292C;}
.body {background-color: #27292C;color: white;}
.main {background: #35383C;}
body {background-color: #27292C;}
h1,h2,h3,h4 {color: #ffffff;}
.btn a {background-color: #ffffff;border: solid 1px #27292C;color: #27292C;}
.btn-primary table td {background-color: #27292C;}
.btn-primary a {background-color: #27292C;border-color: #27292C;color: #ffffff; }
p,span,ul,ol {color:white;}
.msg {color: black;}
`,
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
}
else {
style.appendChild(document.createTextNode(css));
}
}
if(localStorage.dark == 'true'){
applyBackgroundTheme("black") // color for dark mode
}
</script>
<title>Eazy-T: Settings</title>
<!-- <meta name="viewport" content="width=device-width" /> -->
<!-- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -->
</head>
<body id="main" onload="main()">
<script>
function main() {
if("apiKey" in localStorage){
alertify.success('API key found');
}
else {
window.location="intro.html";
}
}//END
//Deletes the API key from local storage
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
getJSON('https://api.torn.com/user/?selections=basic&key=' + localStorage.apiKey,
function(err, data) {
if (err !== null) {
alert('Cannot retrieve BASIC information: ' + err);
} //MjyUA
else {
var error = data.error.error;
alertify.alert('Error: ' + error);
}
});
function setRefreshrate(){
var refreshrate = prompt("Please enter your desired refresh rate in seconds. Each refresh will consume 3 API calls! [500 default, 10 minimum]:", localStorage.refreshrate/1000);
refreshrate = refreshrate * 1000;
if(refreshrate < 10000)refreshrate = 10000;
localStorage.setItem("refreshrate", refreshrate);
alertify.log('Your refreshrate has been set @ '+ localStorage.refreshrate / 1000 + ' seconds');
}
function setDark(){
alertify.confirm("Would you like to enable a dark theme? Press 'cancel' to disable." , function () {
// user clicked "ok"
var darkEnable = true;
localStorage.setItem("dark", darkEnable);
alertify.success('Dark theme has been ENABLED');
//ENABLES DARK THEME
}, function() {
// user clicked cancel
var darkDisable = false;
localStorage.setItem("dark", darkDisable);
alertify.error('Dark theme has been DISABLED');
//DISABLES DARK THEME
});
}
function setDesktop(){
alertify.confirm("Would you like to enable Desktop Mode? Press 'cancel' to disable." , function () {
// user clicked "ok"
var desktopEnable = true;
localStorage.setItem("desktop", desktopEnable);
alertify.success('Desktop mode has been ENABLED');
//ENABLES Desktop
}, function() {
// user clicked cancel
var desktopDisable = false;
localStorage.setItem("desktop", desktopDisable);
alertify.error('Desktop mode has been DISABLED');
//DISABLES Desktop
});
}
function deleteAPI() {
//alertify.log("Your API key has been removed.");
localStorage.removeItem("apiKey");
//alertify.log("Your API key has been removed.");
goHome();
}
function clearStorage() {
localStorage.clear();
alertify.log("Local storage has been cleared!");
window.location="intro.html";
}
function viewStored() {
//alertify.log("API Key: " + localStorage.apiKey);
alertify.log("Name: " + localStorage.playerName + " / API Key: " + localStorage.apiKey);
alertify.log("Refresh Rate: " + localStorage.refreshrate / 1000 + ' Seconds');
}
//Reloads the current window. Eazy
function reloadApp(){window.location.reload()}
function goHome() {
window.location="index.html";
}
function goAbout() {
window.location="about.html";
}
function goDelete() {
alertify.confirm("Application cache will be cleared. This will update the app! // DO NOT continue without a stable internet connection.", function () {
// user clicked "ok"
window.location="delete.html";
}, function() {
// user clicked cancel
alertify.error('Action canceled');
});
}
</script>
<table border="0" cellpadding="0" cellspacing="0" class="body">
<tr>
<td> </td>
<td class="container">
<div class="content">
<!-- START CENTERED WHITE CONTAINER -->
<table class="main">
<!-- START MAIN CONTENT AREA -->
<tr>
<td class="wrapper">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="./index.html"><h1 id="playername">Eazy-T</h1></a>
<button class="btn btn-primary" onclick="setRefreshrate()" type="button">Refresh rate</button>
<p></p>
<button class="btn btn-primary" onclick="setDark()" type="button">Dark Theme</button>
<p></p>
<button class="btn btn-primary" onclick="setDesktop()" type="button">Desktop Mode</button>
<p></p>
<button class="btn btn-primary" onclick="goDelete()" type="button">Delete cache & update app</button>
<p></p>
<button class="btn btn-primary" onclick="clearStorage()" type="button">Clear local storage (API key & settings)</button>
<p></p>
<button class="btn btn-primary" onclick="viewStored()" type="button">View all stored information</button>
<p></p>
<!--<button class="btnAdd" type="button">Install App (Chrome 68+)</button> -->
<p></p>
<p>Note: Api errors will be shown on this page as an alert box.</p>
<p>Note: Post issues here: <a href="https://www.torn.com/forums.php#/p=threads&f=67&t=16044679">Torn Forum Page</a></p>
</td>
</tr>
</table>
</td>
</tr>
<!-- END MAIN CONTENT AREA -->
</table>
<!-- START FOOTER -->
<div class="footer">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="content-block">
<table class="btn btn-primary">
<tbody>
<tr>
<td>
<center><table border="0" cellpadding="0" cellspacing="15">
<tbody>
<tr>
<td> <a onclick="goHome()"><i class="fas fa-home fa-2x"></i></a> </td>
<td> <a onclick="goAbout()"><i class="fas fa-info-circle fa-2x"></i></a> </td>
</tr>
</tbody>
</table></center>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
Deleting the API key & cache will resolve most issues.<br><br>
Created by: <a href="https://www.torn.com/profiles.php?XID=1947498">LunarControl</a>
</td>
</tr>
</table>
</div>
<!-- END FOOTER -->
<!-- END CENTERED WHITE CONTAINER -->
</div>
</td>
<td> </td>
</tr>
</table>
<script src="//unpkg.com/[email protected]/touch-emulator.js"></script>
<script>//TouchEmulator()</script>
<script type="text/javascript" src="js/pulltorefresh-js-0.1.14/dist/pulltorefresh.js"></script>
<script type="text/javascript" src="js/alertify.js"></script>
<script>
/* global PullToRefresh */
PullToRefresh.init({
mainElement: '#main',
onRefresh: function() { reloadApp(); }
});
</script>
</body>
</html>