Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 72x 72x 25x 6x 6x 12x 12x 12x 12x 12x 12x 12x 12x 2x 12x 12x 12x 12x 12x 12x 12x 12x 36x 12x 24x 7x 7x 7x 5x 5x 7x 4x 4x 4x 2x 6x 5x 5x 3x 3x 2x 2x 2x 2x | import { toast } from "./toast.js";
import { noteFeature } from "./analytics.js";
import { shortcutLabel } from "./shortcuts.js";
class Light {
constructor(name) {
this.dom = document.getElementById(name);
this.on = false;
}
update(val) {
if (val === this.on) return;
this.on = val;
this.dom.classList.toggle("on", this.on);
}
}
/**
* The furniture around the screen: the keyboard, drive and cassette lights,
* and the pop-up window the printer prints into.
*/
export class FrontPanel {
constructor({ processor, model, printer, loop }) {
this.processor = processor;
this.model = model;
this.printer = printer;
this.printerWindow = null;
this.printerTextArea = null;
loop.addEventListener("tick", () => this.syncLights());
printer.addEventListener("output", (event) => this.printChar(event.detail));
printer.addEventListener("first-output", () =>
toast(`Printer output is being kept. Press ${shortcutLabel("Alt-B")} to open the printer window.`, {
title: "Printer",
quietKey: "quietPrinterOutput",
}),
);
this.cassette = new Light("motorlight");
this.caps = new Light("capslight");
this.shift = new Light("shiftlight");
this.drive0 = new Light("drive0");
this.drive1 = new Light("drive1");
this.network = new Light("networklight");
this.updateLedVisibility();
}
updateLedVisibility() {
for (const el of document.querySelectorAll(".bbc-only")) {
el.style.display = this.model.isAtom ? "none" : "";
}
for (const el of document.querySelectorAll(".drives-only")) {
el.style.display = this.model.hasDiscDrives ? "" : "none";
}
}
syncLights() {
const { processor } = this;
this.cassette.update(processor.tapeInterface.motorOn);
if (this.model.hasDiscDrives) {
this.drive0.update(processor.fdc.motorOn[0]);
this.drive1.update(processor.fdc.motorOn[1]);
}
if (!this.model.isAtom) {
this.caps.update(processor.sysvia.capsLockLight);
this.shift.update(processor.sysvia.shiftLockLight);
Iif (processor.econet) {
this.network.update(processor.econet.activityLight());
}
}
}
/** What the printer prints lands in its window, when one is open. */
printChar(char) {
if (this.printerTextArea) this.printerTextArea.value += char;
}
checkPrinterWindow() {
if (this.printerWindow && !this.printerWindow.closed) return;
this.printerWindow = window.open("", "_blank", "height=300,width=400");
if (!this.printerWindow) {
toast(
`The printer output window was blocked. Allow pop-up windows for this site, then press ${shortcutLabel("Alt-B")} again.`,
{
title: "Printer",
},
);
return;
}
this.printerWindow.document.write(
'<textarea id="text" rows="15" cols="40" placeholder="Printer outputs here..."></textarea>',
);
this.printerTextArea = this.printerWindow.document.getElementById("text");
this.printerTextArea.value = this.printer.text;
noteFeature("printer", "open");
}
}
|