now remembering last clicked tabs

This commit is contained in:
Stephan Richter
2021-02-19 22:26:35 +01:00
parent 54961c1f14
commit a43c11d3bc
10 changed files with 32 additions and 20 deletions

View File

@@ -14,7 +14,7 @@ var mode = null;
var messageTimer = null;
var messageOpacity = 0;
var pendingAssignment = null;
var lastTab = null;
var clickHistory = [];
function addClass(data){
parts = data.split(" ");
@@ -39,17 +39,23 @@ function arrangeTabs(){
tabs.insertAfter($('.swapbtn'));
var target = null;
var index = null;
$('.window > fieldset > legend').each(function(){
var fs = this.parentNode;
if (!fs.id) fs.id = winId+id;
if (fs.id == lastTab) target = this;
var i = clickHistory.indexOf(fs.id);
if (i>-1 && (index == null || i<index)) {
index = i;
target = this;
}
//if (fs.id == lastTab) target = this;
$(this).appendTo(tabs).click(fs.id,clickLegend);
if (id > 0) {
$(fs).hide();
} else $(this).addClass('front');
id++;
});
if (target != null) clickLegend({'data':lastTab,'target':target});
if (index != null) clickLegend({'data':clickHistory[index],'target':target,'no-update':true});
}
function assign(context){
@@ -65,6 +71,7 @@ function clickLegend(ev){
$(ev.target).addClass('front');
$('.window > fieldset').hide();
$('#'+lastTab).show();
if (!('no-update' in ev)) remember(lastTab);
}
function clickTile(x,y,shift){
@@ -211,6 +218,13 @@ function planClick(ev){
console.log('unknown action "'+mode+'" @ ('+ev.clientX+','+ev.clientY+')');
}
function remember(lastClickedId){
console.log("lastClickedId: "+lastClickedId)
var index = clickHistory.indexOf(lastClickedId);
if (index > -1) clickHistory.splice(index, 1);
clickHistory.unshift(lastClickedId);
}
function remove(id){
$('#'+id).remove();
return false;

View File

@@ -128,6 +128,7 @@ disabled routes : deaktivierte Fahrstraßen
DisableEnableBlock : Block (de)aktivieren
Display "{}" on {}. : „{}“ auf {} anzeigen.
Drop : Verwerfen
Drop brake times : Bremszeiten löschen
Dropped destination of {}. : Ziel von {} verworfen.
1) Duration between 5 {} steps during brake process. : 1) Zeit zwischen 5 {}-Schritten beim Bremsvorgang.
EAST : Osten