-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
356 lines (326 loc) · 14.2 KB
/
index.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HiraRPG</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="node_modules/moment/moment.js"></script>
<script src="js/entities/HiraButton.js"></script>
<script src="js/entities/StoryLevel.js"></script>
<script src="js/entities/Dungeon.js"></script>
<script src="js/entities/Unit.js"></script>
<script src="js/entities/Projectile.js"></script>
<script src="js/entities/HiraPress.js"></script>
<script src="js/entities/HiraText.js"></script>
<script src="js/scenes/BootScene.js"></script>
<script src="js/scenes/WorldNavScene.js"></script>
<script src="js/scenes/MessageScene.js"></script>
<script src="js/scenes/StatsScene.js"></script>
<script src="js/scenes/DialogBoxScene.js"></script>
<script src="js/scenes/CutScene.js"></script>
<script src="js/scenes/CutSceneV2.js"></script>
<script src="js/scenes/CutLoaderScene.js"></script>
<script src="js/scenes/TrainScene.js"></script>
<script src="js/scenes/DungeonScene.js"></script>
<script src="js/scenes/DetailScene.js"></script>
<script src="js/scenes/HintScene.js"></script>
<script src="js/scenes/BattleScene.js"></script>
<script src="js/scenes/ResultScene.js"></script>
<script src="js/scenes/MultipleChoiceScene.js"></script>
<script src="js/scenes/MatchingTypeScene.js"></script>
<script src="js/scenes/JournalScene.js"></script>
<script src="js/scenes/LogScene.js"></script>
<script src="js/scenes/SchedulerScene.js"></script>
<script src="js/scenes/MainScene.js"></script>
<script src="js/game.js"></script>
<style>
html,
body {
margin: 20px;
padding: 0;
background: lightblue;
}
@font-face {
font-family: manaspc;
src: url('assets/font/caudex/Caudex-Regular.ttf');
font-weight:200;
font-weight:normal;
}
#warning-message { display: none; }
@media only screen and (max-width: 768px){
#wrapper { display:none; }
#warning-message { display:block; }
}
/* @media only screen and (orientation:landscape){
#warning-message { display:block; }
} */
@media only screen and (max-width: 768px) {
#this-mobile { display: none; }
}
.center-div {
margin: 0% auto;
padding-top: 3px;
width: 75%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background: white;
min-width: 70px;
}
.modal {
display: block; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 10% auto; /* 15% from the top and centered */
padding: 10px;
border: 1px solid #888;
width: 30%; /* Could be more or less, depending on screen size */
}
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
text-align: center;
font-size: 1.5em;
}
input[type=password], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
text-align: center;
font-size: 1.5em;
}
input[type=submit], select {
width: 100%;
background-color: #272744;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.5em;
}
button {
width: 100%;
background-color: #272744;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.5em;
}
button:hover {
background-color: #32B3ED;
}
.game-area {
display: block;
width: 100%;
text-align:center;
font-smooth:never;
cursor: url('assets/images/cursor/normal.png'),url('assets/images/cursor/disabled.png'),url('assets/images/cursor/hover.png'), auto;
}
h1 {
font-size: 3em;
}
label {
font-size: 1.5em;
}
</style>
</head>
<body>
<h1 id="header_message" style="font-family:'manaspc';padding:20px;text-align:center;">Hira Alpha 1.0</h1>
<div id="this-mobile"></div>
<div id="wrapper">
<div class="center-div">
<div style="font-family:'manaspc';position: absolute;left: -1000px;visibility: hidden;font-smooth:never;">.</div>
<div id="content" class="game-area"></div>
</div>
<h3 style="font-family:'manaspc';padding:20px;text-align:center;">Don't forget to logout to avoid losing data.</h3>
<h3 style="font-family:'manaspc';padding:20px;text-align:center;">Contact me: [email protected]</h3>
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<h1 id="message" style="font-family:'manaspc';text-align:center;">Welcome!</h1>
<button type="button" style="font-family:'manaspc'" id="chooseLogin" >Login</button>
<button type="button" style="font-family:'manaspc'" id="chooseSignup" >Signup</button>
</div>
</div>
</div>
<div id="warning-message" style="font-family:'manaspc';text-align:center;">
<h1>Hira is playable only on desktop.</h1>
<!-- <h2>Enable the onscreen keyboard while in battle by clicking the OKB button on the bottom right of the screen.</h2>
<h3>Also, don't forget to logout to avoid losing data.</h3> -->
</div>
</body>
</html>
<script>
var me = this;
var logged_out = false;
console.log(window.location);
var game_url = "";
$(function () {
game_url = window.location.origin + '/';
console.log(game_url);
});
$('#myModal').on('click', '#chooseLogin',function() {
var loginContent = "<div class='modal-content'><div id='loginForm' style='font-family:\"manaspc\";text-align:center;'><h1 id='message'>Welcome!</h1><form ><label for='username'>Username</label><input type='text' id='username' name='Username' placeholder='Username' style='font-family:\"manaspc\"'><label for='lname'>Password</label><input type='password' id='password' name='Password' placeholder='Password' ><button style='font-family:\"manaspc\"' id='loginButton' value=\"Login\">Login</button></form></div></div>";
$('#myModal').html(loginContent);
});
$('#chooseSignup').click(function() {
var signupContent = " <div class='modal-content'> <div id='loginForm' style='font-family:\"manaspc\";padding:20px;text-align:center;'> <h2 id='signupMessage'>Signup!</h2> <form > <label for='username'>Username</label> <input type='text' id='usernameS' name='Username' placeholder='Username' style='font-family:\"manaspc\"'> <label for='lname'>Password</label> <input type='password' id='password0' name='Password' placeholder='Password' > <label for='lname'>Retype Password</label> <input type='password' id='password1' name='Password' placeholder='Retype Password' style='-webkit-text-security: square;'> <button type='button' style='font-family:\"manaspc\"' id='signUpButton' >Signup</button> </form> </div> </div>";
$('#myModal').html(signupContent);
});
// $('#logout').click(function() {
// if(game.player_name !== '' && !game.logged_out){
// /* end session */
// console.log(game.player_name);
// $.ajax({
// url: game_url + "logout",
// headers: {"Authorization": "Bearer " + game.token },
// type: "POST",
// async: true,
// contentType: "application/json",
// success: function (responseData) {
// $('#myModal').show();
// var logoutMessage = "<div class='modal-content'> <h1 style='font-family:\"manaspc\";padding:20px;text-align:center;'>Logged out and " + responseData['message'] + "</h1><h3 style='font-family:\"manaspc\";padding:20px;text-align:center;'>You can now safely exit.</h3></div>";
// $('#myModal').html(logoutMessage);
// logged_out = true;
// },
// error: function (xhr) {
// // console.log(xhr.responseJSON.message);
// if(xhr.responseJSON){
// $( "#message" ).text(xhr.responseJSON.message);
// } else {
// $( "#message" ).text("Unable to contact server! Please refresh page.");
//
// }
// $( '#loginButton' ).prop('disabled', false);
// $( "#loginButton" ).css('background-color', '#272744');
// }
// });
// }
// });
$('#myModal').on('click', '#loginButton', function(e){
e.preventDefault();
toggleFullScreen();
var data = { "username" : $( "#username" ).val(), "password": $( "#password" ).val()};
$( "#message" ).text("Logging in...");
$( '#loginButton' ).prop('disabled', true);
$(this).css('background-color', 'gray');
$.ajax({
url: game_url + "login",
type: "POST",
data: JSON.stringify(data),
contentType: "application/json",
success: function (responseData) {
// console.log(responseData);
$( "#myModal" ).hide();
game.player_name = responseData['username'];
game.story = responseData['story'];
game.charset = responseData['charset'];
game.token = responseData['token'];
game.sched = responseData['sched'];
game.loaded = true;
},
error: function (xhr) {
// console.log(xhr.responseJSON.message);
if(xhr.responseJSON){
$( "#message" ).text(xhr.responseJSON.message);
} else {
$( "#message" ).text("Unable to contact server! Please refresh page.");
}
$( '#loginButton' ).prop('disabled', false);
$( "#loginButton" ).css('background-color', '#272744');
}
});
});
$('#myModal').on('click', '#signUpButton', function(){
var data = { "username" : $( "#usernameS" ).val(), "password": $( "#password0" ).val(), "password1": $( "#password1" ).val()};
$( "#message" ).text("Signing up...");
$( '#signUpButton' ).prop('disabled', true);
$(this).css('background-color', 'gray');
$.ajax({
url: game_url + "signup",
type: "POST",
data: JSON.stringify(data),
contentType: "application/json",
success: function (responseData) {
var success = "<div class='modal-content'><h1 id='message' style='font-family:\"manaspc\";padding:20px;text-align:center;'>Account registered successfully!</h2><button type='button' style='font-family:\"manaspc\"' id='chooseLogin' >Login</button></div>";
$('#myModal').html(success);
},
error: function (xhr) {
// console.log(xhr.responseJSON.message);
if(xhr.responseJSON){
$( "#signupMessage" ).text(xhr.responseJSON.message);
} else {
$( "#signupMessage" ).text("Unable to contact server! Please refresh page.");
}
$( '#signUpButton' ).prop('disabled', false);
$( "#signUpButton" ).css('background-color', '#272744');
}
});
});
function toggleFullScreen() {
if( $('#this-mobile').css('display')=='none') {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
}
$(window).on("beforeunload", function(e) {
var payload = {distracted: game.distracted, idle: game.idle};
if(game.player_name !== '' && !game.logged_out){
/* end session */
logged_out = true;
console.log(game.player_name);
$.ajax({
url: game_url + "logout",
headers: {"Authorization": "Bearer " + game.token },
type: "POST",
contentType: "application/json",
data: JSON.stringify(payload)
});
}
});
</script>