-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
111 lines (82 loc) · 4.38 KB
/
game.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
<!DOCTYPE html>
<html>
<head>
<title> game setup </title>
<script src="game_function.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.32.2/es6-shim.min.js"> </script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/history.js/1.8/bundled-uncompressed/html4+html5/jquery.history.js"> </script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="game-styles.css">
<link rel="stylesheet" href="//en.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint,shared|mediawiki.skinning.elements|mediawiki.skinning.content|mediawiki.skinning.interface|skins.vector.styles|site|mediawiki.skinning.content.parsoid|ext.cite.style&only=styles&skin=vector"/>
</head>
<body>
<header id = "header-game">
<div class="wrapper">
<div>
<div id="header-image">
</div>
<div id="header-title">
<h1> The Wiki Game</h1>
</div>
</div>
<nav>
<ul>
<li> <a href="set-game.html"> Play </a></li>
<li> <a href="home.html"> Home </a></li>
</ul>
</nav>
</div>
</header>
<section id="game-info">
<p style="font-size: 40px" id = "word-to-find"> Article to find : </p>
<p id="timer"> time left : </p>
<a href="set-game.html" class="button" style = 'display: none' id='button-return'>play again</a>
<script>
// starts the countdown
max_time = +sessionStorage.getItem('max_time');
countdown(max_time);
</script>
</section>
<section id="wiki-pages">
<div class='container'>
<h1 id="wiki-title"></h1>
<div id="content"></div>
<script>
var titleElem = document.getElementById('wiki-title');
var contentElem = document.getElementById('content');
var stylesheetElem = document.getElementById('style');
var savedFirstPage = sessionStorage.getItem('saved_first_page');
var savedTargetPage = sessionStorage.getItem('saved_target_page');
var firstPageRequest, targetPageRequest;
// check if the initial and target article have already been fetched
if(sessionStorage.getItem('target_title') === null && sessionStorage.getItem('target') === null){
targetPageRequest = fetchFeaturedArticle();
firstPageRequest = fetchFeaturedArticle();
}
$(window).on('statechange load', function () {
// if the article have already been fetched
if(sessionStorage.getItem('target_title') !== null && sessionStorage.getItem('title') !== null ){
loadPage(History.getState().title, sessionStorage.getItem('target_title'), titleElem, contentElem, stylesheetElem);
}
else { // otherwise use what the request return from the fetchFeaturedArticle() function.
$.when(targetPageRequest,firstPageRequest).done(function(title, targetTitle) {
sessionStorage.setItem('target_title', targetTitle);
sessionStorage.setItem('title', title);
loadPage(title, targetTitle, titleElem, contentElem, stylesheetElem);
});
}
});
</script>
</div>
</section>
<footer>
<h1> The Wiki Game </h1>
<div class="copyright">
Copyright 2020
</div>
</footer>
</body>
</html>