Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Sound Track

Emmanuel Evuazeze evuazeze

💭
Sound Track
View GitHub Profile
View main.js
...
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
View main.js
...
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
View sw.js
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){
View main.js
/**
* Create form as soon as the page is loaded.
*/
document.addEventListener('DOMContentLoaded', (event) => {
createForm();
});
createForm = () => {
const container = document.querySelector('#form-container');
@evuazeze
evuazeze / index.html
Last active Nov 20, 2018
App Shell for example form
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Offline POSTs</title>
</head>
<body>
<section id="form-container"></section>
</body>
<script src="main.js"></script>
</html>
View restaurant_info.js
let restaurant;
var newMap;
var formEl = document.getElementById('form');
/**
* Initialize map as soon as the page is loaded.
*/
document.addEventListener('DOMContentLoaded', (event) => {
initMap();
});
@evuazeze
evuazeze / radiogroup.js
Last active Jul 26, 2018
Trying to wrap my head around this code from lesson 11 >> 14. Quiz: Implementing Keyboard Event Listeners. Anyone knows what focusedIdx represents or what it does?
View radiogroup.js
(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;