From 7841572a2050f518b427b502dde65c113757830f Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 12 Jul 2013 12:33:09 +0200 Subject: [PATCH] handle old and new embed urls --- static/js/pandora.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/static/js/pandora.js b/static/js/pandora.js index 37c83c5a..dfe6af88 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -30,21 +30,21 @@ appPanel }); } catch(e) {} }; - function getLocalStorage(key) { - //fails if localStorage does not exist or - //if third party cookies are disabled - try { - return localStorage[key]; - } catch(e) {} - } + + // handle old embed and print URLs + document.location.hash = document.location.hash.replace( + /^#(embed|print)=true(&)?/, + function() { + return '#' + arguments[1] + (arguments[2] ? '?' : ''); + } + ); + var animationInterval, enableDebugMode = getLocalStorage('pandora.enableDebugMode'), enableEventLogging = getLocalStorage('pandora.enableEventLogging'), - isEmbed = /^#\?/.test(document.location.hash) - && /embed=true/.test(document.location.hash), + isEmbed = /^#embed(\?.*?)?$/.test(document.location.hash), isMSIE = /MSIE/.test(navigator.userAgent), - isPrint = /^#\?/.test(document.location.hash) - && /print=true/.test(document.location.hash), + isPrint = /^#print(\?.*?)?$/.test(document.location.hash), legacyThemes = {classic: 'oxlight', modern: 'oxdark'}, theme = getLocalStorage('Ox.theme') && JSON.parse(localStorage['Ox.theme']) || 'oxmedium'; @@ -58,6 +58,14 @@ appPanel }); }); + function getLocalStorage(key) { + // fails if localStorage does not exist or if third party cookies are + // disabled + try { + return localStorage[key]; + } catch(e) {} + } + function getPandoraVersion() { var i, path, scripts = document.getElementsByTagName('script'); for (i = 0;i < scripts.length; i++) {