mirror of
https://gitlab.com/ArkHost/WHMCS-ArkhostVPSAG.git
synced 2026-07-23 23:36:06 +02:00
vnc embedded option
This commit is contained in:
@@ -5,6 +5,13 @@
|
||||
* @link https://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>
|
||||
/* 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>
|
||||
<p class="mt-3">Loading VNC Console...</p>
|
||||
</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>
|
||||
@@ -2201,29 +2208,38 @@ jQuery(document).ready(function($) {
|
||||
});
|
||||
|
||||
// Handle hash navigation for VNC tab (when coming from sidebar)
|
||||
function handleVNCHash() {
|
||||
if (window.location.hash === '#vnc') {
|
||||
$('#vnc-tab').tab('show');
|
||||
loadVNCConsole();
|
||||
// Only run if embedded VNC mode is enabled (vnc tab exists)
|
||||
if ($('#vnc-tab').length > 0) {
|
||||
// Check on page load - use the stored variable from top of page
|
||||
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
|
||||
@@ -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() {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user