support switching among tabs

This commit is contained in:
wixette 2020-03-08 17:16:49 +08:00
parent 0382229f54
commit badbe39466
3 changed files with 46 additions and 12 deletions

View File

@ -29,10 +29,10 @@
</div> </div>
</div> </div>
<nav> <nav>
<div id="simulator" class="nav-item l10n">Simulator</div> <div id="nav-sim" class="nav-item l10n">Sim</div>
<div id="debug" class="nav-item l10n">Debug</div> <div id="nav-debug" class="nav-item l10n">Debug</div>
<div id="code" class="nav-item l10n">Code</div> <div id="nav-ref" class="nav-item l10n">Ref</div>
<div id="locale" class="nav-item">En|中文</div> <div id="nav-locale" class="nav-item">En|中文</div>
</nav> </nav>
</header> </header>
@ -575,7 +575,7 @@
<div id="mem-dump"></div> <div id="mem-dump"></div>
</div> </div>
<div id="tab-res"> <div id="tab-ref">
<p> <p>
<span id="source-code" class="l10n">Source code</span>: <span id="source-code" class="l10n">Source code</span>:
<a href="https://github.com/wixette/8800-simulator">github.com/wixette/8800-simulator</a> <a href="https://github.com/wixette/8800-simulator">github.com/wixette/8800-simulator</a>

View File

@ -45,19 +45,19 @@ l10n.MESSAGES = {
'zh': 'Sim-8800: Altair 8800 模拟器', 'zh': 'Sim-8800: Altair 8800 模拟器',
}, },
'simulator': { 'nav-sim': {
'en': 'Simulator', 'en': 'Sim',
'zh': '模拟器', 'zh': '模拟器',
}, },
'debug': { 'nav-debug': {
'en': 'Debug', 'en': 'Debug',
'zh': '调试', 'zh': '调试',
}, },
'code': { 'nav-ref': {
'en': 'Code', 'en': 'Ref',
'zh': '源码', 'zh': '参考',
}, },
'switchboard': { 'switchboard': {

View File

@ -557,8 +557,15 @@ panel.init = function() {
l10n.restoreLocale(); l10n.restoreLocale();
// Initializes event listener for nav buttons. // Initializes event listener for nav buttons.
var button = document.getElementById('locale'); var button = document.getElementById('nav-locale');
button.addEventListener('click', l10n.nextLocale, false); button.addEventListener('click', l10n.nextLocale, false);
button = document.getElementById('nav-sim');
button.addEventListener('click', panel.showTabSim, false);
button = document.getElementById('nav-debug');
button.addEventListener('click', panel.showTabDebug, false);
button = document.getElementById('nav-ref');
button.addEventListener('click', panel.showTabRes, false);
panel.showTabSim();
// Initializes event listener for debug controls. // Initializes event listener for debug controls.
button = document.getElementById('debug-load-data'); button = document.getElementById('debug-load-data');
@ -875,3 +882,30 @@ panel.playToggle = function() {
panel.playSwitch = function() { panel.playSwitch = function() {
panel.playSound('sound-switch'); panel.playSound('sound-switch');
}; };
/**
* Shows the simulator tab, and hides the other two.
*/
panel.showTabSim = function() {
document.getElementById('tab-sim').style.display = 'block';
document.getElementById('tab-debug').style.display = 'none';
document.getElementById('tab-ref').style.display = 'none';
};
/**
* Shows the debug tab, and hides the other two.
*/
panel.showTabDebug = function() {
document.getElementById('tab-sim').style.display = 'none';
document.getElementById('tab-debug').style.display = 'block';
document.getElementById('tab-ref').style.display = 'none';
};
/**
* Shows the resource tab, and hides the other two.
*/
panel.showTabRes = function() {
document.getElementById('tab-sim').style.display = 'none';
document.getElementById('tab-debug').style.display = 'none';
document.getElementById('tab-ref').style.display = 'block';
};