From 282a4e3b06ac9d6df1f9ca3084c981e0e1764aaf Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 23 Aug 2018 20:12:47 -0500 Subject: [PATCH] Fixed issue with idb. Also altered color contrast for accessibility. Working on improving lighthouse scores & implementing gulp next. --- client/css/styles.css | 8 ++++---- client/index.html | 1 + client/js/dbhelper.js | 1 - client/restaurant.html | 1 + client/sw.js | 16 +++++++++------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client/css/styles.css b/client/css/styles.css index e9d54b2..4eae0ec 100644 --- a/client/css/styles.css +++ b/client/css/styles.css @@ -95,7 +95,7 @@ nav h1 a { /* Add a color to all links inside the list */ #breadcrumb li a { - color: #0275d8; + color: #024C92; text-decoration: none; } @@ -174,7 +174,7 @@ nav h1 a { min-width: 100%; } #restaurants-list li h3 { - color: #f18200; + color: #8A4600; font-family: Arial,sans-serif; font-size: 14pt; font-weight: 200; @@ -225,7 +225,7 @@ nav h1 a { /*position: absolute;*/ } #restaurant-name { - color: #f18200; + color: #8A4600; font-family: Arial,sans-serif; font-size: 22pt; font-weight: 200; @@ -280,7 +280,7 @@ nav h1 a { padding: 30px 40px; }*/ #reviews-container h3 { - color: #f58500; + color: #8A4600; font-size: 24pt; font-weight: 300; text-align: center; diff --git a/client/index.html b/client/index.html index 0bea0e3..2b356f3 100644 --- a/client/index.html +++ b/client/index.html @@ -57,6 +57,7 @@

Filter Results

+ diff --git a/client/js/dbhelper.js b/client/js/dbhelper.js index ee5337d..6f5c5d7 100644 --- a/client/js/dbhelper.js +++ b/client/js/dbhelper.js @@ -2,7 +2,6 @@ * Common database helper functions. */ - class DBHelper { /** diff --git a/client/restaurant.html b/client/restaurant.html index 1cf811c..e49e3b4 100644 --- a/client/restaurant.html +++ b/client/restaurant.html @@ -68,6 +68,7 @@

+ diff --git a/client/sw.js b/client/sw.js index 5054c87..3af1192 100644 --- a/client/sw.js +++ b/client/sw.js @@ -1,15 +1,15 @@ // Service Worker // Include DBHelper function for fetching restaurants and putting in indexedDB -self.importScripts('js/dbhelper.js'); +self.importScripts('js/dbhelper.js', 'js/idb.js'); // Data -var myCache = "restauarantReview_001"; +var myCache = "restaurantReview_050"; var cacheFiles = [ '/index.html', '/restaurant.html', '/css/styles.css', - '/data/restaurants.json', + //'/data/restaurants.json', '/img/', '/js/dbhelper.js', '/js/main.js', @@ -21,11 +21,11 @@ var cacheFiles = [ // Event Listener for install - caching the files self.addEventListener("install", function(event) { - //console.log('In eventListener for install, event: ', event) + console.log('In eventListener for install, event: ', event) event.waitUntil(caches.open(myCache).then(function(cache) { return cache.addAll(cacheFiles) - //.then( function() { console.log('Cache worked'); } ) + .then( function() { console.log('Cache worked'); } ) .catch(function(error) { console.log("Caching failed, error: ", error); @@ -55,6 +55,7 @@ self.addEventListener('fetch', function(event) { // Event Listener for activate - self.addEventListener('activate', event => { + console.log("Event trigger - activate"); DBHelper.fetchRestaurants((error, restaurants) => { if (error) { callback(error, null); @@ -62,9 +63,10 @@ self.addEventListener('activate', event => { // Could use switch statement here to update IDB. Curretn Data set is static, needs just one init/. idb.open('restaurantReviews', 1, upgradeDB => { // If not there already, add restaurant data - if(!upgradeDB.objectStroeNAmes.contains('restaurantData')) { + if(!upgradeDB.objectStoreNames.contains('restaurantData')) { let objStore = upgradeDB.createObjectStore('restaurantData', {keyPath: 'id'}); - for (restaurant in restaurants) objStore.add(restaurant); + console.log(restaurants); + restaurants.map(restaurant => objStore.add(restaurant)); } }); }