Make it possible to set a namespace for localStorage, with fallback to document.location.href. Also prefix with 'dat.gui.' to avoid collisions.

This commit is contained in:
Kristoffer Lundén 2017-01-12 15:32:40 +01:00
parent d5b6178e33
commit 5aa551a696

View File

@ -1023,8 +1023,8 @@ function add(gui, object, property, params) {
}
function getLocalStorageHash(gui, key) {
// TODO how does this deal with multiple GUI's?
return document.location.href + '.' + key;
var namespace = localStorage.getItem('dat.gui.namespace') || document.location.href;
return 'dat.gui.' + namespace + '.' + key;
}
function addPresetOption(gui, name, setSelected) {