golf
This commit is contained in:
parent
5e605c3b9a
commit
540c95ae54
110
assets/main.js
110
assets/main.js
@ -2,88 +2,63 @@
|
|||||||
const $ = document.querySelector.bind(document);
|
const $ = document.querySelector.bind(document);
|
||||||
const $$ = document.querySelectorAll.bind(document);
|
const $$ = document.querySelectorAll.bind(document);
|
||||||
|
|
||||||
class LineRemover extends HTMLButtonElement {
|
class Button extends HTMLButtonElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.addEventListener("click", () => {
|
this.addEventListener("click", this.click);
|
||||||
this.closest("div.linecontainer").parentElement.remove();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("line-remover", LineRemover, { extends: "button" });
|
class LineRemover extends Button {
|
||||||
|
click() {
|
||||||
class LinePinner extends HTMLButtonElement {
|
this.closest("div.linecontainer").parentElement.remove();
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.addEventListener("click", () => {
|
|
||||||
this.closest("div.linecontainer").classList.toggle("unpinned");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("line-pinner", LinePinner, { extends: "button" });
|
class LinePinner extends Button {
|
||||||
|
click() {
|
||||||
class LineUpper extends HTMLButtonElement {
|
this.closest("div.linecontainer").classList.toggle("unpinned");
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.addEventListener("click", () => {
|
|
||||||
const l = this.closest("div.linecontainer").parentElement;
|
|
||||||
const s = l.previousElementSibling;
|
|
||||||
if (s == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.before(l);
|
|
||||||
});
|
|
||||||
// TODO connectedCallback to disable this if first in list
|
|
||||||
// TODO change callback (i forget what it's called but i think i saw it) to enable if not first in list
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("line-upper", LineUpper, { extends: "button" });
|
class LineUpper extends Button {
|
||||||
|
click() {
|
||||||
|
const l = this.closest("div.linecontainer").parentElement;
|
||||||
|
const s = l.previousElementSibling;
|
||||||
|
if (s == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s.before(l);
|
||||||
|
}
|
||||||
|
// TODO connectedCallback to disable this if first in list
|
||||||
|
// TODO change callback (i forget what it's called but i think i saw it) to enable if not first in list
|
||||||
|
}
|
||||||
|
|
||||||
class LineDowner extends HTMLButtonElement {
|
class LineDowner extends Button {
|
||||||
constructor() {
|
click() {
|
||||||
super();
|
const l = this.closest("div.linecontainer").parentElement;
|
||||||
this.addEventListener("click", () => {
|
const s = l.nextElementSibling;
|
||||||
const l = this.closest("div.linecontainer").parentElement;
|
if (s == null) return;
|
||||||
const s = l.nextElementSibling;
|
s.after(l);
|
||||||
if (s == null) {
|
}
|
||||||
return
|
// TODO connectedCallback to disable this if last in list
|
||||||
}
|
// TODO change callback (i forget what it's called but i think i saw it) to enable if not last in list
|
||||||
s.after(l);
|
}
|
||||||
});
|
|
||||||
// TODO connectedCallback to disable this if last in list
|
class LineAdder extends Button {
|
||||||
// TODO change callback (i forget what it's called but i think i saw it) to enable if not last in list
|
click() {
|
||||||
|
$("div[is=lines-div]").add()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("line-downer", LineDowner, { extends: "button" });
|
class PoemRegenner extends Button {
|
||||||
|
click() {
|
||||||
class LineAdder extends HTMLButtonElement {
|
$$(".unpinned").forEach((e) => {
|
||||||
constructor() {
|
e.parentElement.regen();
|
||||||
super();
|
|
||||||
this.addEventListener("click", () => {
|
|
||||||
$("div[is=lines-div]").add()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("line-adder", LineAdder, { extends: "button" });
|
|
||||||
|
|
||||||
class PoemRegenner extends HTMLButtonElement {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.addEventListener("click", () => {
|
|
||||||
$$(".unpinned").forEach((e) => {
|
|
||||||
e.parentElement.regen();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
customElements.define("poem-regenner", PoemRegenner, {extends: "button"});
|
|
||||||
|
|
||||||
class PoemLine extends HTMLDivElement {
|
class PoemLine extends HTMLDivElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -112,8 +87,6 @@ class PoemLine extends HTMLDivElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("poem-line", PoemLine, {extends: "div"});
|
|
||||||
|
|
||||||
class Lines extends HTMLDivElement {
|
class Lines extends HTMLDivElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -137,4 +110,11 @@ class Lines extends HTMLDivElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customElements.define("line-remover", LineRemover, { extends: "button" });
|
||||||
|
customElements.define("line-pinner", LinePinner, { extends: "button" });
|
||||||
|
customElements.define("line-upper", LineUpper, { extends: "button" });
|
||||||
|
customElements.define("line-downer", LineDowner, { extends: "button" });
|
||||||
|
customElements.define("line-adder", LineAdder, { extends: "button" });
|
||||||
|
customElements.define("poem-regenner", PoemRegenner, {extends: "button"});
|
||||||
|
customElements.define("poem-line", PoemLine, {extends: "div"});
|
||||||
customElements.define("lines-div", Lines, {extends: "div"});
|
customElements.define("lines-div", Lines, {extends: "div"});
|
||||||
|
@ -124,6 +124,9 @@ func clean(bs []byte) string {
|
|||||||
s = strings.TrimSpace(s)
|
s = strings.TrimSpace(s)
|
||||||
s = strings.ToLower(s)
|
s = strings.ToLower(s)
|
||||||
|
|
||||||
|
// TODO strip _
|
||||||
|
// TODO strip *
|
||||||
|
|
||||||
if alphaPercent(s) < 50.0 {
|
if alphaPercent(s) < 50.0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user