7b6edcbe72
Rename the $() selector to $D() so that it doesn't collide with the jQuery name. The API change is that the 'target' option for Canvas and RFB objects must now be a DOM Canvas element. A string is no longer accepted because this requires that a DOM lookup is done and the Canvas and RFB should have no UI code in them. Modularity.
129 lines
4.2 KiB
HTML
129 lines
4.2 KiB
HTML
<html>
|
|
<head>
|
|
<title>VNC Playback</title>
|
|
<link rel="stylesheet" href="include/plain.css">
|
|
</head>
|
|
<body>
|
|
|
|
Iterations: <input id='iterations' style='width:50'>
|
|
Perftest:<input type='radio' id='mode1' name='mode' checked>
|
|
Realtime:<input type='radio' id='mode2' name='mode'>
|
|
|
|
<input id='startButton' type='button' value='Start' style='width:100px'
|
|
onclick="start();" disabled>
|
|
|
|
<br><br>
|
|
|
|
Results:<br>
|
|
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
|
|
|
|
<br><br>
|
|
|
|
<div id="VNC_screen">
|
|
<div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
|
|
<table border=0 width=100%><tr>
|
|
<td><div id="VNC_status">Loading</div></td>
|
|
</tr></table>
|
|
</div>
|
|
<canvas id="VNC_canvas" width="640px" height="20px">
|
|
Canvas not supported.
|
|
</canvas>
|
|
</div>
|
|
|
|
</body>
|
|
|
|
<!--
|
|
<script type='text/javascript'
|
|
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
|
-->
|
|
|
|
<script src="include/vnc.js"></script>
|
|
<script src="include/playback.js"></script>
|
|
|
|
<script>
|
|
var fname, start_time;
|
|
|
|
function message(str) {
|
|
console.log(str);
|
|
var cell = $D('messages');
|
|
cell.innerHTML += str + "\n";
|
|
cell.scrollTop = cell.scrollHeight;
|
|
}
|
|
|
|
fname = WebUtil.getQueryVar('data', null);
|
|
|
|
if (fname) {
|
|
message("Loading " + fname);
|
|
document.write('<script src="' + fname + '"><\/script>');
|
|
} else {
|
|
message("Must specify data=FOO in query string.");
|
|
}
|
|
|
|
updateState = function (rfb, state, oldstate, msg) {
|
|
switch (state) {
|
|
case 'failed':
|
|
case 'fatal':
|
|
message("noVNC sent '" + state + "' state during iteration " + iteration + " frame " + frame_idx);
|
|
test_state = 'failed';
|
|
break;
|
|
case 'loaded':
|
|
$D('startButton').disabled = false;
|
|
break;
|
|
}
|
|
if (typeof msg !== 'undefined') {
|
|
$D('VNC_status').innerHTML = msg;
|
|
}
|
|
}
|
|
|
|
function start() {
|
|
$D('startButton').value = "Running";
|
|
$D('startButton').disabled = true;
|
|
|
|
iterations = $D('iterations').value;
|
|
iteration = 0;
|
|
start_time = (new Date()).getTime();
|
|
|
|
if ($D('mode1').checked) {
|
|
message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
|
|
mode = 'perftest';
|
|
} else {
|
|
message("Starting realtime playback [" + iterations + " iteration(s)]");
|
|
mode = 'realtime';
|
|
}
|
|
|
|
next_iteration();
|
|
}
|
|
|
|
function finish() {
|
|
// Finished with all iterations
|
|
var total_time, end_time = (new Date()).getTime();
|
|
total_time = end_time - start_time;
|
|
|
|
iter_time = parseInt(total_time / iterations, 10);
|
|
message(iterations + " iterations took " + total_time + "ms, " +
|
|
iter_time + "ms per iteration");
|
|
rfb.get_canvas().stop(); // Shut-off event interception
|
|
$D('startButton').disabled = false;
|
|
$D('startButton').value = "Start";
|
|
|
|
}
|
|
|
|
window.onload = function() {
|
|
iterations = WebUtil.getQueryVar('iterations', 3);
|
|
$D('iterations').value = iterations;
|
|
mode = WebUtil.getQueryVar('mode', 3);
|
|
if (mode === 'realtime') {
|
|
$D('mode2').checked = true;
|
|
} else {
|
|
$D('mode1').checked = true;
|
|
}
|
|
if (fname) {
|
|
message("VNC_frame_data.length: " + VNC_frame_data.length);
|
|
rfb = new RFB({'target': $D('VNC_canvas'),
|
|
'updateState': updateState});
|
|
rfb.testMode(send_array);
|
|
}
|
|
}
|
|
</script>
|
|
</html>
|