fix(ecma): Arreglado bug en la gestión de puntos.
This commit is contained in:
parent
c1989dbb58
commit
3f837cec6d
@ -227,6 +227,8 @@ GamUsino = function(custom){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const get_maximum_points = options => options.length ? Math.max(...options.map(option => option.points.filter(point => point.selected).length)) : 0;
|
||||||
|
|
||||||
this.show_poll = (item, event) => {
|
this.show_poll = (item, event) => {
|
||||||
|
|
||||||
const i = Number(item.getAttribute("data-i"));
|
const i = Number(item.getAttribute("data-i"));
|
||||||
@ -241,7 +243,7 @@ GamUsino = function(custom){
|
|||||||
}, data => document.querySelector(".poll-box>.poll").innerHTML = self.string_variables(fragments.poll_box, {
|
}, data => document.querySelector(".poll-box>.poll").innerHTML = self.string_variables(fragments.poll_box, {
|
||||||
...data.content,
|
...data.content,
|
||||||
i : i,
|
i : i,
|
||||||
maximum_points : data.content.options.length ? Math.max(...data.content.options.map(option => option.points)) : 0,
|
maximum_points : get_maximum_points(data.content.options),
|
||||||
options : create_options_html(data.content.options)
|
options : create_options_html(data.content.options)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -274,13 +276,17 @@ GamUsino = function(custom){
|
|||||||
|
|
||||||
return options.map((option, k) => self.string_variables(fragments.option_item, {
|
return options.map((option, k) => self.string_variables(fragments.option_item, {
|
||||||
...option,
|
...option,
|
||||||
|
points : option.points.filter(point => point.selected).length,
|
||||||
i : k,
|
i : k,
|
||||||
visible : !text || option.text.includes(text),
|
visible : !text || option.text.includes(text),
|
||||||
selected : option.points.some(point => my_ip == point.ip && point.selected) ? " checked" : ""
|
selected : option.points.some(point => my_ip == point.ip && point.selected) ? " checked" : ""
|
||||||
})).join("");
|
})).join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
const build_options = options => document.querySelector(".poll-box>.poll .options>ul").innerHTML = create_options_html(options);
|
const build_options = options => {
|
||||||
|
document.querySelector(".poll-box>.poll>form").setAttribute("data-maximum-points", get_maximum_points(options));
|
||||||
|
document.querySelector(".poll-box>.poll .options>ul").innerHTML = create_options_html(options);
|
||||||
|
};
|
||||||
|
|
||||||
this.select_option = (item, event) => self.send({
|
this.select_option = (item, event) => self.send({
|
||||||
action : "set_option",
|
action : "set_option",
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<!-- [[option_item]] -->
|
<!-- [[option_item]] -->
|
||||||
<li class="option-item" data-i="{i}" data-i18n="{text}" data-i18n-without="true" title="{text}" data-visible="{visible}">
|
<li class="option-item" data-i="{i}" data-i18n="{text}" data-i18n-without="true" title="{text}" data-visible="{visible}">
|
||||||
<span data-i18n="{text}">{text}</span>
|
<span data-i18n="{text}">{text}</span>
|
||||||
<span class="bar" data-points="0"></span>
|
<span class="bar" data-points="{points}"></span>
|
||||||
<span class="select checkbox">
|
<span class="select checkbox">
|
||||||
<input type="checkbox" name="option_{i}" onchange="gamusino.select_option(this, event);"{selected} />
|
<input type="checkbox" name="option_{i}" onchange="gamusino.select_option(this, event);"{selected} />
|
||||||
<span data-icon="chckbox"></span>
|
<span data-icon="chckbox"></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user