mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 14:30:17 +02:00
[CHANGE] JS updated to ES8+ standard where ever possible
This commit is contained in:
parent
021b7b2edb
commit
de12b49527
@ -34,32 +34,36 @@
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include "bundles/datatables-js-bs5.html" %}
|
||||
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
let grp = 2;
|
||||
|
||||
const table = $('#table_tokens').DataTable({
|
||||
'columnDefs': [{orderable: false, targets: [0, 1]}, {
|
||||
'visible': false,
|
||||
'targets': grp
|
||||
}],
|
||||
'order': [[grp, 'asc']],
|
||||
'drawCallback': function (settings) {
|
||||
var api = this.api();
|
||||
var rows = api.rows({page: 'current'}).nodes();
|
||||
var last = null;
|
||||
api.column(grp, {page: 'current'})
|
||||
.data()
|
||||
.each(function (group, i) {
|
||||
if (last !== group) {
|
||||
$(rows).eq(i).before(`<tr class="info"><td colspan="3">${group}</td></tr>`);
|
||||
last = group;
|
||||
}
|
||||
});
|
||||
},
|
||||
'stateSave': true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock extra_javascript %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include "bundles/datatables-css-bs5.html" %}
|
||||
{% endblock extra_css %}
|
||||
|
||||
{% block extra_script %}
|
||||
$(document).ready(function(){
|
||||
let grp = 2;
|
||||
var table = $('#table_tokens').DataTable({
|
||||
"columnDefs": [{ orderable: false, targets: [0,1] },{ "visible": false, "targets": grp }],
|
||||
"order": [[grp, 'asc']],
|
||||
"drawCallback": function (settings) {
|
||||
var api = this.api();
|
||||
var rows = api.rows({ page: 'current' }).nodes();
|
||||
var last = null;
|
||||
api.column(grp, { page: 'current' })
|
||||
.data()
|
||||
.each(function (group, i) {
|
||||
if (last !== group) {
|
||||
$(rows).eq(i).before('<tr class="info"><td colspan="3">' + group + '</td></tr>');
|
||||
last = group;
|
||||
}
|
||||
});
|
||||
},
|
||||
"stateSave": true,
|
||||
});
|
||||
});
|
||||
{% endblock extra_script %}
|
||||
|
@ -234,13 +234,8 @@
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/datatables-js-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$('#table-mains').DataTable({
|
||||
"columnDefs": [
|
||||
@ -270,4 +265,9 @@
|
||||
"stateDuration": 0
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
@ -41,17 +41,17 @@
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/datatables-js-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$('#table-search').DataTable({
|
||||
"stateSave": true,
|
||||
"stateDuration": 0
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
@ -54,8 +54,10 @@
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_script %}
|
||||
{% block extra_javascript %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$("[rel=tooltip]").tooltip();
|
||||
});
|
||||
{% endblock extra_script %}
|
||||
</script>
|
||||
{% endblock extra_javascript %}
|
||||
|
@ -58,8 +58,10 @@
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_script %}
|
||||
{% block extra_javascript %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$("[rel=tooltip]").tooltip();
|
||||
});
|
||||
{% endblock extra_script %}
|
||||
</script>
|
||||
{% endblock extra_javascript %}
|
||||
|
@ -66,30 +66,25 @@
|
||||
{% include 'bundles/datatables-js-bs5.html' %}
|
||||
{% include 'bundles/moment-js.html' with locale=True %}
|
||||
{% include 'bundles/filterdropdown-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
$.fn.dataTable.moment = function(format, locale) {
|
||||
let types = $.fn.dataTable.ext.type;
|
||||
<script>
|
||||
$.fn.dataTable.moment = (format, locale) => {
|
||||
const types = $.fn.dataTable.ext.type;
|
||||
|
||||
// Add type detection
|
||||
types.detect.unshift(function(d) {
|
||||
types.detect.unshift((d) => {
|
||||
return moment(d, format, locale, true).isValid() ?
|
||||
'moment-'+format :
|
||||
null;
|
||||
});
|
||||
|
||||
// Add sorting method - use an integer for the sorting
|
||||
types.order[ 'moment-'+format+'-pre' ] = function(d) {
|
||||
types.order[ 'moment-'+format+'-pre' ] = (d) => {
|
||||
return moment(d, format, locale, true).unix();
|
||||
};
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(() => {
|
||||
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
||||
|
||||
$('#log-entries').DataTable({
|
||||
@ -122,4 +117,9 @@
|
||||
"stateDuration": 0
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
@ -77,14 +77,9 @@
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/datatables-js-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
$(document).ready(function(){
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$('#tab_group_members').DataTable({
|
||||
order: [[0, "asc"]],
|
||||
columnDefs: [
|
||||
@ -97,4 +92,9 @@
|
||||
"stateDuration": 0
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
@ -78,16 +78,17 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/datatables-js-bs5.html' %}
|
||||
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$('#groupsTable').DataTable();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/datatables-css-bs5.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
$(document).ready(function () {
|
||||
$('#groupsTable').DataTable();
|
||||
});
|
||||
{% endblock extra_script %}
|
||||
|
@ -163,7 +163,8 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
||||
|
||||
<script>
|
||||
const clipboard = new ClipboardJS('.copy-text-fa-icon');
|
||||
clipboard.on('success', function (e) {
|
||||
|
||||
clipboard.on('success', (e) => {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
@ -171,12 +172,12 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
clipboard.on('error', (e) => {
|
||||
console.error('Action:', e.action);
|
||||
console.error('Trigger:', e.trigger);
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(() => {
|
||||
const elementEditableSrpAmount = $('.srp');
|
||||
const elementTableSrpList = $('table.srplist');
|
||||
|
||||
@ -202,12 +203,12 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
||||
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
||||
|
||||
elementEditableSrpAmount.editable({
|
||||
display: function(value, response) {
|
||||
display: (value, response) => {
|
||||
return false;
|
||||
},
|
||||
success: function(response, newValue) {
|
||||
newValue = parseInt(newValue);
|
||||
const newValueOutput = newValue.toLocaleString() + " ISK";
|
||||
const newValueOutput = `${newValue.toLocaleString()} ISK`;
|
||||
|
||||
$(this).html(`<b>${newValueOutput}</b>`);
|
||||
},
|
||||
@ -218,11 +219,11 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
||||
}
|
||||
});
|
||||
|
||||
elementEditableSrpAmount.on('hidden', function(e, reason){
|
||||
if(reason === 'save' || reason === 'nochange') {
|
||||
elementEditableSrpAmount.on('hidden', function(e, reason) {
|
||||
if (reason === 'save' || reason === 'nochange') {
|
||||
const next_editable_element = $(this).closest('tr').next().find('.editable');
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
next_editable_element.editable('show');
|
||||
}, 400);
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* render a JS clock for Eve Time
|
||||
* Render the current EVE time in the top menu bar
|
||||
* @param element
|
||||
*/
|
||||
const renderClock = function (element) {
|
||||
const renderClock = (element) => {
|
||||
const datetimeNow = new Date();
|
||||
const h = String(datetimeNow.getUTCHours()).padStart(2, '0');
|
||||
const m = String(datetimeNow.getUTCMinutes()).padStart(2, '0');
|
||||
|
||||
element.html(h + ':' + m);
|
||||
element.html(`${h}:${m}`);
|
||||
};
|
||||
|
||||
// Start the Eve time clock in the top menu bar
|
||||
setInterval(function () {
|
||||
/**
|
||||
* Start the Eve time clock in the top menu bar
|
||||
*/
|
||||
setInterval(() => {
|
||||
renderClock($('.eve-time-wrapper .eve-time-clock'));
|
||||
}, 500);
|
||||
});
|
||||
|
@ -5,21 +5,21 @@
|
||||
* on a regular basis so to keep the user apprised about newly arrived
|
||||
* notifications without having to reload the page.
|
||||
*
|
||||
* The refresh rate can be changes via the Django setting NOTIFICATIONS_REFRESH_TIME.
|
||||
* The refresh rate can be changed via the Django setting NOTIFICATIONS_REFRESH_TIME.
|
||||
* See documentation for details.
|
||||
*/
|
||||
$(() => {
|
||||
'use strict';
|
||||
|
||||
const notificationsRefreshTime = notificationUpdateSettings.refreshTime;
|
||||
const userNotificationsCountViewUrl = notificationUpdateSettings.userNotificationsCountViewUrl;
|
||||
const notificationRefreshTime = notificationUpdateSettings.refreshTime;
|
||||
const userNotificationCountViewUrl = notificationUpdateSettings.userNotificationsCountViewUrl;
|
||||
const elementNotificationIcon = $('#menu_item_notifications .fa-bell');
|
||||
|
||||
/**
|
||||
* Update the notification icon in the top menu
|
||||
*/
|
||||
const updateNotificationIcon = () => {
|
||||
fetch(userNotificationsCountViewUrl)
|
||||
fetch(userNotificationCountViewUrl)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
@ -47,9 +47,9 @@ $(() => {
|
||||
* Activate automatic refresh every x seconds
|
||||
*/
|
||||
const activateIconUpdate = () => {
|
||||
if (notificationsRefreshTime > 0) {
|
||||
if (notificationRefreshTime > 0) {
|
||||
myInterval = setInterval(
|
||||
updateNotificationIcon, notificationsRefreshTime * 1000
|
||||
updateNotificationIcon, notificationRefreshTime * 1000
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -58,7 +58,7 @@ $(() => {
|
||||
* Deactivate automatic refresh
|
||||
*/
|
||||
const deactivateIconUpdate = () => {
|
||||
if ((notificationsRefreshTime > 0) && (typeof myInterval !== 'undefined')) {
|
||||
if ((notificationRefreshTime > 0) && (typeof myInterval !== 'undefined')) {
|
||||
clearInterval(myInterval);
|
||||
}
|
||||
};
|
||||
|
@ -1,26 +1,28 @@
|
||||
/* global notificationUPdateSettings */
|
||||
/* global notificationUPdateSettings, xhr */
|
||||
|
||||
/*
|
||||
This script refreshed the unread notification count in the top menu
|
||||
on a regular basis so to keep the user apprised about newly arrived
|
||||
notifications without having to reload the page.
|
||||
|
||||
The refresh rate can be changes via the Django setting NOTIFICATIONS_REFRESH_TIME.
|
||||
See documentation for details.
|
||||
*/
|
||||
$(function () {
|
||||
/**
|
||||
* This script refreshed the unread notification count in the top menu
|
||||
* on a regular basis so to keep the user apprized about newly arrived
|
||||
* notifications without having to reload the page.
|
||||
*
|
||||
* The refresh rate can be changed via the Django setting NOTIFICATIONS_REFRESH_TIME.
|
||||
* See documentation for details.
|
||||
*/
|
||||
$(document).ready(() => {
|
||||
'use strict';
|
||||
|
||||
let notificationsListViewUrl = notificationUPdateSettings.notificationsListViewUrl;
|
||||
let notificationsRefreshTime = notificationUPdateSettings.notificationsRefreshTime;
|
||||
let userNotificationsCountViewUrl = notificationUPdateSettings.userNotificationsCountViewUrl;
|
||||
const notificationListViewUrl = notificationUPdateSettings.notificationsListViewUrl;
|
||||
const notificationRefreshTime = notificationUPdateSettings.notificationsRefreshTime;
|
||||
const userNotificationCountViewUrl = notificationUPdateSettings.userNotificationsCountViewUrl;
|
||||
|
||||
// update the notification unread count in the top menu
|
||||
let updateNotifications = function () {
|
||||
$.getJSON(userNotificationsCountViewUrl, function (data, status) {
|
||||
/**
|
||||
* Update the notification item in the top menu with the current unread count
|
||||
*/
|
||||
const updateNotifications = () => {
|
||||
$.getJSON(userNotificationCountViewUrl, (data, status) => {
|
||||
if (status === 'success') {
|
||||
let innerHtml = '';
|
||||
let unreadCount = data.unread_count;
|
||||
let innerHtml;
|
||||
const unreadCount = data.unread_count;
|
||||
|
||||
if (unreadCount > 0) {
|
||||
innerHtml = (
|
||||
@ -31,7 +33,7 @@ $(function () {
|
||||
}
|
||||
|
||||
$('#menu_item_notifications').html(
|
||||
`<a href="${notificationsListViewUrl}">${innerHtml}</a>`
|
||||
`<a href="${notificationListViewUrl}">${innerHtml}</a>`
|
||||
);
|
||||
} else {
|
||||
console.error(
|
||||
@ -43,32 +45,41 @@ $(function () {
|
||||
|
||||
let myInterval;
|
||||
|
||||
// activate automatic refreshing every x seconds
|
||||
let activateRefreshing = function () {
|
||||
if (notificationsRefreshTime > 0) {
|
||||
/**
|
||||
* Activate automatic refreshing of notifications
|
||||
*/
|
||||
const activateRefreshing = () => {
|
||||
if (notificationRefreshTime > 0) {
|
||||
myInterval = setInterval(
|
||||
updateNotifications, notificationsRefreshTime * 1000
|
||||
updateNotifications, notificationRefreshTime * 1000
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// deactivate automatic refreshing
|
||||
let deactivateRefreshing = function () {
|
||||
if ((notificationsRefreshTime > 0) && (typeof myInterval !== 'undefined')) {
|
||||
/**
|
||||
* Deactivate automatic refreshing of notifications
|
||||
*/
|
||||
const deactivateRefreshing = () => {
|
||||
if ((notificationRefreshTime > 0) && (typeof myInterval !== 'undefined')) {
|
||||
clearInterval(myInterval);
|
||||
}
|
||||
};
|
||||
|
||||
// refreshing only happens on active browser tab
|
||||
/**
|
||||
* Activate refreshing when the browser tab is active
|
||||
* and deactivate it when it is not
|
||||
*/
|
||||
$(document).on({
|
||||
'show': function () {
|
||||
'show': () => {
|
||||
activateRefreshing();
|
||||
},
|
||||
'hide': function () {
|
||||
'hide': () => {
|
||||
deactivateRefreshing();
|
||||
}
|
||||
});
|
||||
|
||||
// Initial start of refreshing on script loading
|
||||
/**
|
||||
* Initial start of refreshing on script loading
|
||||
*/
|
||||
activateRefreshing();
|
||||
});
|
||||
|
@ -7,24 +7,24 @@
|
||||
* @param duration
|
||||
* @returns {string}
|
||||
*/
|
||||
let getDurationString = function (duration) {
|
||||
const getDurationString = (duration) => { // eslint-disable-line no-unused-vars
|
||||
'use strict';
|
||||
|
||||
let out = '';
|
||||
|
||||
if (duration.years()) {
|
||||
out += duration.years() + 'y ';
|
||||
out += `${duration.years()}y `;
|
||||
}
|
||||
|
||||
if (duration.months()) {
|
||||
out += duration.months() + 'm ';
|
||||
out += `${duration.months()}m `;
|
||||
}
|
||||
|
||||
if (duration.days()) {
|
||||
out += duration.days() + 'd ';
|
||||
out += `${duration.days()}d `;
|
||||
}
|
||||
|
||||
return out + duration.hours() + 'h ' + duration.minutes() + 'm ' + duration.seconds() + 's';
|
||||
return `${out + duration.hours()}h ${duration.minutes()}m ${duration.seconds()}s`;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -32,11 +32,11 @@ let getDurationString = function (duration) {
|
||||
*
|
||||
* condition:
|
||||
* only if moment.js is loaded before,
|
||||
* if not this function returns an empty string to avoid JS errors from happening.
|
||||
* if not, this function returns an empty string to avoid JS errors from happening.
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
let getCurrentEveTimeString = function () {
|
||||
const getCurrentEveTimeString = () => { // eslint-disable-line no-unused-vars
|
||||
'use strict';
|
||||
|
||||
let returnValue = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user