vnc_auto.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. noVNC example: simple example using default UI
  5. Copyright (C) 2012 Joel Martin
  6. noVNC is licensed under the LGPL-3 (see LICENSE.txt)
  7. This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
  8. Connect parameters are provided in query string:
  9. http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
  10. -->
  11. <head>
  12. <title>noVNC</title>
  13. <meta http-equiv="X-UA-Compatible" content="chrome=1">
  14. <link rel="stylesheet" href="include/base.css" title="plain">
  15. <!--
  16. <script type='text/javascript'
  17. src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
  18. -->
  19. <script src="include/vnc.js"></script>
  20. </head>
  21. <body style="margin: 0px;">
  22. <div id="noVNC_screen">
  23. <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
  24. <table border=0 width="100%"><tr>
  25. <td><div id="noVNC_status">Loading</div></td>
  26. <td width="1%"><div id="noVNC_buttons">
  27. <input type=button value="Send CtrlAltDel"
  28. id="sendCtrlAltDelButton">
  29. </div></td>
  30. </tr></table>
  31. </div>
  32. <canvas id="noVNC_canvas" width="640px" height="20px">
  33. Canvas not supported.
  34. </canvas>
  35. </div>
  36. <script>
  37. /*jslint white: false */
  38. /*global window, $, Util, RFB, */
  39. "use strict";
  40. var rfb;
  41. function passwordRequired(rfb) {
  42. var msg;
  43. msg = '<form onsubmit="return setPassword();"';
  44. msg += ' style="margin-bottom: 0px">';
  45. msg += 'Password Required: ';
  46. msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
  47. msg += '<\/form>';
  48. $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
  49. $D('noVNC_status').innerHTML = msg;
  50. }
  51. function setPassword() {
  52. rfb.sendPassword($D('password_input').value);
  53. return false;
  54. }
  55. function sendCtrlAltDel() {
  56. rfb.sendCtrlAltDel();
  57. return false;
  58. }
  59. function updateState(rfb, state, oldstate, msg) {
  60. var s, sb, cad, level;
  61. s = $D('noVNC_status');
  62. sb = $D('noVNC_status_bar');
  63. cad = $D('sendCtrlAltDelButton');
  64. switch (state) {
  65. case 'failed': level = "error"; break;
  66. case 'fatal': level = "error"; break;
  67. case 'normal': level = "normal"; break;
  68. case 'disconnected': level = "normal"; break;
  69. case 'loaded': level = "normal"; break;
  70. default: level = "warn"; break;
  71. }
  72. if (state === "normal") { cad.disabled = false; }
  73. else { cad.disabled = true; }
  74. if (typeof(msg) !== 'undefined') {
  75. sb.setAttribute("class", "noVNC_status_" + level);
  76. s.innerHTML = msg;
  77. }
  78. }
  79. window.onload = function () {
  80. var host, port, password, path, token;
  81. $D('sendCtrlAltDelButton').style.display = "inline";
  82. $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
  83. document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
  84. // By default, use the host and port of server that served this file
  85. host = WebUtil.getQueryVar('host', window.location.hostname);
  86. port = WebUtil.getQueryVar('port', window.location.port);
  87. // If a token variable is passed in, set the parameter in a cookie.
  88. // This is used by nova-novncproxy.
  89. token = WebUtil.getQueryVar('token', null);
  90. if (token) {
  91. WebUtil.createCookie('token', token, 1)
  92. }
  93. password = WebUtil.getQueryVar('password', '');
  94. path = WebUtil.getQueryVar('path', 'websockify');
  95. if ((!host) || (!port)) {
  96. updateState('failed',
  97. "Must specify host and port in URL");
  98. return;
  99. }
  100. rfb = new RFB({'target': $D('noVNC_canvas'),
  101. 'encrypt': WebUtil.getQueryVar('encrypt',
  102. (window.location.protocol === "https:")),
  103. 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
  104. 'true_color': WebUtil.getQueryVar('true_color', true),
  105. 'local_cursor': WebUtil.getQueryVar('cursor', true),
  106. 'shared': WebUtil.getQueryVar('shared', true),
  107. 'view_only': WebUtil.getQueryVar('view_only', false),
  108. 'updateState': updateState,
  109. 'onPasswordRequired': passwordRequired});
  110. rfb.connect(host, port, password, path);
  111. };
  112. </script>
  113. </body>
  114. </html>