Skip to content

Commit

Permalink
UI bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgassler committed Oct 14, 2023
1 parent 5f3e973 commit 5791792
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 51 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Docs/README.md
@@ -1,6 +1,6 @@
# Task Story

[WebUI Version: 0.6.55](https://github.com/StoicDreams/RustWebUI)
[WebUI Version: 0.6.56](https://github.com/StoicDreams/RustWebUI)

Simple task management tool focused around Continuous Agile Software Engineering practices and methodologies.

Expand Down
2 changes: 1 addition & 1 deletion webapp/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "webapp"
version = "0.6.55" #syncwebui
version = "0.6.56" #syncwebui
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
57 changes: 14 additions & 43 deletions webapp/js/webui.js
@@ -1,10 +1,10 @@
(function webuiSetup(){
(function webuiSetup() {
"use strict"
function getEl(sel, mswait) {
return new Promise((resolve, reject) => {
let el = null;
const start = Date.now();
(function check(){
(function check() {
el = document.querySelector(sel);
if (el) {
resolve(el);
Expand All @@ -15,58 +15,38 @@
reject(`Element ${sel} not found.`);
return;
}
setTimeout(check,10);
setTimeout(check, 10);
})();
});
}
function getMatchByKey(target, key) {
let el = target;
let i = 0;
while(el && i++ < 10) {
while (el && i++ < 10) {
if (el[key]) { return el; }
el = el.parentNode;
}
return undefined;
}
function handleNav(target) {
if (!target.parentNode) {
// WebUI Already removed from DOM
return true;
}
let anchor = getMatchByKey(target, 'href');
if (!anchor) {return false;}
// Disabling local navigation which will be handled by PWA webasembly processing
if (anchor.href[0] === '/'
|| anchor.href.substr(0, location.origin.length).toLowerCase() === location.origin.toLowerCase()) {
history.pushState(null, null, anchor.href);
return true;
}
// Assuring external navigation opens a new window|tab
if (anchor.href.substr(0,4) === 'http') {
window.open(anchor.href, '_blank');
return true;
}
return false;
}
const styles = document.createElement('style');
function set_body_class(winWidth) {
// Flag general width by class
let w = winWidth > 3800 ? 'w-4k'
: winWidth > 3400 ? 'w-wqhd'
: winWidth > 2500 ? 'w-qhd'
: winWidth > 1900 ? 'w-fhd'
: winWidth > 1500 ? 'w-hdp'
: winWidth > 1300 ? 'w-hd'
: winWidth > 500 ? 'w-tab'
: 'w-mob'
: winWidth > 2500 ? 'w-qhd'
: winWidth > 1900 ? 'w-fhd'
: winWidth > 1500 ? 'w-hdp'
: winWidth > 1300 ? 'w-hd'
: winWidth > 500 ? 'w-tab'
: 'w-mob'
;
document.body.className = `${w}`;
}
async function applyDynamicStyleRules() {
let w = window;
let h = await getEl('#app > header', 1) || {clientHeight: 0};
let m = await getEl('#app > main', 1) || {clientHeight:0,clientWidth:0};
let f = await getEl('#app > footer', 1) || {clientHeight:0};
let h = await getEl('#app > header', 1) || { clientHeight: 0 };
let m = await getEl('#app > main', 1) || { clientHeight: 0, clientWidth: 0 };
let f = await getEl('#app > footer', 1) || { clientHeight: 0 };
styles.innerHTML = `
:root {
--window-width: ${w.innerWidth}px;
Expand All @@ -89,17 +69,8 @@
applyDynamicStyleRules();
}
getEl('#app', 30000).then(el => {
el.addEventListener('click', ev => {
if (!ev.target) { return false; }
if (handleNav(ev.target)) {
ev.preventDefault();
ev.stopPropagation();
return false;
}
return true;
});
setupWatchers();
setTimeout(()=> {
setTimeout(() => {
el.className = 'page transition in';
setTimeout(() => {
el.className = '';
Expand Down
2 changes: 1 addition & 1 deletion webapp/root_files/service-worker.js
Expand Up @@ -11,7 +11,7 @@ function get_uuid() {
});
}
}
const currentVersion = location.host.substring(0, 9) === 'localhost' ? `${get_uuid()}` : 'webui_0.6.55';
const currentVersion = location.host.substring(0, 9) === 'localhost' ? `${get_uuid()}` : 'webui_0.6.56';
const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${currentVersion}`;
const offlineAssetsInclude = [/\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/];
Expand Down

0 comments on commit 5791792

Please sign in to comment.