Simplify page switching method

This commit is contained in:
Ray Schamp 2015-05-06 09:53:59 -04:00
parent a69d55e995
commit a473ebf565

View file

@ -107,11 +107,9 @@ swfobject.embedSWF('Scratch.swf', 'editor', '100%', '100%', '11.7.0', 'libs/expr
function showPage(path) { function showPage(path) {
var toHide = "body > main, body > main > article, #editor"; var toHide = "body > main, body > main > article, #editor";
var toShow = "#" + path; var toShow = "#" + path;
if (path != "editor") {
toShow += ", body > main";
}
$(toHide).hide(); $(toHide).hide();
$("body > main, body > main > article").has(toShow).show();
$(toShow).show(); $(toShow).show();
} }
@ -120,9 +118,9 @@ $("[data-staticlink]").click(function(e) {
showPage(e.target.attributes['data-staticlink'].value) showPage(e.target.attributes['data-staticlink'].value)
}); });
var initialID = "home";
$(function (){ function initPage() {
if (window.location.hash) { if (window.location.hash) initialID = window.location.hash.substr(1);
showPage(window.location.hash.substr(1)); showPage(initialID);
} }
}); $(initPage);