<commit_before>@extends('layouts.fullscreen')
@section('content')

<script type="text/javascript">

	var dashboard = {

		clock: {
			update: function()
			{
				$('#clock').text( moment().format("h:mma") );
			},
		},

		events: {
			feedUrl: '{{ url() }}/api/events/?orderBy=start',
			poll: function()
			{
				console.log('Polling events');
				$.getJSON( dashboard.events.feedUrl, function( events )
				{
					if( events.data.length != 0 )
					{
						var now = moment();
						var tbody = '';
						var futureEventCount = 0;
						var show = { id : true, name : true, type: true };
						$.each(events.data, function(i, event)
						{
							event.start = moment(event.start);
							event.end = moment(event.end);

							if( event.start.isBefore( now ) && event.end.isAfter( now ) )
							{
								event.status = '<span class="label label-success">Now</span>';
								event.timer = 'Ending ' + event.end.fromNow();

							}
							else if( event.start.isAfter( now ) && event.end.isAfter( now ))
							{
								event.status = '<span class="label label-info">Next</span>';
								event.timer = 'Starting ' + event.start.fromNow();
								if( futureEventCount == 1 ) return true; // only display 1 future event
								futureEventCount++;
							}
							else
							{
								return true; // skip this event
							}
							tbody +=
							'<tr>' + 
								'<td class="event-status">' + event.status + '</td>' +
								'<td class="event-name"><a href="' + event.links[0].uri + '">' + event.name + '</a></td>' +
								'<td class="event-type">' + event.type.name + '</td>' +
								'<td class="event-timer">' + event.timer + '</td>' +
							'</tr>';

						});
						$("#events tbody").html(tbody);
					}
					else
					{
						$("#events tbody").html('<tr><td>No events to show!</td></tr>');
					}
				});
			},
		},
		applicationUsage: {
			feedUrl: '{{ url() }}/api/application-usage/',
			poll: function()
			{
				console.log('Polling application usage');
				$.getJSON( dashboard.applicationUsage.feedUrl, function( applicationUsage )
				{
					if( applicationUsage.length != 0 )
					{
						var tbody = '';
						$.each(applicationUsage, function(i, applicationInUse)
						{
							applicationInUse.userList = '';
							$.each(applicationInUse.users, function(i, user) {
								applicationInUse.userList += '<img src="' + user.avatar_small + '">';
							});
							tbody +=
							'<tr>' + 
								'<td class="application-logo"><img src="' + applicationInUse.logo_small + '"></td>' +
								'<td class="application-name"><a href="' + applicationInUse.url + '">' + applicationInUse.name + '</a></td>' +
								'<td class="application-user-count">' + applicationInUse.users.length + ' In Game</td>' +
								'<td class="application-user-list">' + applicationInUse.userList + '</td>' +
							'</tr>';

						});
						$("#applicationUsage tbody").html(tbody);
					}
					else
					{
						$("#applicationUsage tbody").html('<tr><td>No games being played!</td></tr>');
					}
				});
			},
		},
		shouts: {
			feedUrl: '{{ url() }}/api/shouts/?orderBy=-created_at&take=3',
			poll: function()
			{
				console.log('Polling shouts');
				$.getJSON( dashboard.shouts.feedUrl, function( shouts )
				{
					if( shouts.data.length != 0 )
					{
						var tbody = $('<tbody>');

						$.each(shouts.data, function(idx, shout) {
							var row = $("<tr>");

							row.append(
								$("<td>").append(
									$("<img>").attr('src', shout.user.avatar_medium)
								).addClass('shout-user-avatar shrink')
							);
							row.append(
								$("<td>").append(
									$("<a>").attr('href', shout.user.links[0].uri
									).text(shout.user.username))
								.addClass('shout-user-username shrink')
							);
							row.append(
								$("<td>").text(shout.content)
								.addClass('shout-content expand')
							);

							tbody.append(row);
						});
						$("#shouts").html(tbody);
					}
					else
					{
						$("#shouts tbody").html('<tr><td>No shouts to show!</td></tr>');
					}
				});
			},
		},
	};
	$( document ).ready(function() {
		dashboard.clock.update();
		dashboard.events.poll();
		dashboard.applicationUsage.poll();
		dashboard.shouts.poll();<commit_msg>Fixed "no events/shouts/games" display and improved text style<commit_after>@extends('layouts.fullscreen')
@section('content')

<script type="text/javascript">

	var dashboard = {

		clock: {
			update: function()
			{
				$('#clock').text( moment().format("h:mma") );
			},
		},

		events: {
			feedUrl: '{{ url() }}/api/events/?orderBy=start',
			poll: function()
			{
				console.log('Polling events');
				$.getJSON( dashboard.events.feedUrl, function( events )
				{
					var now = moment();
					var tbody = '';
					var futureEventCount = 0;
					var show = { id : true, name : true, type: true };
					$.each(events.data, function(i, event)
					{
						event.start = moment(event.start);
						event.end = moment(event.end);

						if( event.start.isBefore( now ) && event.end.isAfter( now ) )
						{
							event.status = '<span class="label label-success">Now</span>';
							event.timer = 'Ending ' + event.end.fromNow();

						}
						else if( event.start.isAfter( now ) && event.end.isAfter( now ))
						{
							event.status = '<span class="label label-info">Next</span>';
							event.timer = 'Starting ' + event.start.fromNow();
							if( futureEventCount == 1 ) return true; // only display 1 future event
							futureEventCount++;
						}
						else
						{
							return true; // skip event as it is in the past
						}
						// add a row for the event
						tbody +=
						'<tr>' + 
							'<td class="event-status">' + event.status + '</td>' +
							'<td class="event-name"><a href="' + event.links[0].uri + '">' + event.name + '</a></td>' +
							'<td class="event-type">' + event.type.name + '</td>' +
							'<td class="event-timer">' + event.timer + '</td>' +
						'</tr>';

					});
					if( tbody === '' )
					{
						tbody = '<tr><td class="text-muted">No events to show!</td></tr>';
					}
					$("#events tbody").html( tbody );
				});
			},
		},
		applicationUsage: {
			feedUrl: '{{ url() }}/api/application-usage/',
			poll: function()
			{
				console.log('Polling application usage');
				$.getJSON( dashboard.applicationUsage.feedUrl, function( applicationUsage )
				{
					if( applicationUsage.length != 0 )
					{
						var tbody = '';
						$.each(applicationUsage, function(i, applicationInUse)
						{
							applicationInUse.userList = '';
							$.each(applicationInUse.users, function(i, user) {
								applicationInUse.userList += '<img src="' + user.avatar_small + '">';
							});
							tbody +=
							'<tr>' + 
								'<td class="application-logo"><img src="' + applicationInUse.logo_small + '"></td>' +
								'<td class="application-name"><a href="' + applicationInUse.url + '">' + applicationInUse.name + '</a></td>' +
								'<td class="application-user-count">' + applicationInUse.users.length + ' In Game</td>' +
								'<td class="application-user-list">' + applicationInUse.userList + '</td>' +
							'</tr>';

						});
						$("#applicationUsage tbody").html(tbody);
					}
					else
					{
						$("#applicationUsage tbody").html('<tr><td class="text-muted">No games being played!</td></tr>');
					}
				});
			},
		},
		shouts: {
			feedUrl: '{{ url() }}/api/shouts/?orderBy=-created_at&take=3',
			poll: function()
			{
				console.log('Polling shouts');
				$.getJSON( dashboard.shouts.feedUrl, function( shouts )
				{
					if( shouts.data.length != 0 )
					{
						var tbody = $('<tbody>');

						$.each(shouts.data, function(idx, shout) {
							var row = $("<tr>");

							row.append(
								$("<td>").append(
									$("<img>").attr('src', shout.user.avatar_medium)
								).addClass('shout-user-avatar shrink')
							);
							row.append(
								$("<td>").append(
									$("<a>").attr('href', shout.user.links[0].uri
									).text(shout.user.username))
								.addClass('shout-user-username shrink')
							);
							row.append(
								$("<td>").text(shout.content)
								.addClass('shout-content expand')
							);

							tbody.append(row);
						});
						$("#shouts").html(tbody);
					}
					else
					{
						$("#shouts tbody").html('<tr><td class="text-muted">No shouts to show!</td></tr>');
					}
				});
			},
		},
	};
	$( document ).ready(function() {
		dashboard.clock.update();
		dashboard.events.poll();
		dashboard.applicationUsage.poll();
		dashboard.shouts.poll();
{'fraction_non_alphanumeric': 0.20251823958578488, 'fraction_numerical': 0.002000470698987997, 'mean_word_length': 2.3500197083169097, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4209957', 'n_tokens_mistral': 3945, 'n_tokens_neox': 2750, 'n_words': 489}