summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/cook-page/cook-page.component.ts
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-12-07 15:05:42 -0500
committerTucker Evans <tuckerevans24@gmail.com>2019-12-07 15:05:42 -0500
commitac33c29faf55b640066641d2c328d841fa3e593b (patch)
tree81d53524e0decc1e8b7e3c2fab59aed0135a056b /recipeBuddy/src/app/cook-page/cook-page.component.ts
parent33ff048f5efb30e767780f24424588af562ea400 (diff)
parentcafe1b4fd3cc02554f44ffbaa8467d867a6838cb (diff)
Merge commit 'cafe1b4fd3cc02554f44ffbaa8467d867a6838cb' into chrisundercoffer
Diffstat (limited to 'recipeBuddy/src/app/cook-page/cook-page.component.ts')
-rw-r--r--recipeBuddy/src/app/cook-page/cook-page.component.ts59
1 files changed, 59 insertions, 0 deletions
diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.ts b/recipeBuddy/src/app/cook-page/cook-page.component.ts
new file mode 100644
index 0000000..51a4c67
--- /dev/null
+++ b/recipeBuddy/src/app/cook-page/cook-page.component.ts
@@ -0,0 +1,59 @@
+import {Component, OnInit} from '@angular/core';
+
+/**
+ * @title Card with multiple sections
+ */
+@Component({
+ selector: 'app-cook-page',
+ templateUrl: './cook-page.component.html',
+ styleUrls: ['./cook-page.component.css'],
+})
+export class CookPageComponent implements OnInit {
+ step: number;
+ instructions: string[] = ["Cut the bread", "Toast the bread", "Warm the butter", "Apply butter to bread", "Enjoy"];
+ timers: number[] = [5,60,30,0,0];
+ previousStep: string;
+ currentStep: string;
+ nextStep: string;
+ timeLeft: number;
+
+ timerInterval;
+
+ ngOnInit() {
+ this.step = 1;
+ this.previousStep = "";
+ this.currentStep = this.instructions[this.step-1];
+ this.nextStep = this.instructions[this.step];
+ this.timeLeft = this.timers[this.step-1];
+ }
+
+ next(): void {
+ clearInterval(this.timerInterval);
+ this.step++;
+ this.previousStep = this.instructions[this.step-2];
+ this.currentStep = this.instructions[this.step-1];
+ this.nextStep = this.instructions[this.step];
+ this.timeLeft = this.timers[this.step-1];
+ }
+
+ previous(): void {
+ clearInterval(this.timerInterval);
+ this.step--;
+ this.previousStep = this.instructions[this.step-2];
+ this.currentStep = this.instructions[this.step-1];
+ this.nextStep = this.instructions[this.step];
+ this.timeLeft = this.timers[this.step-1];
+ }
+
+ startTimer(): void {
+ this.timerInterval = setInterval(() => {
+ if(this.timeLeft > 0) {
+ this.timeLeft --;
+ }
+ else {
+ clearInterval(this.timerInterval);
+ }
+ }, 1000)
+ }
+}
+