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

Class AsyncMultiSelect

src/webpage/settings.ts:482–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480 }
481 const button = document.createElement("button");
482 button.textContent = this.textContent;
483 button.onclick = this.onClickEvent.bind(this);
484 this.buttonHtml = button;
485 div.append(button);
486 return div;
487 }
488 private onClickEvent() {
489 this.onClick();
490 }
491 watchForChange() {}
492 submit() {}
493}
494
495export class ColorInput implements OptionsElement<string> {
496 readonly label: string;
497 readonly owner: Options;
498 readonly onSubmit: (str: string) => void;
499 colorContent: string;
500 input!: WeakRef<HTMLInputElement>;
501 value: string;
502 constructor(
503 label: string,
504 onSubmit: (str: string) => void,
505 owner: Options,
506 {initColor = "#000000"} = {},
507 ) {
508 this.label = label;
509 this.colorContent = initColor;
510 this.value = initColor;
511 this.owner = owner;
512 this.onSubmit = onSubmit;
513 }
514 generateHTML(): HTMLDivElement {
515 const div = document.createElement("div");
516 const span = document.createElement("span");
517 span.textContent = this.label;
518 div.append(span);
519 const input = document.createElement("input");
520 input.value = this.colorContent;
521 input.type = "color";
522 input.oninput = this.onChange.bind(this);
523 this.input = new WeakRef(input);
524 div.append(input);
525 return div;
526 }
527 private onChange() {
528 this.owner.changed();
529 const input = this.input.deref();
530 if (input) {
531 const value = input.value as string;
532 this.value = value;
533 this.onchange(value);
534 this.colorContent = value;
535 }
536 }
537 onchange: (str: string) => void = (_) => {};
538 watchForChange(func: (str: string) => void) {
539 this.onchange = func;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected