diff --git a/editor/index.html b/editor/index.html index f7b0e0be7a812f7d4c3c7d3c946bf1ff2b3e9888..3944f466d61ed6df2a0721135fc9d5f3f8d8c3ff 100644 --- a/editor/index.html +++ b/editor/index.html @@ -47,8 +47,8 @@ + - @@ -92,7 +92,7 @@ var sidebar = new Sidebar( editor ).setId( 'sidebar' ); document.body.appendChild( sidebar.dom ); - editor.setTheme( editor.localStorage.getKey( 'theme' ) ); + editor.setTheme( editor.config.getKey( 'theme' ) ); // diff --git a/editor/js/LocalStorage.js b/editor/js/Config.js similarity index 61% rename from editor/js/LocalStorage.js rename to editor/js/Config.js index 88a883a596c94484e542dc89d5a1411ebe32a154..13daa963e04b506862bfb325cba56cd2de614ae1 100644 --- a/editor/js/LocalStorage.js +++ b/editor/js/Config.js @@ -1,4 +1,4 @@ -var LocalStorage = function () { +var Config = function () { var name = 'threejs-editor'; @@ -6,9 +6,9 @@ var LocalStorage = function () { theme: 'css/light.css' }; - if ( localStorage[ name ] !== undefined ) { + if ( window.localStorage[ name ] !== undefined ) { - storage = JSON.parse( localStorage[ name ] ); + storage = JSON.parse( window.localStorage[ name ] ); } @@ -24,7 +24,7 @@ var LocalStorage = function () { storage[ key ] = value; - localStorage[ name ] = JSON.stringify( storage ); + window.localStorage[ name ] = JSON.stringify( storage ); console.log( '[' + /\d\d\:\d\d\:\d\d/.exec( new Date() )[ 0 ] + ']', 'Saved state to LocalStorage.' ); @@ -32,7 +32,7 @@ var LocalStorage = function () { clear: function () { - delete localStorage[ name ]; + delete window.localStorage[ name ]; } diff --git a/editor/js/Editor.js b/editor/js/Editor.js index 160e4dd66f71cd3ed1a0c589cd063159669d32ba..327f650e5f2bda648465751c51df2f51be9a4686 100644 --- a/editor/js/Editor.js +++ b/editor/js/Editor.js @@ -36,9 +36,9 @@ var Editor = function () { windowResize: new SIGNALS.Signal() }; - + + this.config = new Config(); this.loader = new Loader( this ); - this.localStorage = new LocalStorage(); this.scene = new THREE.Scene(); this.sceneHelpers = new THREE.Scene(); diff --git a/editor/js/Loader.js b/editor/js/Loader.js index 9f8b466dc6fb458571ac62dd3acc48fed16b7c10..08daacbed3dbfd2a431d04ccbef42178e2944211 100644 --- a/editor/js/Loader.js +++ b/editor/js/Loader.js @@ -5,7 +5,7 @@ var Loader = function ( editor ) { this.loadLocalStorage = function () { - var state = editor.localStorage.getKey( 'state' ); + var state = editor.config.getKey( 'state' ); if ( state !== undefined ) { @@ -27,7 +27,7 @@ var Loader = function ( editor ) { timeout = setTimeout( function () { - editor.localStorage.setKey( 'state', exporter.parse( editor.scene ) ); + editor.config.setKey( 'state', exporter.parse( editor.scene ) ); }, 3000 ); diff --git a/editor/js/Menubar.File.js b/editor/js/Menubar.File.js index d1eddd47b65ea6ff9318947419cefa4960176ef5..9a4efca18e454e5801805cd56af7777e793efab5 100644 --- a/editor/js/Menubar.File.js +++ b/editor/js/Menubar.File.js @@ -28,7 +28,7 @@ Menubar.File = function ( editor ) { if ( confirm( 'Are you sure?' ) ) { - editor.localStorage.clear(); + editor.config.clear(); location.href = location.pathname; diff --git a/editor/js/Menubar.View.js b/editor/js/Menubar.View.js index 1326c5d45a44eebc36ef317559b26a592bd932c0..f17e2b547988b9c7c85df39552db3ce6452821f2 100644 --- a/editor/js/Menubar.View.js +++ b/editor/js/Menubar.View.js @@ -27,7 +27,7 @@ Menubar.View = function ( editor ) { option.onClick( function () { editor.setTheme( 'css/light.css' ); - editor.localStorage.setKey( 'theme', 'css/light.css' ); + editor.config.setKey( 'theme', 'css/light.css' ); } ); options.add( option ); @@ -40,7 +40,7 @@ Menubar.View = function ( editor ) { option.onClick( function () { editor.setTheme( 'css/dark.css' ); - editor.localStorage.setKey( 'theme', 'css/dark.css' ); + editor.config.setKey( 'theme', 'css/dark.css' ); } ); options.add( option );