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