vnc embedded option

This commit is contained in:
Yuri Karamian
2025-12-18 23:52:35 +01:00
parent f2f2222df7
commit 17d3d20475
@@ -5,6 +5,13 @@
* @link https://arkhost.com * @link https://arkhost.com
* @author ArkHost <support@arkhost.com> * @author ArkHost <support@arkhost.com>
*} *}
{* Store VNC hash for later, remove it to prevent page issues *}
<script>
var arkhostVNCHashDetected = (window.location.hash === '#vnc');
if (arkhostVNCHashDetected) {
history.replaceState(null, null, window.location.pathname + window.location.search);
}
</script>
<style> <style>
/* Hide WHMCS default product details except Domain (keep Domain visible to show VPS hostname) */ /* Hide WHMCS default product details except Domain (keep Domain visible to show VPS hostname) */
@@ -2148,7 +2155,7 @@
<i class="fa fa-spinner fa-spin fa-3x"></i> <i class="fa fa-spinner fa-spin fa-3x"></i>
<p class="mt-3">Loading VNC Console...</p> <p class="mt-3">Loading VNC Console...</p>
</div> </div>
<iframe id="vncIframe" src="" style="width: 100%; height: 600px; border: none; display: none;"></iframe> <iframe id="vncIframe" src="" sandbox="allow-scripts allow-same-origin allow-forms allow-pointer-lock" style="width: 100%; height: 600px; border: none; display: none;"></iframe>
</div> </div>
</div> </div>
</div> </div>
@@ -2201,29 +2208,38 @@ jQuery(document).ready(function($) {
}); });
// Handle hash navigation for VNC tab (when coming from sidebar) // Handle hash navigation for VNC tab (when coming from sidebar)
function handleVNCHash() { // Only run if embedded VNC mode is enabled (vnc tab exists)
if (window.location.hash === '#vnc') { if ($('#vnc-tab').length > 0) {
$('#vnc-tab').tab('show'); // Check on page load - use the stored variable from top of page
loadVNCConsole(); if (typeof arkhostVNCHashDetected !== 'undefined' && arkhostVNCHashDetected) {
setTimeout(function() {
$('#vnc-tab').tab('show');
if (typeof loadVNCConsole === 'function') {
loadVNCConsole();
}
}, 300);
} }
// Listen for hash changes
$(window).on('hashchange', function() {
if (window.location.hash === '#vnc') {
$('#vnc-tab').tab('show');
if (typeof loadVNCConsole === 'function') {
loadVNCConsole();
}
}
});
// Intercept sidebar VNC link clicks
$('a[href$="#vnc"]').on('click', function(e) {
e.preventDefault();
$('#vnc-tab').tab('show');
if (typeof loadVNCConsole === 'function') {
loadVNCConsole();
}
});
} }
// Check on page load
if (window.location.hash === '#vnc') {
setTimeout(handleVNCHash, 100);
}
// Listen for hash changes (when clicking sidebar link while already on page)
$(window).on('hashchange', handleVNCHash);
// Intercept sidebar VNC link clicks
$('a[href$="#vnc"]').on('click', function(e) {
e.preventDefault();
$('#vnc-tab').tab('show');
loadVNCConsole();
history.pushState(null, null, '#vnc');
});
}); });
// VNC Tab functions // VNC Tab functions
@@ -2256,9 +2272,17 @@ function loadVNCConsole() {
}); });
} }
// Open VNC in new tab // Open VNC in new tab - fetch URL via API to avoid session issues
function openVNCNewTab() { function openVNCNewTab() {
window.open(productURL + '&modop=custom&a=VNC', '_blank'); jQuery.get(productURL + '&modop=custom&a=ClientAreaAPI&api=VNC Console&token={$token}', function(data) {
if (data && data.vnc_url) {
window.open(data.vnc_url, '_blank');
} else {
alert('Failed to get VNC URL');
}
}).fail(function() {
alert('Failed to get VNC URL');
});
} }
// Toggle fullscreen for VNC // Toggle fullscreen for VNC