323: Updated js and html templates for consistency and ease of use

This commit is contained in:
metacryst
2023-09-11 15:29:44 -05:00
parent 8076a87f64
commit e1ce1ce4cc
9 changed files with 92 additions and 63 deletions

View File

@@ -1,16 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Index</title>
<title>Quill</title>
<link rel="icon" href="">
<link rel="stylesheet" href="">
<script type="module">
import * as quill from './Quill/quill.js';
window.quill = {};
Object.entries(quill).forEach(([name, exported]) => window[name] = exported);
window.addStyle = function addStyle(cssString) {
let container = document.querySelector("style#quillStyles");
if(!container) {
container = document.createElement('style');
container.id = "quillStyles";
document.head.appendChild(container);
}
let primarySelector = cssString.substring(0, cssString.indexOf("{")).trim();
primarySelector = primarySelector.replace(/\*/g, "all");
primarySelector = primarySelector.replace(/#/g, "id-");
primarySelector = primarySelector.replace(/,/g, "");
let stylesheet = container.querySelector(`:scope > style[id='${primarySelector}']`)
if(!stylesheet) {
stylesheet = document.createElement('style');
stylesheet.id = primarySelector;
stylesheet.appendChild(document.createTextNode(cssString));
container.appendChild(stylesheet);
} else {
stylesheet.innerText = cssString
}
}
window.html = function html(elementString) {
let parser = new DOMParser();
let doc = parser.parseFromString(elementString, 'text/html');
return doc.body.firstChild;
}
</script>
<script type="module" src="index.js"></script>
<script type="module" src=""></script>
</head>
<body>
</body>
</html>