Skip to content
Snippets Groups Projects
flit.toml 847 B
Newer Older
["script[type='module']"]
action = "wrap"
template ='''
<script>
window.attachStartListener = function() {
  	document.getElementById('start_button').addEventListener('click', function() {
  		let element = document.createElement('{{{TAG}}}');
  		let attr_string = `{{{ATTR}}}`
  		attr_string.split(' ').forEach(function(attr) {
  			let attr_array = attr.split('=');
  			element.setAttribute(attr_array[0], attr_array[1].slice(1, -1));
  		});
  		element.innerHTML = `{{{CONTENT}}}`;
  		document.body.appendChild(element);
  		const remove = ['start_container', 'init-styles', 'content_loaded']
  		remove.forEach(function(id) {
			let container = document.getElementById(id);
			container.parentNode.removeChild(container);
  		});
};

document.addEventListener('DOMContentLoaded', () => {
	window.interceptPreloads()
})
</script>'''