77800137517d72fe74d2a31428032719c38c3184
[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           var token = urlParams.get('token');
44           if (token) {
45             history.replaceState(null, "", `/webshell/?host=${encodeURIComponent(urlParams.get('host'))}&login=${encodeURIComponent(urlParams.get('login'))}`)
46           }
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(token + "\n");
51              sh.vt100('(sent authentication token)\n');
52           } else {
53             setTimeout(trySendToken, 200);
54           }
55         };
56
57         var trySendLogin = function() {
58           var login = urlParams.get('login');
59           if (findText("login:")) {
60             sh.keysPressed(login + "\n");
61             // Make this wait shorter when PAM is reconfigured to
62             // present a password prompt that we can wait for.
63             setTimeout(trySendToken, 200);
64           } else {
65             setTimeout(trySendLogin, 200);
66           }
67         };
68
69         trySendLogin();
70       }
71     // -->
72 </script>
73     <script type="text/javascript" src="shell_in_a_box.js"></script>
74   </head>
75   <!-- Load ShellInABox from a timer as Konqueror sometimes fails to
76        correctly deal with the enclosing frameset (if any), if we do not
77        do this
78    -->
79 <body onload="setTimeout(login, 1000)"
80     scroll="no"><noscript>JavaScript must be enabled for ShellInABox</noscript>
81 </body>
82 </html>