Skip to content

Commit

Permalink
Local storage improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
TimTree committed Nov 11, 2018
1 parent 3b789cc commit c351d95
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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.
14 changes: 14 additions & 0 deletions assets/js/featureChecker.js
Original file line number Diff line number Diff line change
@@ -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();
18 changes: 3 additions & 15 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
}
}
Expand All @@ -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(() => {
Expand Down
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</div>
</div>
<div id="copyright">
<div id="copyrightLabel" onclick="hide('titleSlide');show('aboutCreditsSlide', 'grid');">Version 3.0 ~ ©2011-2018 Games by Tim ~ About/Credits</div>
<div id="copyrightLabel" onclick="hide('titleSlide');show('aboutCreditsSlide', 'grid');">Version 3.0.1 ~ ©2011-2018 Games by Tim ~ About/Credits</div>
</div>
</div>

Expand Down Expand Up @@ -188,10 +188,11 @@ <h2>About/Credits</h2>
</div>
<div>
<div class="flexCenter" style="flex-direction:column;font-size:24px;line-height:1.8;">
<span style="margin-bottom:0.8em;font-size:26px;"><strong>Version 3.0</strong></span>
<span style="margin-bottom:0.8em;font-size:26px;"><strong>Version 3.0.1</strong></span>
<span><strong>Creator:</strong> Timothy Hsu</span>
<span><strong>Released (PPT):</strong> Sept. 3, 2011</span>
<span><strong>Released (Web):</strong> Sept. 17, 2018</span>
<span><strong>Updated:</strong> Nov. 10, 2018</span>
<span><strong>License:</strong> <a href="./LICENSE" target="_blank">MIT</a></span>
<span style="margin-top:0.8em;font-size:22px;"><a href="https://github.com/TimTree/bingo-master-board" target="_blank">GitHub Repo</a>
&nbsp;&nbsp;&nbsp;<a href="https://github.com/TimTree/bingo-master-board/releases" target="_blank">Release History</a></span>
Expand Down Expand Up @@ -532,6 +533,7 @@ <h2>Winning Pattern</h2>

</div>

<script src="./assets/js/featureChecker.js"></script>
<script src="./assets/js/main.js"></script>

</body>
Expand Down

0 comments on commit c351d95

Please sign in to comment.