Skip to content

Commit

Permalink
chore: migrate JS to ES2015
Browse files Browse the repository at this point in the history
Use let/const instead of var.
  • Loading branch information
Rotzbua committed Jun 8, 2024
1 parent cb8ae39 commit 60d85d7
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 60d85d7

Please sign in to comment.