rename ballot to raffle

This commit is contained in:
Adrian Thompson
2020-11-03 10:25:15 +01:00
parent d5a7ce1b1e
commit 3ab9f2d7ab

View File

@@ -35,11 +35,10 @@
type="number" type="number"
placeholder="Antall lodd" placeholder="Antall lodd"
@keyup.enter="generateColors" @keyup.enter="generateColors"
v-model="numberOfBallots" v-model="numberOfRaffles"
/> />
<button class="vin-button" @click="generateColors">Generer</button> <button class="vin-button" @click="generateColors">Generer</button>
</div> </div>
<div class="colors"> <div class="colors">
<div <div
v-for="color in colors" v-for="color in colors"
@@ -69,7 +68,7 @@ export default {
}, },
data() { data() {
return { return {
numberOfBallots: 4, numberOfRaffles: 4,
colors: [], colors: [],
blue: 0, blue: 0,
red: 0, red: 0,
@@ -85,14 +84,14 @@ export default {
}; };
}, },
beforeMount() { beforeMount() {
this.$emit("numberOfBallots", this.numberOfBallots); this.$emit("numberOfRaffles", this.numberOfRaffles);
if (this.generateOnInit) { if (this.generateOnInit) {
this.generateColors(); this.generateColors();
} }
}, },
watch: { watch: {
numberOfBallots: function() { numberOfRaffles: function() {
this.$emit("numberOfBallots", this.numberOfBallots); this.$emit("numberOfRaffles", this.numberOfRaffles);
this.generateColors(); this.generateColors();
} }
}, },
@@ -102,7 +101,7 @@ export default {
if (time == 5) { if (time == 5) {
this.generating = false; this.generating = false;
this.generated = true; this.generated = true;
if (this.numberOfBallots > 1 && if (this.numberOfRaffles > 1 &&
[this.redCheckbox, this.greenCheckbox, this.yellowCheckbox, this.blueCheckbox].filter(value => value == true).length == 1) { [this.redCheckbox, this.greenCheckbox, this.yellowCheckbox, this.blueCheckbox].filter(value => value == true).length == 1) {
return return
} }
@@ -117,7 +116,7 @@ export default {
return; return;
} }
this.$ga.event({ this.$ga.event({
eventCategory: "Ballots", eventCategory: "Raffles",
eventAction: "Generate", eventAction: "Generate",
eventValue: JSON.stringify(this.colors) eventValue: JSON.stringify(this.colors)
}); });
@@ -148,8 +147,8 @@ export default {
alert("Du må velge MINST 1 farge"); alert("Du må velge MINST 1 farge");
return; return;
} }
if (this.numberOfBallots > 0) { if (this.numberOfRaffles > 0) {
for (let i = 0; i < this.numberOfBallots; i++) { for (let i = 0; i < this.numberOfRaffles; i++) {
let color = let color =
randomArray[Math.floor(Math.random() * randomArray.length)]; randomArray[Math.floor(Math.random() * randomArray.length)];
this.colors.push(color); this.colors.push(color);