From e341a3e97cc51eb59a0377b7582868d2d2ecda5a Mon Sep 17 00:00:00 2001 From: KLuka Date: Tue, 12 May 2015 16:40:55 +0200 Subject: [PATCH 1/3] User CSS context menu settings fix * Fixed initialization of user CSS settings from cookie. Now we the correct values are being read. This could be possible fix for issue #138. * Changed generation of CSS link elements to get rid of JS deprecated warnings. --- shellinabox/vt100.jspp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index 2786424..0689f9f 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -329,7 +329,7 @@ VT100.prototype.getUserSettings = function() { this.disableAlt = settings.charAt(5) != '0'; if (typeof userCSSList != 'undefined') { for (var i = 0; i < userCSSList.length; ++i) { - userCSSList[i][2] = settings.charAt(i + 5) != '0'; + userCSSList[i][2] = settings.charAt(i + 6) != '0'; } } } @@ -370,18 +370,10 @@ VT100.prototype.initializeUserCSSStyles = function() { // Add user style sheet to document var style = document.createElement('link'); - var id = document.createAttribute('id'); - id.nodeValue = 'usercss-' + i; - style.setAttributeNode(id); - var rel = document.createAttribute('rel'); - rel.nodeValue = 'stylesheet'; - style.setAttributeNode(rel); - var href = document.createAttribute('href'); - href.nodeValue = 'usercss-' + i + '.css'; - style.setAttributeNode(href); - var type = document.createAttribute('type'); - type.nodeValue = 'text/css'; - style.setAttributeNode(type); + style.setAttribute('id', 'usercss-' + i); + style.setAttribute('href', 'usercss-' + i + '.css'); + style.setAttribute('rel', 'stylesheet'); + style.setAttribute('type', 'text/css'); document.getElementsByTagName('head')[0].appendChild(style); style.disabled = !enabled; } From 9d87e59356808a620d5f5db66ab2837580d473de Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 14 May 2015 11:12:11 +0200 Subject: [PATCH 2/3] User CSS initialization fix (issue #138) * Now we use onload event to disable user CSS accoring to default or user settings. Problem was that we were setting the 'disabled' attribute on unloaded stylesheet. This should work in all moderen browsers. --- shellinabox/vt100.jspp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index 0689f9f..dbc70b4 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -375,7 +375,23 @@ VT100.prototype.initializeUserCSSStyles = function() { style.setAttribute('rel', 'stylesheet'); style.setAttribute('type', 'text/css'); document.getElementsByTagName('head')[0].appendChild(style); - style.disabled = !enabled; + + // If stylesheet needs to be disabled we need to do that from onload + // event, otherwise 'disabled' attribute will be ignored. + if (!enabled) { + if ('onload' in style) { + style.onload = function(style) { + return function () { + style.disabled = true; + } + }(style); + } else { + // If onload event is not supported we will try to do it the old + // way. This also works sometimes, mosty in cases when browser + // already has cached version of stylesheet. + style.disabled = true; + } + } } // Add entry to menu From 94a7f6339fe7e484e0870a9f107ecf05b46d1044 Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 14 May 2015 12:51:50 +0200 Subject: [PATCH 3/3] User CSS minor typo fix * Fixed typo for context menu option "Black On White" --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index c9b5776..a22f951 100755 --- a/debian/rules +++ b/debian/rules @@ -36,7 +36,7 @@ override_dh_install: mkdir -p "$(DESTDIR)/etc/shellinabox/options-available" mkdir -p "$(DESTDIR)/etc/shellinabox/options-enabled" for i in \ - "00+Black on White" \ + "00+Black On White" \ "00_White On Black" \ "01_Monochrome" \ "01+Color Terminal"; do \