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