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
(function() { | |
'use strict'; | |
// Define values for keycodes | |
var VK_ENTER = 13; | |
var VK_SPACE = 32; | |
var VK_LEFT = 37; | |
var VK_UP = 38; | |
var VK_RIGHT = 39; | |
var VK_DOWN = 40; |
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
let restaurant; | |
var newMap; | |
var formEl = document.getElementById('form'); | |
/** | |
* Initialize map as soon as the page is loaded. | |
*/ | |
document.addEventListener('DOMContentLoaded', (event) => { | |
initMap(); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Offline POSTs</title> | |
</head> | |
<body> | |
<section id="form-container"></section> | |
</body> | |
<script src="main.js"></script> | |
</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
/** | |
* Create form as soon as the page is loaded. | |
*/ | |
document.addEventListener('DOMContentLoaded', (event) => { | |
createForm(); | |
}); | |
createForm = () => { | |
const container = document.querySelector('#form-container'); |
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
self.addEventListener('fetch', function(event) { | |
var request = event.request; | |
if (request.method === "POST") { | |
event.respondWith( | |
// Try to POST form data to server | |
fetch(event.request) | |
.catch(function() { | |
// If it doesn't work, post a message to reassure user | |
self.clients.matchAll().then(function (clients){ |
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
... | |
failedPostListener = () => { | |
navigator.serviceWorker.addEventListener('message', event => { | |
var form = document.getElementById('form'); | |
// Alert displays the message sent from our service worker | |
alert(event.data.msg); | |
// Assuming personal-details database have been created with |
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
... | |
handleConnectionChange = (event) => { | |
if(event.type == "online"){ | |
// Setup the request | |
var headers = new Headers(); | |
// Set some Headers | |
headers.set('Accept', 'application/json'); | |
// Get Data from indexedDB |
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
""" | |
:type firstname: {String} | |
:type lastname: {String} | |
:type age: {Integer}] | |
""" | |
def my_string_formatting(firstname, lastname, age): | |
print(f"Hello, my name is {firstname} {lastname}, I'm {age}") |