Skip to content

Commit

Permalink
added alert() for iOS/Safari private browsing
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Oct 9, 2013
1 parent f0bc2a2 commit 56acdba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,19 @@ function storage_get(name, use_localstorage) {
return v ? JSON.parse(v) : v;
}

var private_browsing_noted = false;
function storage_set(name, value, use_localstorage) {
var s = use_localstorage ? localStorage : sessionStorage;
s.setItem(konopas_set.id + '.' + name, JSON.stringify(value));
try {
s.setItem(konopas_set.id + '.' + name, JSON.stringify(value));
} catch (e) {
if ((e.code === DOMException.QUOTA_EXCEEDED_ERR) && (s.length === 0)) {
if (!private_browsing_noted) {
alert("It looks like you're using an iOS or Safari browser in private mode, which disables localStorage. This will result in a suboptimal KonOpas experience.");
private_browsing_noted = true;
}
} else throw e;
}
}

function toggle_star(el, id) {
Expand Down

0 comments on commit 56acdba

Please sign in to comment.