From 10ce6930d2e9845dbcad6c7499d271675b8c7495 Mon Sep 17 00:00:00 2001 From: lorilee Date: Mon, 16 Aug 2010 17:23:11 -0700 Subject: [PATCH] Don't hardcode the formats --- js/import.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/js/import.js b/js/import.js index 557ca61e4..be7938886 100644 --- a/js/import.js +++ b/js/import.js @@ -35,18 +35,12 @@ function matchFile(fname) { if (extension == "gz" || extension == "bz2" || extension == "zip") { len--; } - $("#plugins 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; + // Only toggle if the format of the file can be imported + if($("select[name='format'] option[value='" + fname_array[len - 1] + "']").length == 1) { + $("#plugins option:selected").removeAttr("selected"); + $("select[name='format'] option[value='" + fname_array[len - 1] + "']").attr('selected', 'selected'); + changePluginOpts(); } - changePluginOpts(); } } $(document).ready(function() {