Last active
October 7, 2015 08:38
-
-
Save elijahmanor/3136315 to your computer and use it in GitHub Desktop.
Show Total JabbR Count Across All Rooms
This file contains hidden or 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
| (function( $ ) { | |
| var $lobby = $( "#tabs-lobby" ), $sparkline, counts = []; | |
| $lobby.find( "button" ).append( $( "<span />", { "class": "count", text: "0" } ) ); | |
| $.getScript( "//cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.1/jquery.sparkline.min.js", function() { | |
| $sparkline = $( "<span style='height: 20px; width: 500px; padding: 0; margin: 0;' class='sparkline'>Loading..</span>" ).appendTo( "#room-filter-form" ); | |
| }); | |
| var dotnetconfCounts = []; | |
| function updateDotNetConf() { | |
| var $dotnetconfTab = $( "#tabs-dotnetconf_live" ), | |
| dotnetconfMax = localStorage[ "dotnetconfMax" ] || 0, | |
| dotnetconfCurrent = $( "#userlist-dotnetconf_live .user" ).length, | |
| oldCount = parseInt( $dotnetconfTab.find( ".count" ).text(), 10 ), | |
| $topicBar = $( "#topic-bar" ), | |
| $dotnetconfSparkline = $topicBar.find( ".sparkline" ); | |
| if ( !$dotnetconfTab.find( ".count" ).length ) { | |
| $dotnetconfTab.find( "button" ).append( $( "<span />", { "class": "count", text: "0" } ) ); | |
| } | |
| if ( !$dotnetconfSparkline.length ) { | |
| $dotnetconfSparkline = $( "<span style='height: 15px; width: 500px; float: right; padding-right: 25px; padding-left: 25px;' class='sparkline'>Loading..</span>" ).appendTo( "#roomTopic-dotnetconf_live" ); | |
| } | |
| if ( dotnetconfCurrent > dotnetconfMax ) { | |
| dotnetconfMax = dotnetconfCurrent; | |
| localStorage[ "dotnetconfMax" ] = dotnetconfMax; | |
| } | |
| dotnetconfCounts.push( dotnetconfCurrent ); | |
| if ( dotnetconfCurrent !== oldCount ) { | |
| $dotnetconfTab.find( ".count" ).text( dotnetconfCurrent + "/" + dotnetconfMax ).effect( "highlight", 250 ); | |
| } | |
| if ( $dotnetconfSparkline && $dotnetconfSparkline.sparkline ) { | |
| $dotnetconfSparkline.sparkline( dotnetconfCounts, { height: "25px", width: "500px" } ); | |
| } | |
| } | |
| (function updateCount() { | |
| var $count = $lobby.find( ".count" ), | |
| jabbrMax = window.localStorage[ "jabbr.max" ] || 0, | |
| count = 0; | |
| $( "#userlist-lobby .room .count" ).each( function() { | |
| count += parseInt( $( this ).text().match( /\d+/ ), 10 ) || 0; | |
| }); | |
| counts.push( count ); | |
| if ( count > jabbrMax ) { | |
| window.localStorage["jabbr.max"] = count; | |
| jabbrMax = count; | |
| } | |
| if ( count !== parseInt( $count.text(), 10 ) ) { | |
| $count.text( count + "/" + jabbrMax ).effect( "highlight", 250 ); | |
| } | |
| if ( $sparkline ) { $sparkline.sparkline( counts, { height: "30px", width: "500px" } ); } | |
| updateDotNetConf(); | |
| window.setTimeout( updateCount, 5000 ); | |
| })(); | |
| })( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment