Merge pull request #284 from KLuka/master

Some fixes
This commit is contained in:
Luka Krajger 2015-03-05 15:32:24 +01:00
commit 1dd54b224b
5 changed files with 48 additions and 11 deletions

View file

@ -568,7 +568,7 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) {
// also has difficulties with SSL connections that are being proxied. // also has difficulties with SSL connections that are being proxied.
int ieBug = 0; int ieBug = 0;
const char *userAgent = getFromHashMap(&http->header, "user-agent"); const char *userAgent = getFromHashMap(&http->header, "user-agent");
const char *msie = userAgent ? strstr(userAgent, "MSIE ") : NULL; const char *msie = userAgent ? strstr(userAgent, "Trident") : NULL;
if (msie) { if (msie) {
ieBug++; ieBug++;
} }

View file

@ -1616,7 +1616,8 @@ static void launcherDaemon(int fd) {
int status; int status;
pid_t pid; pid_t pid;
while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (WIFEXITED(pid) || WIFSIGNALED(pid)) { debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status));
if (WIFEXITED(status) || WIFSIGNALED(status)) {
char key[32]; char key[32];
snprintf(&key[0], sizeof(key), "%d", pid); snprintf(&key[0], sizeof(key), "%d", pid);
deleteFromHashMap(childProcesses, key); deleteFromHashMap(childProcesses, key);
@ -1636,7 +1637,8 @@ static void launcherDaemon(int fd) {
break; break;
} }
while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (WIFEXITED(pid) || WIFSIGNALED(pid)) { debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status));
if (WIFEXITED(status) || WIFSIGNALED(status)) {
char key[32]; char key[32];
snprintf(&key[0], sizeof(key), "%d", pid); snprintf(&key[0], sizeof(key), "%d", pid);
deleteFromHashMap(childProcesses, key); deleteFromHashMap(childProcesses, key);

View file

@ -99,6 +99,16 @@
'</style>'); '</style>');
} }
})(); })();
// User warning on window close
window.onbeforeunload = function(e) {
if (typeof window.shellinabox.session != "undefined") {
return "Are you sure you want to leave this page?";
} else {
return null;
}
}
--></script> --></script>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script type="text/javascript" src="ShellInABox.js"></script> <script type="text/javascript" src="ShellInABox.js"></script>
@ -107,7 +117,7 @@
correctly deal with the enclosing frameset (if any), if we do not correctly deal with the enclosing frameset (if any), if we do not
do this do this
--> -->
<body onload="setTimeout('new ShellInABox()', 100)" <body onload="setTimeout('window.shellinabox = new ShellInABox()', 100)"
scroll="no"><noscript>JavaScript scroll="no"><noscript>JavaScript
must be enabled for ShellInABox</noscript></body> must be enabled for ShellInABox</noscript></body>
</html> </html>

View file

