From a473ebf565447b85ecb712b7dcb09fabd502d86f Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Wed, 6 May 2015 09:53:59 -0400 Subject: [PATCH] Simplify page switching method --- js/scratchx.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/js/scratchx.js b/js/scratchx.js index 6a5d3f4..dd74123 100644 --- a/js/scratchx.js +++ b/js/scratchx.js @@ -107,11 +107,9 @@ swfobject.embedSWF('Scratch.swf', 'editor', '100%', '100%', '11.7.0', 'libs/expr function showPage(path) { var toHide = "body > main, body > main > article, #editor"; var toShow = "#" + path; - if (path != "editor") { - toShow += ", body > main"; - } $(toHide).hide(); + $("body > main, body > main > article").has(toShow).show(); $(toShow).show(); } @@ -120,9 +118,9 @@ $("[data-staticlink]").click(function(e) { showPage(e.target.attributes['data-staticlink'].value) }); - -$(function (){ - if (window.location.hash) { - showPage(window.location.hash.substr(1)); - } -}); +var initialID = "home"; +function initPage() { + if (window.location.hash) initialID = window.location.hash.substr(1); + showPage(initialID); +} +$(initPage);