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 @@