import htm from 'https://unpkg.com/htm?module'
const html = htm.bind(m);
var root = document.body
var currentUser = null;
try {
currentUser = JSON.parse(Cookies.get("currentUser"))
} catch {}
var loggingIn = false;
var logInError = ""
var PlayerHead = {
oncreate: function (vnode) {
const ctx = vnode.dom.getContext('2d');
ctx.imageSmoothingEnabled = false
let img = new Image();
img.src = `/getTexture/${currentUser.uuid}?type=skin`
img.onload = function(){
ctx.drawImage(img, 8, 8, 8, 8, 0, 0, 32, 32);
}
},
view: function(vnode) {
return html `
`
}
}
var Header = {
view: function() {
return html`
`
}
}
var ErrorText = {
view: function(vnode) {
return html`
${vnode.attrs.error.errorMessage}
`
}
}
m.route(root, "/", {
"/": {
view: function() {
return html`
<${Header} />
${currentUser ?
html`
` :
html`Please log in to continue.`
}
`
}
},
"/skinchanger": function SkinChanger() {
var pageError = null;
var success = false;
return {
view: function() {
if (!currentUser) {
m.route.set("/login")
}
return html`
<${Header} />
${currentUser ?
success ?
html `
Texture successfully uploaded!
Go back
` :
html`
Select Skin/Cape
(only .PNG supported)
{
pageError = null
}}
/>
${pageError && html`<${ErrorText} error=${pageError}/>`}
` :
html`Please log in to continue.`
}
`
}
}
},
"/login": {
view: function() {
if (currentUser) {
m.route.set("/")
}
let oninput = () => {
logInError = null
}
return html`
<${Header} />
${logInError && html`
<${ErrorText} error=${logInError} />
`}
`
}
}
})