From c351d959883c9808caf5e6504e2453860c8afa96 Mon Sep 17 00:00:00 2001 From: TimTree Date: Sat, 10 Nov 2018 16:02:38 -0800 Subject: [PATCH] Local storage improvements --- README.md | 6 ++---- assets/js/featureChecker.js | 14 ++++++++++++++ assets/js/main.js | 18 +++--------------- index.html | 6 ++++-- 4 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 assets/js/featureChecker.js diff --git a/README.md b/README.md index c316b3d..5cd2429 100755 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ Find other keyboard shortcuts in the __How to Use__ page. For general feedback, you can leave a comment on [my Website's project page](https://www.gamesbytim.com/2018/09/bingo-master-board-host-bingo-games-on.html). For bugs, see the next question. ### I found a bug! -Great! Report the bug on [GitHub issues](https://github.com/timtree/bingo-master-board/issues), and I'll see what I can do to fix it. When reporting, let me know what browser you're using, and make sure someone else hasn't already reported the bug. Note that there may be bugs I can't fix if the bug is from the browser itself. +Great! Report the bug on [GitHub issues](https://github.com/TimTree/bingo-master-board/issues), and I'll see what I can do to fix it. When reporting, let me know what browser you're using, and make sure someone else hasn't already reported the bug. Note that there may be bugs I can't fix if the bug is from the browser itself. -If you feel confident, you can [send a pull request](https://github.com/timtree/bingo-master-board/pulls) for bug fixes only. I've never dealt with a pull request before, so please bear with me if you do this. If I approve your pull request, you'll receive credit in the game's Credits page. +If you feel confident, you can [send a pull request](https://github.com/TimTree/bingo-master-board/pulls) for bug fixes only. I've never dealt with a pull request before, so please bear with me if you do this. If I approve your pull request, you'll receive credit in the game's Credits page. ### Wasn't there a PowerPoint version of this? @@ -60,7 +60,5 @@ There are multiple reasons for the switch, including, but not limited to, the fo * No more worrying about macro security warnings * Ability to add features not possible with PowerPoint, like mouseover effects, keyboard shortcuts, and more. -[*~Games by Tim*](https://www.gamesbytim.com) - ## License Bingo Master Board is licensed under the MIT License. diff --git a/assets/js/featureChecker.js b/assets/js/featureChecker.js new file mode 100644 index 0000000..fa9e057 --- /dev/null +++ b/assets/js/featureChecker.js @@ -0,0 +1,14 @@ +// Check Local Storage support +function testLocalStorage() { + const doesItWork = 'test'; + try { + localStorage.setItem(doesItWork, '1'); + localStorage.removeItem(doesItWork); + return true; + } + catch (error) { + return false; + } +} + +const supportsLocalStorage = testLocalStorage(); diff --git a/assets/js/main.js b/assets/js/main.js index 8eadaad..b09773d 100755 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -16,7 +16,7 @@ let saveData = { firstRun: 0 } -if(typeof(localStorage) !== "undefined") { +if(supportsLocalStorage) { if (localStorage.getItem("bingoMasterBoardSaveData")) { const parsedData = JSON.parse(localStorage.getItem("bingoMasterBoardSaveData")); for (let i = 0; i < Object.keys(parsedData).length; i += 1) { @@ -28,20 +28,8 @@ if(typeof(localStorage) !== "undefined") { } } -var isNotSafariPrivate = function() { - var doesItWork = 'test', storage = window.sessionStorage; - try { - storage.setItem(doesItWork, '1'); - storage.removeItem(doesItWork); - return true; - } - catch (error) { - return false; - } -} - function save() { - if ( isNotSafariPrivate() ) { + if (supportsLocalStorage) { localStorage.setItem('bingoMasterBoardSaveData', JSON.stringify(saveData)); } } @@ -64,7 +52,7 @@ function init() { show("masterBoardSlide", "grid"); },50); } else { - if (saveData.firstRun === 0) { + if (saveData.firstRun === 0 && supportsLocalStorage) { saveData.firstRun = 1; save(); setTimeout(() => { diff --git a/index.html b/index.html index bde0342..ca893fe 100755 --- a/index.html +++ b/index.html @@ -85,7 +85,7 @@ @@ -188,10 +188,11 @@

About/Credits

- Version 3.0 + Version 3.0.1 Creator: Timothy Hsu Released (PPT): Sept. 3, 2011 Released (Web): Sept. 17, 2018 + Updated: Nov. 10, 2018 License: MIT GitHub Repo    Release History @@ -532,6 +533,7 @@

Winning Pattern

+