mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2024-12-04 19:27:37 +00:00
moar slides, disable localhost pwa cache
This commit is contained in:
parent
0b60742e8a
commit
dad9a93078
@ -4,6 +4,10 @@ body {
|
|||||||
font-size: 3vh;
|
font-size: 3vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-size: 3vh;
|
||||||
|
}
|
||||||
|
|
||||||
br {
|
br {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
@ -63,8 +67,23 @@ slide-deck img.expandable:hover {
|
|||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.card {
|
||||||
|
margin: 0.5em;
|
||||||
|
padding: 1.0em;
|
||||||
|
float: left;
|
||||||
|
text-align: center;
|
||||||
|
border: solid 2px darkgreen;
|
||||||
|
background: lightcyan;
|
||||||
|
width: 18vw;
|
||||||
|
height: 12vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.card span {
|
||||||
|
height: 12vh;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 800px) {
|
@media only screen and (max-width: 800px) {
|
||||||
body {
|
body, code {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
button, input {
|
button, input {
|
||||||
@ -74,10 +93,13 @@ slide-deck img.expandable:hover {
|
|||||||
label > div, input {
|
label > div, input {
|
||||||
width: 90vw;
|
width: 90vw;
|
||||||
}
|
}
|
||||||
|
div.card {
|
||||||
|
width: 80vw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 1200px) {
|
@media only screen and (max-width: 1200px) {
|
||||||
body {
|
body, code {
|
||||||
font-size: 2vh;
|
font-size: 2vh;
|
||||||
}
|
}
|
||||||
button, input {
|
button, input {
|
||||||
@ -123,6 +145,7 @@ img {
|
|||||||
|
|
||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
slide-deck > div {
|
slide-deck > div {
|
||||||
|
BIN
images/triad.png
Normal file
BIN
images/triad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
38
pwa.js
38
pwa.js
@ -33,7 +33,7 @@ class Pwa {
|
|||||||
* Cache version
|
* Cache version
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.CACHE_VERSION = 1.0;
|
this.CACHE_VERSION = 1.2;
|
||||||
/**
|
/**
|
||||||
* Pre-emptive files to cache
|
* Pre-emptive files to cache
|
||||||
* @type {string[]}
|
* @type {string[]}
|
||||||
@ -181,24 +181,26 @@ class Pwa {
|
|||||||
this.scope.addEventListener('fetch', event => {
|
this.scope.addEventListener('fetch', event => {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
caches.open(this.CACHE_NAME).then(async cache => {
|
caches.open(this.CACHE_NAME).then(async cache => {
|
||||||
const response = await cache.match(event.request);
|
if (!event.request.url.startsWith("http://localhost")) {
|
||||||
if (response) {
|
const response = await cache.match(event.request);
|
||||||
// found it, see if expired
|
if (response) {
|
||||||
const headers = response.headers.entries();
|
// found it, see if expired
|
||||||
let date = null;
|
const headers = response.headers.entries();
|
||||||
for (let pair of headers) {
|
let date = null;
|
||||||
if (pair[0] === 'date') {
|
for (let pair of headers) {
|
||||||
date = new Date(pair[1]);
|
if (pair[0] === 'date') {
|
||||||
break;
|
date = new Date(pair[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!date) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
const age = parseInt(((new Date().getTime() - date.getTime()) / 1000).toString());
|
||||||
|
const ttl = this.getTTL(event.request.url);
|
||||||
|
if (ttl === null || (ttl && age < ttl)) {
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!date) {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
const age = parseInt(((new Date().getTime() - date.getTime()) / 1000).toString());
|
|
||||||
const ttl = this.getTTL(event.request.url);
|
|
||||||
if (ttl === null || (ttl && age < ttl)) {
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not found or expired, fresh request
|
// not found or expired, fresh request
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
<title>Why Frameworks in the First Place?</title>
|
<title>Why Frameworks in the First Place?</title>
|
||||||
<h1>Why Frameworks in the First Place?</h1>
|
<h1>Why Frameworks in the First Place?</h1>
|
||||||
<ul>
|
<div class="center">
|
||||||
<li class="appear" repeat="why">{{item}}</li>
|
<div class="card appear" repeat="why">
|
||||||
</ul>
|
<span>{{item}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
this.why = [
|
this.why = [
|
||||||
"Differences in the DOM (i.e. jQuery normalization)",
|
"Differences in the DOM (i.e. jQuery normalization)",
|
||||||
@ -11,7 +13,8 @@
|
|||||||
"Asynchronous module loading/dependency graph",
|
"Asynchronous module loading/dependency graph",
|
||||||
"Testability",
|
"Testability",
|
||||||
"Databinding",
|
"Databinding",
|
||||||
"Contacts (Types and Interfaces ➡ TypeScript)",
|
"Contracts (Types and Interfaces ➡ TypeScript)",
|
||||||
"Minification or \"Packing\""
|
"Minification or \"Packing\""
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
|
<next-slide>090-embrace</next-slide>
|
4
slides/090-embrace.html
Normal file
4
slides/090-embrace.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<title>Embrace the Triad</title>
|
||||||
|
<h1>Embrace the Triad</h1>
|
||||||
|
<img src="/images/triad.png" alt="The triad: JavaScript, CSS3 and HTML5"/>
|
||||||
|
<next-slide>100-javascript-new</next-slide>
|
20
slides/100-javascript-new.html
Normal file
20
slides/100-javascript-new.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<title>What's New with JavaScript?</title>
|
||||||
|
<h1>What's New with JavaScript?</h1>
|
||||||
|
<div class="center">
|
||||||
|
<div class="card appear" repeat="whatsnew">
|
||||||
|
<span>{{item}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
this.whatsnew = [
|
||||||
|
"Scope and Variables",
|
||||||
|
"Powerful Strings",
|
||||||
|
"The Spread Operator",
|
||||||
|
"Destructuring",
|
||||||
|
"Parameters",
|
||||||
|
"Classes",
|
||||||
|
"Modules",
|
||||||
|
"...and a lot more!"
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
<next-slide>110-variables</next-slide>
|
19
slides/110-variables.html
Normal file
19
slides/110-variables.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<title>JavaScript Scope and Variables</title>
|
||||||
|
<h1>JavaScript Scope and Variables</h1>
|
||||||
|
<pre>var x = 1;</pre>
|
||||||
|
<pre class="appear">
|
||||||
|
// local scope
|
||||||
|
for (let x = 1; x < 100; x+=1) {...}
|
||||||
|
var y = 1;
|
||||||
|
function process(inp) {
|
||||||
|
let y = inp * 2;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
process(y);
|
||||||
|
</pre>
|
||||||
|
<pre class="appear">
|
||||||
|
// constants
|
||||||
|
const x = 1;
|
||||||
|
x = 2; // 💣 BOOM!
|
||||||
|
</pre>
|
||||||
|
<next-slide>120-gosinta</next-slide>
|
26
slides/120-gosinta.html
Normal file
26
slides/120-gosinta.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<title>Arrow Functions (Gosinta)</title>
|
||||||
|
<h1>Arrow Functions (Gosinta)</h1>
|
||||||
|
<pre>
|
||||||
|
var solarsystem = {
|
||||||
|
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter',
|
||||||
|
'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
|
||||||
|
showPlanets: function() {
|
||||||
|
this.planets.forEach(function(planet, idx) {
|
||||||
|
console.log(this.planets[idx]);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
solarsystem.showPlanets(); // crash! ⛔
|
||||||
|
</pre>
|
||||||
|
<pre class="appear">
|
||||||
|
var solarsystem = {
|
||||||
|
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter',
|
||||||
|
'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
|
||||||
|
showPlanets: function() {
|
||||||
|
this.planets.forEach((planet, idx) => {
|
||||||
|
console.log(this.planets[idx]);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
solarsystem.showPlanets(); // success! 🌍
|
||||||
|
</pre>
|
Loading…
Reference in New Issue
Block a user