Difference between revisions of "Modding:Mod compatibility/barchart"

From Stardew Valley Wiki
Jump to navigation Jump to search
(combine ok + workaround, tweak text)
(tweak format, update script)
Line 7: Line 7:
 
| {{{soon|0}}}% have an update coming soon.
 
| {{{soon|0}}}% have an update coming soon.
 
|-
 
|-
| <div style="display: inline-block; width: {{#expr:{{{broken|30}}} * 2}}px; background: #F99;">&nbsp;</div>
+
| <div style="display: inline-block; width: {{#expr:{{{broken|0}}} * 2}}px; background: #F99;">&nbsp;</div>
| {{{broken|0}}}% are broken and not open-source.<br /><small>(Many of these broke in Stardew Valley 1.1 or 1.2. Some may be updated by their authors.)</small>
+
| {{{broken|0}}}% are broken and not open-source.¹
|}<noinclude>
+
|}
 +
<small>¹ Many of these broke in Stardew Valley 1.1 or 1.2. Some may be updated by their authors.</small><noinclude>
  
 
==Usage==
 
==Usage==
Line 29: Line 30:
 
var soon = $("#mod-list tr[data-status='soon']").length;
 
var soon = $("#mod-list tr[data-status='soon']").length;
 
var broken = $("#mod-list tr[data-status='broken']").length;
 
var broken = $("#mod-list tr[data-status='broken']").length;
 +
 +
var total = ok + workaround + soon + broken;
 +
var okPercent = Math.round(ok / total * 100);
 +
var workaroundPercent = Math.round(workaround / total * 100);
 +
var soonPercent = Math.round(soon / total * 100);
 +
var brokenPercent = Math.round(broken / total * 100);
  
 
`
 
`
 
{{/barchart
 
{{/barchart
   |ok        = ${ok}
+
   |ok        = ${okPercent}
   |workaround = ${workaround}
+
   |workaround = ${workaroundPercent}
   |soon      = ${soon}
+
   |soon      = ${soonPercent}
   |broken    = ${broken}
+
   |broken    = ${brokenPercent}
 
}}
 
}}
 
`
 
`

Revision as of 02:52, 20 July 2017

 
0% are compatible or have a working alternative.
 
0% have an update coming soon.
 
0% are broken and not open-source.¹

¹ Many of these broke in Stardew Valley 1.1 or 1.2. Some may be updated by their authors.

Usage

List the percentage values for each group:

{{/barchart
  |ok         = 52
  |workaround = 23
  |soon       = 10
  |broken     = 15
}}

Script

This tiny script generates the template call when run from the parent page.

var ok = $("#mod-list tr[data-status='ok']").length;
var workaround = $("#mod-list tr[data-status='workaround']").length;
var soon = $("#mod-list tr[data-status='soon']").length;
var broken = $("#mod-list tr[data-status='broken']").length;

var total = ok + workaround + soon + broken;
var okPercent = Math.round(ok / total * 100);
var workaroundPercent = Math.round(workaround / total * 100);
var soonPercent = Math.round(soon / total * 100);
var brokenPercent = Math.round(broken / total * 100);

`
{{/barchart
  |ok         = ${okPercent}
  |workaround = ${workaroundPercent}
  |soon       = ${soonPercent}
  |broken     = ${brokenPercent}
}}
`