pikvm/pikvm#813: optional page close confirmation

This commit is contained in:
Maxim Devaev 2022-09-01 12:24:17 +03:00
parent a244c36010
commit c15d743f48
3 changed files with 22 additions and 5 deletions

View File

@ -318,6 +318,15 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td>Ask page close confirmation:</td>
<td align="right">
<div class="switch-box">
<input checked type="checkbox" id="page-close-ask-switch">
<label for="page-close-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</tr>
</table> </table>
<hr> <hr>
<div class="buttons buttons-row"> <div class="buttons buttons-row">

View File

@ -96,6 +96,8 @@ li(class="right")
label(for="gpio-switch-__v3_usb_breaker__") label(for="gpio-switch-__v3_usb_breaker__")
span(class="switch-inner") span(class="switch-inner")
span(class="switch") span(class="switch")
tr
+menu_switch_notable("page-close-ask-switch", "Ask page close confirmation", true, true)
hr hr
div(class="buttons buttons-row") div(class="buttons buttons-row")
button(data-force-hide-menu data-show-window="keyboard-window" class="row50") &bull; Show keyboard button(data-force-hide-menu data-show-window="keyboard-window" class="row50") &bull; Show keyboard

View File

@ -32,11 +32,17 @@ import {Session} from "./session.js";
export function main() { export function main() {
if (checkBrowser()) { if (checkBrowser()) {
window.onbeforeunload = function(event) { tools.storage.bindSimpleSwitch($("page-close-ask-switch"), "page.close.ask", true, function(value) {
let text = "Are you sure you want to close PiKVM session?"; if (value) {
event.returnValue = text; window.onbeforeunload = function(event) {
return text; let text = "Are you sure you want to close PiKVM session?";
}; event.returnValue = text;
return text;
};
} else {
window.onbeforeunload = null;
}
});
initWindowManager(); initWindowManager();