Wired up load and save buttons; general cleanup
This commit is contained in:
@@ -7,40 +7,46 @@ class BaseScriptElement extends HTMLElement {
|
||||
}
|
||||
|
||||
action(...args) { console.log("Hello, World!"); }
|
||||
serialize() { return { [this.tagName.toLowerCase()]: {"value": ""} }; }
|
||||
}
|
||||
|
||||
class BaseInputScriptElement extends BaseScriptElement {
|
||||
get prefix() { return 'BaseInputScriptElement'; }
|
||||
get defaultValue() { return '1'; }
|
||||
get postfix() { return ''; }
|
||||
get defaultValue() { return '1'; }
|
||||
get postfix() { return ''; }
|
||||
get value() { return this.getElementsByClassName("script-input")[0].value; }
|
||||
constructor() { super(); }
|
||||
constructor() { super(); this.loadingValue }
|
||||
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
<li>
|
||||
<label>${this.prefix}</label>
|
||||
<input type="text" class="script-input" value="${this.defaultValue}"/>
|
||||
<input type="text" class="script-input" value="${this.loadingValue || this.defaultValue}"/>
|
||||
<label>${this.postfix}</label>
|
||||
</li>
|
||||
`;
|
||||
}
|
||||
|
||||
action() { console.log("Input Value: ", this.value ); }
|
||||
action() { console.log("Input Value: ", this.value ); }
|
||||
serialize() { return { [this.tagName.toLowerCase()]: {"value": this.value} }; }
|
||||
}
|
||||
|
||||
class RepeatElement extends BaseInputScriptElement {
|
||||
get prefix() { return 'Repeat'; }
|
||||
get defaultValue() { return '10'; }
|
||||
get defaultValue() { return '10'; }
|
||||
get children() {
|
||||
return this.getElementsByClassName("script-nest")[0].children;
|
||||
}
|
||||
constructor() {
|
||||
super();
|
||||
this.loadableChildren = []
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
<li>
|
||||
<label>${this.prefix}</label>
|
||||
<input type="text" class="script-input" value="${this.defaultValue}"/>
|
||||
<input type="text" class="script-input" value="${this.loadingValue || this.defaultValue}"/>
|
||||
<label>${this.postfix}</label>
|
||||
<ul class="script-nest"
|
||||
ondrop="dragDropHandler(event)"
|
||||
@@ -48,6 +54,13 @@ class RepeatElement extends BaseInputScriptElement {
|
||||
></ul>
|
||||
</li>
|
||||
`;
|
||||
|
||||
this.setChildren();
|
||||
}
|
||||
|
||||
setChildren() {
|
||||
for (const elm of this.loadableChildren)
|
||||
this.getElementsByClassName("script-nest")[0].append(elm);
|
||||
}
|
||||
|
||||
action(Painter) {
|
||||
@@ -57,6 +70,17 @@ class RepeatElement extends BaseInputScriptElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serialize() {
|
||||
let serializedChildren = [];
|
||||
|
||||
for (const elm of this.children) {
|
||||
serializedChildren.push( elm.serialize() );
|
||||
}
|
||||
|
||||
const loopCount = this.getElementsByClassName("script-input")[0].value;
|
||||
return { [this.tagName.toLowerCase()]: {"value": serializedChildren, "loopCount": loopCount} };
|
||||
}
|
||||
}
|
||||
|
||||
class LeftElement extends BaseInputScriptElement {
|
||||
@@ -162,15 +186,6 @@ class BrushSizeElement extends BaseInputScriptElement {
|
||||
get defaultValue() { return 24; }
|
||||
get postfix() { return 'px'; }
|
||||
constructor() { super(); }
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
<li>
|
||||
<label>${this.prefix}</label>
|
||||
<input type="text" class="script-input" value="${this.defaultValue}"/>
|
||||
<label>${this.postfix}</label>
|
||||
</li>
|
||||
`;
|
||||
}
|
||||
action(Painter) {
|
||||
Painter.brushSize = this.value;
|
||||
Painter.canvasContext.lineWidth = this.value;
|
||||
@@ -185,7 +200,7 @@ class BrushColorElement extends BaseInputScriptElement {
|
||||
this.innerHTML = `
|
||||
<li>
|
||||
<label>${this.prefix}</label>
|
||||
<input type="color" class="script-input" value="${this.defaultValue}"/>
|
||||
<input type="color" class="script-input" value="${this.loadingValue || this.defaultValue}"/>
|
||||
<label>${this.postfix}</label>
|
||||
</li>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user