Frontend:

- Make all theme colours CSS Vars.
 - Dynamic text in loading box.

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-21 20:24:59 +00:00
parent a24642b3da
commit 88ae58368e
9 changed files with 78 additions and 29 deletions

View File

@ -1,7 +1,18 @@
# What to do next: # What to do next:
* Backend - Add Indexes: ## Frontend:
* Implement error pages.
* Alerts box should not be clickable, bar should be.
* Issue page: Submit using API.
* Support multiple service origins/destinations:
- Where there are multiples an array is returned for trainServices.service
* Enable text search for `locationName` on find-code page.
## Backend:
* DB Indexes:
- "stations": 3ALPHA, STANOX, TIPLOC - "stations": 3ALPHA, STANOX, TIPLOC
- "corpus": 3ALPHA, NLC, NLCDESC(TEXT) - "corpus": 3ALPHA, NLC, NLCDESC(TEXT)
* Backend - The list of services should always be an array [] as per the NRCC MEssages. * Add Gitea Issue API
* Frontend - Implement error pages

View File

@ -20,7 +20,7 @@
<div id="loading"> <div id="loading">
<div class="spinner"> <div class="spinner">
</div> </div>
<p>Loading</p> <p id="loading_desc">Loading</p>
</div> </div>
<div id="content"> <div id="content">
@ -34,18 +34,19 @@
</div> </div>
</div> </div>
<div id="alerts"> <div id="alerts" onclick="">
<div id="alerts_bar" onclick="inflateAlerts()"> <div id="alerts_bar" onclick="inflateAlerts()">
<img id="alert_icon" src="./images/nav/alert_icon.svg" alt=""> <img id="alert_icon" src="./images/nav/alert_icon.svg" alt="">
<p id="alert_bar_note"></p> <p id="alert_bar_note"></p>
<button id="alert_expand_arrow">&#8897;</button> <button id="alert_expand_arrow">&#8897;</button>
<div id="alerts_msg"> <div id="alerts_msg" onclick="NULL">
</div> </div>
</div> </div>
</div> </div>
<div id="output"> <div id="output">
<table> <table>
<caption>Train Services</caption>
<tr> <tr>
<th class="name">Origin</th> <th class="name">Origin</th>
<th class="name">Dest.</th> <th class="name">Dest.</th>
@ -61,9 +62,9 @@
</div> </div>
</div> </div>
<div id="ferry" class="hide-when-loading"> <div id="ferry" class="hide-when-loading secondary-table">
<p>Ferry Services</p>
<table> <table>
<caption>Ferry Services</caption>
<tr> <tr>
<th class="name">Origin</th> <th class="name">Origin</th>
<th class="name">Dest.</th> <th class="name">Dest.</th>
@ -76,9 +77,9 @@
</table> </table>
</div> </div>
<div id="bus" class="hide-when-loading"> <div id="bus" class="hide-when-loading secondary-table">
<p>Bus Services</p>
<table> <table>
<caption>Bus Services</caption>
<tr> <tr>
<th class="name">Origin</th> <th class="name">Origin</th>
<th class="name">Dest.</th> <th class="name">Dest.</th>

View File

@ -38,7 +38,7 @@
<div id="loading"> <div id="loading">
<div class="spinner"> <div class="spinner">
</div> </div>
<p>Searching</p> <p id="loading_desc">Searching</p>
</div> </div>
<label for="name">Location name:</label><br> <label for="name">Location name:</label><br>

View File

@ -20,7 +20,7 @@
<div id="loading"> <div id="loading">
<div class="spinner"> <div class="spinner">
</div> </div>
<p>Loading</p> <p id="loading_desc">Loading</p>
</div> </div>
<!-- Popup Menu --> <!-- Popup Menu -->

View File

