Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharat23 committed Jul 21, 2017
0 parents commit a6116d0
Show file tree
Hide file tree
Showing 18 changed files with 16,409 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/pwa-ppt.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

423 changes: 423 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Empty file added Gruntfile.js
Empty file.
56 changes: 56 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<title>PWA - Intellimeet</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/material.min.css">
<link rel="stylesheet" type="text/css" href="css/material.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<!-- Always shows a header, even in smaller screens. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Title</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation. We hide it in small screens. -->
<nav class="mdl-navigation mdl-layout--large-screen-only">
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Title</span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content"><!-- Your content goes here --></div>
</main>
</div>
</body>
<script type="text/javascript" src="js/material.min.js"></script>
<script>
var success = function (msg) {
console.log('Service Worker Registered Successfully', msg);
};
var error = function (err) {
console.log('Service worker registeration failed', err);
};
if('serviceWorker' in navigator){
navigator.serviceWorker.register('/my-sw.js')
.then(success)
.catch(error);
}
</script>
</html>
75 changes: 75 additions & 0 deletions app/my-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
var CACHE_NAME = 'bharat-v1';

var CACHE_BLACKLIST = ['/my-sw.js','/sw.js'];

var CACHE_LIST = [
'/index.html',
'/css/material.min.css',
'/css/material.min.js'
];

self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(CACHE_NAME).then(function (cache) {
console.log('cache opened');
return cache.addAll(CACHE_LIST);
})
);
});

/*self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request)
.then(function (response) {
return response || fetch(event.request);
})
);
});*/

self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request)
.then(function (response) {
if(response)
return response;

var fetchRequest = event.request.clone();
return fetch(fetchRequest)
.then(function (response) {
if(!response || response.status !== 200 || response.type != 'basic')
return response;

var responseClone = response.clone();
console.log('fetch Request Runtime: ', fetchRequest);
if(CACHE_BLACKLIST.indexOf(fetchRequest) === -1){
console.log('not in black list ');
caches.open(CACHE_NAME)
.then(function (cache) {
console.log('cache opened on run time')
cache.put(fetchRequest, responseClone)
});
}

return response;
})
})
.catch(function () {
return caches.match('');
})
);
});


self.addEventListener('activate', function(event) {
var cacheWhitelist = [CACHE_NAME];
console.log('Activate Event Fired');
event.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (cacheWhitelist.indexOf(key) === -1) {
return caches.delete(key);
}
}));
})
);
});
Loading

0 comments on commit a6116d0

Please sign in to comment.