Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
test viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTheGeek committed Dec 11, 2023
1 parent e5d6dcf commit 49f33c7
Showing 1 changed file with 47 additions and 44 deletions.
91 changes: 47 additions & 44 deletions templates/viewer.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
{% extends 'base.html' %}

{% block title %}Page des Étudiants{% endblock %}

{% block content %}

<!-- Add HTML elements for the VNC viewer here -->
<div id="vncViewerContainer"></div>

<script>
document.addEventListener("DOMContentLoaded", function () {
// Function to get the value of a URL parameter by name
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}

// Get the VNC URL parameter from the URL
var vncUrl = getParameterByName("vncUrl");

// Check if a VNC URL is present
if (vncUrl) {
// Display the VNC viewer using the provided URL
displayVNCViewer(vncUrl);
} else {
// Handle the case where the VNC URL parameter is missing
console.error("VNC URL parameter is missing.");
}
});

// Function to display the VNC viewer with the provided URL
function displayVNCViewer(vncUrl) {
// Initialize the VNC viewer using noVNC
var vncViewer = new RFB(document.getElementById('vncViewerContainer'), vncUrl, {});
vncViewer.connect();
}
</script>

{% endblock %}
{% extends 'base.html' %}

{% block title %}Page des Étudiants{% endblock %}

{% block content %}

<!-- Add HTML elements for the VNC viewer here -->
<div id="vncViewerContainer"></div>

<script>
document.addEventListener("DOMContentLoaded", function () {
// Function to get the value of a URL parameter by name
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}

// Get the VNC URL parameter from the URL
var vncUrl = getParameterByName("vncUrl");

// Check if a VNC URL is present
if (vncUrl) {
// Display the VNC viewer using the provided URL
displayVNCViewer(vncUrl);
} else {
// Handle the case where the VNC URL parameter is missing
console.error("VNC URL parameter is missing.");
}
});

// Function to display the VNC viewer with the provided URL
function displayVNCViewer(vncUrl) {
var iframe = document.createElement('iframe');
iframe.src = vncUrl;
iframe.width = "100%";
iframe.height = "100%";
iframe.style.border = "none";
document.getElementById('vncViewerContainer').appendChild(iframe);
}
</script>

{% endblock %}

0 comments on commit 49f33c7

Please sign in to comment.