@signalk/app-dock 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/public/dock.js +22 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Open: `http://your-sk-server:3000/@signalk/app-dock/`
|
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
|
-
**Double-tap anywhere** on the screen to open the dock. Tap an app icon to switch. The dock auto-dismisses after selection, or tap the backdrop to close it. Double-click works the same way for mouse users.
|
|
34
|
+
**Double-tap anywhere** on the screen to open the dock. Tap an app icon to switch. Tap the icon of the app already on screen to reload it, for example after the app was updated on the server. The dock auto-dismisses after selection, or tap the backdrop to close it. Double-click works the same way for mouse users.
|
|
35
35
|
|
|
36
36
|
Tip: double-tapping a clickable element in the underlying webapp will activate that element once before the dock opens -- aim double-taps at non-interactive regions (maps, gauge backgrounds, empty space).
|
|
37
37
|
|
package/package.json
CHANGED
package/public/dock.js
CHANGED
|
@@ -626,6 +626,18 @@
|
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
// Reloads the frame at the page it is on now. A frame on another origin
|
|
630
|
+
// refuses access to its location, so it starts over at the app's URL.
|
|
631
|
+
function reloadFrame($frame, app) {
|
|
632
|
+
showLoading(app.label)
|
|
633
|
+
$frame.addEventListener('load', hideLoading, { once: true })
|
|
634
|
+
try {
|
|
635
|
+
$frame.contentWindow.location.reload()
|
|
636
|
+
} catch {
|
|
637
|
+
$frame.src = app.url
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
629
641
|
function switchToApp(index) {
|
|
630
642
|
const app = cfg.apps[index]
|
|
631
643
|
if (!app) return
|
|
@@ -641,6 +653,16 @@
|
|
|
641
653
|
const fresh = opensFresh(app)
|
|
642
654
|
const alreadyLoaded = !fresh && !!iframes[app.url]
|
|
643
655
|
|
|
656
|
+
// Tapping the app already on screen reloads it where it is, so a webapp
|
|
657
|
+
// updated on the server is picked up without restarting the browser.
|
|
658
|
+
// destroy mode and fresh apps get a new frame below anyway.
|
|
659
|
+
if (alreadyLoaded && cfg.iframeMode !== 'destroy' && iframes[app.url].classList.contains('active')) {
|
|
660
|
+
reloadFrame(iframes[app.url], app)
|
|
661
|
+
updateHandle()
|
|
662
|
+
hideDock()
|
|
663
|
+
return
|
|
664
|
+
}
|
|
665
|
+
|
|
644
666
|
if (cfg.iframeMode === 'destroy') {
|
|
645
667
|
$iframeContainer.innerHTML = ''
|
|
646
668
|
Object.keys(iframes).forEach((k) => delete iframes[k])
|