This file contains hidden or 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
importScripts('path/to/offline-google-analytics-import.js'); | |
goog.offlineGoogleAnalytics.initialize(); | |
// Implement any other service worker caching strategies appropriate for your web app. |
This file contains hidden or 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 getFilenameFromUrl(path){ | |
path = path.substring(path.lastIndexOf("/")+ 1); | |
return (path.match(/[^.]+(\.[^?#]+)?/) || [])[0]; | |
} | |
this.addEventListener('fetch', event => { | |
if (event.request.mode === 'navigate' || (event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html'))) { | |
event.respondWith( | |
fetch(event.request.url).catch(error => { |
This file contains hidden or 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
toolbox.router.get('/beer/css/(.*)', global.toolbox.cacheFirst, { | |
cache: { | |
name: 'beer-stylesheets', | |
maxEntries: 10, | |
maxAgeSeconds: 604800 | |
}, | |
// Set a timeout threshold of 2 seconds | |
networkTimeoutSeconds: 4 | |
}); |
This file contains hidden or 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
logData 0 | |
// bring up the login screen | |
navigate http://webmail.aol.com | |
logData 1 | |
// log in | |
setValue name=loginId [email protected] | |
setValue name=password somepassword |
This file contains hidden or 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
cdn3.optimizely.com | |
a.visualrevenue.com | |
www.google-analytics.com | |
pixel.quantserve.com | |
budgetedbauer.com |
This file contains hidden or 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
var messagesRef = new Firebase('https://brilliant-fire-3159.firebaseio.com/users'); | |
var userId = 0; | |
// For user authentication | |
function authHandler(error, authData) { | |
if (error) { | |
console.log('Login Failed!', error); | |
} else { | |
// Set the gravatar | |
document.getElementById('gravatar').src = authData.password.profileImageURL; |
This file contains hidden or 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
messagesRef.limitToLast(10).on('child_added', function (snapshot) { | |
var data = snapshot.val(); | |
var message = data.text; | |
if (message != undefined) | |
{ | |
messageResults.value += '\n' + message; | |
} | |
}); |
This file contains hidden or 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
var messagesRef = new Firebase('https://brilliant-fire-3159.firebaseio.com'); | |
var messageField = document.getElementById('messageInput'); | |
// Save data to firebase | |
function savedata(){ | |
var message = messageField.value; | |
messagesRef.push({fieldName:'messageField', text:message}); | |
messageField.value = ''; |
This file contains hidden or 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
"use strict"; | |
this.addEventListener('fetch', event => { | |
// Save Data support | |
if(event.request.headers.get('save-data')){ | |
//Return smaller images | |
if (/\.jpg$|.gif$|.png$/.test(event.request.url)) { | |
let saveDataUrl = event.request.url.substr(0, event.request.url.lastIndexOf(".")) + '-savedata' + event.request.url.substr(event.request.url.lastIndexOf("."), event.request.url.length - 1); |
This file contains hidden or 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 binarySearch(sortedArray, searchValue, minIndex, maxIndex) { | |
'use strict'; | |
var currentIndex; | |
var currentElement; | |
while (minIndex <= maxIndex) { | |
// Find the value of the middle of the array | |
var middleIndex = (minIndex + maxIndex) / 2 | 0; | |
currentElement = sortedArray[middleIndex]; |