mybuddy/static/import_export/guess_format.js

22 lines
711 B
JavaScript
Raw Normal View History

2022-10-13 02:04:59 +00:00
(function($) {
$().ready(function () {
$('input.guess_format[type="file"]').change(function () {
var files = this.files;
var dropdowns = $(this.form).find('select.guess_format');
if(files.length > 0) {
var extension = files[0].name.split('.').pop().trim().toLowerCase();
for(var i = 0; i < dropdowns.length; i++) {
var dropdown = dropdowns[i];
dropdown.selectedIndex = 0;
for(var j = 0; j < dropdown.options.length; j++) {
if(extension === dropdown.options[j].text.trim().toLowerCase()) {
dropdown.selectedIndex = j;
break;
}
}
}
}
});
});
})(django.jQuery);