Skip to content

Commit

Permalink
Merge pull request #547 from Rotzbua/chore_migrate_es2015
Browse files Browse the repository at this point in the history
chore: migrate JS to ES2015
  • Loading branch information
Mogost authored Jun 9, 2024
2 parents bf69bae + 60d85d7 commit 0539442
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions constance/static/admin/js/constance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
$('#content-main').on('click', '.reset-link', function(e) {
e.preventDefault();

var field_selector = this.dataset.fieldId.replace(/ /g, "\\ ")
var field = $('#' + field_selector);
var fieldType = this.dataset.fieldType;
const field_selector = this.dataset.fieldId.replace(/ /g, "\\ ")
const field = $('#' + field_selector);
const fieldType = this.dataset.fieldType;

if (fieldType === 'checkbox') {
field.prop('checked', this.dataset.default === 'true');
} else if (fieldType === 'date') {
var defaultDate = new Date(this.dataset.default * 1000);
const defaultDate = new Date(this.dataset.default * 1000);
$('#' + this.dataset.fieldId).val(defaultDate.strftime(get_format('DATE_INPUT_FORMATS')[0]));
} else if (fieldType === 'datetime') {
var defaultDate = new Date(this.dataset.default * 1000);
const defaultDate = new Date(this.dataset.default * 1000);
$('#' + this.dataset.fieldId + '_0').val(defaultDate.strftime(get_format('DATE_INPUT_FORMATS')[0]));
$('#' + this.dataset.fieldId + '_1').val(defaultDate.strftime(get_format('TIME_INPUT_FORMATS')[0]));
} else {
Expand Down

0 comments on commit 0539442

Please sign in to comment.