xi-conversations

Minimal clone of thunderbird conversations
git clone https://git.ce9e.org/xi-conversations.git

commit
39860ce59c1ac40ad99408b4f33d7e4465f2c2f5
parent
29613db30294494e44d30d9158482dab0c4b2455
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-09-04 18:34
avoid html2element for icons

Diffstat

M content/js/util.js 18 ++++++++++++++----

1 files changed, 14 insertions, 4 deletions


diff --git a/content/js/util.js b/content/js/util.js

@@ -47,14 +47,24 @@ export var html2element = function(html) {
   47    47 };
   48    48 
   49    49 export var createIcon = function(key) {
   50    -1 	var html;
   -1    50 	var nssvg = 'http://www.w3.org/2000/svg';
   -1    51 	var nsxlink = 'http://www.w3.org/1999/xlink';
   -1    52 
   -1    53 	var svg = document.createElementNS(nssvg, 'svg') ;
   -1    54 	var use = document.createElementNS(nssvg, 'use') ;
   -1    55 	svg.setAttribute('class', 'icon');
   -1    56 	svg.append(use);
   -1    57 
   51    58 	if (key.substring(0, 2) === 'x-') {
   52    -1 		html = '<svg class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="/content/material-icons.svg#' + key.substring(2) + '"></use></svg>';
   -1    59 		use.setAttributeNS(nsxlink, 'href', `/content/material-icons.svg#${key.substring(2)}`);
   -1    60 		svg.setAttribute('viewBox', '0 0 24 24');
   53    61 	} else {
   54    62 		// File no longer exists. Is there a new one?
   55    -1 		html = '<svg class="icon" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="chrome://messenger/skin/icons/mail-toolbar.svg#' + key + '"></use></svg>';
   -1    63 		use.setAttributeNS(nsxlink, 'href', `chrome://messenger/skin/icons/mail-toolbar.svg#${key}`);
   -1    64 		svg.setAttribute('viewBox', '0 0 18 18');
   56    65 	}
   57    -1 	return html2element(html);
   -1    66 
   -1    67 	return svg;
   58    68 };
   59    69 
   60    70 export var createDate = function(date) {