/* 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. */ 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); this.prefix = "mgslider_yF5sTZLy"; this.yourvalue = "Your value"; mgsliders.push({field: field, obj: this}); } mgslider.prototype.fzero = function (s) { for (var c = s.length-1; c >= 0; c--) { if (s[c] != "0") { return c; } } return 0; }; mgslider.prototype.suggest_digits = function (x) { x = x.toFixed(10); return this.fzero(x) - x.search(/\./); }; mgslider.prototype.f2s = function (val, detect) { if (detect) { return val.toFixed(this.suggest_digits(val)).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) + " | \
" + this.yourvalue + ": | \