improved message handling
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.5.35</version>
|
<version>1.5.36</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const POST = 'POST';
|
|||||||
const PROPS = 'props';
|
const PROPS = 'props';
|
||||||
const SQUARE = 30;
|
const SQUARE = 30;
|
||||||
const SVG = 'svg';
|
const SVG = 'svg';
|
||||||
|
const MSG_TIME = 5000;
|
||||||
var selected = null;
|
var selected = null;
|
||||||
var mode = null;
|
var mode = null;
|
||||||
var messageTimer = null;
|
var messageTimer = null;
|
||||||
@@ -41,11 +42,18 @@ function addClass(data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addMessage(txt){
|
function addMessage(txt){
|
||||||
|
let delay = MSG_TIME;
|
||||||
|
if (txt.includes('⌛')){
|
||||||
|
let parts = txt.split('⌛');
|
||||||
|
delay = parseInt(parts[0]);
|
||||||
|
txt = parts[1];
|
||||||
|
}
|
||||||
let mid = 'm'+Date.now();
|
let mid = 'm'+Date.now();
|
||||||
$('#messages').append($('<div/>').attr('id',mid).html(txt));
|
$('#messages').append($('<div/>').attr('id',mid).html(txt));
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('#'+mid).remove();
|
$('#'+mid).remove();
|
||||||
},10000);
|
},delay);
|
||||||
|
if (delay != MSG_TIME) countDown(mid,delay/1000,txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTile(x,y){
|
function addTile(x,y){
|
||||||
@@ -86,11 +94,9 @@ function assign(context){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changeSpeed(inputId){
|
function changeSpeed(inputId){
|
||||||
console.log(inputId);
|
|
||||||
let parts = inputId.split('_');
|
let parts = inputId.split('_');
|
||||||
let val = $('#'+inputId).val();
|
let val = $('#'+inputId).val();
|
||||||
let data = { realm : parts[0], id : parts[1], action : "setSpeed", speed : val};
|
let data = { realm : parts[0], id : parts[1], action : "setSpeed", speed : val};
|
||||||
console.log(data);
|
|
||||||
let caption = $('#'+inputId+'_caption');
|
let caption = $('#'+inputId+'_caption');
|
||||||
caption.text(caption.text().replace(/\d+/,val));
|
caption.text(caption.text().replace(/\d+/,val));
|
||||||
request(data);
|
request(data);
|
||||||
@@ -114,9 +120,7 @@ function clickTile(x,y,shift){
|
|||||||
if (pendingAssignment != null) {
|
if (pendingAssignment != null) {
|
||||||
var key = pendingAssignment.assign;
|
var key = pendingAssignment.assign;
|
||||||
delete pendingAssignment.assign;
|
delete pendingAssignment.assign;
|
||||||
console.log("assigning key:",key);
|
|
||||||
pendingAssignment[key] = id;
|
pendingAssignment[key] = id;
|
||||||
console.log("pA:",pendingAssignment);
|
|
||||||
request(pendingAssignment);
|
request(pendingAssignment);
|
||||||
pendingAssignment = null;
|
pendingAssignment = null;
|
||||||
$(PLAN).css('cursor','');
|
$(PLAN).css('cursor','');
|
||||||
@@ -155,6 +159,15 @@ function copyCv(ev){
|
|||||||
$('input[name=val]').val(td.innerText);
|
$('input[name=val]').val(td.innerText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function countDown(mid,time,msg){
|
||||||
|
time = parseInt(time);
|
||||||
|
$('#'+mid).html(msg.replace('%secs%',time));
|
||||||
|
time = time -1;
|
||||||
|
if (time>0) setTimeout(function(){
|
||||||
|
countDown(mid,time,msg);
|
||||||
|
},1000);
|
||||||
|
}
|
||||||
|
|
||||||
function dropClass(data){
|
function dropClass(data){
|
||||||
var parts = data.split(" ");
|
var parts = data.split(" ");
|
||||||
for (var i=1; i<parts.length; i++) $('#'+parts[0]).removeClass(parts[i]);
|
for (var i=1; i<parts.length; i++) $('#'+parts[0]).removeClass(parts[i]);
|
||||||
@@ -235,7 +248,7 @@ function place(data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function planClick(ev){
|
function planClick(ev){
|
||||||
console.log('planClick:',ev);
|
//console.log('planClick:',ev);
|
||||||
var plan=$('#scroll').get(0);
|
var plan=$('#scroll').get(0);
|
||||||
var x = Math.floor((plan.scrollLeft+ev.clientX)/SQUARE);
|
var x = Math.floor((plan.scrollLeft+ev.clientX)/SQUARE);
|
||||||
var y = Math.floor((plan.scrollTop+ev.clientY)/SQUARE);
|
var y = Math.floor((plan.scrollTop+ev.clientY)/SQUARE);
|
||||||
@@ -253,7 +266,7 @@ function planClick(ev){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function remember(lastClickedId){
|
function remember(lastClickedId){
|
||||||
console.log("lastClickedId: "+lastClickedId)
|
//console.log("lastClickedId: "+lastClickedId)
|
||||||
var index = clickHistory.indexOf(lastClickedId);
|
var index = clickHistory.indexOf(lastClickedId);
|
||||||
if (index > -1) clickHistory.splice(index, 1);
|
if (index > -1) clickHistory.splice(index, 1);
|
||||||
clickHistory.unshift(lastClickedId);
|
clickHistory.unshift(lastClickedId);
|
||||||
@@ -265,7 +278,7 @@ function remove(id){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function request(data){
|
function request(data){
|
||||||
console.log("request:",data);
|
//console.log("request:",data);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'plan',
|
url : 'plan',
|
||||||
method : POST,
|
method : POST,
|
||||||
@@ -331,7 +344,7 @@ function stream(ev){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitForm(formId){
|
function submitForm(formId){
|
||||||
console.log("submitForm("+formId+")");
|
//console.log("submitForm("+formId+")");
|
||||||
return request($('#'+formId).serialize());
|
return request($('#'+formId).serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ Values : Werte
|
|||||||
WaitForContact : Auf Kontakt warten
|
WaitForContact : Auf Kontakt warten
|
||||||
Wait for {}, then : auf {} warten, dann
|
Wait for {}, then : auf {} warten, dann
|
||||||
Wait {} ms, then : {} ms warten, dann
|
Wait {} ms, then : {} ms warten, dann
|
||||||
{} waiting {} secs. : {} wartet {} Sekunden.
|
{} waiting %secs% secs. : {} wartet %secs% Sekunden.
|
||||||
Wait times : Wartezeiten
|
Wait times : Wartezeiten
|
||||||
Was not able to assign {} to {}! : Konnte {} nicht an {} zuweisen!
|
Was not able to assign {} to {}! : Konnte {} nicht an {} zuweisen!
|
||||||
Was not able to lock {} : Konnte {} nicht reservieren
|
Was not able to lock {} : Konnte {} nicht reservieren
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
|
|
||||||
if (autopilot) {
|
if (autopilot) {
|
||||||
if (isNull(waitTime)) waitTime = 0;
|
if (isNull(waitTime)) waitTime = 0;
|
||||||
if (waitTime>0) plan.stream(t("{} waiting {} secs.",this,(int)(waitTime/1000)));
|
if (waitTime>0) plan.stream(waitTime+"⌛"+t("{} waiting %secs% secs.",this));
|
||||||
new DelayedExecution(waitTime,this) {
|
new DelayedExecution(waitTime,this) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -242,7 +242,8 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
PriorityQueue<Trail> trails = new PriorityQueue<>();
|
PriorityQueue<Trail> trails = new PriorityQueue<>();
|
||||||
|
|
||||||
for (Route route : startBlock.leavingRoutes()) {
|
for (Route route : startBlock.leavingRoutes()) {
|
||||||
int score = (route.endsAt(destination)) ? 100_000 : 0;
|
boolean reachesDest = route.endsAt(destination);
|
||||||
|
int score = reachesDest ? 100_000 : 0;
|
||||||
|
|
||||||
if (isSet(startDirection) && route.startDirection != startDirection) { // Route startet entgegen der aktuellen Fahrtrichtung des Zuges
|
if (isSet(startDirection) && route.startDirection != startDirection) { // Route startet entgegen der aktuellen Fahrtrichtung des Zuges
|
||||||
if (!train.pushPull) continue; // Zug kann nicht wenden
|
if (!train.pushPull) continue; // Zug kann nicht wenden
|
||||||
@@ -254,7 +255,7 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
|
|
||||||
if (!route.allowed(new Context(train).block(startBlock).direction(startDirection))) {
|
if (!route.allowed(new Context(train).block(startBlock).direction(startDirection))) {
|
||||||
LOG.debug(" - {} not allowed for {}", route, train);
|
LOG.debug(" - {} not allowed for {}", route, train);
|
||||||
if (!route.endsAt(destination)) continue;
|
if (!reachesDest) continue;
|
||||||
LOG.debug(" …overridden by destination of train!", route, train);
|
LOG.debug(" …overridden by destination of train!", route, train);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user