Commit e376f134 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_but: display results

parent 38df79e3
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<script id="result_template" type="text/x-handlebars-template"> <script id="result_template" type="text/x-handlebars-template">
<table> <table>
<caption>Result ({{match_count}} matches)</caption> <caption>Result (<a href="https://www.rugbyworldcup.com/2023/matches">{{match_count}} matches</a>)</caption>
<thead> <thead>
<tr> <tr>
<th>Score</th> <th>Score</th>
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
{{/if}} {{/if}}
</li>{{/each}}</ul> </li>{{/each}}</ul>
<button type="button" data-wc2018="renderExport">Share!</button> <button type="button" data-wc2018="renderExport">Share!</button>
<!--button type="button" data-wc2018="renderImport">Import</button--> <button type="button" data-wc2018="renderImport">Import</button>
<!--button type="button" data-wc2018="renderResult">Result</button--> <button type="button" data-wc2018="renderResult">Result</button>
</script> </script>
<script id="share_template" type="text/x-handlebars-template"> <script id="share_template" type="text/x-handlebars-template">
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<textarea required name="password_text" <textarea required name="password_text"
id="password_text">{{password_text}}</textarea> id="password_text">{{password_text}}</textarea>
<input type="submit" value="Import"></input> <input type="submit" value="Import"></input>
</form> nutnut </form>
<form data-wc2018="submitNewCode"> <form data-wc2018="submitNewCode">
<label for="player">Player</label> <label for="player">Player</label>
<input required name="player" id="player"></input> <input required name="player" id="player"></input>
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.58506.47731.21435</string> </value> <value> <string>1011.3955.57992.12117</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1693772860.24</float> <float>1694433862.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*globals window, document, RSVP, rJS, jIO, Handlebars, LZString*/ /*globals window, document, RSVP, rJS, jIO, Handlebars, LZString, console*/
/*jslint indent: 2, maxlen: 80*/ /*jslint indent: 2, maxlen: 100, nomen: true*/
/*jslint nomen: true*/
(function (window, document, RSVP, rJS, jIO, Handlebars, LZString) { (function (window, document, RSVP, rJS, jIO, Handlebars, LZString) {
"use strict"; "use strict";
...@@ -57,6 +56,7 @@ ...@@ -57,6 +56,7 @@
if (tmp.eventPhaseId.type !== 'Pool') { if (tmp.eventPhaseId.type !== 'Pool') {
continue; continue;
} }
result_list.push({ result_list.push({
id: 'match_' + (i + 1), id: 'match_' + (i + 1),
value: {}, value: {},
...@@ -240,9 +240,10 @@ ...@@ -240,9 +240,10 @@
}, },
remote_sub_storage: { remote_sub_storage: {
type: 'world_cup_data', type: 'world_cup_data',
document_id: './world_cup_2018_data.json', document_idXX: './world_cup_2018_data.json',
document_idXXX: 'https://raw.githubusercontent.com/lsv/' + document_idXXX: 'https://raw.githubusercontent.com/lsv/' +
'fifa-worldcup-2018/master/data.json', 'fifa-worldcup-2018/master/data.json',
document_id: 'https://corsproxy.io/?https%3A%2F%2Fapi.wr-rims-prod.pulselive.com%2Frugby%2Fv3%2Fevent%2F1893%2Fschedule%3Flanguage%3Den',
attachment_id: 'enclosure', attachment_id: 'enclosure',
sub_storage: { sub_storage: {
type: 'http' type: 'http'
...@@ -480,8 +481,7 @@ ...@@ -480,8 +481,7 @@
score, score,
home_result, home_result,
away_result, away_result,
home_bet, bet,
away_bet,
key_count = 0, key_count = 0,
decoded; decoded;
for (key in code_dict) { for (key in code_dict) {
...@@ -502,6 +502,8 @@ ...@@ -502,6 +502,8 @@
return gadget.renderImport(); return gadget.renderImport();
} }
console.log('code_dict', code_dict);
// Check match result // Check match result
for (i = 0; i < match_list.length; i += 1) { for (i = 0; i < match_list.length; i += 1) {
home_result = match_list[i].value.home_result; home_result = match_list[i].value.home_result;
...@@ -509,6 +511,17 @@ ...@@ -509,6 +511,17 @@
for (key in code_dict) { for (key in code_dict) {
if (code_dict.hasOwnProperty(key)) { if (code_dict.hasOwnProperty(key)) {
// console.log(match_list[i]); // console.log(match_list[i]);
bet = code_dict[key].result_list[i];
if (
// draw
((bet === 0) && (home_result === away_result)) ||
((bet === 1) && (home_result > away_result)) ||
((bet === 2) && (home_result < away_result))
) {
code_dict[key].score += 1;
}
/*
home_bet = code_dict[key].result_list[2 * (parseInt(match_list[i].id.slice(6), 10) - 1)]; home_bet = code_dict[key].result_list[2 * (parseInt(match_list[i].id.slice(6), 10) - 1)];
away_bet = code_dict[key].result_list[2 * (parseInt(match_list[i].id.slice(6), 10) - 1) + 1]; away_bet = code_dict[key].result_list[2 * (parseInt(match_list[i].id.slice(6), 10) - 1) + 1];
if ((home_result === home_bet) && if ((home_result === home_bet) &&
...@@ -531,7 +544,7 @@ ...@@ -531,7 +544,7 @@
score = 1; score = 1;
} }
code_dict[key].score += score; code_dict[key].score += score;*/
/* /*
if (i === 0) { if (i === 0) {
player_list.push({ player_list.push({
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.58492.51761.29798</string> </value> <value> <string>1011.3975.53334.5341</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1693771993.21</float> <float>1694433153.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_content_security_policy</string> </key> <key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'none\'; img-src \'self\'; media-src \'self\'; connect-src \'self\' raw.githubusercontent.com; script-src \'self\' \'unsafe-eval\'; style-src \'self\';</string> </value> <value> <string>default-src \'none\'; img-src \'self\'; media-src \'self\'; connect-src \'self\' corsproxy.io raw.githubusercontent.com; script-src \'self\' \'unsafe-eval\'; style-src \'self\';</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_x_frame_options</string> </key> <key> <string>configuration_x_frame_options</string> </key>
...@@ -428,7 +428,7 @@ ...@@ -428,7 +428,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.49822.40856.18739</string> </value> <value> <string>1011.3951.5357.1211</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -448,7 +448,7 @@ ...@@ -448,7 +448,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1693252020.78</float> <float>1694433215.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment