Merge branch 'master' into darkmode
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 48 KiB |
@ -0,0 +1,52 @@
|
||||
function updateContent() {
|
||||
update();
|
||||
$('body').localize();
|
||||
}
|
||||
const defaultLanguage = 'en';
|
||||
i18next
|
||||
.use(i18nextXHRBackend)
|
||||
.use(i18nextBrowserLanguageDetector)
|
||||
.init({
|
||||
fallbackLng: defaultLanguage,
|
||||
debug: true,
|
||||
backend: {
|
||||
loadPath: 'locales/{{lng}}.json',
|
||||
},
|
||||
}, (err, t) => {
|
||||
const languages = [
|
||||
['de', 'Deutsch'],
|
||||
['en', 'English'],
|
||||
['es-ES', 'Español'],
|
||||
['fr', 'Français'],
|
||||
['it', 'Italiano'],
|
||||
['ru', 'Русский'],
|
||||
['ja', '日本語'],
|
||||
['pt-BR', 'Português'],
|
||||
['zh-CN', '简体中文'],
|
||||
['zh-TW', '繁體中文']
|
||||
],
|
||||
languageSelector = $('#language');
|
||||
languages.map(([code, name]) => {
|
||||
languageSelector.append(`<option value="${code}"${code == i18next.language ? ' selected' : ''}>${name}</option>`);
|
||||
});
|
||||
if (!languageSelector.find('[selected]').length)
|
||||
languageSelector.val(defaultLanguage);
|
||||
languageSelector.on('change', function () {
|
||||
if (this.value == i18next.language)
|
||||
return;
|
||||
i18next.changeLanguage(this.value);
|
||||
});
|
||||
jqueryI18next.init(i18next, $);
|
||||
i18next.on('languageChanged', lng => {
|
||||
if (!languageSelector.find(`[value=${lng}]`).length) {
|
||||
i18next.changeLanguage(defaultLanguage);
|
||||
return;
|
||||
}
|
||||
languageSelector.val(lng);
|
||||
updateContent();
|
||||
});
|
||||
// init set content
|
||||
$(document).ready(initialize);
|
||||
$(document).on('input', updateContent);
|
||||
$('input[type = radio]').on('change', updateContent);
|
||||
});
|
@ -0,0 +1,80 @@
|
||||
{
|
||||
"general": {
|
||||
"daisy-mae": "Jorna"
|
||||
},
|
||||
"welcome": {
|
||||
"salutation": "Hallo, und Willkommen bei der <b>Turnip Prophet</b> App auf deinem Nook Phone.",
|
||||
"description": "Mit dieser App kannst du die Rübenpreise deiner Insel täglich verfolgen, aber du musst die Preise selbst eingeben!",
|
||||
"conclusion": "Danach wird die Turnip Prophet App <b>magisch</b> deine Rübenpreise vorhersagen, welche du den Rest der Woche haben wirst."
|
||||
},
|
||||
"first-time": {
|
||||
"title": "Erstmaliger Einkäufer",
|
||||
"description": "Kaufst du zum ersten Mal Rüben von Jorna auf deiner Insel? <i>(Dies beeinflusst dein Verkaufsmuster)</i>",
|
||||
"yes": "Ja",
|
||||
"no": "Nein"
|
||||
},
|
||||
"patterns": {
|
||||
"title": "Vorheriges Verkaufsmuster",
|
||||
"description": "Wie war das Verkaufsmuster der letzten Woche? <i>(Dies beeinflusst dein Verkaufsmuster)</i>",
|
||||
"pattern": "Verkaufsmuster",
|
||||
"all": "Alle Verkaufsmuster",
|
||||
"decreasing": "Absteigend",
|
||||
"fluctuating": "Schwankend",
|
||||
"unknown": "Ich weiß nicht",
|
||||
"large-spike": "Stark Ansteigend",
|
||||
"small-spike": "Leicht Ansteigend"
|
||||
},
|
||||
"prices": {
|
||||
"description": "Wie hoch war der Preis für Rüben diese Woche auf deiner Insel? <i>(Wenn du zum ersten Mal Rüben kaufst, wird dieses Feld deaktiviert)</i>",
|
||||
"open": {
|
||||
"am": "Vorm. (Vormittag) - 8:00 Uhr bis 11:59 Uhr",
|
||||
"pm": "Nachm. (Nachmittag) - 12:00 Uhr bis 22:00 Uhr"
|
||||
},
|
||||
"copy-permalink": "Seite teilen",
|
||||
"permalink-copied": "Seitenlink kopiert!",
|
||||
"reset": "Eingegebene Daten zurücksetzen",
|
||||
"reset-warning": "Bist du sicher, dass du deine eingegebenen Daten zurücksetzen möchtest?\n\nDies kann nicht rückgängig gemacht werden!"
|
||||
},
|
||||
"weekdays": {
|
||||
"monday": "Montag",
|
||||
"tuesday": "Dienstag",
|
||||
"wednesday": "Mittwoch",
|
||||
"thursday": "Donnerstag",
|
||||
"friday": "Freitag",
|
||||
"saturday" : "Samstag",
|
||||
"sunday": "Sonntag",
|
||||
"abr": {
|
||||
"monday": "Mo",
|
||||
"tuesday": "Di",
|
||||
"wednesday": "Mi",
|
||||
"thursday": "Do",
|
||||
"friday": "Fr",
|
||||
"saturday" : "Sa"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"morning": "Vorm.",
|
||||
"afternoon": "Nachm."
|
||||
},
|
||||
"output": {
|
||||
"title": "Berechnung",
|
||||
"chance": "% Chance",
|
||||
"to": "bis",
|
||||
"minimum": "Garantiertes Minimum",
|
||||
"maximum": "Potentielles Maximum",
|
||||
"chart": {
|
||||
"input": "Eingegebener Preis",
|
||||
"minimum": "Garantiertes Minimum",
|
||||
"maximum": "Potentielles Maximum"
|
||||
}
|
||||
},
|
||||
"textbox": {
|
||||
"description": "Nachdem du einige Rübenpreise eingegeben hast, macht der Turnip Prophet etwas Magie und zeigt dir die verschiedenen möglichen Verkaufsmuster an, die auf deiner Insel auftreten können.",
|
||||
"development": "Diese App befindet sich noch in der Entwicklung, wird sich aber mit der Zeit verbessern!",
|
||||
"thanks": "Nichts von all dem wäre möglich gewesen, ohne das <a href=\"https://twitter.com/_Ninji/status/1244818665851289602?s=20\">Ninji</a> herausgefunden hätte, wie Nepp und Schlepp ihre Rübenpreise kalkulieren.",
|
||||
"support": "Hilfe, Kommentare und Beiträge sind auffindbar über <a href=\"https://github.com/mikebryant/ac-nh-turnip-prices/issues\">GitHub.com</a> (nur in Englisch).",
|
||||
"contributors-text": "Oh! Und vergessen wir nicht, denen zu danken, die bis jetzt dazu beigetragen haben!",
|
||||
"contributors": "Mitwirkende",
|
||||
"language": "Sprache"
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
{
|
||||
"general": {
|
||||
"daisy-mae": "Daisy Mae"
|
||||
},
|
||||
"welcome": {
|
||||
"salutation": "Hello, and welcome to the <b>Turnip Prophet</b> app on your Nook Phone.",
|
||||
"description": "This app lets you track your island's turnip prices daily, but you'll have to put the prices in yourself!",
|
||||
"conclusion": "After that, the Turnip Prophet app will <b>magically</b> predict the turnip prices you'll have for the rest of the week."
|
||||
},
|
||||
"first-time": {
|
||||
"title": "First-Time Buyer",
|
||||
"description": "Is this your first time buying turnips from Daisy Mae on your island?<i>(This affects your pattern)</i>",
|
||||
"yes": "Yes",
|
||||
"no": "No"
|
||||
},
|
||||
"patterns": {
|
||||
"title": "Previous Pattern",
|
||||
"description": "What was last week's turnip price pattern?<i>(This affects your pattern)</i>",
|
||||
"pattern": "Pattern",
|
||||
"all": "All patterns",
|
||||
"decreasing": "Decreasing",
|
||||
"fluctuating": "Fluctuating",
|
||||
"unknown": "I don't know",
|
||||
"large-spike": "Large Spike",
|
||||
"small-spike": "Small Spike"
|
||||
},
|
||||
"prices": {
|
||||
"description": "What was the price of turnips this week on your island? <i>(If this is your first time buying turnips, this field will be disabled)</i>",
|
||||
"open": {
|
||||
"am": "AM - 8:00 am to 11:59 am",
|
||||
"pm": "PM - 12:00 pm to 10:00 pm"
|
||||
},
|
||||
"copy-permalink": "Copy permalink",
|
||||
"permalink-copied": "Permalink copied!",
|
||||
"reset": "Reset Turnip Prophet",
|
||||
"reset-warning": "Are you sure you want to reset all fields?\n\nThis cannot be undone!"
|
||||
},
|
||||
"weekdays": {
|
||||
"monday": "Monday",
|
||||
"tuesday": "Tuesday",
|
||||
"wednesday": "Wednesday",
|
||||
"thursday": "Thursday",
|
||||
"friday": "Friday",
|
||||
"saturday" : "Saturday",
|
||||
"sunday": "Sunday",
|
||||
"abr": {
|
||||
"monday": "Mon",
|
||||
"tuesday": "Tue",
|
||||
"wednesday": "Wed",
|
||||
"thursday": "Thu",
|
||||
"friday": "Fri",
|
||||
"saturday" : "Sat"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"morning": "AM",
|
||||
"afternoon": "PM"
|
||||
},
|
||||
"output": {
|
||||
"title": "Output",
|
||||
"chance": "% Chance",
|
||||
"to": "to",
|
||||
"minimum": "Guaranteed Minimum",
|
||||
"maximum": "Potential Maximum",
|
||||
"chart": {
|
||||
"input": "Input Price",
|
||||
"minimum": "Guaranteed Minimum",
|
||||
"maximum": "Potential Maximum"
|
||||
}
|
||||
},
|
||||
"textbox": {
|
||||
"description": "After you've listed some turnip prices, the Turnip Prophet will run some numbers and display the different possible patterns that your island may experience.",
|
||||
"development": "This app is still in development, but will improve over time!",
|
||||
"thanks": "None of this would have been possible without <a href=\"https://twitter.com/_Ninji/status/1244818665851289602?s=20\">Ninji's work</a> figuring out just how Timmy and Tommy value their turnips.",
|
||||
"support": "Support, comments and contributions are available through <a href=\"https://github.com/mikebryant/ac-nh-turnip-prices/issues\">Github</a>",
|
||||
"contributors-text": "Oh! And let's not forget to thank those who have contributed so far!",
|
||||
"contributors": "Contributors",
|
||||
"language": "Language"
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
{
|
||||
"general": {
|
||||
"daisy-mae": "Porcelette"
|
||||
},
|
||||
"welcome": {
|
||||
"salutation": "Bonjour et bienvenue sur l'application du <b>Turnip Prophet</b> de ton Nook Phone.",
|
||||
"description": "Cette appli te permet de garder un œil quotidien sur le cours du navet de ton île, en le renseignant ici par toi-même !",
|
||||
"conclusion": "Une fois les prix renseignés, l'appli du Turnip Prophet va <b>magiquement</b> prédire le cours du navet de ton île pour le reste de la semaine."
|
||||
},
|
||||
"first-time": {
|
||||
"title": "Premier Achat",
|
||||
"description": "Est-ce la toute première fois que t'achètes des navets à Porcelette sur ton île ?<i>(Cela influencera le type de ta courbe actuelle)</i>",
|
||||
"yes": "Oui",
|
||||
"no": "Non"
|
||||
},
|
||||
"patterns": {
|
||||
"title": "Courbe du cours précédent",
|
||||
"description": "De quel type était la courbe de ton cours du navet la semaine dernière ?<i>(Cela influencera le type de ta courbe actuelle)</i>",
|
||||
"pattern": "Type de Courbe",
|
||||
"all": "Tous les types",
|
||||
"decreasing": "Décroissante",
|
||||
"fluctuating": "Variable",
|
||||
"unknown": "Je ne sais pas",
|
||||
"large-spike": "Grand Pic",
|
||||
"small-spike": "Petit Pic"
|
||||
},
|
||||
"prices": {
|
||||
"description": "À quel prix Porcelette vendait ses navets sur ton île cette semaine ?<i>(Si c'est la première fois que t'en achètes, ce champ sera desactivé)</i>",
|
||||
"open": {
|
||||
"am": "Matin (AM) - de 8:00 à 11:59",
|
||||
"pm": "Après-midi (PM) - de 12:00 à 22:00"
|
||||
},
|
||||
"copy-permalink": "Copier le permalien",
|
||||
"permalink-copied": "Permalien copié !",
|
||||
"reset": "Réinitialiser les données",
|
||||
"reset-warning": "Es-tu sûr·e de vouloir réinitialiser tous les champs ?\n\nCe choix est définitif !"
|
||||
},
|
||||
"weekdays": {
|
||||
"monday": "Lundi",
|
||||
"tuesday": "Mardi",
|
||||
"wednesday": "Mercredi",
|
||||
"thursday": "Jeudi",
|
||||
"friday": "Vendredi",
|
||||
"saturday" : "Samedi",
|
||||
"sunday": "Dimanche",
|
||||
"abr": {
|
||||
"monday": "Lun",
|
||||
"tuesday": "Mar",
|
||||
"wednesday": "Mer",
|
||||
"thursday": "Jeu",
|
||||
"friday": "Ven",
|
||||
"saturday" : "Sam"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"morning": "AM",
|
||||
"afternoon": "PM"
|
||||
},
|
||||
"output": {
|
||||
"title": "Résultats",
|
||||
"chance": "% Chance",
|
||||
"to": "à",
|
||||
"minimum": "Minimum Garanti",
|
||||
"maximum": "Maximum Potentiel",
|
||||
"chart": {
|
||||
"input": "Prix renseigné",
|
||||
"minimum": "Minimum Garanti",
|
||||
"maximum": "Maximum Potentiel"
|
||||
}
|
||||
},
|
||||
"textbox": {
|
||||
"description": "Après avoir renseigné quelques prix, le Turnip Prophet fera des calculs et affichera les différents types possibles pour les courbes que ton île pourrait avoir.",
|
||||
"development": "Cette appli est en développement, mais elle s'améliore jour après jour !",
|
||||
"thanks": "Rien de tout ça n'aurait pu être possible sans <a href=\"https://twitter.com/_Ninji/status/1244818665851289602?s=20\">le travail de Ninji</a> et son analyse sur comment Méli et Mélo déterminent la valeur des Navets.",
|
||||
"support": "Aide, commentaires et contributions sont disponibles via <a href=\"https://github.com/mikebryant/ac-nh-turnip-prices/issues\">Github</a>",
|
||||
"contributors-text": "Oh ! Et n'oublions pas de remercier toutes les personnes ayant contribué jusqu'à maintenant !",
|
||||
"contributors": "Contributeurs",
|
||||
"language": "Langue"
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
{
|
||||
"general": {
|
||||
"name": "Turnip Prophet",
|
||||
"daisy-mae": "Brunella"
|
||||
},
|
||||
"welcome": {
|
||||
"salutation": "Ciao e benvenuto nell'app <b>Turnip Prophet</b> del tuo Nook Phone.",
|
||||
"description": "Questa applicazione ti permetterà di tenere traccia del prezzo giornaliero delle rape. Ma dovrai inserire i prezzi da te!",
|
||||
"conclusion": "Se lo fai Turnip Prophet predirrà <b>magicamente</b> i prezzi delle rape che avrai per il resto della settimana."
|
||||
},
|
||||
"first-time": {
|
||||
"title": "Primo Acquisto",
|
||||
"description": "È la prima volta che acquisti sulla tua isola le rape da Brunella?<i>(influisce sul comportamento dei prezzi)</i>",
|
||||
"yes": "Sì",
|
||||
"no": "No"
|
||||
},
|
||||
"patterns": {
|
||||
"title": "Comportamento Precedente",
|
||||
"description": "Qual è stato il comportamento dei prezzi delle rape nella scorsa settimana?<i>(influisce sul comportamento dei prezzi)</i>",
|
||||
"pattern": "Comportamento",
|
||||
"all": "Tutti i comportamenti",
|
||||
"decreasing": "Decrescente",
|
||||
"fluctuating": "Oscillante",
|
||||
"unknown": "Non lo so!",
|
||||
"large-spike": "Grande picco",
|
||||
"small-spike": "Piccolo picco"
|
||||
},
|
||||
"prices": {
|
||||
"description": "Qual era il prezzo di acquisto delle rape sulla tua isola questa settimana? <i>(Se è la prima volta che le compri questo campo è disabilitato)</i>",
|
||||
"open": {
|
||||
"am": "Mattina - dalle 8:00 alle 11:59",
|
||||
"pm": "Pomeriggio - dalle 12:00 alle 22:00"
|
||||
},
|
||||
"copy-permalink": "Copia permalink",
|
||||
"permalink-copied": "Permalink copiato!",
|
||||
"reset": "Resetta Turnip Prophet",
|
||||
"reset-warning": "Sei sicuro di voler resettare tutti i campi?\n\nNon può essere annullato!"
|
||||
},
|
||||
"weekdays": {
|
||||
"monday": "Lunedì",
|
||||
"tuesday": "Martedì",
|
||||
"wednesday": "Mercoledì",
|
||||
"thursday": "Giovedì",
|
||||
"friday": "Venerdì",
|
||||
"saturday": "Sabato",
|
||||
"sunday": "Domenica",
|
||||
"abr": {
|
||||
"monday": "Lun",
|
||||
"tuesday": "Mar",
|
||||
"wednesday": "Mer",
|
||||
"thursday": "Gio",
|
||||
"friday": "Ven",
|
||||
"saturday": "Sab"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"morning": "AM",
|
||||
"afternoon": "PM"
|
||||
},
|
||||
"output": {
|
||||
"title": "Risultati",
|
||||
"chance": "Probabilità %",
|
||||
"to": "a",
|
||||
"minimum": "Minimo Garantito",
|
||||
"maximum": "Massimo Potenziale",
|
||||
"chart": {
|
||||
"input": "Prezzo Iniziale",
|
||||
"minimum": "Minimo Gatantito",
|
||||
"maximum": "Massimo Potenziale"
|
||||
}
|
||||
},
|
||||
"textbox": {
|
||||
"description": "Dopo aver inserito alcuni prezzi, Turnip Prophet calcolerà e mostrerà i possibili comportamenti del prezzo delle rape nella tua isola.",
|
||||
"development": "Quest'applicazione è in ancora in sviluppo ma migliorerà col tempo!",
|
||||
"thanks": "Niente di questo sarebbe possibile senza <a href=\"https://twitter.com/_Ninji/status/1244818665851289602?s=20\">il lavoro di Ninji</a> nello scoprire come Mirko e Marco valutano le rape.",
|
||||
"support": "Chiedi supporto o lascia commenti e contributi su <a href=\"https://github.com/mikebryant/ac-nh-turnip-prices/issues\">Github</a>",
|
||||
"contributors-text": "Oh! Non dimentichiamoci di ringraziare chi ha contribuito fin'ora!",
|
||||
"contributors": "Collaboratori"
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
{
|
||||
"general": {
|
||||
"daisy-mae": "Daisy Mae"
|
||||
},
|
||||
"welcome": {
|
||||
"salutation": "Olá, e bem-vindo ao aplicativo <b>Turnip Prophet</b> em seu Nook Phone.",
|
||||
"description": "Este aplicativo lhe permite acompanhar os preços diários de nabo em sua ilha, porém você terá que colocar os preços você mesmo!",
|
||||
"conclusion": "Depois disso, o aplicativo Turnip Prophet irá <b>magicamente</b> prever os preços dos nabos que você terá pelo resto da semana."
|
||||
},
|
||||
"first-time": {
|
||||
"title": "Comprador de primeira viagem",
|
||||
"description": "Esta é a primeira vez que você compra nabos de Daisy Mae em sua ilha? <i>(Isso afeta seu padrão)</i>",
|
||||
"yes": "Sim",
|
||||
"no": "Não"
|
||||
},
|
||||
"patterns": {
|
||||
"title": "Padrão Anterior",
|
||||
"description": "Qual foi o padrão de preços de nabo da semana passada? <i>(Isso afeta seu padrão)</i>",
|
||||
"pattern": "Padrão",
|
||||
"all": "Todos padrões",
|
||||
"decreasing": "Diminuindo",
|
||||
"fluctuating": "Flutuante",
|
||||
"unknown": "Eu não sei",
|
||||
"large-spike": "Grande Pico",
|
||||
"small-spike": "Pequeno Pico"
|
||||
},
|
||||
"prices": {
|
||||
"description": "Qual foi o preço dos nabos esta semana em sua ilha? <i>(Se esta é a primeira vez que compra nabos, este campo ficará desativado)</i>",
|
||||
"open": {
|
||||
"am": "AM - 8:00 am até 11:59 am",
|
||||
"pm": "PM - 12:00 pm até 10:00 pm"
|
||||
},
|
||||
"copy-permalink": "Copiar permalink",
|
||||
"permalink-copied": "Permalink copiado!",
|
||||
"reset": "Redefinir Turnip Prophet",
|
||||
"reset-warning": "Tem certeza de que deseja redefinir todos os campos?\n\nIsso não pode ser desfeito!"
|
||||
},
|
||||
"weekdays": {
|
||||
"monday": "Segunda-feira",
|
||||
"tuesday": "Terça-feira",
|
||||
"wednesday": "Quarta-feira",
|
||||
"thursday": "Quinta-feira",
|
||||
"friday": "Sexta-feira",
|
||||
"saturday" : "Sábado",
|
||||
"sunday": "Domingo",
|
||||
"abr": {
|
||||
"monday": "Seg",
|
||||
"tuesday": "Ter",
|
||||
"wednesday": "Qua",
|
||||
"thursday": "Qui",
|
||||
"friday": "Sex",
|
||||
"saturday" : "Sab"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"morning": "AM",
|
||||
"afternoon": "PM"
|
||||
},
|
||||
"output": {
|
||||
"title": "Resultado",
|
||||
"chance": "% Chance",
|
||||
"to": "to",
|
||||
"minimum": "Mínimo Garantido",
|
||||
"maximum": "Potencial Máximo",
|
||||
"chart": {
|
||||
"input": "Preço de entrada",
|
||||
"minimum": "Mínimo Garantido",
|
||||
"maximum": "Potencial Máximo"
|
||||
}
|
||||
},
|
||||
"textbox": {
|
||||
"description": "Depois de listar alguns preços de nabo, o Turnip Prophet irá calcular alguns números e exibirá os diferentes padrões possíveis que sua ilha pode experienciar.",
|
||||
"development": "Este aplicativo ainda está em desenvolvimento, mas melhorará com o tempo!",
|
||||
"thanks": "Nada disso seria possível sem o <a href=\"https://twitter.com/_Ninji/status/1244818665851289602?s=20\">trabalho de Ninji's</a> descobrindo como Timmy e Tommy valorizam seus nabos.",
|
||||
"support": "Suporte, comentários e contribuições estão disponíveis através do <a href=\"https://github.com/mikebryant/ac-nh-turnip-prices/issues\">Github</a>",
|
||||
"contributors-text": "Oh! E não vamos nos esquecer de agradecer àqueles que contribuíram até agora!",
|
||||
"contributors": "Contribuidores",
|
||||
"language": "Linguagem"
|
||||
}
|
||||
}
|
@ -1,90 +1,75 @@
|
||||
// PWA Code adapted from https://github.com/pwa-builder/PWABuilder
|
||||
const CACHE = "pwa-precache";
|
||||
const CACHE = "pwa-precache-v1";
|
||||
const precacheFiles = [
|
||||
"/index.html",
|
||||
"/js/predictions.js",
|
||||
"/js/scripts.js",
|
||||
"/css/styles.css",
|
||||
"https://code.jquery.com/jquery-3.4.1.min.js",
|
||||
"/index.html",
|
||||
"/js/predictions.js",
|
||||
"/js/scripts.js",
|
||||
"/css/styles.css",
|
||||
"https://code.jquery.com/jquery-3.4.1.min.js",
|
||||
];
|
||||
|
||||
self.addEventListener("install", function (event) {
|
||||
console.log("[PWA] Install Event processing");
|
||||
console.log("[PWA] Install Event processing");
|
||||
|
||||
console.log("[PWA] Skip waiting on install");
|
||||
self.skipWaiting();
|
||||
console.log("[PWA] Skip waiting on install");
|
||||
self.skipWaiting();
|
||||
|
||||
event.waitUntil(
|
||||
caches.open(CACHE).then(function (cache) {
|
||||
console.log("[PWA] Caching pages during install");
|
||||
return cache.addAll(precacheFiles);
|
||||
})
|
||||
);
|
||||
event.waitUntil(
|
||||
caches.open(CACHE).then(function (cache) {
|
||||
console.log("[PWA] Caching pages during install");
|
||||
return cache.addAll(precacheFiles);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// Allow sw to control of current page
|
||||
self.addEventListener("activate", function (event) {
|
||||
console.log("[PWA] Claiming clients for current page");
|
||||
event.waitUntil(self.clients.claim());
|
||||
console.log("[PWA] Claiming clients for current page");
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
// If any fetch fails, it will look for the request in the cache and serve it from there first
|
||||
self.addEventListener("fetch", function (event) {
|
||||
if (event.request.method !== "GET") return;
|
||||
if (event.request.method !== "GET") return;
|
||||
|
||||
event.respondWith(
|
||||
fromCache(event.request).then(
|
||||
(response) => {
|
||||
// The response was found in the cache so we responde with it and update the entry
|
||||
|
||||
// This is where we call the server to get the newest version of the
|
||||
// file to use the next time we show view
|
||||
event.waitUntil(
|
||||
fetch(event.request).then(function (response) {
|
||||
return updateCache(event.request, response);
|
||||
})
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
() => {
|
||||
// The response was not found in the cache so we look for it on the server
|
||||
return fetch(event.request)
|
||||
.then(function (response) {
|
||||
// If request was success, add or update it in the cache
|
||||
event.waitUntil(
|
||||
updateCache(event.request, response.clone())
|
||||
);
|
||||
|
||||
return response;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(
|
||||
"[PWA] Network request failed and no cache." + error
|
||||
);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
event.respondWith(
|
||||
(async () => {
|
||||
let response;
|
||||
try {
|
||||
// Fetch from network first.
|
||||
response = await fetch(event.request);
|
||||
event.waitUntil(updateCache(event.request, response.clone()));
|
||||
} catch (error) {
|
||||
try {
|
||||
// Try if there's locally cached version.
|
||||
response = await fromCache(event.request);
|
||||
} catch (error) {
|
||||
console.log("[PWA] Network request failed and no cache." + error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
||||
function fromCache(request) {
|
||||
// Check to see if you have it in the cache
|
||||
// Return response
|
||||
// If not in the cache, then return
|
||||
return caches.open(CACHE).then(function (cache) {
|
||||
return cache.match(request).then(function (matching) {
|
||||
if (!matching || matching.status === 404) {
|
||||
return Promise.reject("no-match");
|
||||
}
|
||||
// Check to see if you have it in the cache
|
||||
// Return response
|
||||
// If not in the cache, then return
|
||||
return caches.open(CACHE).then(function (cache) {
|
||||
return cache.match(request).then(function (matching) {
|
||||
if (!matching || matching.status === 404) {
|
||||
return Promise.reject("no-match");
|
||||
}
|
||||
|
||||
return matching;
|
||||
});
|
||||
});
|
||||
return matching;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateCache(request, response) {
|
||||
return caches.open(CACHE).then(function (cache) {
|
||||
return cache.put(request, response);
|
||||
});
|
||||
return caches.open(CACHE).then(function (cache) {
|
||||
return cache.put(request, response);
|
||||
});
|
||||
}
|
||||
|