forked from matkl/average-color
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (79 loc) · 3.55 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Average Colour</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="style.css" rel="stylesheet" inline> <!-- inlined! -->
<!-- SEO stuff -->
<meta name="description" content="Average Colour is a tool to find the average colour in an image.">
<meta name="keywords" content="PWA, tool, image">
<meta name="author" content="Thomas Rettig">
<link rel="canonical" href="https://avg-colour.netlify.app/">
<meta name="og:title" content="Average Colour">
<meta name="og:type" content="website">
<meta name="og:url" content="https://avg-colour.netlify.app/">
<meta name="og:image" content="https://avg-colour.netlify.app/og-image.png">
<meta name="twitter:title" content="Average Colour">
<meta name="twitter:description" content="Average Colour is a tool to find the average colour in an image.">
<meta name="twitter:site" content="@thomasrettig13">
<meta name="twitter:creator" content="@thomasrettig13">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://avg-colour.netlify.app/og-image.png">
<meta name="twitter:image:alt" content="An eyedropper icon placed next to text containing the words “Average Color’">
<!-- PWA stuff -->
<link href="favicon-light.svg" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: light)">
<link href="favicon-dark.svg" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: dark)">
<link rel="apple-touch-icon" href="apple-touch-icon-512x512.png">
<meta name="theme-color" content="#008080">
<link rel="manifest" href="manifest.webmanifest">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body>
<header>
<h1>Average Colour</h1>
<p>A tool to find the average colour in an image.</p>
</header>
<main id="target">
<label for="upload" id="upload-label">Drop images here (or click to upload)</label>
<input type="file" id="upload" aria-labelledby="upload-label" accept="image/png, image/jpeg, image/gif, image/jpg" multiple>
</main>
<!--PWA install prompt-->
<aside>
<button id="add-btn">Add to home</button>
<a href="about" id="about-btn">About</a>
</aside>
<!--Output-->
<section id="images"></section>
<!--Script begins-->
<script>
// register our service worker
if (navigator && navigator.serviceWorker) {
navigator.serviceWorker.register("sw.js");
}
let deferredPrompt;
const addBtn = document.getElementById("add-btn");
addBtn.style.display = "none";
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;
// Update UI to notify the user they can add to home screen
addBtn.style.display = "block";
addBtn.addEventListener("click", (e) => {
// hide our user interface that shows our A2HS button
addBtn.style.display = "none";
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
deferredPrompt = null;
});
});
});
</script>
<script src="average-color.js" inline></script>
</body>
</html>