Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
.DS_Store
# Vim
*~
*.swp
*.swo
*.swn

# OS
.DS_Store

# Eclipse
.buildpath
.project
.settings

# LibreOffice
.~lock*
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<div id="description">
<h1>Mr. Data Converter</h1>
<p>I will convert your Excel data into one of several web-friendly formats, including HTML, JSON and XML.</p>
<p>Fork me on <a href="http://github.com/shancarter/Mr-Data-Converter">github</a>.</p>
</div>
<div id='settings'>
<h3>Settings</h3>
Expand All @@ -35,8 +34,8 @@ <h3>Settings</h3>
</p>
<p>Decimal Sign:

<label><input class="settingsElement" type="radio" name="decimal" id='decimalDot' value="dot" checked/> Dot</label>
<label><input class="settingsElement" type="radio" name="decimal" id='decimalComma' value="comma" /> Comma</label>
<label><input class="settingsElement" type="radio" name="decimal" id='decimalDot' value="dot" /> Dot</label>
<label><input class="settingsElement" type="radio" name="decimal" id='decimalComma' value="comma" checked/> Comma</label>
</p>
<p><label><input class="settingsElement" type="checkbox" name="" value="" id="headersProvidedCB" checked /> First row is the header</label></p>
<div class="settingsGroup">
Expand Down
2 changes: 1 addition & 1 deletion js/CSVParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var CSVParser = {
if (dataArray[r]) {
//replace comma with dot if comma is decimal separator
if(decimalSign='comma' && isDecimal_re.test(dataArray[r][i])){
dataArray[r][i] = dataArray[r][i].replace(",", ".");
//dataArray[r][i] = dataArray[r][i].replace(",", ".");
}
if (CSVParser.isNumber(dataArray[r][i])) {
numInts++
Expand Down
23 changes: 20 additions & 3 deletions js/DataGridRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,31 @@ var DataGridRenderer = {
var outputText = "";
var numRows = dataGrid.length;
var numColumns = headerNames.length;
var slug = function(str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();

// remove accents, swap ñ for n, etc
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeeiiiiooooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}

str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes

return str;
}

//begin render loop
outputText += "<table>"+newLine;
outputText += '<table class="">'+newLine;
outputText += indent+"<thead>"+newLine;
outputText += indent+indent+"<tr>"+newLine;

for (var j=0; j < numColumns; j++) {
outputText += indent+indent+indent+'<th class="'+headerNames[j]+'-cell">';
outputText += indent+indent+indent+'<th class="'+slug(headerNames[j])+'">';
outputText += headerNames[j];
outputText += '</th>'+newLine;
};
Expand All @@ -108,7 +125,7 @@ var DataGridRenderer = {
}
outputText += indent+indent+"<tr"+rowClassName+">"+newLine;
for (var j=0; j < numColumns; j++) {
outputText += indent+indent+indent+'<td class="'+headerNames[j]+'-cell">';
outputText += indent+indent+indent+'<td class="'+slug(headerNames[j])+'">';
outputText += row[j]
outputText += '</td>'+newLine
};
Expand Down
4 changes: 2 additions & 2 deletions js/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function DataConverter(nodeId) {
{"text":"XML - Properties", "id":"xmlProperties", "notes":""},
{"text":"XML - Nodes", "id":"xml", "notes":""},
{"text":"XML - Illustrator", "id":"xmlIllustrator", "notes":""}];
this.outputDataType = "json";
this.outputDataType = "html";

this.columnDelimiter = "\t";
this.rowDelimiter = "\n";
Expand Down Expand Up @@ -70,7 +70,7 @@ DataConverter.prototype.create = function(w,h) {
var self = this;

//build HTML for converter
this.inputHeader = $('<div class="groupHeader" id="inputHeader"><p class="groupHeadline">Input CSV or tab-delimited data. <span class="subhead"> Using Excel? Simply copy and paste. No data on hand? <a href="#" id="insertSample">Use sample</a></span></p></div>');
this.inputHeader = $('<div class="groupHeader" id="inputHeader"><p class="groupHeadline">Input CSV or tab-delimited data. <span class="subhead"> Using Excel? Simply copy and paste. <a href="#" id="insertSample">Use sample</a></span></p></div>');
this.inputTextArea = $('<textarea class="textInputs" id="dataInput"></textarea>');
var outputHeaderText = '<div class="groupHeader" id="inputHeader"><p class="groupHeadline">Output as <select name="Data Types" id="dataSelector" >';
for (var i=0; i < this.outputDataTypes.length; i++) {
Expand Down