diff options
author | jakefeasel <jfeasel@gmail.com> | 2012-10-01 23:07:40 -0700 |
---|---|---|
committer | jakefeasel <jfeasel@gmail.com> | 2012-10-01 23:07:40 -0700 |
commit | f7729f272848ac04b62d3ea1dff3481b3faa6e2d (patch) | |
tree | 26b46e4cdeddfd3de37425102555dea68670e664 | |
parent | a42884201c9a10c3b31ddf02ac24986b29281106 (diff) | |
download | sqlfiddle-f7729f272848ac04b62d3ea1dff3481b3faa6e2d.zip sqlfiddle-f7729f272848ac04b62d3ea1dff3481b3faa6e2d.tar.gz sqlfiddle-f7729f272848ac04b62d3ea1dff3481b3faa6e2d.tar.bz2 |
Support for additional input type
-rw-r--r-- | javascripts/libs/ddl_builder/ddl_builder.js | 6 | ||||
-rw-r--r-- | javascripts/libs/ddl_builder/qunit/fixture.html | 26 | ||||
-rw-r--r-- | javascripts/libs/ddl_builder/qunit/guessValueSeparators.js | 2 | ||||
-rw-r--r-- | javascripts/libs/ddl_builder/qunit/main.js | 2 | ||||
-rw-r--r-- | javascripts/libs/ddl_builder/qunit/recordCount.js | 14 |
5 files changed, 43 insertions, 7 deletions
diff --git a/javascripts/libs/ddl_builder/ddl_builder.js b/javascripts/libs/ddl_builder/ddl_builder.js index 67f541b..a2797dc 100644 --- a/javascripts/libs/ddl_builder/ddl_builder.js +++ b/javascripts/libs/ddl_builder/ddl_builder.js @@ -190,7 +190,11 @@ define( if (lines[i].search(/[A-Z0-9_]/i) != -1 && !header_found) // if this line contains letters/numbers/underscores, then we can assume we've hit the header row { var chunks = $.trim(lines[i]).match(/([A-Z0-9_]+ ?)+([^A-Z0-9_]*)/gi); - + if (chunks.length == 1) + { + chunks = $.trim(lines[i]).match(/([A-Z0-9_]+ ?)+?([^A-Z0-9_]*)/gi); + } + header_found = true; for (var j = 0; j < chunks.length; j++) diff --git a/javascripts/libs/ddl_builder/qunit/fixture.html b/javascripts/libs/ddl_builder/qunit/fixture.html index a152620..d2d5d40 100644 --- a/javascripts/libs/ddl_builder/qunit/fixture.html +++ b/javascripts/libs/ddl_builder/qunit/fixture.html @@ -77,4 +77,30 @@ B11 frog green 1G2 girl red </span> + <span id="bracketHeaders" types="int,varchar(3),datetime" valueSeparator="/\s\s+/" headers="Serial Number,LID,Last Updated Date" recordCount="12"> +[Serial Number] [LID] [Last Updated Date] +-------------------------------------- +123456 AAA 2012-09-24 +123456 AAA 2012-09-23 +123456 AAA 2012-09-22 +123456 AAA 2012-09-21 +123456 BBB 2012-09-20 +123456 BBB 2012-09-19 +123456 AAA 2012-09-18 +123456 AAA 2012-09-17 +123456 AAA 2012-09-16 +234567 BBB 2012-09-24 +234567 BBB 2012-09-23 +234567 AAA 2012-09-22 + </span> + <span id="singleSpacedColumnNames" types="int,int,int,int,int" valueSeparator="/\s+/" headers="customdata,check,service,loc,value" recordCount="6"> +customdata check service loc value + 101 0 0 4 4 + 101 0 0 3 3 + 101 5 4 4 3 + 102 0 0 1 2 + 102 4 4 3 3 + 103 0 0 4 4 + </span> + </div> diff --git a/javascripts/libs/ddl_builder/qunit/guessValueSeparators.js b/javascripts/libs/ddl_builder/qunit/guessValueSeparators.js index 59a4f50..c118837 100644 --- a/javascripts/libs/ddl_builder/qunit/guessValueSeparators.js +++ b/javascripts/libs/ddl_builder/qunit/guessValueSeparators.js @@ -8,7 +8,7 @@ define(["jQuery","QUnit", "DDLBuilder/ddl_builder"], function ($,QUnit,DDLBuilde if (result.separator) QUnit.equal(ddl_builder.guessValueSeparator($("#" + id).html()).separator.toString(), sep.toString(), "Guessing Value Separators"); else - QUnit.ok(false, "Guess failed with message:" + result.message); + QUnit.ok(false, "Guessing value separators failed with message:" + result.message); }; diff --git a/javascripts/libs/ddl_builder/qunit/main.js b/javascripts/libs/ddl_builder/qunit/main.js index 8abd0a7..aba2ec9 100644 --- a/javascripts/libs/ddl_builder/qunit/main.js +++ b/javascripts/libs/ddl_builder/qunit/main.js @@ -16,7 +16,7 @@ define([ $("#qunit-fixture #ddlInputText span").each(function () { var $this = $(this); - QUnit.test("Parsing " + this.id, function () { + QUnit.test("Parsing " + $this.attr('id'), function () { columnTypes($this.attr('id'), $this.attr('types')); guessValueSeparators($this.attr('id'), $this.attr('valueSeparator')); headerNames($this.attr('id'), $this.attr('headers')); diff --git a/javascripts/libs/ddl_builder/qunit/recordCount.js b/javascripts/libs/ddl_builder/qunit/recordCount.js index 90791a5..0ec59fd 100644 --- a/javascripts/libs/ddl_builder/qunit/recordCount.js +++ b/javascripts/libs/ddl_builder/qunit/recordCount.js @@ -2,11 +2,17 @@ define(["jQuery","QUnit", "DDLBuilder/ddl_builder"], function ($,QUnit,DDLBuilde return function (id,count) { var ddl_builder = new DDLBuilder({ddlTemplate: "[{{#each_with_index data}}{{#if index}},{{/if}}}{{index}}{{/each_with_index}}}]"}); - var result = ddl_builder.parse($("#" + id).html()); - if ($.parseJSON(result)) - QUnit.equal($.parseJSON(result).length, count, "Getting Record Count"); + var result = ddl_builder.parse($("#" + id).html()), + parsedResult = false; + + try { + parsedResult = $.parseJSON(result); + } catch (err){} + + if (parsedResult) + QUnit.equal(parsedResult.length, count, "Getting Record Count"); else - QUnit.ok(false, "Unable to parse result to JSON array ("+ result +")"); + QUnit.ok(false, "Getting Record Count failed: Unable to parse result to JSON array ("+ result +")"); }; }); |