2018-02-24 00:56:03 -05:00
|
|
|
|
// keeps track of how many events have been displayed
|
|
|
|
|
let count = 1;
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
|
|
|
|
|
if (typeof clientInfo === 'undefined') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
/*
|
|
|
|
|
Expand alias tab if they have any
|
|
|
|
|
*/
|
|
|
|
|
$('#profile_aliases_btn').click(function (e) {
|
2018-02-22 01:06:21 -05:00
|
|
|
|
const aliases = $('#profile_aliases').text().trim();
|
2018-02-21 20:29:23 -05:00
|
|
|
|
if (aliases && aliases.length !== 0) {
|
|
|
|
|
$('#profile_aliases').slideToggle(150);
|
2018-04-02 01:25:06 -04:00
|
|
|
|
$(this).toggleClass('oi-caret-top');
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-02-24 00:56:03 -05:00
|
|
|
|
/*
|
|
|
|
|
load the initial 40 events
|
|
|
|
|
*/
|
2018-02-21 20:29:23 -05:00
|
|
|
|
$.each(clientInfo.Meta, function (index, meta) {
|
2018-02-24 00:56:03 -05:00
|
|
|
|
if (meta.key.includes("Event")) {
|
|
|
|
|
loadMeta(meta);
|
|
|
|
|
if (count % 40 === 0) {
|
|
|
|
|
count++;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-03-27 00:54:20 -04:00
|
|
|
|
count++;
|
2018-02-24 00:56:03 -05:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
load additional events on scroll
|
|
|
|
|
*/
|
|
|
|
|
$(window).scroll(function () {
|
|
|
|
|
if ($(window).scrollTop() === $(document).height() - $(window).height() || $(document).height() === $(window).height()) {
|
|
|
|
|
while (count % 40 !== 0 && count < clientInfo.Meta.length) {
|
|
|
|
|
loadMeta(clientInfo.Meta[count - 1]);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2018-02-21 20:29:23 -05:00
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-02-24 00:56:03 -05:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
load meta thats not an event
|
|
|
|
|
*/
|
|
|
|
|
$.each(clientInfo.Meta, function (index, meta) {
|
|
|
|
|
if (!meta.key.includes("Event")) {
|
|
|
|
|
let metaString = `<div class="profile-meta-entry"><span class="profile-meta-value text-primary">${meta.value}</span><span class="profile-meta-title text-muted"> ${meta.key}</span></div>`;
|
|
|
|
|
$("#profile_meta").append(metaString);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-03-09 03:01:12 -05:00
|
|
|
|
/*
|
|
|
|
|
get ip geolocation info into modal
|
|
|
|
|
*/
|
|
|
|
|
$('.ip-locate-link').click(function (e) {
|
2018-03-13 17:30:22 -04:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
const ip = $(this).data("ip");
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$.getJSON('https://extreme-ip-lookup.com/json/' + ip)
|
2018-03-09 03:01:12 -05:00
|
|
|
|
.done(function (response) {
|
2018-03-28 23:01:09 -04:00
|
|
|
|
$('#mainModal .modal-title').text(ip);
|
|
|
|
|
$('#mainModal .modal-body').text("");
|
2018-04-04 15:38:34 -04:00
|
|
|
|
if (response.ipName.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("Hostname — " + response.ipName + '<br/>');
|
|
|
|
|
}
|
|
|
|
|
if (response.isp.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("ISP — " + response.isp + '<br/>');
|
|
|
|
|
}
|
|
|
|
|
if (response.org.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("Organization — " + response.org + '<br/>');
|
|
|
|
|
}
|
|
|
|
|
if (response['businessName'].length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("Business — " + response.businessName + '<br/>');
|
|
|
|
|
}
|
|
|
|
|
if (response['businessWebsite'].length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("Website — " + response.businessWebsite + '<br/>');
|
|
|
|
|
}
|
|
|
|
|
if (response.city.length > 0 || response.region.length > 0 || response.country.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append("Location — ");
|
|
|
|
|
}
|
|
|
|
|
if (response.city.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append(response.city);
|
|
|
|
|
}
|
|
|
|
|
if (response.region.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append(', ' + response.region);
|
|
|
|
|
}
|
|
|
|
|
if (response.country.length > 0) {
|
|
|
|
|
$('#mainModal .modal-body').append(', ' + response.country);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-28 23:01:09 -04:00
|
|
|
|
$('#mainModal').modal();
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
|
|
|
|
$('#mainModal .modal-title').text("Error");
|
|
|
|
|
$('#mainModal .modal-body').html('<span class="text-danger">—'+ error + '</span>');
|
2018-03-09 03:01:12 -05:00
|
|
|
|
$('#mainModal').modal();
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-02-21 20:29:23 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function penaltyToName(penaltyName) {
|
|
|
|
|
switch (penaltyName) {
|
|
|
|
|
case "Flag":
|
2018-03-27 00:54:20 -04:00
|
|
|
|
return "Flagged";
|
2018-02-21 20:29:23 -05:00
|
|
|
|
case "Warning":
|
|
|
|
|
return "Warned";
|
|
|
|
|
case "Report":
|
|
|
|
|
return "Reported";
|
|
|
|
|
case "Ban":
|
|
|
|
|
return "Banned";
|
|
|
|
|
case "Kick":
|
|
|
|
|
return "Kicked";
|
|
|
|
|
case "TempBan":
|
|
|
|
|
return "Temp Banned";
|
|
|
|
|
case "Unban":
|
|
|
|
|
return "Unbanned";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 00:54:20 -04:00
|
|
|
|
function shouldIncludePlural(num) {
|
|
|
|
|
return num > 1 ? 's' : '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mostRecentDate = 0;
|
|
|
|
|
let currentStepAmount = 0;
|
2018-03-27 20:27:01 -04:00
|
|
|
|
let lastStep = '';
|
2018-03-27 00:54:20 -04:00
|
|
|
|
function timeStep(stepDifference) {
|
2018-03-27 20:27:01 -04:00
|
|
|
|
let hours = stepDifference / (1000 * 60 * 60);
|
|
|
|
|
let days = stepDifference / (1000 * 60 * 60 * 24);
|
|
|
|
|
let weeks = stepDifference / (1000 * 60 * 60 * 24 * 7);
|
2018-03-27 00:54:20 -04:00
|
|
|
|
|
|
|
|
|
if (Math.round(weeks) > Math.round(currentStepAmount / 24 * 7)) {
|
|
|
|
|
currentStepAmount = Math.round(weeks);
|
|
|
|
|
return `${currentStepAmount} week${shouldIncludePlural(currentStepAmount)} ago`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.round(days) > Math.round(currentStepAmount / 24)) {
|
|
|
|
|
currentStepAmount = Math.round(days);
|
|
|
|
|
return `${currentStepAmount} day${shouldIncludePlural(currentStepAmount)} ago`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.round(hours) > currentStepAmount) {
|
|
|
|
|
currentStepAmount = Math.round(hours);
|
|
|
|
|
return `${currentStepAmount} hour${shouldIncludePlural(currentStepAmount)} ago`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
function loadMeta(meta) {
|
|
|
|
|
let eventString = '';
|
2018-03-27 20:27:01 -04:00
|
|
|
|
const metaDate = moment.utc(meta.when).valueOf();
|
2018-03-27 00:54:20 -04:00
|
|
|
|
|
|
|
|
|
if (mostRecentDate === 0) {
|
|
|
|
|
mostRecentDate = metaDate;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
const step = timeStep(moment.utc().valueOf() - metaDate);
|
2018-03-27 00:54:20 -04:00
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
if (step !== lastStep && step !== undefined && metaDate > 0) {
|
2018-03-27 00:54:20 -04:00
|
|
|
|
$('#profile_events').append('<span class="p2 text-white profile-event-timestep"><span class="text-primary">—</span> ' + step + '</span>');
|
|
|
|
|
lastStep = step;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
// it's a penalty
|
|
|
|
|
if (meta.class.includes("Penalty")) {
|
|
|
|
|
if (meta.value.punisherId !== clientInfo.clientId) {
|
2018-04-19 01:48:14 -04:00
|
|
|
|
const timeRemaining = meta.value.type === 'TempBan' && meta.value.timeRemaining.length > 0 ?
|
2018-04-13 02:32:30 -04:00
|
|
|
|
`(${meta.value.timeRemaining} remaining)` :
|
|
|
|
|
'';
|
|
|
|
|
eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)}</span> by <span class="text-highlight"> <a class="link-inverse" href="${meta.value.punisherId}">${meta.value.punisherName}</a></span > for <span style="color: white; ">${meta.value.offense}</span><span class="text-muted"> ${timeRemaining}</span></div>`;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-03-27 00:54:20 -04:00
|
|
|
|
eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)} </span> <span class="text-highlight"><a class="link-inverse" href="${meta.value.offenderId}"> ${meta.value.offenderName}</a></span > for <span style="color: white; ">${meta.value.offense}</span></div>`;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-02 01:25:06 -04:00
|
|
|
|
else if (meta.key.includes("Alias")) {
|
2018-04-04 15:38:34 -04:00
|
|
|
|
eventString = `<div><span class="text-success">${meta.value}</span></div>`;
|
2018-04-02 01:25:06 -04:00
|
|
|
|
}
|
2018-02-21 20:29:23 -05:00
|
|
|
|
// it's a message
|
|
|
|
|
else if (meta.key.includes("Event")) {
|
|
|
|
|
eventString = `<div><span style="color:white;">></span><span class="text-muted"> ${meta.value}</span></div>`;
|
|
|
|
|
}
|
|
|
|
|
$('#profile_events').append(eventString);
|
|
|
|
|
}
|