IW4M-Admin/WebfrontCore/wwwroot/js/profile.js

140 lines
5.6 KiB
JavaScript
Raw Normal View History

$(document).ready(function () {
2021-07-01 22:58:09 -04:00
/*
Expand alias tab if they have any
*/
2018-02-21 20:29:23 -05:00
$('#profile_aliases_btn').click(function (e) {
const aliases = $('#profile_aliases').text().trim();
2018-02-21 20:29:23 -05:00
if (aliases && aliases.length !== 0) {
$('#profile_aliases').slideToggle(150);
$(this).toggleClass('oi-caret-top');
2018-02-21 20:29:23 -05:00
}
});
2021-07-01 22:58:09 -04:00
const ipAddresses = $('.ip-lookup-profile');
$.each(ipAddresses, function (index, address) {
let ip = $(address).data('ip');
if (ip.length === 0) {
return;
}
$.get('https://ip2c.org/' + ip, function (result) {
const countryCode = result.split(';')[1].toLowerCase();
const country = result.split(';')[3];
if (country === 'Unknown') {
return;
}
$('#ip_lookup_country').text(country);
if (countryCode !== 'zz' && countryCode !== '') {
2021-11-02 19:12:47 -04:00
$(address).css('background-image', `url('https://flagcdn.com/w80/${countryCode}.png')`);
}
2021-07-01 22:58:09 -04:00
});
});
/* set the end time for initial event query */
startAt = $('.loader-data-time').last().data('time');
$('#filter_meta_container_button').click(function () {
$('#filter_meta_container').hide();
$('#filter_meta_container').removeClass('d-none');
$('#filter_meta_container').addClass('d-block');
$('#filter_meta_container').slideDown();
});
/*
* load context of chat
*/
$(document).off('click', '.client-message');
$(document).on('click', '.client-message', function (e) {
showLoader();
const location = $(this);
$('.client-message-prefix').removeClass('oi-chevron-bottom');
$('.client-message-prefix').removeClass('oi-chevron-right');
$('.client-message-prefix').addClass('oi-chevron-right');
$(this).children().filter('.client-message-prefix').removeClass('oi-chevron-right');
$(this).children().filter('.client-message-prefix').addClass('oi-chevron-bottom');
2021-07-01 22:58:09 -04:00
$.get('/Stats/GetMessageAsync', {
'serverId': $(this).data('serverid'),
'when': $(this).data('when')
})
2019-03-26 22:02:11 -04:00
.done(function (response) {
$('.client-message-context').remove();
location.after(response);
hideLoader();
})
.fail(function (jqxhr, textStatus, error) {
errorLoader();
});
});
/*
* load info on ban/flag
*/
$(document).off('click', '.automated-penalty-info-detailed');
$(document).on('click', '.automated-penalty-info-detailed', function (e) {
showLoader();
const location = $(this).parent();
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
'penaltyId': $(this).data('penalty-id')
})
.done(function (response) {
$('.penalty-info-context').remove();
location.after(response);
hideLoader();
})
.fail(function (jqxhr, textStatus, error) {
errorLoader();
});
});
2018-03-09 03:01:12 -05:00
/*
get ip geolocation info into modal
*/
$('.ip-locate-link').click(function (e) {
e.preventDefault();
const ip = $(this).data("ip");
$.getJSON('https://extreme-ip-lookup.com/json/' + ip + '?key=demo')
2018-03-09 03:01:12 -05:00
.done(function (response) {
$('#mainModal .modal-title').text(ip);
$('#mainModal .modal-body').text('');
if (response.ipName.length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_HOSTNAME']} &mdash; ${response.ipName}<br/>`);
}
if (response.isp.length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_ISP']} &mdash; ${response.isp}<br/>`);
}
if (response.org.length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_ORG']} &mdash; ${response.org}<br/>`);
}
if (response['businessName'].length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_BUSINESS']} &mdash; ${response.businessName}<br/>`);
}
if (response['businessWebsite'].length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_WEBSITE']} &mdash; ${response.businessWebsite}<br/>`);
}
if (response.city.length > 0 || response.region.length > 0 || response.country.length > 0) {
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_LOCATION']} &mdash; `);
}
if (response.city.length > 0) {
$('#mainModal .modal-body').append(response.city);
}
if (response.region.length > 0) {
2021-07-01 22:58:09 -04:00
$('#mainModal .modal-body').append((response.city.length > 0 ? ', ' : '') + response.region);
}
if (response.country.length > 0) {
$('#mainModal .modal-body').append((response.country.length > 0 ? ', ' : '') + response.country);
}
$('#mainModal').modal();
})
.fail(function (jqxhr, textStatus, error) {
$('#mainModal .modal-title').text("Error");
$('#mainModal .modal-body').html('<span class="text-danger">&mdash;' + error + '</span>');
2018-03-09 03:01:12 -05:00
$('#mainModal').modal();
});
});
2018-02-21 20:29:23 -05:00
});