make Snap! work in Safari 11 offline (file:// protocol) again, Sheesh

upd4.1
Jens Mönig 2017-09-26 18:47:52 +02:00
rodzic ee4d650f41
commit ca4f94469f
2 zmienionych plików z 17 dodań i 4 usunięć

20
gui.js
Wyświetl plik

@ -269,7 +269,7 @@ IDE_Morph.prototype.openIn = function (world) {
var hash, usr, myself = this, urlLanguage = null;
// get persistent user data, if any
if (localStorage) {
if (this.hasLocalStorage()) {
usr = localStorage['-snap-user'];
if (usr) {
usr = SnapCloud.parseResponse(usr)[0];
@ -2188,24 +2188,36 @@ IDE_Morph.prototype.saveSetting = function (key, value) {
if (!this.savingPreferences) {
return;
}
if (localStorage) {
if (this.hasLocalStorage()) {
localStorage['-snap-setting-' + key] = value;
}
};
IDE_Morph.prototype.getSetting = function (key) {
if (localStorage) {
if (this.hasLocalStorage()) {
return localStorage['-snap-setting-' + key];
}
return null;
};
IDE_Morph.prototype.removeSetting = function (key) {
if (localStorage) {
if (this.hasLocalStorage()) {
delete localStorage['-snap-setting-' + key];
}
};
IDE_Morph.prototype.hasLocalStorage = function () {
// checks whether localStorage is available,
// this kludgy try/catch mechanism is needed
// because Safari 11 is paranoid about accessing
// localstorage from the file:// protocol
try {
return !isNil(localStorage);
} catch (err) {
return false;
}
};
// IDE_Morph sprite list access
IDE_Morph.prototype.addNewSprite = function () {

Wyświetl plik

@ -3659,6 +3659,7 @@ Fixes:
* GUI: fixed camera support for Safari, thanks, Bernat!
* Morphic: added stopEditing() event for keyboardReceiver
* Blocks: added floating toggle for keyboard entry to scripts toolbar
* GUI: make Snap! work in Safari 11 offline (file:// protocol) again, Sheesh
=== v4.1 release candidate ===