-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,294 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"background_color":"#000000","display":"standalone","icons":[{"sizes":"144x144","src":"index.144x144.png","type":"image/png"},{"sizes":"180x180","src":"index.180x180.png","type":"image/png"},{"sizes":"512x512","src":"index.512x512.png","type":"image/png"}],"name":"UTY","orientation":"any","start_url":"./index.html"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!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"> | ||
<title>You are offline</title> | ||
<style> | ||
html { | ||
background-color: #000000; | ||
color: #ffffff; | ||
} | ||
|
||
body { | ||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; | ||
margin: 2rem; | ||
} | ||
|
||
p { | ||
margin-block: 1rem; | ||
} | ||
|
||
button { | ||
display: block; | ||
padding: 1rem 2rem; | ||
margin: 3rem auto 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>You are offline</h1> | ||
<p>This application requires an Internet connection to run for the first time.</p> | ||
<p>Press the button below to try reloading:</p> | ||
<button type="button">Reload</button> | ||
<script> | ||
document.querySelector('button').addEventListener('click', () => { | ||
window.location.reload(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// This service worker is required to expose an exported Godot project as a | ||
// Progressive Web App. It provides an offline fallback page telling the user | ||
// that they need an Internet connection to run the project if desired. | ||
// Incrementing CACHE_VERSION will kick off the install event and force | ||
// previously cached resources to be updated from the network. | ||
const CACHE_VERSION = "1708874288|437342416"; | ||
const CACHE_PREFIX = "UTY-sw-cache-"; | ||
const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION; | ||
const OFFLINE_URL = "index.offline.html"; | ||
// Files that will be cached on load. | ||
const CACHED_FILES = ["index.html","index.js","index.offline.html","index.icon.png","index.apple-touch-icon.png","index.worker.js","index.audio.worklet.js"]; | ||
// Files that we might not want the user to preload, and will only be cached on first load. | ||
const CACHABLE_FILES = ["index.wasm","index.pck"]; | ||
const FULL_CACHE = CACHED_FILES.concat(CACHABLE_FILES); | ||
|
||
self.addEventListener("install", (event) => { | ||
event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(CACHED_FILES))); | ||
}); | ||
|
||
self.addEventListener("activate", (event) => { | ||
event.waitUntil(caches.keys().then( | ||
function (keys) { | ||
// Remove old caches. | ||
return Promise.all(keys.filter(key => key.startsWith(CACHE_PREFIX) && key != CACHE_NAME).map(key => caches.delete(key))); | ||
}).then(function() { | ||
// Enable navigation preload if available. | ||
return ("navigationPreload" in self.registration) ? self.registration.navigationPreload.enable() : Promise.resolve(); | ||
}) | ||
); | ||
}); | ||
|
||
async function fetchAndCache(event, cache, isCachable) { | ||
// Use the preloaded response, if it's there | ||
let response = await event.preloadResponse; | ||
if (!response) { | ||
// Or, go over network. | ||
response = await self.fetch(event.request); | ||
} | ||
if (isCachable) { | ||
// And update the cache | ||
cache.put(event.request, response.clone()); | ||
} | ||
return response; | ||
} | ||
|
||
self.addEventListener("fetch", (event) => { | ||
const isNavigate = event.request.mode === "navigate"; | ||
const url = event.request.url || ""; | ||
const referrer = event.request.referrer || ""; | ||
const base = referrer.slice(0, referrer.lastIndexOf("/") + 1); | ||
const local = url.startsWith(base) ? url.replace(base, "") : ""; | ||
const isCachable = FULL_CACHE.some(v => v === local) || (base === referrer && base.endsWith(CACHED_FILES[0])); | ||
if (isNavigate || isCachable) { | ||
event.respondWith(async function () { | ||
// Try to use cache first | ||
const cache = await caches.open(CACHE_NAME); | ||
if (event.request.mode === "navigate") { | ||
// Check if we have full cache during HTML page request. | ||
const fullCache = await Promise.all(FULL_CACHE.map(name => cache.match(name))); | ||
const missing = fullCache.some(v => v === undefined); | ||
if (missing) { | ||
try { | ||
// Try network if some cached file is missing (so we can display offline page in case). | ||
return await fetchAndCache(event, cache, isCachable); | ||
} catch (e) { | ||
// And return the hopefully always cached offline page in case of network failure. | ||
console.error("Network error: ", e); | ||
return await caches.match(OFFLINE_URL); | ||
} | ||
} | ||
} | ||
const cached = await cache.match(event.request); | ||
if (cached) { | ||
return cached; | ||
} else { | ||
// Try network if don't have it in cache. | ||
return await fetchAndCache(event, cache, isCachable); | ||
} | ||
}()); | ||
} | ||
}); | ||
|
||
self.addEventListener("message", (event) => { | ||
// No cross origin | ||
if (event.origin != self.origin) { | ||
return; | ||
} | ||
const id = event.source.id || ""; | ||
const msg = event.data || ""; | ||
// Ensure it's one of our clients. | ||
self.clients.get(id).then(function (client) { | ||
if (!client) { | ||
return; // Not a valid client. | ||
} | ||
if (msg === "claim") { | ||
self.skipWaiting().then(() => self.clients.claim()); | ||
} else if (msg === "clear") { | ||
caches.delete(CACHE_NAME); | ||
} else if (msg === "update") { | ||
self.skipWaiting().then(() => self.clients.claim()).then(() => self.clients.matchAll()).then(all => all.forEach(c => c.navigate(c.url))); | ||
} else { | ||
onClientMessage(event); | ||
} | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
minesweeper | ||
=========== | ||
Clone of Microsoft's Minesweeper from Windows XP. An effort was made to duplicate every feature (excluding menus) as exactly as possible. | ||
|
||
Demo: https://ziebelje.github.io/minesweeper/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background-color: #bdbdbd; | ||
} | ||
|
||
#play_area { | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Minesweeper</title> | ||
<script type="text/javascript" src="js/rocket.12.06.js"></script> | ||
<script type="text/javascript" src="js/seedrandom.js"></script> | ||
<script type="text/javascript" src="js/minesweeper.js"></script> | ||
<script type="text/javascript" src="js/tile.js"></script> | ||
<script type="text/javascript" src="js/face.js"></script> | ||
<script type="text/javascript" src="js/grid.js"></script> | ||
<script type="text/javascript" src="js/ssd.js"></script> | ||
<link rel="stylesheet" href="css/minesweeper.css"> | ||
</head> | ||
<body> | ||
<div id="play_area"></div> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
arcade.minesweeper.face = function(minesweeper, container) { | ||
this.minesweeper = minesweeper; | ||
container.appendChild(this.get_element()); | ||
} | ||
|
||
arcade.minesweeper.face.prototype.minesweeper; | ||
arcade.minesweeper.face.prototype.state; | ||
arcade.minesweeper.face.prototype.element; | ||
arcade.minesweeper.face.prototype.mouse_left = 1; | ||
arcade.minesweeper.face.prototype.mouse_right = 3; | ||
|
||
arcade.minesweeper.face.prototype.get_element = function() { | ||
var self = this; | ||
if(!this.element) { | ||
this.element = $.createElement("div") | ||
.style({"width": 26, "height": 26, "margin": "auto", "background-image": "url('image/sprite.png')", "background-repeat": "no-repeat"}) | ||
.addEventListener("mousedown", function() { | ||
if(self.state === "smile") self.set_state("depressed_smile"); | ||
}) | ||
.addEventListener("mouseup", function() { | ||
if(self.state === "depressed_smile") { | ||
self.set_state("smile"); | ||
self.minesweeper.restart(); | ||
} | ||
}) | ||
.addEventListener("mouseout", function() { | ||
if(self.state === "depressed_smile") self.set_state("smile"); | ||
}) | ||
.addEventListener("mouseover", function(e) { | ||
if(e.which === self.mouse_left && self.state === "smile") self.set_state("depressed_smile"); | ||
}) | ||
this.set_state("smile"); | ||
} | ||
return this.element[0]; | ||
} | ||
|
||
arcade.minesweeper.face.prototype.set_state = function(state) { | ||
this.state = state; | ||
switch(state) { | ||
case "smile": | ||
this.element.style({"background-position": "0px -55px"}) | ||
break; | ||
case "depressed_smile": | ||
this.element.style({"background-position": "-26px -55px"}); | ||
break; | ||
case "scared": | ||
this.element.style({"background-position": "-52px -55px"}); | ||
break; | ||
case "dead": | ||
this.element.style({"background-position": "-78px -55px"}); | ||
break; | ||
case "sunglasses": | ||
this.element.style({"background-position": "-104px -55px"}); | ||
break; | ||
} | ||
} | ||
arcade.minesweeper.face.prototype.get_state = function() { | ||
return this.state; | ||
} |
Oops, something went wrong.