Skip to content

Commit

Permalink
Changed url parameter passing to localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframHempel committed Dec 14, 2014
1 parent dfc328a commit e4caa36
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/js/LayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,14 @@ lm.utils.copy( lm.LayoutManager.prototype, {
* @returns {Object} config
*/
_createConfig: function( config ) {
var windowConfig = lm.utils.getQueryStringParam( 'gl-window' );

if( windowConfig ) {
var windowConfigKey = lm.utils.getQueryStringParam( 'gl-window' );
if( windowConfigKey ) {
this.isSubWindow = true;
config = window.decodeURIComponent( windowConfig );
config = lm.utils.filterXss( config );
config = localStorage.getItem( windowConfigKey );
config = JSON.parse( config );
config = ( new lm.utils.ConfigMinifier() ).unminifyConfig( config );
localStorage.removeItem( windowConfigKey );
}

config = $.extend( true, {}, lm.config.defaultConfig, config );
Expand Down Expand Up @@ -770,7 +770,7 @@ lm.utils.copy( lm.LayoutManager.prototype, {
this.emit( 'popIn' );
}, this));

document.title = this.config.content[ 0 ].title;
document.title = lm.utils.stripTags( this.config.content[ 0 ].title );

$( 'head' ).append( $( 'body link, body style, template, .gl_keep' ) );

Expand Down
15 changes: 11 additions & 4 deletions src/js/controls/BrowserPopout.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,27 @@ lm.utils.copy( lm.controls.BrowserPopout.prototype, {
* @returns {String} URL
*/
_createUrl: function() {
var config = { content: this._config },
var config = { content: this._config },
storageKey = 'gl-window-config-' + lm.utils.getUniqueId(),
urlParts;

config = ( new lm.utils.ConfigMinifier() ).minifyConfig( config );
config = window.encodeURIComponent( JSON.stringify( config ) );

try{
localStorage.setItem( storageKey, JSON.stringify( config ) );
} catch( e ) {
throw new Error( 'Error while writing to localStorage ' + e.toString() );
}

urlParts = document.location.href.split( '?' );

// URL doesn't contain GET-parameters
if( urlParts.length === 1 ) {
return urlParts[ 0 ] + '?gl-window=' + config;
return urlParts[ 0 ] + '?gl-window=' + storageKey;

// URL contains GET-parameters
} else {
return document.location.href + '&gl-window=' + config;
return document.location.href + '&gl-window=' + storageKey;
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/js/controls/DragProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lm.controls.DragProxy = function( x, y, dragListener, layoutManager, contentItem

this.element = $( lm.controls.DragProxy._template );
this.element.css({ left: x, top: y });
this.element.find( '.lm_title' ).html( lm.utils.filterXss( this._contentItem.config.title, true ) );
this.element.find( '.lm_title' ).html( this._contentItem.config.title );
this.childElementContainer = this.element.find( '.lm_content' );
this.childElementContainer.append( contentItem.element );

Expand Down
2 changes: 1 addition & 1 deletion src/js/controls/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ lm.utils.copy( lm.controls.Tab.prototype,{
*/
setTitle: function( title ) {
this.element.attr( 'title', lm.utils.stripTags( title ) );
this.titleElement.html( lm.utils.filterXss( title, true ) );
this.titleElement.html( title );
},

/**
Expand Down

0 comments on commit e4caa36

Please sign in to comment.