summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-03-29 14:11:38 +0000
committerhallgren <hallgren@chalmers.se>2012-03-29 14:11:38 +0000
commita519d01754f053eaa8301c5433c5a1c64a80d7f9 (patch)
tree6d2f62a9513154d5bcf959991305fe5b43cbba24 /src
parent0f04d889034e7e172c10b0fd235aa421c150137e (diff)
gfse: show an informative error message in browsers that lack support for localStorage
Diffstat (limited to 'src')
-rw-r--r--src/www/gfse/editor.js10
-rw-r--r--src/www/gfse/localstorage.js8
2 files changed, 15 insertions, 3 deletions
diff --git a/src/www/gfse/editor.js b/src/www/gfse/editor.js
index 4edc7f193..6e7d78cd5 100644
--- a/src/www/gfse/editor.js
+++ b/src/www/gfse/editor.js
@@ -1440,9 +1440,13 @@ function dir_bugfix() {
}
if(editor) {
- initial_view();
- touch_edit();
- dir_bugfix();
+ if(supports_html5_storage()) {
+ initial_view();
+ touch_edit();
+ dir_bugfix();
+ }
+ else
+ editor.innerHTML="<p>This browser does not appear to support localStorage, and the grammar editor does not work without it. Sorry!"
}
//console.log("hi")
diff --git a/src/www/gfse/localstorage.js b/src/www/gfse/localstorage.js
index 696a432fb..162b1db3b 100644
--- a/src/www/gfse/localstorage.js
+++ b/src/www/gfse/localstorage.js
@@ -2,6 +2,14 @@
// Grammars are stored locally in the browser using localStorage.
// See http://diveintohtml5.info/storage.html
+function supports_html5_storage() {
+ try {
+ return 'localStorage' in window && window['localStorage'] !== null;
+ } catch (e) {
+ return false;
+ }
+}
+
var local={
prefix:"gf.editor.simple.grammar",
get: function (name,def) {