Merge pull request #300 from KLuka/usercss

User CSS related fixes
This commit is contained in:
Luka Krajger 2015-05-14 16:31:15 +02:00
commit 458d441e75
2 changed files with 23 additions and 15 deletions

2
debian/rules vendored
View file

@ -36,7 +36,7 @@ override_dh_install:
mkdir -p "$(DESTDIR)/etc/shellinabox/options-available" mkdir -p "$(DESTDIR)/etc/shellinabox/options-available"
mkdir -p "$(DESTDIR)/etc/shellinabox/options-enabled" mkdir -p "$(DESTDIR)/etc/shellinabox/options-enabled"
for i in \ for i in \
"00+Black on White" \ "00+Black On White" \
"00_White On Black" \ "00_White On Black" \
"01_Monochrome" \ "01_Monochrome" \
"01+Color Terminal"; do \ "01+Color Terminal"; do \

View file

@ -329,7 +329,7 @@ VT100.prototype.getUserSettings = function() {
this.disableAlt = settings.charAt(5) != '0'; this.disableAlt = settings.charAt(5) != '0';
if (typeof userCSSList != 'undefined') { if (typeof userCSSList != 'undefined') {
for (var i = 0; i < userCSSList.length; ++i) { 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,20 +370,28 @@ VT100.prototype.initializeUserCSSStyles = function() {
// Add user style sheet to document // Add user style sheet to document
var style = document.createElement('link'); var style = document.createElement('link');
var id = document.createAttribute('id'); style.setAttribute('id', 'usercss-' + i);
id.nodeValue = 'usercss-' + i; style.setAttribute('href', 'usercss-' + i + '.css');
style.setAttributeNode(id); style.setAttribute('rel', 'stylesheet');
var rel = document.createAttribute('rel'); style.setAttribute('type', 'text/css');
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);
document.getElementsByTagName('head')[0].appendChild(style); 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 // Add entry to menu