Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ html, body {
}

body {
background-color: blueviolet;
height: 100vh;
background: blueviolet;
background: linear-gradient(to right, #6100c2, #a100bd);
}

*[hidden] {
Expand Down Expand Up @@ -212,10 +214,11 @@ form#result button#submit {
font-size: 0.75em;
}

@media screen and (max-width: 650px), (max-height: 500px) {
@media screen and (max-width: 620px), (max-height: 500px) {
body {
height: auto;
min-height: 100vh;
background: none;
}

main {
Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Check the UUID of your Minecraft username with a click of a button!">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#16222a">
<title>What's my Minecraft UUID?</title>
<link rel="stylesheet" href="./css/style.css">
<link rel="stylesheet" href="./css/icons.css">
Expand Down
6 changes: 5 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ window.addEventListener("DOMContentLoaded", function(event) {
uuidResult.focus();
uuidResult.select();
});
}, false);
}, false);

if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/js/worker.js");
}
57 changes: 57 additions & 0 deletions js/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var CACHE = "mc-uuid";

// On install, cache some resources.
self.addEventListener("install", function(evt) {
console.log("The service worker is being installed.");

// Ask the service worker to keep installing until the returning promise
// resolves.
evt.waitUntil(precache());
});

// On fetch, use cache but update the entry with the latest contents
// from the server.
self.addEventListener("fetch", function(event) {
console.log("The service worker is serving the asset.");
// You can use `respondWith()` to answer immediately, without waiting for the
// network response to reach the service worker...
event.respondWith(fromCache(event.request));
// ...and `waitUntil()` to prevent the worker from being killed until the
// cache is updated.
event.waitUntil(update(event.request));
});

// Open a cache and use `addAll()` with an array of assets to add all of them
// to the cache. Return a promise resolving when all the assets are added.
function precache() {
return caches.open(CACHE).then(function (cache) {
return cache.addAll([
"/",
"/index.html",
"/css",
"/font",
"/js"
]);
});
}

// Open the cache where the assets were stored and search for the requested
// resource. Notice that in case of no matching, the promise still resolves
// but it does with `undefined` as value.
function fromCache(request) {
return caches.open(CACHE).then(function (cache) {
return cache.match(request).then(function (matching) {
return matching || Promise.reject("no-match");
});
});
}

// Update consists in opening the cache, performing a network request and
// storing the new response data.
function update(request) {
return caches.open(CACHE).then(function (cache) {
return fetch(request).then(function (response) {
return cache.put(request, response);
});
});
}
9 changes: 9 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "What's my Minecraft UUID?",
"short_name": "Minecraft UUID",
"theme_color": "#2196f3",
"background_color": "#2196f3",
"display": "standalone",
"scope": "https://mc-uuid.jasonhk.net",
"start_url": "/"
}