diff options
author | lorilee <leelorik@gmail.com> | 2010-06-11 09:09:03 +0400 |
---|---|---|
committer | lorilee <leelorik@gmail.com> | 2010-06-11 09:09:03 +0400 |
commit | 90c77996555c33e0d149f382a2800622f3df7292 (patch) | |
tree | 854594fb274fa7db3a3533f518ff21edd29078d2 /js/import.js | |
parent | 9c25fa4ebb52219045d471c238049380097849e3 (diff) |
Added a function that detects the filetype of the selected import file and changes the displayed options accordingly
Diffstat (limited to 'js/import.js')
-rw-r--r-- | js/import.js | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/js/import.js b/js/import.js index ffeb874095..303405f29e 100644 --- a/js/import.js +++ b/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")); }); -});
\ No newline at end of file + + $("#select_local_import_file").change(function() { + matchFile($(this).attr("value")); + }) + });
\ No newline at end of file |