more thorough tests for localStorage presence
This commit is contained in:
parent
100cc1792a
commit
3337e2133a
@ -20,16 +20,24 @@ define([], function () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!localStorage || typeof(localStorage.getItem) !== 'function') {
|
var failStore = function () {
|
||||||
require('jquery', function ($) {
|
require(['jquery'], function ($) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'HEAD',
|
type: 'HEAD',
|
||||||
url: '/common/feedback.html?NO_LOCALSTORAGE=' + (+new Date()),
|
url: '/common/feedback.html?NO_LOCALSTORAGE=' + (+new Date()),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
window.alert("CryptPad needs localStorage to work, try a different browser");
|
window.alert("CryptPad needs localStorage to work, try a different browser");
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
var test_key = 'localStorage_test';
|
||||||
|
var testval = Math.random().toString();
|
||||||
|
localStorage.setItem(test_key, testval);
|
||||||
|
if (localStorage.getItem(test_key) !== test_key) {
|
||||||
|
return failStore();
|
||||||
|
}
|
||||||
|
} catch (e) { console.error(e); return failStore(); }
|
||||||
|
|
||||||
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
|
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user