@ -172,7 +172,6 @@ ShellInABox.prototype.sendRequest = function(request) {
(this.session ? '&session=' + (this.session ? '&session=' +
encodeURIComponent(this.session) : '&rooturl='+ encodeURIComponent(this.session) : '&rooturl='+
encodeURIComponent(this.rooturl)); encodeURIComponent(this.rooturl));
request.setRequestHeader('Content-Length', content.length);
request.onreadystatechange = function(shellInABox) { request.onreadystatechange = function(shellInABox) {
return function() { return function() {
@ -230,7 +229,6 @@ ShellInABox.prototype.sendKeys = function(keys) {
'&height=' + this.terminalHeight + '&height=' + this.terminalHeight +
'&session=' +encodeURIComponent(this.session)+ '&session=' +encodeURIComponent(this.session)+
'&keys=' + encodeURIComponent(keys); '&keys=' + encodeURIComponent(keys);
request.setRequestHeader('Content-Length', content.length);
request.onreadystatechange = function(shellInABox) { request.onreadystatechange = function(shellInABox) {
return function() { return function() {
try { try {

View file

@ -175,7 +175,7 @@ function VT100(container) {
} }
this.getUserSettings(); this.getUserSettings();
this.initializeElements(container); this.initializeElements(container);
this.maxScrollbackLines = 500; this.maxScrollbackLines = 2000;
this.npar = 0; this.npar = 0;
this.par = [ ]; this.par = [ ];
this.isQuestionMark = false; this.isQuestionMark = false;
@ -1157,8 +1157,12 @@ VT100.prototype.resizer = function() {
// still get confused if somebody enters a character that is wider/narrower // still get confused if somebody enters a character that is wider/narrower
// than normal. This can happen if the browser tries to substitute a // than normal. This can happen if the browser tries to substitute a
// characters from a different font. // characters from a different font.
if (this.cursorWidth > 0) {
this.cursor.style.width = this.cursorWidth + 'px'; this.cursor.style.width = this.cursorWidth + 'px';
}
if (this.cursorHeight > 0) {
this.cursor.style.height = this.cursorHeight + 'px'; this.cursor.style.height = this.cursorHeight + 'px';
}
// Adjust height for one pixel padding of the #vt100 element. // Adjust height for one pixel padding of the #vt100 element.
// The latter is necessary to properly display the inactive cursor. // The latter is necessary to properly display the inactive cursor.
@ -1167,6 +1171,12 @@ VT100.prototype.resizer = function() {
: (window.innerHeight || : (window.innerHeight ||
document.documentElement.clientHeight || document.documentElement.clientHeight ||
document.body.clientHeight))-1; document.body.clientHeight))-1;
// Prevent ever growing consoles on iPad.
if (navigator.userAgent.match(/iPad/i) != null) {
height -= 1;
}
var partial = height % this.cursorHeight; var partial = height % this.cursorHeight;
this.scrollable.style.height = (height > 0 ? height : 0) + 'px'; this.scrollable.style.height = (height > 0 ? height : 0) + 'px';
this.padding.style.height = (partial > 0 ? partial : 0) + 'px'; this.padding.style.height = (partial > 0 ? partial : 0) + 'px';
@ -1531,8 +1541,20 @@ VT100.prototype.insertBlankLine = function(y, color, style) {
}; };
VT100.prototype.updateWidth = function() { VT100.prototype.updateWidth = function() {
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/ // if the cursorWidth is zero, something is wrong. Try to get it some other way.
this.cursorWidth*this.scale); if (this.cursorWidth <= 0) {
if (this.cursor.clientWidth <= 0) {
// Rats, this.cursor.clientWidth is zero too. Best guess?
this.terminalWidth = 80;
} else {
// update the size.
this.cursorWidth = this.cursor.clientWidth;
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale);
}
} else {
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale);
}
return this.terminalWidth; return this.terminalWidth;
}; };
@ -2713,6 +2735,8 @@ VT100.prototype.handleKey = function(event) {
case 123: /* F12 */ ch = '\u001B[24~'; break; case 123: /* F12 */ ch = '\u001B[24~'; break;
case 144: /* Num Lock */ return; case 144: /* Num Lock */ return;
case 145: /* Scroll Lock */ return; case 145: /* Scroll Lock */ return;
case 163: /* # for FF15 */ ch = this.applyModifiers(35, event); break;
case 173: /* - for FF15 */ ch = this.applyModifiers(45, event); break;
case 186: /* ; */ ch = this.applyModifiers(59, event); break; case 186: /* ; */ ch = this.applyModifiers(59, event); break;
case 187: /* = */ ch = this.applyModifiers(61, event); break; case 187: /* = */ ch = this.applyModifiers(61, event); break;
case 188: /* , */ ch = this.applyModifiers(44, event); break; case 188: /* , */ ch = this.applyModifiers(44, event); break;
@ -2857,6 +2881,9 @@ VT100.prototype.fixEvent = function(event) {
case 109: /* - -> _ */ u = 45; s = 95; break; case 109: /* - -> _ */ u = 45; s = 95; break;
case 111: /* / -> ? */ u = 47; s = 63; break; case 111: /* / -> ? */ u = 47; s = 63; break;
case 163: /* # -> ~ FF15 */ u = 96; s = 126; break;
case 173: /* - -> _ FF15 */ u = 45; s = 95; break;
case 186: /* ; -> : */ u = 59; s = 58; break; case 186: /* ; -> : */ u = 59; s = 58; break;
case 187: /* = -> + */ u = 61; s = 43; break; case 187: /* = -> + */ u = 61; s = 43; break;
case 188: /* , -> < */ u = 44; s = 60; break; case 188: /* , -> < */ u = 44; s = 60; break;