WIP changing course
This commit is contained in:
parent
e7aef581c0
commit
c3234bd812
@ -3,6 +3,7 @@ const $ = document.querySelector.bind(document);
|
|||||||
const $$ = document.querySelectorAll.bind(document);
|
const $$ = document.querySelectorAll.bind(document);
|
||||||
|
|
||||||
const initialLines = 10;
|
const initialLines = 10;
|
||||||
|
const originalityThresh = 10;
|
||||||
|
|
||||||
// I am truly sorry
|
// I am truly sorry
|
||||||
function invoker(methodName) {
|
function invoker(methodName) {
|
||||||
@ -74,6 +75,7 @@ class LineEditor extends Button {
|
|||||||
this.span.innerText = this.i.value;
|
this.span.innerText = this.i.value;
|
||||||
this.f.remove();
|
this.f.remove();
|
||||||
this.span.setAttribute("style", "display:inline");
|
this.span.setAttribute("style", "display:inline");
|
||||||
|
this.dispatchEvent(edited);
|
||||||
}
|
}
|
||||||
click() {
|
click() {
|
||||||
if (this.editing) {
|
if (this.editing) {
|
||||||
@ -136,6 +138,10 @@ class PoemLine extends HTMLDivElement {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.ltp = $("#linetmpl");
|
this.ltp = $("#linetmpl");
|
||||||
|
this.addEventListener("edited", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.querySelector("span[is=dna-square]").edited();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
@ -161,6 +167,7 @@ class PoemLine extends HTMLDivElement {
|
|||||||
this.querySelector(".linetext").innerText = payload.Text;
|
this.querySelector(".linetext").innerText = payload.Text;
|
||||||
this.querySelector(".linetext").setAttribute("data-source", payload.Source.Name);
|
this.querySelector(".linetext").setAttribute("data-source", payload.Source.Name);
|
||||||
this.querySelector("span[is=dna-square]").update(payload.Source);
|
this.querySelector("span[is=dna-square]").update(payload.Source);
|
||||||
|
this.originalText = payload.Text;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,28 +215,35 @@ class PoemLines extends HTMLDivElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DNASquare extends HTMLSpanElement {
|
class SourceText extends HTMLParagraphElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
this.setAttribute("style", `
|
this.setAttribute("style", `
|
||||||
background-color: black;
|
|
||||||
border: 1px solid white;
|
border: 1px solid white;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 1em;
|
width: 1em;
|
||||||
height: 1em;
|
height: 1em;
|
||||||
vertical-align: middle;`);
|
vertical-align: middle;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edited() {
|
||||||
|
}
|
||||||
|
|
||||||
update(source) {
|
update(source) {
|
||||||
var title = `${source.Name} (${source.GutID})`;
|
var title = source.Name;
|
||||||
this.setAttribute("title", title);
|
this.setAttribute("title", source.Name);
|
||||||
console.log(this);
|
//this.style.backgroundColor = stringColor(source.Name);
|
||||||
|
this.style.backgroundColor = "black";
|
||||||
|
this.style.borderColor = "white";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const reorder = new CustomEvent("reorder", {bubbles: true});
|
const reorder = new CustomEvent("reorder", {bubbles: true});
|
||||||
customElements.define("dna-square", DNASquare, { extends: "span" });
|
const edited = new CustomEvent("edited", {bubbles: true});
|
||||||
|
customElements.define("source-text", SourceText, { extends: "p" });
|
||||||
customElements.define("line-remover", LineRemover, { extends: "button" });
|
customElements.define("line-remover", LineRemover, { extends: "button" });
|
||||||
customElements.define("line-pinner", LinePinner, { extends: "button" });
|
customElements.define("line-pinner", LinePinner, { extends: "button" });
|
||||||
customElements.define("line-editor", LineEditor, { extends: "button" });
|
customElements.define("line-editor", LineEditor, { extends: "button" });
|
||||||
|
11
main.go
11
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -30,9 +31,8 @@ func connectDB() (*sql.DB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type source struct {
|
type source struct {
|
||||||
ID int64
|
ID int64
|
||||||
Name string
|
Name string
|
||||||
GutID string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type phrase struct {
|
type phrase struct {
|
||||||
@ -96,8 +96,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
sourceSplit := strings.SplitN(s.Name, " ", 2)
|
sourceSplit := strings.SplitN(s.Name, " ", 2)
|
||||||
if len(sourceSplit) > 1 {
|
if len(sourceSplit) > 1 {
|
||||||
s.Name = strings.TrimSpace(sourceSplit[1])
|
s.Name = fmt.Sprintf("%s (%s)",
|
||||||
s.GutID = strings.TrimSpace(sourceSplit[0])
|
strings.TrimSpace(sourceSplit[1]),
|
||||||
|
strings.TrimSpace(sourceSplit[0]))
|
||||||
}
|
}
|
||||||
p.Source = s
|
p.Source = s
|
||||||
p.ID = id.Int64()
|
p.ID = id.Int64()
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
<button is="line-downer">down</button>
|
<button is="line-downer">down</button>
|
||||||
<button is="line-remover">remove</button>
|
<button is="line-remover">remove</button>
|
||||||
</span>
|
</span>
|
||||||
<span is="dna-square"></span>
|
|
||||||
<span class="linetext"></span>
|
<span class="linetext"></span>
|
||||||
|
<p style="display:none" class="source"></p>
|
||||||
</template>
|
</template>
|
||||||
<h1>Trunkless</h1>
|
<h1>Trunkless</h1>
|
||||||
<script src="/main.js"></script>
|
<script src="/main.js"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user