Added a function that detects the filetype of the selected import file and changes the displayed options accordingly
This commit is contained in:
59
js/import.js
59
js/import.js
@@ -4,17 +4,62 @@
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Toggles the hiding and showing of each plugin's options
|
||||
* according to the currently selected plugin from the dropdown list
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#plugins").change(function() {
|
||||
|
||||
/**
|
||||
* Toggles the hiding and showing of each plugin's options
|
||||
* according to the currently selected plugin from the dropdown list
|
||||
*/
|
||||
function changePluginOpts() {
|
||||
$(".format_specific_options").each(function() {
|
||||
$(this).hide();
|
||||
});
|
||||
var selected_plugin_name = $("#plugins option:selected").attr("value");
|
||||
$("#" + selected_plugin_name + "_options").fadeIn('slow');
|
||||
if(selected_plugin_name == "csv") {
|
||||
$("#import_notification").text("Note: If the file contains multiple tables, they will be combined into one");
|
||||
} else {
|
||||
$("#import_notification").text("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the hiding and showing of each plugin's options and sets the selected value
|
||||
* in the plugin dropdown list according to the format of the selected file
|
||||
*/
|
||||
function matchFile(fname) {
|
||||
fname_array = fname.toLowerCase().split(".");
|
||||
len = fname_array.length;
|
||||
if(len != 0) {
|
||||
extension = fname_array[len - 1];
|
||||
if (extension == "gz" || extension == "bz2" || extension == "zip") {
|
||||
len--;
|
||||
}
|
||||
$("option:selected").removeAttr("selected");
|
||||
switch (fname_array[len - 1]) {
|
||||
case "csv" : $("select[name='format'] option[value='csv']").attr('selected', 'selected'); break;
|
||||
case "docsql" : $("select[name='format'] option[value='docsql']").attr('selected', 'selected'); break;
|
||||
case "ldi" : $("select[name='format'] option[value='ldi']").attr('selected', 'selected'); break;
|
||||
case "ods" : $("select[name='format'] option[value='ods']").attr('selected', 'selected'); break;
|
||||
case "sql" : $("select[name='format'] option[value='sql']").attr('selected', 'selected'); break;
|
||||
case "xls" : $("select[name='format'] option[value='xls']").attr('selected', 'selected'); break;
|
||||
case "xlsx" : $("select[name='format'] option[value='xlsx']").attr('selected', 'selected'); break;
|
||||
case "xml" : $("select[name='format'] option[value='xml']").attr('selected', 'selected'); break;
|
||||
}
|
||||
changePluginOpts();
|
||||
}
|
||||
}
|
||||
|
||||
$("#plugins").change(function() {
|
||||
changePluginOpts();
|
||||
});
|
||||
});
|
||||
|
||||
$("#input_import_file").change(function() {
|
||||
matchFile($(this).attr("value"));
|
||||
});
|
||||
|
||||
$("#select_local_import_file").change(function() {
|
||||
matchFile($(this).attr("value"));
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user