MCPcopy Create free account
hub / github.com/MathMan05/Fermi / generateHTML

Method generateHTML

src/webpage/settings.ts:504–550  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

502 this.onClick();
503 }
504 watchForChange() {}
505 submit() {}
506}
507
508export class ColorInput implements OptionsElement<string> {
509 readonly label: string;
510 readonly owner: Options;
511 readonly onSubmit: (str: string) => void;
512 colorContent: string;
513 input!: WeakRef<HTMLInputElement>;
514 value: string;
515 constructor(
516 label: string,
517 onSubmit: (str: string) => void,
518 owner: Options,
519 {initColor = "#000000"} = {},
520 ) {
521 this.label = label;
522 this.colorContent = initColor;
523 this.value = initColor;
524 this.owner = owner;
525 this.onSubmit = onSubmit;
526 }
527 generateHTML(): HTMLDivElement {
528 const div = document.createElement("div");
529 const span = document.createElement("span");
530 span.textContent = this.label;
531 div.append(span);
532 const input = document.createElement("input");
533 input.value = this.colorContent;
534 input.type = "color";
535 input.oninput = this.onChange.bind(this);
536 this.input = new WeakRef(input);
537 div.append(input);
538 return div;
539 }
540 private onChange() {
541 this.owner.changed();
542 const input = this.input.deref();
543 if (input) {
544 const value = input.value as string;
545 this.value = value;
546 this.onchange(value);
547 this.colorContent = value;
548 }
549 }
550 onchange: (str: string) => void = (_) => {};
551 watchForChange(func: (str: string) => void) {
552 this.onchange = func;
553 }

Callers

nothing calls this directly

Calls 1

addMethod · 0.80

Tested by

no test coverage detected