function closeWindow() {
	if (window.webkit) {
		window.webkit.messageHandlers.closeWindow.postMessage('close')
	}
}
function runTemplate(title) {
	const header = `
<div id="titleBar"><h1>${title}</h1><a href="#" id="closeButton" onclick="closeWindow()">&times;</a></div>
<ul id="menu">
<li><a href="metadataEditor.html">metadata</a></li>
<li><a href="simplePackEditor.html">packs</a></li>
</ul>
`

	document.addEventListener('DOMContentLoaded', () => {
		const contentDiv = document.createElement('div')
		contentDiv.id = 'content'
		while (document.body.firstChild) {
			contentDiv.appendChild(document.body.firstChild)
		}
		document.body.appendChild(contentDiv)

		document.body.insertAdjacentHTML('afterbegin', header)
		const link = document.createElement('link')
		link.rel = 'stylesheet'
		link.href = 'style.css'
		document.head.appendChild(link)
		const currentPath = window.location.pathname.split('/').pop().split('?')[0]
		const links = document.querySelectorAll('a')
		links.forEach((link) => {
			if (link.getAttribute('href') === currentPath) {
				link.classList.add('selected')
			}
		})
	})
}
