moar slides, disable localhost pwa cache

This commit is contained in:
Jeremy Likness 2020-01-28 10:23:02 -08:00
parent 0b60742e8a
commit dad9a93078
8 changed files with 122 additions and 25 deletions

View File

@ -4,6 +4,10 @@ body {
font-size: 3vh;
}
code {
font-size: 3vh;
}
br {
clear: both;
}
@ -63,8 +67,23 @@ slide-deck img.expandable:hover {
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) {
body {
body, code {
font-size: 14px;
}
button, input {
@ -74,10 +93,13 @@ slide-deck img.expandable:hover {
label > div, input {
width: 90vw;
}
div.card {
width: 80vw;
}
}
@media only screen and (max-width: 1200px) {
body {
body, code {
font-size: 2vh;
}
button, input {
@ -123,6 +145,7 @@ img {
.center {
text-align: center;
vertical-align: middle;
}
slide-deck > div {

BIN
images/triad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

38
pwa.js
View File

@ -33,7 +33,7 @@ class Pwa {
* Cache version
* @type {number}
*/
this.CACHE_VERSION = 1.0;
this.CACHE_VERSION = 1.2;
/**
* Pre-emptive files to cache
* @type {string[]}
@ -181,24 +181,26 @@ class Pwa {
this.scope.addEventListener('fetch', event => {
event.respondWith(
caches.open(this.CACHE_NAME).then(async cache => {
const response = await cache.match(event.request);
if (response) {
// found it, see if expired
const headers = response.headers.entries();
let date = null;
for (let pair of headers) {
if (pair[0] === 'date') {
date = new Date(pair[1]);
break;
if (!event.request.url.startsWith("http://localhost")) {
const response = await cache.match(event.request);
if (response) {
// found it, see if expired
const headers = response.headers.entries();
let date = null;
for (let pair of headers) {
if (pair[0] === 'date') {
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

View File

@ -1,8 +1,10 @@
<title>Why Frameworks in the First Place?</title>
<h1>Why Frameworks in the First Place?</h1>
<ul>
<li class="appear" repeat="why">{{item}}</li>
</ul>
<div class="center">
<div class="card appear" repeat="why">
<span>{{item}}</span>
</div>
</div>
<script>
this.why = [
"Differences in the DOM (i.e. jQuery normalization)",
@ -11,7 +13,8 @@
"Asynchronous module loading/dependency graph",
"Testability",
"Databinding",
"Contacts (Types and Interfaces ➡ TypeScript)",
"Contracts (Types and Interfaces ➡ TypeScript)",
"Minification or \"Packing\""
];
</script>
</script>
<next-slide>090-embrace</next-slide>

4
slides/090-embrace.html Normal file
View 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>

View 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
View 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 &lt; 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
View 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>