18995: add missing <!DOCTYPE>
[arvados.git] / apps / workbench / app / views / virtual_machines / webshell.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <!DOCTYPE html>
6 <html lang="en">
7   <head>
8     <title><%= @object.hostname %> / <%= Rails.configuration.Workbench.SiteName %></title>
9     <link rel="stylesheet" href="<%= asset_path 'webshell/styles.css' %>" type="text/css">
10     <style type="text/css">
11       body {
12         margin: 0px;
13       }
14     </style>
15     <script type="text/javascript"><!--
16       (function() {
17         // We would like to hide overflowing lines as this can lead to
18         // visually jarring results if the browser substitutes oversized
19         // Unicode characters from different fonts. Unfortunately, a bug
20         // in Firefox prevents it from allowing multi-line text
21         // selections whenever we change the "overflow" style. So, only
22         // do so for non-Netscape browsers.
23         if (typeof navigator.appName == 'undefined' ||
24             navigator.appName != 'Netscape') {
25           document.write('<style type="text/css">' +
26                          '#vt100 #console div, #vt100 #alt_console div {' +
27                          '  overflow: hidden;' +
28                          '}' +
29                          '</style>');
30         }
31       })();
32
33       function login(username, token) {
34         var sh = new ShellInABox("<%= j @webshell_url %>");
35
36         var findText = function(txt) {
37           var a = document.querySelectorAll("span.ansi0");
38           for (var i = 0; i < a.length; i++) {
39             if (a[i].textContent.indexOf(txt) > -1) {
40               return true;
41             }
42           }
43           return false;
44         }
45
46         var trySendToken = function() {
47           // change this text when PAM is reconfigured to present a
48           // password prompt that we can wait for.
49           if (findText("assword:")) {
50              sh.keysPressed("<%= j Thread.current[:arvados_api_token] %>\n");
51              sh.vt100('(sent authentication token)\n');
52           } else {
53             setTimeout(trySendToken, 200);
54           }
55         };
56
57         var trySendLogin = function() {
58           if (findText("login:")) {
59             sh.keysPressed("<%= j params[:login] %>\n");
60             // Make this wait shorter when PAM is reconfigured to
61             // present a password prompt that we can wait for.
62             setTimeout(trySendToken, 200);
63           } else {
64             setTimeout(trySendLogin, 200);
65           }
66         };
67
68         trySendLogin();
69       }
70     // -->
71 </script>
72     <script type="text/javascript" src="<%= asset_path 'webshell/shell_in_a_box.js' %>"></script>
73   </head>
74   <!-- Load ShellInABox from a timer as Konqueror sometimes fails to
75        correctly deal with the enclosing frameset (if any), if we do not
76        do this
77    -->
78 <body onload="setTimeout(login, 1000)"
79     scroll="no"><noscript>JavaScript must be enabled for ShellInABox</noscript>
80 </body>
81 </html>