From cb84b79bbcd8d4a59a0761dd1674ca684e48b6c2 Mon Sep 17 00:00:00 2001
From: psychobunny <psycho.bunny@hotmail.com>
Date: Mon, 29 Sep 2014 04:26:49 -0400
Subject: [PATCH] 'no users browsing' feature for presence chart

---
 public/src/forum/admin/general/dashboard.js | 37 +++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/public/src/forum/admin/general/dashboard.js b/public/src/forum/admin/general/dashboard.js
index 55fbfeb159..c74fc4d291 100644
--- a/public/src/forum/admin/general/dashboard.js
+++ b/public/src/forum/admin/general/dashboard.js
@@ -307,6 +307,10 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) {
 	}
 
 	function updateTopicsGraph(topics) {
+		if (!Object.keys(topics).length) {
+			topics = {"0": 1};
+		}
+
 		var tids = Object.keys(topics),
 			segments = graphs.topics.segments;
 
@@ -338,24 +342,28 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) {
 					continue;
 				}
 
-				do {
-					for (var i = 0, ii = topicColors.length; i < ii; i++) {
-						var chosenColor = topicColors[i];
-
-						if ($.inArray(chosenColor, usedTopicColors) === -1) {
-							color = chosenColor;
-							usedTopicColors.push(color);
-							break;
+				if (tid === '0') {
+					color = '#4D5360';
+				} else {
+					do {
+						for (var i = 0, ii = topicColors.length; i < ii; i++) {
+							var chosenColor = topicColors[i];
+
+							if ($.inArray(chosenColor, usedTopicColors) === -1) {
+								color = chosenColor;
+								usedTopicColors.push(color);
+								break;
+							}
 						}
-					}
-				} while (color === null && usedTopicColors.length < topicColors.length);
+					} while (color === null && usedTopicColors.length < topicColors.length);
+				}
 
 				if (color) {
 					graphs.topics.addData({
-						value: tid,
+						value: value,
 						color: color,
 						highlight: lighten(color, 10),
-						label: "tid " + tid
+						label: tid !== '0' ? "tid " + tid : "No users browsing"
 					});
 
 					segments[segments.length - 1].tid = tid;
@@ -367,12 +375,13 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) {
 			var legend = $('#topics-legend').html('');
 
 			for (var i = 0, ii = segments.length; i < ii; i++) {
-				var topic = segments[i];
+				var topic = segments[i],
+					label = topic.tid === '0' ? topic.label : '<a href="' + RELATIVE_PATH + '/topic/' + topic.tid + '" target="_blank"> ' + topic.label + '</a>';
 
 				legend.append(
 					'<li>' +
 						'<div style="background-color: ' + topic.highlightColor + '; border-color: ' + topic.strokeColor + '"></div>' +
-						'<span><a href="' + RELATIVE_PATH + '/topic/' + topic.tid + '" target="_blank"> ' + topic.label + '</a></span>' +
+						'<span>' + label + '</span>' +
 					'</li>');
 			}
 		}