diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-10-17 19:53:40 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-10-17 19:53:40 -0400 |
commit | d578345cfd53df8a91ae8e0e1346b711332a999a (patch) | |
tree | fa9a2e6c855a532dbd99910c7cdac1dc468010da /src/SMAPI.Web/wwwroot/Content | |
parent | ebe41180c41f544919c03fb3bf6029437a7d65a4 (diff) | |
parent | f8c9a2929bb42ef7f71fa3a2d258c5566960aa69 (diff) | |
download | SMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.tar.gz SMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.tar.bz2 SMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content')
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/mods.js | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/js/mods.js b/src/SMAPI.Web/wwwroot/Content/js/mods.js index ac2754a4..945f93ef 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/mods.js +++ b/src/SMAPI.Web/wwwroot/Content/js/mods.js @@ -9,12 +9,16 @@ smapi.modList = function (mods, enableBeta) { soon: 0, broken: 0, abandoned: 0, - invalid: 0 + invalid: 0, + percentCompatible: 0, + percentBroken: 0, + percentObsolete: 0 }; var data = { mods: mods, showAdvanced: false, - visibleStats: $.extend({}, defaultStats), + visibleMainStats: $.extend({}, defaultStats), + visibleBetaStats: $.extend({}, defaultStats), filters: { source: { value: { @@ -124,7 +128,8 @@ smapi.modList = function (mods, enableBeta) { var words = data.search.toLowerCase().split(" "); // apply criteria - var stats = data.visibleStats = $.extend({}, defaultStats); + var mainStats = data.visibleMainStats = $.extend({}, defaultStats); + var betaStats = data.visibleBetaStats = $.extend({}, defaultStats); for (var i = 0; i < data.mods.length; i++) { var mod = data.mods[i]; mod.Visible = true; @@ -132,10 +137,20 @@ smapi.modList = function (mods, enableBeta) { // check filters mod.Visible = this.matchesFilters(mod, words); if (mod.Visible) { - stats.total++; - stats[this.getCompatibilityGroup(mod)]++; + mainStats.total++; + betaStats.total++; + + mainStats[this.getCompatibilityGroup(mod.Compatibility.Status)]++; + betaStats[this.getCompatibilityGroup(mod.LatestCompatibility.Status)]++; } } + + // add aggregate stats + for (let stats of [mainStats, betaStats]) { + stats.percentCompatible = Math.round((stats.compatible + stats.workaround) / stats.total * 100); + stats.percentBroken = Math.round((stats.soon + stats.broken) / stats.total * 100); + stats.percentObsolete = Math.round(stats.abandoned / stats.total * 100); + } }, /** @@ -220,11 +235,10 @@ smapi.modList = function (mods, enableBeta) { /** * Get a mod's compatibility group for mod metrics. - * @param {object} mod The mod to check. + * @param {string} mod The mod status for which to get the group. * @returns {string} The compatibility group (one of 'compatible', 'workaround', 'soon', 'broken', 'abandoned', or 'invalid'). */ - getCompatibilityGroup: function (mod) { - var status = mod.LatestCompatibility.Status; + getCompatibilityGroup: function (status) { switch (status) { // obsolete case "abandoned": |