From 3f837cec6d47291afed56b4394c7e3fe314d84f5 Mon Sep 17 00:00:00 2001 From: KyMAN <0kyman0@gmail.com> Date: Fri, 5 Apr 2024 17:38:58 +0200 Subject: [PATCH] =?UTF-8?q?fix(ecma):=20Arreglado=20bug=20en=20la=20gesti?= =?UTF-8?q?=C3=B3n=20de=20puntos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Public/ecma/GamUsino.ecma.js | 10 ++++++++-- Public/index.html | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Public/ecma/GamUsino.ecma.js b/Public/ecma/GamUsino.ecma.js index 8728e4a..5a1dc7a 100644 --- a/Public/ecma/GamUsino.ecma.js +++ b/Public/ecma/GamUsino.ecma.js @@ -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) => { 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.content, 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) })); @@ -274,13 +276,17 @@ GamUsino = function(custom){ return options.map((option, k) => self.string_variables(fragments.option_item, { ...option, + points : option.points.filter(point => point.selected).length, i : k, visible : !text || option.text.includes(text), selected : option.points.some(point => my_ip == point.ip && point.selected) ? " checked" : "" })).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({ action : "set_option", diff --git a/Public/index.html b/Public/index.html index 0fb904a..e77db04 100644 --- a/Public/index.html +++ b/Public/index.html @@ -45,7 +45,7 @@
  • {text} - +