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.
This commit is contained in:
KLuka 2015-05-12 16:40:55 +02:00
parent cb2c39c502
commit e341a3e97c

View file

@ -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;
}