Refactor/Virtual lottery #70
@@ -166,8 +166,16 @@ const drawWinner = async (req, res) => {
|
|||||||
Math.floor(Math.random() * attendeeListDemocratic.length)
|
Math.floor(Math.random() * attendeeListDemocratic.length)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let winners = await VirtualWinner.find({ timestamp_sent: undefined }).sort({
|
||||||
|
timestamp_drawn: 1
|
||||||
|
});
|
||||||
|
|
||||||
var io = req.app.get('socketio');
|
var io = req.app.get('socketio');
|
||||||
io.emit("winner", { color: colorToChooseFrom, name: winner.name });
|
io.emit("winner", {
|
||||||
|
color: colorToChooseFrom,
|
||||||
|
name: winner.name,
|
||||||
|
winner_count: winners.length + 1
|
||||||
|
});
|
||||||
|
|
||||||
let newWinnerElement = new VirtualWinner({
|
let newWinnerElement = new VirtualWinner({
|
||||||
name: winner.name,
|
name: winner.name,
|
||||||
|
|||||||
@@ -1,36 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="current-drawn-container">
|
<div class="current-drawn-container" v-if="drawing">
|
||||||
<div class="current-draw" v-if="drawing">
|
<h2 v-if="vinnersNameDrawn !== true">TREKKER {{ ordinalNumber() }} VINNER</h2>
|
||||||
<h2>TREKKER</h2>
|
<h2 v-else>VINNER</h2>
|
||||||
<div
|
|
||||||
:class="currentColor + '-raffle'"
|
<div
|
||||||
class="raffle-element center-new-winner"
|
:class="currentColor + '-raffle'"
|
||||||
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
|
class="raffle-element"
|
||||||
>
|
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
|
||||||
<span v-if="currentName && colorDone">{{ currentName }}</span>
|
>
|
||||||
</div>
|
<span v-if="currentName && colorDone">{{ currentName }}</span>
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="current-draw" v-if="drawingDone">
|
|
||||||
<h2>VINNER</h2>
|
|
||||||
<div
|
|
||||||
:class="currentColor + '-raffle'"
|
|
||||||
class="raffle-element center-new-winner"
|
|
||||||
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
|
|
||||||
>
|
|
||||||
<span v-if="currentName && colorDone">{{ currentName }}</span>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -184,6 +166,23 @@ export default {
|
|||||||
confetti(Object.assign({}, confettiDefaultValues, {origin: originPoint }, launchAngle))
|
confetti(Object.assign({}, confettiDefaultValues, {origin: originPoint }, launchAngle))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ordinalNumber(number=this.currentWinnerLocal.winnerCount) {
|
||||||
|
const dictonary = {
|
||||||
|
1: "første",
|
||||||
|
2: "andre",
|
||||||
|
3: "tredje",
|
||||||
|
4: "fjerde",
|
||||||
|
5: "femte",
|
||||||
|
6: "sjette",
|
||||||
|
7: "syvende",
|
||||||
|
8: "åttende",
|
||||||
|
9: "niende",
|
||||||
|
10: "tiende",
|
||||||
|
11: "ellevte",
|
||||||
|
12: "tolvte"
|
||||||
|
};
|
||||||
|
return number in dictonary ? dictonary[number] : number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,22 +195,27 @@ export default {
|
|||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
.current-drawn-container {
|
.current-drawn-container {
|
||||||
display: flex;
|
grid-column: 1 / 5;
|
||||||
justify-content: center;
|
display: grid;
|
||||||
align-items: center;
|
place-items: center;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.raffle-element {
|
.raffle-element {
|
||||||
width: 140px;
|
width: 280px;
|
||||||
height: 140px;
|
height: 300px;
|
||||||
font-size: 1.2rem;
|
font-size: 2rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 0.75rem;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
-webkit-mask-size: cover;
|
||||||
|
-moz-mask-size: cover;
|
||||||
|
mask-size: cover;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user