basics of timer functionality

mic_level
Matthew Huntington 3 years ago
parent d108b9ebb3
commit 9165723bbe

@ -1,9 +1,17 @@
<script lang="ts">
import axios from 'axios';
const getAccumulatedSeconds = (newerTime, olderTime) => {
return Math.floor((newerTime-olderTime)/1000);
}
export default {
data() {
return {
categories:[]
categories:[],
running: false,
startTime:0,
savedPreviousSeconds:0
}
},
methods: {
@ -15,10 +23,12 @@
console.log(this.practice_category_id);
},
start(event){
console.log('starting');
this.startTime = Date.now();
this.running = true;
},
stop(event){
console.log('stopping');
this.running = false;
this.savedPreviousSeconds += getAccumulatedSeconds(Date.now(), this.startTime);
}
},
mounted() {
@ -32,14 +42,14 @@
<template>
<details>
<summary><h2>Timer</h2></summary>
<button @click="start">Start Timer</button>
<button @click="stop">Stop Timer</button>
<button :disabled="running" @click="start">Start Timer</button>
<button :disabled="!running" @click="stop">Stop Timer</button>
<form @submit="submit">
<label>Description</label>
<input v-model="description" type="text"/>
<label>Seconds</label>
<input v-model="seconds" type="number"/>
<input v-model="savedPreviousSeconds" type="number"/>
<label>Comments</label>
<textarea v-model="comments"/>

Loading…
Cancel
Save