Fixed Issue 433: Usability: use HTML <label> (e.g., for checkboxes) (for index page)

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2260 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2011-09-29 05:58:02 +00:00
parent fbc990a2e0
commit 0e6c37ce35
14 changed files with 272 additions and 114 deletions

View File

@ -19,15 +19,21 @@
</tr> </tr>
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td> <tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip"/></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <td><label for="$skip">Discard initial</label></td>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td colspan="2">Store blank rows</td></tr> <td><label for="$limit">Load at most</label></td>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td> <td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<td colspan="2">Store blank cells as nulls</td></tr> <label for="$limit">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div></div> </table></div></div>

View File

@ -22,19 +22,30 @@
<td rowspan="2" width="40%"><div class="grid-layout layout-tightest"><table bind="sheetRecordContainer"></table></div></td> <td rowspan="2" width="40%"><div class="grid-layout layout-tightest"><table bind="sheetRecordContainer"></table></div></td>
<td colspan="2"><div class="grid-layout layout-tightest"><table> <td colspan="2"><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" /></td><td>Ignore first</td> <tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" /> line(s) at beginning of file</td></tr> <td><label for="$ignore">Ignore first</label></td>
<tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" /></td><td>Parse next</td> <td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
<td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" /> line(s) as column headers</td></tr> <label for="$ignore">line(s) at beginning of file</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" id="$headers" /></td>
<td colspan="2">Store blank rows</td></tr> <td><label for="$headers">Parse next</label></td>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td> <td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" />
<td colspan="2">Store blank cells as nulls</td></tr> <label for="$headers">line(s) as column headers</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip" /></td>
<td><label for="$skip">Discard initial</label></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><label for="$limit">Load at most</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<label for="$limit">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div></div> </table></div></div>

View File

