/** * Sets the selected tab to the summary tab and loads the summary page. */ function setupNotebook() { console.log("setupNotebook() starting"); changeTab('summaryTab'); // Initially show Summary tab showContent('summaryPageContent') loadSummaryPage(); loadPages(); setCookie("time", "0"); setCookie("scriptScrollY", 0); setCookie("summaryScrollY", 0); run(); // start the script scrolling } /** * Loads the summary tab page; */ function loadSummaryPage() { incidents.doc = getDocumentFromFrame('summaryTabPage'); window.frames[0].loadSummary(incidents); } /** * Loads content of the pages for Simulation Script and Current Event */ function loadPages() { window.frames[1].loadScript(events, incidents); window.frames[2].loadScript(events, incidents); window.frames[4].loadRoles(events, incidents); } /** * Start scrolling the script in an infinite loop. */ function run() { run.initialDelay = 1000; setTimeout("run.run()", run.initialDelay); run.run = function() { setTime(); }; } /** * Sets 'simulationTime' to the current simulation time in seconds. * This method runs itself every second to keep the time current. * Sets the cookie 'time' to the value of 'simulationTime'. * @return */ function setTime() { /** Load the sim time file and extract the seconds */ loadJSON("../dynamicdata/sim_elapsedtime.json", function(response) { try { simclockjson = JSON.parse(response); seconds = simclockjson.elapsedtime; setTime.time = seconds; // increment time by one second (or initialize it if it has not been set before) // setTime.time = (typeof setTime.time == 'undefined') ? 0 : ++setTime.time; setCookie("time", "" + setTime.time); // display the latest simulation time document.getElementById("simulationTime").innerHTML = Time.formatTime(setTime.time); } catch(e) { console.log("Error attempt to parse sim_elapsedtime.json: "+response) } setTimeout("setTime()", 1000); }); } /** * Selects a new tab to be viewed. * @param id The id for the tab to be selected */ function changeTab(id) { /* Set all tabs to not being active */ document.getElementById("summaryTab").className = "notActive"; document.getElementById("scriptTab").className = "notActive"; document.getElementById("currentTab").className = "notActive"; document.getElementById("mapsTab").className = "notActive"; document.getElementById("rolesTab").className = "notActive"; /* Set the selected tab to being active */ document.getElementById(id).className = "activeTab"; } /** * @param id The id of the frame element. * @return The document of the frame element. */ function getDocumentFromFrame(id) { var frame=document.getElementById(id); var doc=(frame.contentWindow || frame.contentDocument); if (doc.document)doc=doc.document; return doc; } /** * Hides a tab page * @param d The div of the page to hide. */ function hideContent(d) { document.getElementById(d).style.display = "none"; } /** * Switches the tab page. * @param d The div of the page to show. */ function showContent(d) { hideContent('summaryPageContent'); hideContent('scriptPageContent'); hideContent('currentEventPageContent'); hideContent('mapsPageContent'); hideContent('rolePageContent'); document.getElementById(d).style.display = "block"; }