2017-11-04 19:42:31 -04:00
|
|
|
|
<script src="/webfront/scripts/wordcloud2.js"></script>
|
2017-11-13 16:58:23 -05:00
|
|
|
|
<div style="display:none;" class="chat-history">
|
|
|
|
|
<h2>Chat history </h2>
|
|
|
|
|
<br/>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="word-cloud-wrapper" style="text-align: center; display: none;">
|
|
|
|
|
<canvas id="chat-word-cloud" width="750" height="750"></canvas>
|
|
|
|
|
</div>
|
2017-11-04 19:42:31 -04:00
|
|
|
|
<script>
|
|
|
|
|
if (parseGet("clientid") == "undefined") {
|
2017-11-13 16:58:23 -05:00
|
|
|
|
$('#word-cloud-wrapper').show();
|
2017-11-04 19:42:31 -04:00
|
|
|
|
$.getJSON("/_words", function (result) {
|
|
|
|
|
var wordList = [];
|
2017-11-13 16:58:23 -05:00
|
|
|
|
var largestWord = 0;
|
2017-11-04 19:42:31 -04:00
|
|
|
|
$.each(result, function (i, word) {
|
2017-11-13 16:58:23 -05:00
|
|
|
|
if (word.Count > largestWord)
|
|
|
|
|
largestWord = word.Count;
|
2017-11-04 19:42:31 -04:00
|
|
|
|
wordList.push([word.Word, word.Count]);
|
|
|
|
|
});
|
2017-11-13 16:58:23 -05:00
|
|
|
|
var _weightFactor = Math.min(1, (1 / largestWord) / 0.003599);
|
|
|
|
|
WordCloud(document.getElementById('chat-word-cloud'), { list: wordList, backgroundColor: "rgb(34,34,34)", color: "rgb(0, 122, 204)", wait: 0, weightFactor: _weightFactor });
|
2017-11-04 19:42:31 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
2017-11-13 16:58:23 -05:00
|
|
|
|
$('.chat-history').show();
|
2017-11-04 19:42:31 -04:00
|
|
|
|
$.getJSON("/_clientchat?clientid=" + parseGet("clientid"), function (result) {
|
|
|
|
|
result = result.sort(function (a, b) {
|
|
|
|
|
return new Date(b.TimeSent) - new Date(a.TimeSent);
|
|
|
|
|
});
|
|
|
|
|
|
2017-11-13 16:58:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result.length == 0) {
|
|
|
|
|
$('.chat-history h2').append('is empty.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
$('.chat-history h2').append('for <b>' + result[0].ClientName + '</b> (' + result.length + ' messages)');
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-04 19:42:31 -04:00
|
|
|
|
$.each(result, function (i, chat) {
|
|
|
|
|
var date = new Date(chat.TimeSent);
|
2017-11-13 16:58:23 -05:00
|
|
|
|
$('.chat-history').append("<div><span>" + date.toLocaleString() + " — </span><span><b>" + chat.ClientName + "</b></span>: <span>" + chat.Message + "</span></div>");
|
2017-11-04 19:42:31 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|