From 6986c418e79e39ac939a8565c9b514ddd7028f0e Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Tue, 27 Oct 2020 23:01:46 +0100 Subject: [PATCH] implemented storing of tiling layout on device --- pom.xml | 2 +- resources/js/plan.js | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index a956ae8..a8f506b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.srsoftware web4rail - 0.6.8 + 0.6.9 Web4Rail jar Java Model Railway Control diff --git a/resources/js/plan.js b/resources/js/plan.js index ede0ab4..32991b8 100644 --- a/resources/js/plan.js +++ b/resources/js/plan.js @@ -101,6 +101,11 @@ function fadeMessage(){ $('#messages').css('opacity',o/OPAC); } +function getCookie(key) { + var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); + return keyValue ? keyValue[2] : null; +} + function heartbeat(data){ $('#heartbeat').show().fadeOut(2000); return false; @@ -162,12 +167,9 @@ function request(data){ $(PLAN).append($(resp)); } else if (resp.startsWith('<')) { var isWindow = $(resp).attr('class') == 'window'; - if (isWindow){ - $('.window').remove(); - $('#plan').css('height','50%'); - } - $(BODY).append($(resp)); - $('.window').css('height','50%'); + if (isWindow) $('.window').remove(); + $(BODY).append($(resp)); + if (isWindow) tileWindow(); } else { addMessage(resp); } @@ -202,15 +204,18 @@ function stream(ev){ } function swapTiling(ev){ - if ($('.swapbtn').text() == '◧'){ - $('.swapbtn').text('⬒'); - $('.window').css('height','').css('width','50%'); - $(PLAN).css('height','').css('width','50%'); - } else { - $('.swapbtn').text('◧'); - $('.window').css('height','50%').css('width',''); - $(PLAN).css('height','50%').css('width',''); - } + var vertical = getCookie("tiling") == 'v'; + document.cookie = "tiling="+(vertical?'h':'v'); + tileWindow(); +} + +function tileWindow(){ + var vertical = getCookie("tiling") == 'v'; + var width = vertical ? '50%':''; + var height = vertical ? '' : '50%'; + $(PLAN).css('width',width).css('height',height); + $('.window').css('width',width).css('height',height); + $('.swapbtn').text(vertical ? '⇩' : '⇨'); } function train(id,action){