Created
January 23, 2018 06:06
-
-
Save PerfectlyNormal/19e0b28ab686614f7f59000675b86073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery throttle / debounce - v1.1 - 3/7/2010 | |
* http://benalman.com/projects/jquery-throttle-debounce-plugin/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); | |
$("#filterText").on('keyup', $.debounce(250, function() { | |
$("#autosum").remove(); | |
minutes = $(".list-group-item-info:visible .badge").map((index, badge) => { var raw = badge.innerHTML; var hours = parseInt(raw.split(':')[0], 10); var minutes = parseInt(raw.split(':')[1], 10); return minutes + hours*60}).get().reduce((accumulator, currentValue) => accumulator + currentValue, 0); | |
hours = Math.floor(minutes / 60); | |
minutes -= hours * 60 | |
$($("hr")[0]).after(`<p id='autosum'>Totalt: ${hours}:${String('0' + minutes).slice(-2)}</p>`); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment