diff --git a/Readme.md b/Readme.md index 29e7fc3..d1ec8f8 100644 --- a/Readme.md +++ b/Readme.md @@ -249,7 +249,7 @@ The kiosk machine still needs a working internet connection (ethernet, or WiFi c - **1-finger swipe** (dual mode) - Navigate within page (arrow keys) - **On-screen keyboard** - Auto-shows on text fields or click keyboard icon - **Navigation menu** - Click key icon (top-left) to access site list and gesture cheat sheet -- **Back/forward buttons** (optional, off by default) - two half-transparent ◀ ▶ buttons at the top middle of the screen, for kiosks with no keyboard or mouse side buttons. They appear on a tap, click or mouse movement and fade after a few seconds. Turn on in Core Settings → Display & Interaction, or the Web UI, where you can also set how solid they look (opacity 10–100%, default 50). +- **Back / home / forward buttons** (optional, off by default) - three half-transparent buttons (◀ 🏠 ▶) at the top middle of the screen; the home button returns the site on screen to the address it was set up with under Sites & Page Timing, for kiosks with no keyboard or mouse side buttons. They appear on a tap, click or mouse movement and fade after a few seconds. Turn on in Core Settings → Display & Interaction, or the Web UI, where you can also set how solid they look (opacity 10–100%, default 50). ### On-Screen Keyboard - **HTML-based keyboard** with full QWERTY layout @@ -778,6 +778,7 @@ smb://WORKGROUP/COMPUTER/PrinterName - `Ctrl+Shift+Tab` or `Ctrl+[` - Previous tab - `Ctrl+PageDown` / `Ctrl+PageUp` - Next/Previous tab (the standard browser keys) - `Alt+Right` / `Alt+Left` - Page forward / back within the current site (the standard browser keys; they used to switch tabs) +- `Alt+Home` - Back to the current site's own start address (the one set under Sites & Page Timing) - Mouse side buttons (back/forward) - the same page forward/back - `F10` or `Ctrl+H` - Toggle hidden tabs - `Escape` - Return to normal tabs (from hidden) diff --git a/kiosk-app/main.js b/kiosk-app/main.js index c565a22..02f97f4 100644 --- a/kiosk-app/main.js +++ b/kiosk-app/main.js @@ -772,6 +772,23 @@ function rotateToNextSite(){ } } +// The address a site is loaded from: its configured URL, with the site's +// own login filled in (if it has one) and local files/folders turned into +// the kiosk's viewer addresses. Used when a site's view is first created +// and by the home button, so both always agree. +function buildTabUrl(t){ + let url=t.url; + if(t.username&&t.password){ + try{ + const u=new URL(t.url); + u.username=t.username; + u.password=t.password; + url=u.toString(); + }catch(e){} + } + return resolveLocalSite(url); +} + function attachView(i){ closeHTMLKeyboard(); @@ -1157,11 +1174,16 @@ function returnToTabs(){ // mouse's side buttons, and the optional on-screen buttons). Not while the // screen is locked or a dialog (PIN, WiFi, power...) is open on top - the // keys would silently navigate the page hidden behind it. -function historyGo(direction){ - if(isLockedOut)return; +function historyBlocked(){ + if(isLockedOut)return true; for(const w of [pinWindow,wifiWindow,promptWindow,pauseWindow]){ - if(w&&!w.isDestroyed())return; + if(w&&!w.isDestroyed())return true; } + return false; +} + +function historyGo(direction){ + if(historyBlocked())return; const view=showingHidden?hiddenViews[currentHiddenIndex]:views[currentIndex]; if(!view||!view.webContents||view.webContents.isDestroyed())return; const wc=view.webContents; @@ -1174,6 +1196,36 @@ function historyGo(direction){ markActivity(); } +// The tab (index into tabs) behind the n-th hidden view: hidden sites are the +// ones with duration -1, in order. +function hiddenViewIndexToTabIndex(h){ + let n=0; + for(let i=0;i Sites & Page Timing), whatever page the user has +// browsed to since. Acts on the site that's on screen, so with several +// sites each one goes to its own address. +function historyHome(){ + if(historyBlocked())return; + const view=showingHidden?hiddenViews[currentHiddenIndex]:views[currentIndex]; + if(!view||!view.webContents||view.webContents.isDestroyed())return; + const tabIdx=showingHidden?hiddenViewIndexToTabIndex(currentHiddenIndex):viewIndexToTabIndex(currentIndex); + if(tabIdx<0||!tabs[tabIdx])return; + const target=buildTabUrl(tabs[tabIdx]); + if(view.webContents.getURL()!==target){ + view.webContents.loadURL(target).catch(()=>{}); + } + markActivity(); +} + function showPinEntry(){ if(pinWindow&&!pinWindow.isDestroyed()){ pinWindow.focus(); @@ -1579,16 +1631,7 @@ async function createWindow(){ mainWindow.addBrowserView(view); - let url=t.url; - if(t.username&&t.password){ - try{ - const u=new URL(t.url); - u.username=t.username; - u.password=t.password; - url=u.toString(); - }catch(e){} - } - url=resolveLocalSite(url); + const url=buildTabUrl(t); const initialOrigin=new URL(t.url).origin; @@ -1691,6 +1734,7 @@ async function createWindow(){ ipcMain.on('toggle-hidden',toggleHidden); ipcMain.on('history-nav',(event,direction)=>{ if(direction==='back'||direction==='forward')historyGo(direction); + else if(direction==='home')historyHome(); }); ipcMain.on('return-to-tabs',forceReturnToTabs); ipcMain.on('user-activity',markActivity); @@ -1890,6 +1934,7 @@ async function createWindow(){ // Standard browser keys for page back/forward. globalShortcut.register('Alt+Left',()=>{historyGo('back');}); globalShortcut.register('Alt+Right',()=>{historyGo('forward');}); + globalShortcut.register('Alt+Home',()=>{historyHome();}); globalShortcut.register('F10',toggleHidden); globalShortcut.register('Control+H',toggleHidden); diff --git a/kiosk-app/preload.js b/kiosk-app/preload.js index c405bfb..b71d873 100644 --- a/kiosk-app/preload.js +++ b/kiosk-app/preload.js @@ -115,7 +115,7 @@ ipcRenderer.on('keyboard-button-enabled',(event,enabled)=>{ } }); -// On-screen back/forward buttons (top middle, half transparent) - an +// On-screen back / home / forward buttons (top middle, half transparent) - an // option for screens with no keyboard or mouse side buttons. let historyButtonsEnabled=false; let historyBar=null; @@ -280,7 +280,7 @@ window.addEventListener('DOMContentLoaded',()=>{ historyBar.id='electron-history-bar'; historyBar.style.cssText=` position:fixed;top:12px;left:50%;transform:translateX(-50%); - display:none;gap:14px;z-index:999999;opacity:${historyOpacity}; + display:none;gap:18px;z-index:999999;opacity:${historyOpacity}; transition:opacity 0.15s;user-select:none; `; const makeButton=(label,direction,path)=>{ @@ -302,6 +302,7 @@ window.addEventListener('DOMContentLoaded',()=>{ }; historyBar.append( makeButton('Back','back','M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'), + makeButton('Home (this site\'s start page)','home','M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'), makeButton('Forward','forward','M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z') ); historyBar.addEventListener('mouseenter',()=>{historyBar.style.opacity=String(historyHoverOpacity());}); diff --git a/menus/display.sh b/menus/display.sh index f2e6496..f579e47 100644 --- a/menus/display.sh +++ b/menus/display.sh @@ -20,7 +20,7 @@ display_status() { echo "Pause button: $(onoff "$ENABLE_PAUSE_BUTTON")" echo "Keyboard button: $(onoff "$ENABLE_KEYBOARD_BUTTON")" echo "Navigation button: $(onoff "$ENABLE_NAV_BUTTON")" - echo "Back/forward btns: $(onoff "$ENABLE_HISTORY_BUTTONS") (opacity ${HISTORY_BUTTONS_OPACITY}%)" + echo "Back/home/fwd btns: $(onoff "$ENABLE_HISTORY_BUTTONS") (opacity ${HISTORY_BUTTONS_OPACITY}%)" } display_menu_builder() { @@ -30,8 +30,8 @@ display_menu_builder() { "Toggle pause button (currently: $(onoff "$ENABLE_PAUSE_BUTTON"))" "Toggle on-screen keyboard button (currently: $(onoff "$ENABLE_KEYBOARD_BUTTON"))" "Toggle navigation/help button (currently: $(onoff "$ENABLE_NAV_BUTTON"))" - "Toggle on-screen back/forward buttons (currently: $(onoff "$ENABLE_HISTORY_BUTTONS"))" - "Back/forward button opacity (currently: ${HISTORY_BUTTONS_OPACITY}%)" + "Toggle on-screen back/home/forward buttons (currently: $(onoff "$ENABLE_HISTORY_BUTTONS"))" + "Back/home/forward button opacity (currently: ${HISTORY_BUTTONS_OPACITY}%)" ) MENU_HANDLERS=( action_set_touch_mode @@ -144,10 +144,10 @@ action_toggle_nav_button() { action_toggle_history_buttons() { if [[ "$ENABLE_HISTORY_BUTTONS" == "true" ]]; then ENABLE_HISTORY_BUTTONS="false" - log_warning "On-screen back/forward buttons disabled" + log_warning "On-screen back/home/forward buttons disabled" else ENABLE_HISTORY_BUTTONS="true" - log_success "On-screen back/forward buttons enabled" + log_success "On-screen back/home/forward buttons enabled" fi save_config } @@ -156,10 +156,10 @@ action_toggle_history_buttons() { # They get a little more solid while the mouse is over them. action_set_history_opacity() { echo - echo "How solid the on-screen back/forward buttons look (10 = faint, 100 = solid)." + echo "How solid the on-screen back/home/forward buttons look (10 = faint, 100 = solid)." HISTORY_BUTTONS_OPACITY=$(ask_integer "Opacity percent" "$HISTORY_BUTTONS_OPACITY" 10 100) save_config - log_success "Back/forward button opacity: ${HISTORY_BUTTONS_OPACITY}%" + log_success "Back/home/forward button opacity: ${HISTORY_BUTTONS_OPACITY}%" if [[ "$ENABLE_HISTORY_BUTTONS" != "true" ]]; then log_info "The buttons are off - turn them on with the entry above." fi diff --git a/webui/public/index.html b/webui/public/index.html index 9b49176..c4cf4b3 100644 --- a/webui/public/index.html +++ b/webui/public/index.html @@ -95,7 +95,7 @@ - +
Home page @@ -106,7 +106,7 @@