summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/cook-page/cook-page.component.ts
diff options
context:
space:
mode:
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)
+ }
+}
+