-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
184 lines (167 loc) · 9.22 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
<!DOCTYPE html>
<html>
<head>
<link rel="manifest" href="manifest.webmanifest">
<title>Tic Tac Toe</title>
<script src="game.js"></script>
<script src="spgame.js"></script>
<link type="text/css" rel="stylesheet" href="https://fluentdesignforweb.github.io/fluent.css">
<link type="text/css" rel="stylesheet" href="https://fluentdesignforweb.github.io/Icons/css/fluent-icons.css">
<link type="text/css" rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="pwabuilder-sw.js"></script>
<script>
let deferredPrompt = null;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
});
async function install() {
if (deferredPrompt) {
deferredPrompt.prompt();
console.log(deferredPrompt)
deferredPrompt.userChoice.then(function(choiceResult){
if (choiceResult.outcome === 'accepted') {
console.log('Your PWA has been installed');
} else {
console.log('User chose to not install your PWA');
}
deferredPrompt = null;
});
}
closeinstaller();
}
function showinstaller(){
document.getElementById("install_button").style.display="Block";
}
function closeinstaller(){
document.getElementById("install_button").style.display="none";
}
</script>
<script>
function checkinstall(){
if (window.matchMedia('(display-mode: standalone)').matches) {
closeinstaller();
console.log('display-mode is standalone');
}
else
showinstaller();
}
</script>
</head>
<body onload="checkinstall()">
<div class="content">
<div id="main_menu" class="page_container center primary_white">
<h1>Tic Tac Toe</h1>
<h3 class="ta_center">Select A Mode</h3>
<br><br>
<button class="large primary_inverted" onclick="spg()">Single Player</button><br>
<button class="large primary_inverted" onclick="mpg()">Two Players</button><br><br>
<button class="large primary_inverted" id="install_button" onclick="install()">Install Tic Tac Toe</button>
</div>
<div id="one_player_name" class="page_container center primary_white">
<h3 class="ta_center">Enter Name</h3>
<br><br>
<input class="center" id="namepx" type="text" placeholder="Input Name for Player"><br><br>
<h5 class="ta_center">Player Will Get First Chance</h5>
<br><br>
<div class="page_container columns small10 large8 medium8 center">
<button class="primary_inverted " onclick="mainmenu()" style="display: inline-block;">Main Menu</button>
<button class="primary_inverted" onclick="opgame()" style="display: inline-block;">Proceed</button><br><br>
</div>
</div>
<div id="two_player_name" class="page_container center primary_white">
<h3 class="ta_center">Enter Names</h3>
<br><br>
<input class="center" id="namex" type="text" placeholder="Input Name for Player X"><br><br>
<input class="center" id="namey" type="text" placeholder="Input Name for Player Y"><br><br><br>
<h5 class="ta_center">Player X Will Get First Chance</h5>
<br><br>
<div class="page_container columns small10 large8 medium8 center">
<button class="primary_inverted " onclick="mainmenu()" style="display: inline-block;">Main Menu</button>
<button class="primary_inverted" onclick="tpgame()" style="display: inline-block;">Proceed</button><br><br>
</div>
</div>
<div id="one_player_game" class="page_container center primary_white">
<h5 class="ta_center"><span id="playerxname1">Player</span> : <span id="scorex1">0</span></h5>
<h5 class="ta_center"><span id="">CPU</span> : <span id="scorey1">0</span></h5>
<div class="board">
<input type="text" id="box11" onclick="fill11();" value=" "/>
<input type="text" id="box21" onclick="fill21();" value=" "/>
<input type="text" id="box31" onclick="fill31();" value=" "/><br>
<input type="text" id="box41" onclick="fill41();" value=" "/>
<input type="text" id="box51" onclick="fill51();" value=" "/>
<input type="text" id="box61" onclick="fill61();" value=" "/><br>
<input type="text" id="box71" onclick="fill71();" value=" "/>
<input type="text" id="box81" onclick="fill81();" value=" "/>
<input type="text" id="box91" onclick="fill91();" value=" "/><br>
</div>
<br>
<h3 id="result1" class="ta_center"></h3>
<div class="page_container ta_center">
<button class=" primary_inverted" onclick="resetboard1();" style="display: inline-block;">Reset Board</button>
<button class=" primary_inverted" id="reset" onclick="reset1()" style="display: inline-block;">Reset Score</button>
<button class=" primary_inverted" id="install_button" onclick="spg()" style="display: inline-block;">Name Change</button>
<button class=" primary_inverted " onclick="mainmenu()" style="display: inline-block;">Main Menu</button><br><br>
</div>
</div>
<div id="two_player_game" class="page_container center primary_white">
<h5 class="ta_center"><span id="playerxname">Player X</span> : <span id="scorex">0</span></h5>
<h5 class="ta_center"><span id="playeryname">Player Y</span> : <span id="scorey">0</span></h5>
<div class="board">
<input type="text" id="box1" onclick="fill1();" value=" "/>
<input type="text" id="box2" onclick="fill2();" value=" "/>
<input type="text" id="box3" onclick="fill3();" value=" "/><br>
<input type="text" id="box4" onclick="fill4();" value=" "/>
<input type="text" id="box5" onclick="fill5();" value=" "/>
<input type="text" id="box6" onclick="fill6();" value=" "/><br>
<input type="text" id="box7" onclick="fill7();" value=" "/>
<input type="text" id="box8" onclick="fill8();" value=" "/>
<input type="text" id="box9" onclick="fill9();" value=" "/><br>
</div>
<br>
<h3 id="result" class="ta_center"></h3>
<div class="page_container ta_center">
<button class=" primary_inverted" onclick="resetboard();" style="display: inline-block;">Reset Board</button>
<button class=" primary_inverted" id="reset" onclick="reset()" style="display: inline-block;">Reset Score</button>
<button class=" primary_inverted" id="install_button" onclick="mpg()" style="display: inline-block;">Name Change</button>
<button class=" primary_inverted " onclick="mainmenu()" style="display: inline-block;">Main Menu</button><br><br>
</div>
</div>
</div>
<div class="modal_container" id="install_button_surface">
<div class="modal_content zi2">
<br><br><br><br><br><br><br><br>
<div class="column large6 medium8 small12 center">
<button class="circular primary_red right" style="width: 50px; height: 50px; padding: 0px;" onclick="closeinstaller()">
<i class="ms-Icon ms-Icon--Cancel"></i>
</button><br><br><br><br>
<button id="install_button" class="primary_blue center" onclick="install();" style="height: 100px; width: 300px; font-size: 28px;">
Install Tic Tac Toe
</button>
</div>
</div>
</div>
</body>
<script>
// This is the "Offline copy of pages" service worker
// Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
// Check compatibility for the browser we're running this in
if ("serviceWorker" in navigator) {
if (navigator.serviceWorker.controller) {
console.log("[PWA Builder] active service worker found, no need to register");
} else {
// Register the service worker
navigator.serviceWorker
.register("pwabuilder-sw.js", {
scope: "./"
})
.then(function (reg) {
console.log("[PWA Builder] Service worker has been registered for scope: " + reg.scope);
});
}
}
</script>
</html>