@ -192,9 +192,12 @@ Refine.GDataImportingController.prototype._showParsingPanel = function() {
if (this._doc.type != 'table') { if (this._doc.type != 'table') {
var sheetTable = this._parsingPanelElmts.sheetRecordContainer[0]; var sheetTable = this._parsingPanelElmts.sheetRecordContainer[0];
$.each(this._options.worksheets, function(i, v) { $.each(this._options.worksheets, function(i, v) {
var id = 'gdata-worksheet-' + Math.round(Math.random() * 1000000);
var tr = sheetTable.insertRow(sheetTable.rows.length); var tr = sheetTable.insertRow(sheetTable.rows.length);
var td0 = $(tr.insertCell(0)).attr('width', '1%'); var td0 = $(tr.insertCell(0)).attr('width', '1%');
var checkbox = $('<input>') var checkbox = $('<input>')
.attr('id', id)
.attr('type', 'radio') .attr('type', 'radio')
.attr('name', 'gdata-importing-parsing-worksheet') .attr('name', 'gdata-importing-parsing-worksheet')
.attr('sheetUrl', this.link) .attr('sheetUrl', this.link)
@ -202,8 +205,16 @@ Refine.GDataImportingController.prototype._showParsingPanel = function() {
if (i === 0) { if (i === 0) {
checkbox.attr('checked', 'true'); checkbox.attr('checked', 'true');
} }
$(tr.insertCell(1)).text(this.name);
$(tr.insertCell(2)).text(this.rows + ' rows'); $('<label>')
.attr('for', id)
.text(this.name)
.appendTo(tr.insertCell(1));
$('<label>')
.attr('for', id)
.text(this.rows + ' rows')
.appendTo(tr.insertCell(2));
}); });
if (this._options.ignoreLines > 0) { if (this._options.ignoreLines > 0) {

View File

@ -14,23 +14,32 @@
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" /></td><td>Ignore first</td> <tr>
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" /> line(s) at beginning of file</td></tr> <td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
<tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" /></td><td>Parse next</td> <td><label for="$ignore">Ignore first</label></td>
<td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" /> line(s) as column headers</td></tr> <td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td> <label for="$ignore">line(s) at beginning of file</label></td></tr>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" id="$headers" /></td>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <td><label for="$headers">Parse next</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" />
<label for="$headers">line(s) as column headers</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip" /></td>
<td><label for="$skip">Discard initial</label></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><label for="$limit">Load at most</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<label for="$limit">row(s) of data</label></td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2">Store blank rows</td></tr> <td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<td colspan="2">Store blank cells as nulls</td></tr> <td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td>Store file source<br/>(file names, URLs)<br/>in each row</td></tr> <td><label for="$include-file-sources">Store file source<br/>(file names, URLs)<br/>in each row</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -121,9 +121,11 @@ Refine.ExcelParserUI.prototype._initialize = function() {
var sheetTable = this._optionContainerElmts.sheetRecordContainer[0]; var sheetTable = this._optionContainerElmts.sheetRecordContainer[0];
$.each(this._config.sheetRecords, function(i, v) { $.each(this._config.sheetRecords, function(i, v) {
var id = 'core-excel-worksheet-' + Math.round(Math.random() * 1000000);
var tr = sheetTable.insertRow(sheetTable.rows.length); var tr = sheetTable.insertRow(sheetTable.rows.length);
var td0 = $(tr.insertCell(0)).attr('width', '1%'); var td0 = $(tr.insertCell(0)).attr('width', '1%');
var checkbox = $('<input>') var checkbox = $('<input>')
.attr('id', id)
.attr('type', 'checkbox') .attr('type', 'checkbox')
.attr('index', i) .attr('index', i)
.appendTo(td0); .appendTo(td0);
@ -131,8 +133,15 @@ Refine.ExcelParserUI.prototype._initialize = function() {
checkbox.attr('checked', 'true'); checkbox.attr('checked', 'true');
} }
$(tr.insertCell(1)).text(this.name); $('<label>')
$(tr.insertCell(2)).text(this.rows + ' rows'); .attr('for', id)
.text(this.name)
.appendTo(tr.insertCell(1));
$('<label>')
.attr('for', id)
.text(this.rows + ' rows')
.appendTo(tr.insertCell(2));
}); });
if (this._config.ignoreLines > 0) { if (this._config.ignoreLines > 0) {

View File

@ -22,30 +22,42 @@
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td colspan="2">Rows are separated by</td></tr> <tr><td colspan="2">Rows are separated by</td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" /></td><td>new line characters \n</td></tr> <tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" /></td><td>custom <td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
<td><label for="$row-separator-custom">custom</label>
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr> <input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
<tr><td colspan="2">Escape special characters with \</td></tr> <tr><td colspan="2">Escape special characters with \</td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" /></td><td>Ignore first</td> <tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" /> line(s) at beginning of file</td></tr> <td><label for="$ignore">Ignore first</label></td>
<tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" /></td><td>Parse next</td> <td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
<td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" /> line(s) as column headers</td></tr> <label for="$ignore">line(s) at beginning of file</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td> <tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" id="$headers" /></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <td><label for="$headers">Parse next</label></td>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" />
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <label for="$headers">line(s) as column headers</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip" /></td>
<td><label for="$skip">Discard initial</label></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><label for="$limit">Load at most</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<label for="$limit">row(s) of data</label></td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="guessCellValueTypesCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="guessCellValueTypesCheckbox" id="$guess" /></td>
<td>Parse cell text into<br/>numbers, dates, ...</td></tr> <td><label for="$guess">Parse cell text into<br/>numbers, dates, ...</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2">Store blank rows</td></tr> <td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<td colspan="2">Store blank cells as nulls</td></tr> <td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td>Store file source<br/>(file names, URLs)<br/>in each row</td></tr> <td><label for="$include-file-sources">Store file source<br/>(file names, URLs)<br/>in each row</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -10,10 +10,12 @@
</tr> </tr>
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> record(s) of data</td></tr> <td><label for="$limit">Load at most</label></td>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<td colspan="2">Store file source (file names, URLs) in each row</td></tr> <label for="$limit">record(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td colspan="2"><label for="$include-file-sources">Store file source (file names, URLs) in each row</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -70,6 +70,17 @@ Refine.JsonParserUI.prototype.getOptions = function() {
recordPath: this._config.recordPath recordPath: this._config.recordPath
}; };
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
if (this._optionContainerElmts.limitCheckbox[0].checked) { if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1); options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else { } else {

View File

@ -20,26 +20,36 @@
</td></tr> </td></tr>
<tr><td colspan="2">Lines are separated by</td></tr> <tr><td colspan="2">Lines are separated by</td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" /></td><td>new line characters \n</td></tr> <tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" /></td><td>custom <td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
<td><label for="$row-separator-custom">custom</label>
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr> <input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
<tr><td colspan="2">Escape special characters with \</td></tr> <tr><td colspan="2">Escape special characters with \</td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2">Store blank rows</td></tr> <td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<td colspan="2">Store blank cells as nulls</td></tr> <td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td>Store file source<br/>(file names, URLs)<br/>in each row</td></tr> <td><label for="$include-file-sources">Store file source<br/>(file names, URLs)<br/>in each row</label></td></tr>
</table></div></td> </table></div></td>
<td colspan="2"><div class="grid-layout layout-tightest"><table> <td colspan="2"><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" /></td><td>Ignore first</td> <tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" /> line(s) at beginning of file</td></tr> <td><label for="$ignore">Ignore first</label></td>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td> <td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <label for="$ignore">line(s) at beginning of file</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip" /></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <td><label for="$skip">Discard initial</label></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><label for="$limit">Load at most</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<label for="$limit">row(s) of data</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -16,45 +16,65 @@
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td colspan="2">Columns are separated by</td></tr> <tr><td colspan="2">Columns are separated by</td></tr>
<tr><td width="1%"><input type="radio" name="column-separator" value="comma" /></td><td>commas (CSV)</td></tr> <tr><td width="1%"><input type="radio" name="column-separator" value="comma" id="$column-separator-comma" /></td>
<tr><td width="1%"><input type="radio" name="column-separator" value="tab" /></td><td>tabs (TSV)</td></tr> <td><label for="$column-separator-comma">commas (CSV)</label></td></tr>
<tr><td width="1%"><input type="radio" name="column-separator" value="custom" /></td> <tr><td width="1%"><input type="radio" name="column-separator" value="tab" id="$column-separator-tab" /></td>
<td>custom <input bind="columnSeparatorInput" type="text" class="lightweight" size="5" /></td></tr> <td><label for="$column-separator-tab">tabs (TSV)</label></td></tr>
<tr><td width="1%"><input type="radio" name="column-separator" value="custom" id="$column-separator-custom" /></td>
<td><label for="$column-separator-custom">custom</label>
<input bind="columnSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
<tr><td colspan="2">Escape special characters with \</td></tr> <tr><td colspan="2">Escape special characters with \</td></tr>
</table></div></td> </table></div></td>
<td colspan="2"><div class="grid-layout layout-tightest"><table> <td colspan="2"><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" /></td><td>Ignore first</td> <tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" /> line(s) at beginning of file</td></tr> <td><label for="$ignore">Ignore first</label></td>
<tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" /></td><td>Parse next</td> <td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
<td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" /> line(s) as column headers</td></tr> <label for="$ignore">line(s) at beginning of file</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" /></td><td>Discard initial</td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <tr><td width="1%"><input type="checkbox" bind="headerLinesCheckbox" id="$headers" /></td>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <td><label for="$headers">Parse next</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> row(s) of data</td></tr> <td><input bind="headerLinesInput" type="text" class="lightweight" size="2" value="1" />
<label for="$headers">line(s) as column headers</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="skipCheckbox" id="$skip" /></td>
<td><label for="$skip">Discard initial</label></td>
<td><input bind="skipInput" type="text" class="lightweight" size="2" value="0" />
<label for="$skip">row(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><label for="$limit">Load at most</label></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<label for="$limit">row(s) of data</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td colspan="2">Rows are separated by</td></tr> <tr><td colspan="2">Rows are separated by</td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" /></td><td>new line characters \n</td></tr> <tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" /></td><td>custom <td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
<td><label for="$row-separator-custom">custom</label>
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr> <input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
<tr><td colspan="2">Escape special characters with \</td></tr> <tr><td colspan="2">Escape special characters with \</td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="guessCellValueTypesCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="guessCellValueTypesCheckbox" id="$guess" /></td>
<td>Parse cell text into<br/>numbers, dates, ...</td></tr> <td><label for="$guess">Parse cell text into<br/>numbers, dates, ...</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="processQuoteMarksCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="processQuoteMarksCheckbox" id="$quotes" /></td>
<td>Quotation marks are used<br/>to enclose cells containing<br/>column separators</td></tr> <td><label for="$quotes">Quotation marks are used<br/>to enclose cells containing<br/>column separators</label></td></tr>
</table></div></td> </table></div></td>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" /></td> <tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
<td colspan="2">Store blank rows</td></tr> <td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" /></td>
<td colspan="2">Store blank cells as nulls</td></tr> <tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <td colspan="2"><label for="$store-blank-cells">Store blank cells as nulls</label></td></tr>
<td>Store file source<br/>(file names, URLs)<br/>in each row</td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td><label for="$include-file-sources">Store file source<br/>(file names, URLs)<br/>in each row</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -10,10 +10,13 @@
</tr> </tr>
<tr> <tr>
<td><div class="grid-layout layout-tightest"><table> <td><div class="grid-layout layout-tightest"><table>
<tr><td width="1%"><input type="checkbox" bind="limitCheckbox" /></td><td>Load at most</td> <tr><td width="1%"><input type="checkbox" bind="limitCheckbox" id="$limit" /></td>
<td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" /> record(s) of data</td></tr> <td><label for="$limit">Load at most</label></td>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" /></td> <td><input bind="limitInput" type="text" class="lightweight" size="2" value="0" />
<td colspan="2">Store file source (file names, URLs) in each row</td></tr> <label for="$limit">record(s) of data</label></td></tr>
<tr><td width="1%"><input type="checkbox" bind="includeFileSourcesCheckbox" id="$include-file-sources" /></td>
<td colspan="2"><label for="$include-file-sources">Store file source (file names, URLs) in each row</label></td></tr>
</table></div></td> </table></div></td>
</tr> </tr>
</table></div> </table></div>

View File

@ -69,7 +69,17 @@ Refine.XmlParserUI.prototype.getOptions = function() {
var options = { var options = {
recordPath: this._config.recordPath recordPath: this._config.recordPath
}; };
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
if (this._optionContainerElmts.limitCheckbox[0].checked) { if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1); options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else { } else {
@ -194,7 +204,9 @@ Refine.XmlParserUI.prototype._showPickRecordElementsUI = function() {
}); });
} }
}; };
if (this._config.dom) {
renderNode(this._config.dom, elmts.domContainer, []); renderNode(this._config.dom, elmts.domContainer, []);
}
}; };
Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() { Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() {

View File

@ -35,31 +35,69 @@ var DOM = {};
DOM.bind = function(elmt) { DOM.bind = function(elmt) {
var map = {}; var map = {};
var idmap = {};
for (var i = 0; i < elmt.length; i++) { for (var i = 0; i < elmt.length; i++) {
DOM._bindDOMElement(elmt[i], map); DOM._bindDOMElement(elmt[i], map, idmap);
}
for (var key in idmap) {
if (idmap.hasOwnProperty(key)) {
for (var i = 0; i < elmt.length; i++) {
DOM._resolveIdInDOMElement(elmt[i], idmap);
}
break;
}
} }
return map; return map;
}; };
DOM._bindDOMElement = function(elmt, map) { DOM._bindDOMElement = function(elmt, map, idmap) {
var bind = elmt.getAttribute("bind"); var bind = elmt.getAttribute("bind");
if (bind !== null && bind.length > 0) { if (bind !== null && bind.length > 0) {
map[bind] = $(elmt); map[bind] = $(elmt);
} }
var id = elmt.id;
if (id !== null && id.length > 0 && id.substring(0, 1) == '$') {
var newID = id.substring(1) + '-' + Math.round(Math.random() * 1000000);
idmap[id] = newID;
elmt.id = newID;
}
if (elmt.hasChildNodes()) { if (elmt.hasChildNodes()) {
DOM._bindDOMChildren(elmt, map); DOM._bindDOMChildren(elmt, map, idmap);
} }
}; };
DOM._bindDOMChildren = function(elmt, map) { DOM._bindDOMChildren = function(elmt, map, idmap) {
var node = elmt.firstChild; var node = elmt.firstChild;
while (node !== null) { while (node !== null) {
var node2 = node.nextSibling; var node2 = node.nextSibling;
if (node.nodeType == 1) { if (node.nodeType == 1) {
DOM._bindDOMElement(node, map); DOM._bindDOMElement(node, map, idmap);
}
node = node2;
}
};
DOM._resolveIdInDOMElement = function(elmt, idmap) {
var forAttr = elmt.getAttribute("for");
if (forAttr !== null && forAttr.length > 0 && forAttr in idmap) {
elmt.setAttribute("for", idmap[forAttr]);
}
if (elmt.hasChildNodes()) {
DOM._resolveIdInDOMChildren(elmt, idmap);
}
};
DOM._resolveIdInDOMChildren = function(elmt, idmap) {
var node = elmt.firstChild;
while (node !== null) {
var node2 = node.nextSibling;
if (node.nodeType == 1) {
DOM._resolveIdInDOMElement(node, idmap);
} }
node = node2; node = node2;
} }

View File

@ -55,6 +55,10 @@ h2 {
font-weight: bold; font-weight: bold;
} }
label {
cursor: pointer;
}
input[type=text] { input[type=text] {
padding: @padding_tighter; padding: @padding_tighter;
font-size: 1em; font-size: 1em;