Browse Source

Fixed up site and added demos

pull/89/head
Matthew Holt 11 years ago
parent
commit
c9ae25104d
  1. 10
      docs.html
  2. 12
      index.html
  3. 1094353
      resources/files/big.csv
  4. 10
      resources/files/malformed.tsv
  5. 1136
      resources/files/normal.csv
  6. 6
      resources/js/jquery.parse.min.js
  7. 70
      resources/js/main.js

10
docs.html

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
<link rel="icon" class="favicon" href="favicon.ico" type="image/vnd.microsoft.icon">
<link rel="shortcut icon" class="favicon" href="favicon.ico" type="image/vnd.microsoft.icon">
<script src="resources/js/jquery2-0-2.min.js"></script>
<script src="https://raw.githack.com/mholt/jquery.parse/master/jquery.parse.min.js"></script>
<script src="resources/js/jquery.parse.min.js"></script>
<script src="resources/js/main.js"></script>
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
</head>
@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<div class="grid-100">
<p class="text-center" style="padding-bottom: 0; margin-bottom: -20px;">
<a href="index.html">Back to Home</a>
<a href="/">Back to Home</a>
</p>
<h1>Papa Parse</h1>
<br>
@ -504,7 +504,7 @@ @@ -504,7 +504,7 @@
Papa uses HTML 5's FileReader API to load files, which uses a stream to read in the data. FileReader doesn't technically allow us to hook into the underlying stream (other than providing occasional progress reports), but it does let us load the file in chunks/blobs. Don't worry about that though, because if you want to stream, you'll still get results, row-by-row, into your <a href="#step">step</a> function.
</p>
</div>
<div class="clear"></div><br>
<div class="clear"></div>
<hr>
@ -533,7 +533,7 @@ @@ -533,7 +533,7 @@
<h3>What kinds of numbers does it recognize?</h3>
<p>
Papa can convert numbers like: 1, -2, 1.23, -4.56, .123, 1., 2., 1.23e4, 5.67E+7, -1.23e4, 5.67e-7, etc.
Papa can convert numbers like: 0, "1", -2, 1.23, -4.56, .123, 1., 2., 1.23e4, 5.67E+7, -1.23e4, 5.67e-7, etc.
</p>
<h3>Does whitespace affect dynamic typing?</h3>
@ -571,7 +571,7 @@ @@ -571,7 +571,7 @@
<div class="grid-100">
<footer>
<a href="index.html">Papa Parse</a> is brought to you by <a href="https://github.com/mholt/jquery.parse/graphs/contributors">these contributors</a>. Thanks!
<a href="/">Papa Parse</a> is brought to you by <a href="https://github.com/mholt/jquery.parse/graphs/contributors">these contributors</a>. Thanks!
</footer>
</div>

12
index.html

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
<link rel="icon" class="favicon" href="favicon.ico" type="image/vnd.microsoft.icon">
<link rel="shortcut icon" class="favicon" href="favicon.ico" type="image/vnd.microsoft.icon">
<script src="resources/js/jquery2-0-2.min.js"></script>
<script src="https://raw.githack.com/mholt/jquery.parse/master/jquery.parse.min.js"></script>
<script src="resources/js/jquery.parse.min.js"></script>
<script src="resources/js/main.js"></script>
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
</head>
@ -91,11 +91,9 @@ @@ -91,11 +91,9 @@
</p>
<p class="text-center samples">
<b>Files:</b>
<a href="javascript:alert('Link to static file');">Basic</a>
<a href="javascript:alert('Link to static file');">Header Row</a>
<a href="javascript:alert('Link to static file');">Numbers</a>
<a href="javascript:alert('Link to static file');">Malformed</a>
<a href="javascript:alert('Link to static file');">Big</a>
<a href="resources/files/normal.csv">Normal</a>
<a href="resources/files/malformed.tsv">Malformed</a>
<a href="resources/files/big.csv">Big</a>
</p>
<br><br>
</div>
@ -231,7 +229,7 @@ @@ -231,7 +229,7 @@
<div class="grid-100">
<footer>
<a href="index.html">Papa Parse</a> is brought to you by <a href="https://github.com/mholt/jquery.parse/graphs/contributors">these contributors</a>. Thanks!
<a href="/">Papa Parse</a> is brought to you by <a href="https://github.com/mholt/jquery.parse/graphs/contributors">these contributors</a>. Thanks!
</footer>
</div>

