UNPKG

qcobjects-handler-contactform

Version:
65 lines (62 loc) 2.19 kB
/** * QCObjects SDK 1.0 * ________________ * * Author: Jean Machuca <correojean@gmail.com> * * Cross Browser Javascript Framework for MVC Patterns * QuickCorp/QCObjects is licensed under the * GNU Lesser General Public License v3.0 * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt) * * Permissions of this copyleft license are conditioned on making available * complete source code of licensed works and modifications under the same * license or the GNU GPLv3. Copyright and license notices must be preserved. * Contributors provide an express grant of patent rights. However, a larger * work using the licensed work through interfaces provided by the licensed * work may be distributed under different terms and without source code for * the larger work. * * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com> * * Everyone is permitted to copy and distribute verbatim copies of this * license document, but changing it is not allowed. */ "use strict"; const version = "0.0.1"; const appName = "qcobjects-handler-contactform"; const cacheSufix = (Math.round(Date.now()/(1000*3600))).toString(); // 1 hour const cacheName = `qcobjects-app-${appName}-${version}-${cacheSufix}`; const start_url = "/?homescreen=1"; caches.delete(cacheName); // force to reload cache for the first time the sw is loaded self.addEventListener("install", e => { e.waitUntil( caches.open(cacheName).then(cache => { return cache.addAll([`${start_url}`, "/", "README.md", "VERSION", "api/com.qcobjects.backend.microservice.openapi.js", "api/com.qcobjects.backend.microservice.openapi.json.js", "api/com.qcobjects.backend.microservice.openapi.yaml.js", "app.js", "config.json", "index.js", "spec/support/jasmine.json", "spec/testsSpec.js"]) .then(() => self.skipWaiting()); }) ); }); self.addEventListener("activate", event => { event.waitUntil(self.clients.claim()); }); self.addEventListener("fetch", event => { event.respondWith( caches.open(cacheName) .then(cache => cache.match(event.request, {ignoreSearch: true})) .then(response => { return response || fetch(event.request); }) ); });