Browse Source

Player utility now supports latest features

pull/72/merge
Matthew Holt 11 years ago
parent
commit
cd10f50f7c
  1. 2
      papaparse.js
  2. 4
      player/player.css
  3. 4
      player/player.html
  4. 31
      player/player.js

2
papaparse.js

@ -492,7 +492,7 @@
} }
else if (isFunction(config.chunk)) else if (isFunction(config.chunk))
{ {
config.chunk(results); config.chunk(results); // TODO: Implement abort? (like step)
results = undefined; results = undefined;
} }

4
player/player.css

@ -29,6 +29,10 @@ label {
display: block; display: block;
} }
input[type=number] {
width: 55px;
}
.text-center { .text-center {
text-align: center; text-align: center;

4
player/player.html

@ -16,13 +16,17 @@
<div class="grid-25"> <div class="grid-25">
<label><input type="checkbox" id="download"> Download</label> <label><input type="checkbox" id="download"> Download</label>
<label><input type="checkbox" id="stream"> Stream</label> <label><input type="checkbox" id="stream"> Stream</label>
<label><input type="checkbox" id="chunk"> Chunk</label>
<label><input type="checkbox" id="worker"> Worker thread</label> <label><input type="checkbox" id="worker"> Worker thread</label>
<label><input type="checkbox" id="header"> Header row</label> <label><input type="checkbox" id="header"> Header row</label>
<label><input type="checkbox" id="dynamicTyping"> Dynamic typing</label> <label><input type="checkbox" id="dynamicTyping"> Dynamic typing</label>
<label><input type="checkbox" id="keepEmptyRows"> Keep empty rows</label>
<label>Preview: <input type="number" min="0" max="1000" placeholder="default" id="preview"></label> <label>Preview: <input type="number" min="0" max="1000" placeholder="default" id="preview"></label>
<label>Encoding: <input type="text" id="encoding" placeholder="default" size="10"></label> <label>Encoding: <input type="text" id="encoding" placeholder="default" size="10"></label>
<label>Comment char: <input type="text" size="5" maxlength="1" placeholder="default" id="comments"></label> <label>Comment char: <input type="text" size="5" maxlength="1" placeholder="default" id="comments"></label>
<label>Delimiter: <input type="text" size="5" maxlength="1" placeholder="auto" id="delimiter"> <a href="javascript:" id="insert-tab">tab</a></label> <label>Delimiter: <input type="text" size="5" maxlength="1" placeholder="auto" id="delimiter"> <a href="javascript:" id="insert-tab">tab</a></label>
<label>Papa.LocalChunkSize: <input type="number" min="0" placeholder="default" id="localChunkSize"></label>
<label>Papa.RemoteChunkSize: <input type="number" min="0" placeholder="default" id="remoteChunkSize"></label>
</div> </div>
<div class="grid-75 text-center"> <div class="grid-75 text-center">

31
player/player.js

@ -1,4 +1,4 @@
var stepped = 0; var stepped = 0, chunks = 0, rows = 0;
var start, end; var start, end;
$(function() $(function()
@ -6,10 +6,22 @@ $(function()
$('#submit').click(function() $('#submit').click(function()
{ {
stepped = 0; stepped = 0;
chunks = 0;
rows = 0;
var txt = $('#input').val(); var txt = $('#input').val();
var localChunkSize = $('#localChunkSize').val();
var remoteChunkSize = $('#remoteChunkSize').val();
var files = $('#files')[0].files; var files = $('#files')[0].files;
var config = buildConfig(); var config = buildConfig();
// NOTE: Chunk size does not get reset if changed and then set back to empty/default value
if (localChunkSize)
Papa.LocalChunkSize = localChunkSize;
if (remoteChunkSize)
Papa.RemoteChunkSize = remoteChunkSize;
if (files.length > 0) if (files.length > 0)
{ {
start = performance.now(); start = performance.now();
@ -54,17 +66,32 @@ function buildConfig()
worker: $('#worker').prop('checked'), worker: $('#worker').prop('checked'),
comments: $('#comments').val(), comments: $('#comments').val(),
complete: completeFn, complete: completeFn,
download: $('#download').prop('checked') download: $('#download').prop('checked'),
keepEmptyRows: $('#keepEmptyRows').prop('checked'),
chunk: $('#chunk').prop('checked') ? chunkFn : undefined
}; };
} }
function stepFn(results, parser) function stepFn(results, parser)
{ {
stepped++; stepped++;
rows += results.data.length;
}
function chunkFn(results, file)
{
if (!results)
return;
chunks++;
rows += results.data.length;
} }
function completeFn() function completeFn()
{ {
end = performance.now(); end = performance.now();
if (arguments[0] && arguments[0].data)
rows = arguments[0].data.length;
console.log("Finished input. Time:", end-start, arguments); console.log("Finished input. Time:", end-start, arguments);
console.log("Rows:", rows, "Stepped:", stepped, "Chunks:", chunks);
} }
Loading…
Cancel
Save