1094353
resources/files/big.csv

File diff suppressed because it is too large Load Diff

10
resources/files/malformed.tsv

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
site lon lat max min precip snow snowdepth
1V4 -72.02 44.42 13 -5 0.01 -99 -99
BTV -73.15 44.47 14 -9 0.00 0.0 7 52
MVL -72.62 44.54 11 -7 0.00 -99 -99
MPV -72.56 44.20 1"2 -4 0.00 -99 -99
MSS -74.85 44.93 4 -150.00 -99 -99
PBG -73.47 44.65 15 -12 0.00 -99 -99
RUT -72.95 43.53 18 -2 -99 -99 -99
SLK -74.20 44.39 7 -12 0.00 -99 -99
VSF -72.50 43.34 20 -1 0.04 -99 -99
Can't render this file because it has a wrong number of fields in line 3.

1136
resources/files/normal.csv

File diff suppressed because it is too large Load Diff

6
resources/js/jquery.parse.min.js vendored

File diff suppressed because one or more lines are too long

70
resources/js/main.js

@ -4,14 +4,35 @@ $(function() @@ -4,14 +4,35 @@ $(function()
var scrollDuration = 400;
var reallyBig = 1024 * 1024; // 1 MB
var textDemos = {
basic: 'AK,63.588753,-154.493062,Alaska\nAL,32.318231,-86.902298,Alabama\nAR,35.20105,-91.831833,Arkansas\nAZ,34.048928,-111.093731,Arizona\nCA,36.778261,-119.417932,California\nCO,39.550051,-105.782067,Colorado\nCT,41.603221,-73.087749,Connecticut\nDC,38.905985,-77.033418,"District of Columbia"\nDE,38.910832,-75.52767,Delaware\nFL,27.664827,-81.515754,Florida',
header: 'Address,City,State,Zipcode,Name,Phone Number,Group,URL\n1 Crossgates Mall Road,Albany,NY,12203,Apple Store Cross Gates,(518) 869-3192,"Example ""Group"" 1",http://www.apple.com/retail/crossgates/\nDuke Rd & Walden Ave,Buffalo,NY,14225,Apple Store Walden Galleria,(716) 685-2762,Example Group 2,http://www.apple.com/retail/walden/\n630 Old Country Rd.,Garden City,NY,11530,Apple Store Roosevelt Field,(516) 248-3347,Example Group 3,http://www.apple.com/retail/rooseveltfield/\n160 Walt Whitman Rd.,Huntington Station,NY,11746,Apple Store Walt Whitman,(631) 425-1563,Example Group 3,http://www.apple.com/retail/waltwhitman/\n9553 Carousel Center Drive,Syracuse,NY,13290,Apple Store Carousel,(315) 422-8484,Example Group 2,http://www.apple.com/retail/carousel/\n2655 Richmond Ave,Staten Island,NY,10314,Apple Store Staten Island,(718) 477-4180,Example Group 1,http://www.apple.com/retail/statenisland/\n7979 Victor Road,Victor,NY,14564,Apple Store Eastview,(585) 421-3030,Example Group 1,http://www.apple.com/retail/eastview/\n1591 Palisades Center Drive,West Nyack,NY,10994,Apple Store Palisades,(845) 353-6756,Example Group 2,http://www.apple.com/retail/palisades/\n125 Westchester Ave.,White Plains,NY,10601,Apple Store The Westchester,(914) 428-1877,Example Group 3,http://www.apple.com/retail/thewestchester/\n103 Prince Street,New York,NY,10012,Apple Store SoHo,(212) 226-3126,Example Group 2,http://www.apple.com/retail/soho/'
basic: {
input: '1-1,1-2,1-3,1-4\n2-1,2-2,2-3,2-4\n3-1,3-2,3-3,3-4',
header: false,
dynamicTyping: false,
stream: false
},
header: {
input: 'First;Second;Third\n1-1;1-2;1-3\n2-1;2-2;2-3',
header: true,
dynamicTyping: false,
stream: false
},
numbers: {
input: 'Item|SKU|Cost|Quantity\nBook|ABC1234|10.95|4\nMovie|DEF5678|29.99|3',
header: true,
dynamicTyping: true,
stream: false
},
malformed: {
input: 'Item,SKU,Cost,Quantity\nBook,ABC1234,10.95,4,Extra\nMovie,DEF5678",29.99,3',
header: true,
dynamicTyping: true,
stream: false
}
};
var textareaFilename = textareaFilename; // internal use only
// State - don't touch!
var scrolledToDemoOnce = false;
var rowCounts = {}, errCounts = {}, finished = 0, queued = 0;
var rowCount = 0, errCount = 0, finished = 0, queued = 0;
var start, end;
@ -69,20 +90,20 @@ $(function() @@ -69,20 +90,20 @@ $(function()
// PARSE TEXT
var input = $('#input').val();
rowCounts[textareaFilename] = 0;
errCounts[textareaFilename] = 0;
rowCount = 0;
errCount = 0;
if (!input)
{
statusErr("** Nothing to parse - please provide input **");
$('#input').focus();
return done(textareaFilename);
return done();
}
if (!bigCheck(input))
{
statusErr("** Parsing aborted - recommend streaming large strings **");
return done(textareaFilename);
return done();
}
status("Parsing text...");
@ -95,8 +116,8 @@ $(function() @@ -95,8 +116,8 @@ $(function()
if (is('stream'))
{
var baseMsg = "Finished parsing " + rowCounts[textareaFilename] + " rows of data in <b>" + perfResult() + "</b> with <b>" + errCounts[textareaFilename] + " errors</b>.";
if (errCounts[textareaFilename] == 0)
var baseMsg = "Finished parsing " + rowCount + " rows of data in <b>" + perfResult() + "</b> with <b>" + errCount + " errors</b>.";
if (errCount == 0)
statusGood("&#10003; " + baseMsg);
else
statusErr("x " + baseMsg);
@ -113,7 +134,7 @@ $(function() @@ -113,7 +134,7 @@ $(function()
render(data);
}
done(textareaFilename);
done();
}
else
{
@ -125,8 +146,8 @@ $(function() @@ -125,8 +146,8 @@ $(function()
{
before: function(file, inputElem)
{
rowCounts[file.name] = 0;
errCounts[file.name] = 0;
rowCount = 0;
errCount = 0;
if (!bigCheck(file))
return false;
@ -148,18 +169,18 @@ $(function() @@ -148,18 +169,18 @@ $(function()
finished++;
$('#output').empty();
var baseMsg = "Parsed <b>" + file.name + "</b> containing <b>" + rowCounts[file.name] + " rows</b> in <b>" + perfResult() + "</b> with <b>" + errCounts[file.name] + " errors</b>.";
var baseMsg = "Parsed <b>" + file.name + "</b> containing <b>" + rowCount + " rows</b> in <b>" + perfResult() + "</b> with <b>" + (is('stream') ? errCount : data.errors.length) + " errors</b>.";
if (!is('stream'))
{
if (errCounts[file.name] == 0)
if (data.errors.length == 0)
statusGood("&#10003; " + baseMsg);
else
statusErr("x " + baseMsg);
}
else
{
if (errCounts[file.name] == 0)
if (errCount == 0)
statusGood("&#10003; " + baseMsg);
else
statusErr("x " + baseMsg);
@ -181,8 +202,8 @@ $(function() @@ -181,8 +202,8 @@ $(function()
function done(filename)
{
$('#submit').prop('disabled', false);
rowCounts[filename] = 0;
errCounts[filename] = 0;
rowCount = 0;
errCount = 0;
finished = 0;
queued = 0;
status("");
@ -235,10 +256,8 @@ $(function() @@ -235,10 +256,8 @@ $(function()
function stepFunc(data, file, inputElem)
{
if (!file)
file = { name: textareaFilename };
rowCounts[file.name]++;
errCounts[file.name] += data.errors.length;
rowCount++;
errCount += data.errors.length;
}
function is(checkboxId)
@ -277,7 +296,12 @@ $(function() @@ -277,7 +296,12 @@ $(function()
{
$('.demo-insert').click(function()
{
$('#input').val(textDemos[$(this).data('demo')]);
var demo = textDemos[$(this).data('demo')];
$('#clearfiles').click();
$('#input').val(demo.input);
$('#header').prop('checked', demo.header);
$('#dyntype').prop('checked', demo.dynamicTyping);
$('#stream').prop('checked', demo.stream);
});
$('#tabdelim').click(function()

Loading…
Cancel
Save