From a064a91278fc0573b525a415d34d062e79b01d4e Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 18 Aug 2015 10:16:50 +0200 Subject: [PATCH] Add F/OSS fail meter --- failmeter/css/failmeter.css | 12 +++ failmeter/index.html | 185 ++++++++++++++++++++++++++++++++++++ failmeter/js/failmeter.js | 62 ++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 failmeter/css/failmeter.css create mode 100644 failmeter/index.html create mode 100644 failmeter/js/failmeter.js diff --git a/failmeter/css/failmeter.css b/failmeter/css/failmeter.css new file mode 100644 index 0000000..cee0013 --- /dev/null +++ b/failmeter/css/failmeter.css @@ -0,0 +1,12 @@ +body { + padding-top: 80px; +} + +.fail:hover { + background-color: #eee; +} + +.progress { + margin-bottom: 0; + background-color: #cacaca; +} diff --git a/failmeter/index.html b/failmeter/index.html new file mode 100644 index 0000000..e862683 --- /dev/null +++ b/failmeter/index.html @@ -0,0 +1,185 @@ + + + + + F/OSS Fail meter + + + + + + + + + + + +
+

Size

+ + +

Source Control

+ + +

Building From Source

+ + +

Bundling

+ + +

Libraries

+ + +

System Install

+ + +

Code Oddities

+ + +

Communication

+ + +

Releases

+ + +

History

+ + +

Licensing

+ + +

Documentation

+ + + + + diff --git a/failmeter/js/failmeter.js b/failmeter/js/failmeter.js new file mode 100644 index 0000000..8c3bc3e --- /dev/null +++ b/failmeter/js/failmeter.js @@ -0,0 +1,62 @@ +var max_points = 0; +var points = 0; + +function append_point_values() { + $('li[data-points]').each(function() { + points = $(this).attr('data-points'); + $(this).append(' [' + points + ' points of FAIL]'); + }); +} + +function calc_max_points() { + $('ul:not(.choose-one) > li[data-points]').each(function() { + points = $(this).attr('data-points'); + max_points += +points; + }); + + $('li:has(ul.choose-one)').each(function() { + var this_max = NaN; + $(this).children('ul.choose-one').children('li').each(function() { + points = +$(this).attr('data-points'); + + if (isNaN(this_max) || points > this_max) { + this_max = points; + } + }); + + max_points += this_max; + }); +} + +function update_points() { + var points = 0; + + $('.active').each(function() { + points += +$(this).attr('data-points'); + }); + + if (max_points == 0) { + percent = 0; + } else { + percent = points / max_points * 100; + } + + $('#failmeter').attr('aria-valuenow', percent).css('width', percent + '%'); + $('#points').html(points + '/' + max_points); + + if (percent == 0) { + failtext = 'Perfect! All signs point to succes!'; + } else if (percent < 1.6) { + failtext = 'You are probably doing okay, but you could be better.'; + } else if (percent < 3.8) { + failtext = 'Babies cry when your code is downloaded.'; + } else if (percent < 5.7) { + failtext = 'Kittens die when your code is downloaded.'; + } else if (percent < 8.2) { + failtext = 'HONK HONK. THE FAILBOAT HAS ARRIVED!'; + } else { + failtext = 'So much fail, your code should have its own reality show.'; + } + + $('#failtext').html(failtext); +}