@ -23,19 +23,24 @@ async function fetchEntry(){ // This can be condensed
async function parseData(values){ async function parseData(values){
if (values.crs != ""){ if (values.crs != ""){
setLoadingDesc(`Searching\n${values.crs.toUpperCase()}`)
var data = await getData("crs", values.crs) var data = await getData("crs", values.crs)
} else if (values.nlc != ""){ } else if (values.nlc != ""){
setLoadingDesc(`Searching\n${values.nlc.toUpperCase()}`)
var data = await getData("nlc", values.nlc) var data = await getData("nlc", values.nlc)
} else if (values.tiploc != ""){ } else if (values.tiploc != ""){
setLoadingDesc(`Searching\n${values.tiploc.toUpperCase()}`)
var data = await getData("tiploc", values.tiploc) var data = await getData("tiploc", values.tiploc)
} else if (values.stanox != ""){ } else if (values.stanox != ""){
setLoadingDesc(`Searching\n${values.stanox.toUpperCase()}`)
var data = await getData("stanox", values.stanox) var data = await getData("stanox", values.stanox)
} else if (values.name != ""){ } else if (values.name != ""){
setLoadingDesc(`Searching\n${values.name.capitalize()}`)
var data = await getData("name", values.name) var data = await getData("name", values.name)
} else { } else {
errorNoData() errorNoData()
hideLoading() hideLoading()
return return;
} }
displayData(data); displayData(data);

View File

@ -1,4 +1,4 @@
// Toggle Loading Box // Loading Box
async function clearLoading() { async function clearLoading() {
document.getElementById("loading").style = "display: none;"; document.getElementById("loading").style = "display: none;";
} }
@ -7,6 +7,10 @@ async function showLoading() {
document.getElementById("loading").style = "display: block;"; document.getElementById("loading").style = "display: block;";
} }
async function setLoadingDesc(desc) {
document.getElementById("loading_desc").textContent = `${desc}`;
}
// Enable delays // Enable delays
const delay = ms => new Promise(res => setTimeout(res, ms)); const delay = ms => new Promise(res => setTimeout(res, ms));

View File

@ -4,6 +4,7 @@ init()
/* Supporting Functions */ /* Supporting Functions */
async function init() { async function init() {
var stn = await getQuery("stn"); var stn = await getQuery("stn");
setLoadingDesc(`Loading\n${stn.toUpperCase()}`)
log(`init: Looking up: ${stn}`); log(`init: Looking up: ${stn}`);
var sv = await getQuery("sv"); var sv = await getQuery("sv");
log(`init: Staff Version: ${sv}`); log(`init: Staff Version: ${sv}`);
@ -13,10 +14,12 @@ async function init() {
} else { } else {
try { try {
var data = await publicLdb(stn) var data = await publicLdb(stn)
setLoadingDesc(`${stn.toUpperCase()}\nParsing Data`)
log("init: Fetched LDB Data") log("init: Fetched LDB Data")
parseLdb(data) parseLdb(data)
} catch (err) { } catch (err) {
var data = null var data = null
setLoadingDesc(`Handling\nError`)
log("init: Unable to fetch LDB data") log("init: Unable to fetch LDB data")
} }
} }
@ -54,6 +57,7 @@ async function parseLdb(data) {
// Build and Display Functions // Build and Display Functions
async function buildPage(data) { async function buildPage(data) {
setLoadingDesc('Loading\nTrains')
var stationName = data.GetStationBoardResult.locationName; var stationName = data.GetStationBoardResult.locationName;
log(`buildPage: Data ready for ${stationName}`); log(`buildPage: Data ready for ${stationName}`);
var generateTime = new Date(await data.GetStationBoardResult.generatedAt); var generateTime = new Date(await data.GetStationBoardResult.generatedAt);
@ -61,6 +65,7 @@ async function buildPage(data) {
setHeaders(stationName, generateTime); setHeaders(stationName, generateTime);
// Check for notices and if true pass to function // Check for notices and if true pass to function
if (data.GetStationBoardResult.nrccMessages) { if (data.GetStationBoardResult.nrccMessages) {
setLoadingDesc('Loading\nAlerts')
displayAlerts(data.GetStationBoardResult.nrccMessages.message); displayAlerts(data.GetStationBoardResult.nrccMessages.message);
} }
if (typeof data.GetStationBoardResult.trainServices == 'undefined') { if (typeof data.GetStationBoardResult.trainServices == 'undefined') {
@ -69,9 +74,11 @@ async function buildPage(data) {
displayTrains(data) displayTrains(data)
} }
if (data.GetStationBoardResult.ferryServices) { if (data.GetStationBoardResult.ferryServices) {
setLoadingDesc('Loading\nFerries')
displayFerry(data.GetStationBoardResult.ferryServices) displayFerry(data.GetStationBoardResult.ferryServices)
} }
if (data.GetStationBoardResult.busServices) { if (data.GetStationBoardResult.busServices) {
setLoadingDesc('Loading\nBusses')
displayBus(data.GetStationBoardResult.busServices) displayBus(data.GetStationBoardResult.busServices)
} }
} }

View File

@ -28,7 +28,7 @@
width: 100%; width: 100%;
height: 50px; height: 50px;
background-color: var(--overlay-color); background-color: var(--overlay-color);
color: lightgrey; color: var(--second-text-color);
} }
#station_name { #station_name {
@ -84,8 +84,8 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 40px; height: 40px;
background-color: darkorange; background-color: var(--main-alert-color);
color: white; color: var(--second-text-color);
} }
#alert_icon{ #alert_icon{
@ -114,7 +114,7 @@
background: none; background: none;
border: none; border: none;
font-weight: 900; font-weight: 900;
color: white; color: var(--second-text-color);
transition: transform 0.25s linear; transition: transform 0.25s linear;
} }
@ -124,7 +124,8 @@
left: 0; left: 0;
top: 40px; top: 40px;
width: 100%; width: 100%;
background-color: orange; background-color: var(--main-alert-color);
background-image: radial-gradient(var(--second-alert-color) 10%,var(--main-alert-color) 70%); /* Undecided whether this actually looks better than plain orange? */
} }
#alerts_msg p { #alerts_msg p {
@ -146,8 +147,16 @@ table {
margin-top: 3px; margin-top: 3px;
font-size: 10.5px; font-size: 10.5px;
} }
#ferry{
margin-top: 45px; caption{
padding-top: 5px;
padding-bottom: 10px;
font-size: larger;
font-weight: 900;
}
.secondary-table{
margin-top: 25px;
} }
.name{ .name{
width: 25%; width: 25%;
@ -155,7 +164,7 @@ table {
} }
.name-item { .name-item {
color: yellow; color: var(--board-name-color);
} }
.plat{ .plat{
@ -174,7 +183,7 @@ table {
margin: 0; margin: 0;
margin-left: 3px; margin-left: 3px;
text-align: left; text-align: left;
color: lightblue; color: var(--note-text-color);
} }
.changed{ .changed{
@ -201,12 +210,12 @@ table {
/* Animations */ /* Animations */
@keyframes pulse-change { @keyframes pulse-change {
50% { 50% {
color: orange; color: var(--main-warning-color);
} }
} }
@keyframes pulse-cancel { @keyframes pulse-cancel {
50% { 50% {
color: darkorange; color: var(--main-alert-color);
} }
} }

View File

@ -34,11 +34,19 @@
/* COLOR VARS */ /* COLOR VARS */
:root { :root {
--main-bg-color: #404c55; --main-bg-color: #404c55;
--second-bg-color: #2b343c; /* Use as first arg in radial gradient */
--accent-color: #007979; --accent-color: #007979;
--overlay-color: #3c6f79de; --overlay-color: #3c6f79de;
--main-text-color: #00b7b7; --main-text-color: #00b7b7;
--second-text-color: azure;
--note-text-color: #9de7ff;
--link-color: azure; --link-color: azure;
--box-border-color: ;
--link-visited-color: azure; --link-visited-color: azure;
--main-alert-color: #ed6d00;
--second-alert-color: #e77f00; /* Use as second arg in radial gradient */
--main-warning-color: orange;
--board-name-color: #fcfc09;
} }
/* Loading Box: */ /* Loading Box: */
@keyframes spinner { @keyframes spinner {
@ -53,7 +61,7 @@
animation: 1.5s linear infinite spinner; animation: 1.5s linear infinite spinner;
animation-play-state: inherit; animation-play-state: inherit;
border: solid 5px var(--overlay-color); border: solid 5px var(--overlay-color);
border-bottom-color: white; border-bottom-color: var(--second-text-color);
border-radius: 50%; border-radius: 50%;
content: ""; content: "";
height: 40px; height: 40px;
@ -75,10 +83,13 @@
padding: 20px; padding: 20px;
padding-bottom: 1px; padding-bottom: 1px;
min-width: 90px; min-width: 90px;
max-width: 90px;
transition: 0.5s;
} }
#loading p { #loading p {
padding-top: 50px; padding-top: 50px;
font-weight: bolder; font-weight: bolder;
overflow-wrap: normal;
} }
/* MAIN */ /* MAIN */
@ -88,6 +99,7 @@ html{
} }
body { body {
background-color: var(--main-bg-color); background-color: var(--main-bg-color);
background-image: radial-gradient(var(--second-bg-color), var(--main-bg-color));
color: var(--main-text-color); color: var(--main-text-color);
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
text-align: center; text-align: center;
@ -286,7 +298,7 @@ footer {
background-color: var(--accent-color); background-color: var(--accent-color);
font-family: firamono, monospace; font-family: firamono, monospace;
font-size: smaller; font-size: smaller;
color: white; color: var(--second-text-color);
width: 100%; width: 100%;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@ -294,10 +306,10 @@ footer {
} }
footer a { footer a {
text-decoration: underline; text-decoration: underline;
color: white; color: var(--link-color);
} }
footer a:visited { footer a:visited {
color: white; color: var(--link-visited-color);
} }
footer a:hover { footer a:hover {
color: beige; color: beige;