fix version of parcel
This commit is contained in:
41
src/roast.ts
41
src/roast.ts
@@ -5,12 +5,25 @@ let targets: number[] = [];
|
||||
let currentTargetIndex = 0;
|
||||
let interval: NodeJS.Timeout | null = null;
|
||||
|
||||
interface Window {
|
||||
startTimer?: Function; // function to start the timer
|
||||
stopTimer?: Function; // function to stop the timer
|
||||
logEvent?: Function; // function to log a new event
|
||||
resetSystem?: Function; // function to reset all actions in the system
|
||||
setPlan?: Function; // function to update the temp event plan
|
||||
navigateTemp?: Function; //function to navigate forward/back between events in the setPlan() temp plan
|
||||
logTemp?: Function; //function to log a temputure event
|
||||
exportCSV?: Function; //function to export the events to CSV
|
||||
showGraph?: Function; //function to show the graph on screen
|
||||
}
|
||||
|
||||
function startTimer(): void {
|
||||
if (isRunning) {
|
||||
alert("Timer is already running. Click again to reset.");
|
||||
return;
|
||||
}
|
||||
timer = 0;
|
||||
updateTimerDisplay();
|
||||
isRunning = true;
|
||||
interval = setInterval(() => {
|
||||
timer++;
|
||||
@@ -19,7 +32,9 @@ function startTimer(): void {
|
||||
}
|
||||
|
||||
function stopTimer(): void {
|
||||
clearInterval(interval!);
|
||||
if(interval !== null){
|
||||
clearInterval(interval);
|
||||
}
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@@ -31,10 +46,12 @@ function updateTimerDisplay(): void {
|
||||
|
||||
function logEvent(eventName: string): void {
|
||||
if (eventName === "Charge") {
|
||||
if (log.length > 0) {
|
||||
if (log.length > 0 || isRunning) {
|
||||
if(isRunning){
|
||||
stopTimer();
|
||||
}
|
||||
log = [];
|
||||
timer = 0;
|
||||
isRunning = false;
|
||||
}
|
||||
startTimer();
|
||||
log.push({ time: formatTime(timer), event: eventName });
|
||||
@@ -139,14 +156,14 @@ function exportCSV(): void {
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
// Expose functions to the global scope
|
||||
// Expose functions to the global scope (allowing html direct access)
|
||||
if (typeof window !== 'undefined') {
|
||||
window.startTimer = startTimer;
|
||||
window.stopTimer = stopTimer;
|
||||
window.logEvent = logEvent;
|
||||
window.resetSystem = resetSystem;
|
||||
window.setPlan = setPlan;
|
||||
window.navigateTemp = navigateTemp;
|
||||
window.logTemp = logTemp;
|
||||
window.exportCSV = exportCSV;
|
||||
window.startTimer = startTimer;
|
||||
window.stopTimer = stopTimer;
|
||||
window.logEvent = logEvent;
|
||||
window.resetSystem = resetSystem;
|
||||
window.setPlan = setPlan;
|
||||
window.navigateTemp = navigateTemp;
|
||||
window.logTemp = logTemp;
|
||||
window.exportCSV = exportCSV;
|
||||
}
|
||||
Reference in New Issue
Block a user