[CHANGE] JS updated to ES8+ standard where ever possible

This commit is contained in:
Peter Pfeufer
2023-12-10 14:56:15 +01:00
parent 021b7b2edb
commit de12b49527
13 changed files with 231 additions and 208 deletions

View File

@@ -66,60 +66,60 @@
{% include 'bundles/datatables-js-bs5.html' %}
{% include 'bundles/moment-js.html' with locale=True %}
{% include 'bundles/filterdropdown-js.html' %}
<script>
$.fn.dataTable.moment = (format, locale) => {
const types = $.fn.dataTable.ext.type;
// Add type detection
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' ] = (d) => {
return moment(d, format, locale, true).unix();
};
};
$(document).ready(() => {
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
$('#log-entries').DataTable({
order: [[0, 'desc'], [1, 'asc']],
filterDropDown:
{
columns: [
{
idx: 1
},
{
idx: 2
},
{
idx: 3
},
{
idx: 4
},
{
idx: 5
},
{
idx: 6
}
],
bootstrap: true
},
"stateSave": true,
"stateDuration": 0
});
});
</script>
{% 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;
// Add type detection
types.detect.unshift(function(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) {
return moment(d, format, locale, true).unix();
};
};
$(document).ready(function(){
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
$('#log-entries').DataTable({
order: [[0, 'desc'], [1, 'asc']],
filterDropDown:
{
columns: [
{
idx: 1
},
{
idx: 2
},
{
idx: 3
},
{
idx: 4
},
{
idx: 5
},
{
idx: 6
}
],
bootstrap: true
},
"stateSave": true,
"stateDuration": 0
});
});
{% endblock %}

View File

@@ -77,24 +77,24 @@
{% block extra_javascript %}
{% include 'bundles/datatables-js-bs5.html' %}
<script>
$(document).ready(() => {
$('#tab_group_members').DataTable({
order: [[0, "asc"]],
columnDefs: [
{
"sortable": false,
"targets": [2]
},
],
"stateSave": true,
"stateDuration": 0
});
});
</script>
{% endblock %}
{% block extra_css %}
{% include 'bundles/datatables-css-bs5.html' %}
{% endblock %}
{% block extra_script %}
$(document).ready(function(){
$('#tab_group_members').DataTable({
order: [[0, "asc"]],
columnDefs: [
{
"sortable": false,
"targets": [2]
},
],
"stateSave": true,
"stateDuration": 0
});
});
{% endblock %}

View File

@@ -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 %}