6 th {{ st.tr["Variant"] }}
8 th {{ st.tr["Cadence"] }}
9 th {{ st.tr["Random?"] }}
12 v-for="c in sortedChallenges"
13 :class="{toyou:c.priority==1,fromyou:c.priority==2}"
14 @click="$emit('click-challenge',c)"
19 td(:class="getRandomnessClass(c)")
23 import { store } from "@/store";
25 name: "my-challenge-list",
26 props: ["challenges"],
33 sortedChallenges: function() {
34 // Show in order: challenges I sent, challenges I received, other challenges
35 let minAdded = Number.MAX_SAFE_INTEGER;
37 let augmentedChalls = this.challenges.map(c => {
39 if (!!c.to && c.to == this.st.user.name) priority = 1;
41 c.from.sid == this.st.user.sid ||
42 (c.from.id > 0 && c.from.id == this.st.user.id)
46 if (c.added < minAdded) minAdded = c.added;
47 if (c.added > maxAdded) maxAdded = c.added;
48 return Object.assign({}, c, { priority: priority });
50 const deltaAdded = maxAdded - minAdded;
51 return augmentedChalls.sort((c1, c2) => {
52 return c2.priority - c1.priority + (c2.added - c1.added) / deltaAdded;
57 withWho: function(c) {
58 if (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id)
59 return c.to || this.st.tr["Any player"];
60 return c.from.name || "@nonymous";
62 getRandomnessClass: function(c) {
64 ["random-" + c.randomness]: true
71 <style lang="sass" scoped>
72 // NOTE: the style applied to <tr> element doesn't work
76 background-color: #fcd785
80 background-color: #FF5733
82 background-color: #2B63B4
84 background-color: #33B42B