| @@ -1,12 +1,20 @@ | |||||
| <template> | <template> | ||||
| <div class="objective" > | |||||
| <div | |||||
| class="objective" | |||||
| @click="clearObjective" | |||||
| v-longclick="forceClearObjective"> | |||||
| <div> | <div> | ||||
| {{ objective.name }} | {{ objective.name }} | ||||
| <span v-if="objective.position"> ({{ objective.position }})</span> | <span v-if="objective.position"> ({{ objective.position }})</span> | ||||
| </div> | </div> | ||||
| <div><Timer ref="timer" :initialTime="objective.initialSpawnTime" /></div> | |||||
| <div> | |||||
| <Timer | |||||
| ref="timer" | |||||
| :initialTime="objective.initialSpawnTime" | |||||
| /> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </template> | </template> | ||||
| @@ -28,6 +36,18 @@ | |||||
| } | } | ||||
| }, | }, | ||||
| methods: { | methods: { | ||||
| clearObjective: function () { | |||||
| if (this.$refs.timer.currentTime === 0) { | |||||
| this.resetTimer() | |||||
| } | |||||
| }, | |||||
| forceClearObjective: function () { | |||||
| this.resetTimer() | |||||
| }, | |||||
| resetTimer: function () { | |||||
| this.$refs.timer.setTime(this.objective.respawnTime) | |||||
| this.$refs.timer.startTimer() | |||||
| } | |||||
| }, | }, | ||||
| components: { | components: { | ||||
| Timer | Timer | ||||
| @@ -5,16 +5,19 @@ | |||||
| </template> | </template> | ||||
| <script> | <script> | ||||
| 'use strict' | |||||
| export default { | export default { | ||||
| name: 'Timer', | name: 'Timer', | ||||
| data () { | data () { | ||||
| return { | return { | ||||
| currentTime: this.$attrs.initialTime | |||||
| currentTime: this.$attrs.initialTime, | |||||
| timerIntervalId: null | |||||
| } | } | ||||
| }, | }, | ||||
| methods: { | methods: { | ||||
| startTimer: function () { | startTimer: function () { | ||||
| this.timerIntevalId = setInterval(() => { | |||||
| this.stopTimer() | |||||
| this.timerIntervalId = setInterval(() => { | |||||
| this.currentTime-- | this.currentTime-- | ||||
| if (this.currentTime === 0) { | if (this.currentTime === 0) { | ||||
| this.stopTimer() | this.stopTimer() | ||||
| @@ -22,7 +25,10 @@ | |||||
| }, 1000) | }, 1000) | ||||
| }, | }, | ||||
| stopTimer: function () { | stopTimer: function () { | ||||
| clearInterval(this.timerIntevalId) | |||||
| clearInterval(this.timerIntervalId) | |||||
| }, | |||||
| setTime: function (time) { | |||||
| this.currentTime = time | |||||
| } | } | ||||
| }, | }, | ||||
| computed: { | computed: { | ||||
| @@ -8,7 +8,7 @@ import VueI18n from 'vue-i18n' | |||||
| Vue.config.productionTip = false | Vue.config.productionTip = false | ||||
| Vue.use(VueI18n) | Vue.use(VueI18n) | ||||
| Vue.directive('longclick', longClickDirective({delay: 1000, interval: 0})) | |||||
| Vue.directive('longclick', longClickDirective({delay: 750, interval: 0})) | |||||
| /* eslint-disable no-new */ | /* eslint-disable no-new */ | ||||
| new Vue({ | new Vue({ | ||||