/* Copyright (C) 2022 Max R. P. Grossmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //from og let efficacy = js_vars.efficacy * 100; // import and transform constants let endowment = (Math.round(js_vars.endowment * 100) / 100).toFixed(2); let price = js_vars.price; // let base_prob = js_vars.theft_success * 100; // let lost_from_attacks = (Math.round(js_vars.lost_from_attacks * 100) / 100).toFixed(2); // let failed_attack = (Math.round(js_vars.failed_attack * 100) / 100).toFixed(2) // let slider = document.getElementById("sliders_here"); if(price>=2){ // document.getElementById("failed_attack").innerHTML = Math.round(failed_attack,0); // document.getElementById("lost_from_attacks").innerHTML = Math.round(lost_from_attacks,0); document.getElementById("endowment").innerHTML = Math.round(endowment,0); document.getElementById("price").innerHTML = Math.round(price,0); // document.getElementById("base_prob").innerHTML = Math.round(base_prob,0); } else { // document.getElementById("failed_attack").innerHTML = failed_attack; // document.getElementById("lost_from_attacks").innerHTML = lost_from_attacks; document.getElementById("endowment").innerHTML = Math.round(endowment,0) document.getElementById("price").innerHTML = price.toFixed(2) // Math.round(price,2); // document.getElementById("base_prob").innerHTML = base_prob; } // document.getElementById("efficacy").innerHTML = efficacy; // pass constants to html for in-text BRINGING PRICE OBJECT BREAKS ALL HTML ITEMS - removing "= efficacy" doesn't seem to break things var mgsliders = Array(); mgsliders.lookup = function (which) { for (var j = 0; j < mgsliders.length; j++) { if (mgsliders[j].field == which) { return mgsliders[j].obj; } } return undefined; }; function mgslider(field, min, max, step) { this.field = field; this.min = parseFloat(min); this.max = parseFloat(max); this.step = parseFloat(step); this.digits = this.suggest_digits(step, 2); this.prefix = "mgslider_yF5sTZLy"; this.yourvalue = "Your value"; mgsliders.push({field: field, obj: this}); } mgslider.prototype.similar = function (a, b, tolerance) { if (tolerance === undefined) { tolerance = Number.EPSILON; } return Math.abs(a-b) < tolerance; }; mgslider.prototype.is_whole = function (x) { return this.similar(x, Math.floor(x)) && this.similar(x, Math.ceil(x)); }; mgslider.prototype.suggest_digits = function (x, default_) { for (var d = 0; d <= 9; d++) { var tmp = x*Math.pow(10, d); if (this.is_whole(tmp)) { return d; } } return default_; }; mgslider.prototype.f2s = function (val, detect) { if (detect) { return val.toFixed(this.suggest_digits(val, this.digits)).replace("-", "–"); } return val.toFixed(this.digits).replace("-", "–"); }; mgslider.prototype.id = function (id_) { if (id_ === undefined) { id_ = ""; } return this.prefix + "_" + this.field + "_" + id_; }; mgslider.prototype.markup = function () { return "\
" + this.f2s(this.min, true) + " | \\ \ \ | \" + this.f2s(this.max, true) + " | \
" +
`Purchasing` + " units of security, \
you will have $ remaining. \ Once you are satisfied with your decision, please click the \"next\" button to move to the next page. \ | \