7 //Index: rename into Home
8 .row(v-show="display=='variants'")
9 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
10 label(for="prefixFilter") Type first letters...
11 input#prefixFilter(v-model="curPrefix")
12 my-variant-summary(v-for="(v,idx) in sortedCounts"
20 For a guide and recipes on how to configure / customize this project,<br>
22 <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
24 <h3>Installed CLI Plugins</h3>
26 <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
28 <h3>Essential Links</h3>
30 <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
31 <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
32 <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
33 <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
34 <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
38 <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
39 <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
40 <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
41 <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
42 <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
53 // created: function() {
69 // Javascript for index page: mostly counters updating
79 sortedCounts: function () {
80 const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase());
81 const variantsCounts = variantArray
83 return v.name.startsWith(capitalizedPrefix);
89 count: this.counts[v.name] || 0,
92 return variantsCounts.sort((a,b) => {
93 if (a.count != b.count)
94 return b.count - a.count;
95 // Else, alphabetic ordering
96 return a.name.localeCompare(b.name);
100 created: function() {
102 window.onhashchange = this.setDisplay;
104 const url = socketUrl;
105 const sid = getRandString();
106 this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index");
107 const socketMessageListener = msg => {
108 const data = JSON.parse(msg.data);
109 if (data.code == "counts")
110 this.counts = data.counts;
111 else if (data.code == "increase")
112 this.counts[data.vid]++;
113 else if (data.code == "decrease")
114 this.counts[data.vid]--;
116 const socketCloseListener = () => {
117 this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index");
118 this.conn.addEventListener('message', socketMessageListener);
119 this.conn.addEventListener('close', socketCloseListener);
121 this.conn.onmessage = socketMessageListener;
122 this.conn.onclose = socketCloseListener;
124 // TODO: AJAX call get corr games (all variants)
125 // si dernier lastMove sur serveur n'est pas le mien et nextColor == moi, alors background orange
126 // ==> background orange si à moi de jouer par corr (sur main index)
127 // (helper: static fonction "GetNextCol()" dans base_rules.js)
131 setDisplay: function() {
133 location.hash = "#variants"; //default
134 this.display = location.hash.substr(1);
147 <!-- Add "scoped" attribute to limit CSS to this component only -->
148 <style scoped lang="scss">
153 list-style-type: none;
157 display: inline-block;