Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const UI = {
UI.initSetting('shared', true);
UI.initSetting('bell', 'on');
UI.initSetting('view_only', false);
UI.initSetting('warn_before_close', false);
UI.initSetting('show_dot', false);
UI.initSetting('path', 'websockify');
UI.initSetting('repeaterID', '');
Expand Down Expand Up @@ -369,6 +370,7 @@ const UI = {
UI.addSettingChangeHandler('shared');
UI.addSettingChangeHandler('view_only');
UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
UI.addSettingChangeHandler('warn_before_close');
UI.addSettingChangeHandler('show_dot');
UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor);
UI.addSettingChangeHandler('host');
Expand Down Expand Up @@ -887,6 +889,7 @@ const UI = {
UI.updateSetting('compression');
UI.updateSetting('shared');
UI.updateSetting('view_only');
UI.updateSetting('warn_before_close');
UI.updateSetting('path');
UI.updateSetting('repeaterID');
UI.updateSetting('logging');
Expand Down Expand Up @@ -1221,8 +1224,10 @@ const UI = {
// preventDefault() or a nonempty returnValue, though the latter is
// considered legacy. The custom string is ignored by modern browsers,
// which display a native message, but older browsers will show it.
e.preventDefault();
e.returnValue = _("Are you sure you want to disconnect the session?");
if (UI.getSetting('warn_before_close')) {
e.preventDefault();
e.returnValue = _("Are you sure you want to disconnect the session?");
}
},

updateBeforeUnload() {
Expand Down Expand Up @@ -1769,13 +1774,15 @@ const UI = {
.classList.add('noVNC_hidden');
document.getElementById('noVNC_clipboard_button')
.classList.add('noVNC_hidden');
UI.disableSetting('warn_before_close');
} else {
document.getElementById('noVNC_keyboard_button')
.classList.remove('noVNC_hidden');
document.getElementById('noVNC_toggle_extra_keys_button')
.classList.remove('noVNC_hidden');
document.getElementById('noVNC_clipboard_button')
.classList.remove('noVNC_hidden');
UI.enableSetting('warn_before_close');
}
},

Expand Down
7 changes: 7 additions & 0 deletions vnc.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
View only
</label>
</li>
<li>
<label>
<input id="noVNC_setting_warn_before_close" type="checkbox"
class="toggle">
Warn before close
</label>
</li>
<li><hr></li>
<li>
<label>
Expand Down