mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Converts ui/drive_lights.js
to Typescript (#70)
This change also exposes the `Callbacks` and `DriveNumber` types from `disk2.ts`.
This commit is contained in:
parent
342f024a85
commit
6395a9009e
@ -145,10 +145,10 @@ const PHASE_DELTA = [
|
|||||||
[1, -2, -1, 0]
|
[1, -2, -1, 0]
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
const DRIVE_NUMBERS = [1, 2] as const;
|
export const DRIVE_NUMBERS = [1, 2] as const;
|
||||||
type DriveNumber = MemberOf<typeof DRIVE_NUMBERS>;
|
export type DriveNumber = MemberOf<typeof DRIVE_NUMBERS>;
|
||||||
|
|
||||||
interface Callbacks {
|
export interface Callbacks {
|
||||||
driveLight: (drive: DriveNumber, on: boolean) => void;
|
driveLight: (drive: DriveNumber, on: boolean) => void;
|
||||||
dirty: (drive: DriveNumber, dirty: boolean) => void;
|
dirty: (drive: DriveNumber, dirty: boolean) => void;
|
||||||
label: (drive: DriveNumber, name: string) => void;
|
label: (drive: DriveNumber, name: string) => void;
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
export default function DriveLights()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
driveLight: function(drive, on) {
|
|
||||||
var disk = document.querySelector('#disk' + drive);
|
|
||||||
disk.style.backgroundImage =
|
|
||||||
on ? 'url(css/red-on-16.png)' :
|
|
||||||
'url(css/red-off-16.png)';
|
|
||||||
},
|
|
||||||
dirty: function() {
|
|
||||||
// document.querySelector('#disksave' + drive).disabled = !dirty;
|
|
||||||
},
|
|
||||||
label: function(drive, label) {
|
|
||||||
if (label) {
|
|
||||||
document.querySelector('#disk-label' + drive).innerText = label;
|
|
||||||
}
|
|
||||||
return document.querySelector('#disk-label' + drive).innerText;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
24
js/ui/drive_lights.ts
Normal file
24
js/ui/drive_lights.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { Callbacks, DriveNumber } from '../cards/disk2';
|
||||||
|
|
||||||
|
export default class DriveLights implements Callbacks {
|
||||||
|
public driveLight(drive: DriveNumber, on: boolean) {
|
||||||
|
const disk =
|
||||||
|
document.querySelector('#disk' + drive)! as HTMLElement;
|
||||||
|
disk.style.backgroundImage =
|
||||||
|
on ? 'url(css/red-on-16.png)' :
|
||||||
|
'url(css/red-off-16.png)';
|
||||||
|
}
|
||||||
|
|
||||||
|
public dirty() {
|
||||||
|
// document.querySelector('#disksave' + drive).disabled = !dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public label(drive: DriveNumber, label: string) {
|
||||||
|
const labelElement =
|
||||||
|
document.querySelector('#disk-label' + drive)! as HTMLElement;
|
||||||
|
if (label) {
|
||||||
|
labelElement.innerText = label;
|
||||||
|
}
|
||||||
|
return labelElement.innerText;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user