|
From: <tob...@us...> - 2014-02-27 23:09:10
|
Revision: 7896
http://sourceforge.net/p/bigdata/code/7896
Author: tobycraig
Date: 2014-02-27 23:09:07 +0000 (Thu, 27 Feb 2014)
Log Message:
-----------
#823 - Disable textarea when a large file is selected
Modified Paths:
--------------
branches/RDR/bigdata-war/src/html/new.html
branches/RDR/bigdata-war/src/html/workbench.js
Modified: branches/RDR/bigdata-war/src/html/new.html
===================================================================
--- branches/RDR/bigdata-war/src/html/new.html 2014-02-27 19:07:35 UTC (rev 7895)
+++ branches/RDR/bigdata-war/src/html/new.html 2014-02-27 23:09:07 UTC (rev 7896)
@@ -42,7 +42,9 @@
</div>
<textarea id="load-box" placeholder="(Type in or drag a file containing RDF data, a SPARQL update or a file path or URL)"></textarea>
+ <p id="large-file-message">Your file is too large to display here, but will be uploaded as normal. <a href="#" id="clear-file">Remove file</a></p>
<p>
+ <input type="file" id="load-file"><br>
<label for="load-type">Type:</label>
<select id="load-type">
<option value="sparql" selected="selected">SPARQL</option>
Modified: branches/RDR/bigdata-war/src/html/workbench.js
===================================================================
--- branches/RDR/bigdata-war/src/html/workbench.js 2014-02-27 19:07:35 UTC (rev 7895)
+++ branches/RDR/bigdata-war/src/html/workbench.js 2014-02-27 23:09:07 UTC (rev 7896)
@@ -88,7 +88,7 @@
}
}
-var NAMESPACE, NAMESPACE_URL;
+var NAMESPACE, NAMESPACE_URL, fileContents;
// default namespace
useNamespace('kb', '/namespace/kb/sparql');
getNamespaces();
@@ -135,23 +135,43 @@
var f = files[0];
// if file is too large, tell user to supply local path
- if(f.size > 1048576) {
+ if(f.size > 1048576 * 100) {
alert('File too large, enter local path to file');
$('#load-box').val('/path/to/' + f.name);
setType('path');
- $('#large-file-message').hide();
+ $('#load-box').prop('disabled', false)
+ $('#large-file-message, #clear-file').hide();
} else {
- // display file contents in the textarea
var fr = new FileReader();
fr.onload = function(e2) {
- $('#load-box').val(e2.target.result);
+ if(f.size > 10240) {
+ // do not use textarea
+ $('#load-box').prop('disabled', true)
+ $('#large-file-message, #clear-file').show()
+ $('#load-box').val('');
+ fileContents = e2.target.result;
+ } else {
+ // display file contents in the textarea
+ clearFile();
+ $('#load-box').val(e2.target.result);
+ }
guessType(f.name.split('.').pop().toLowerCase(), e2.target.result);
};
fr.readAsText(f);
}
+
$('#load-file').val('');
}
+function clearFile(e) {
+ if(e) {
+ e.preventDefault();
+ }
+ $('#load-box').prop('disabled', false)
+ $('#large-file-message, #clear-file').hide()
+ fileContents = null;
+}
+
function guessType(extension, content) {
// try to guess type
if(extension == 'rq') {
@@ -237,11 +257,12 @@
$('#load-box').on('drop', handleFile);
$('#load-box').on('paste', handlePaste);
$('#load-type').change(handleTypeChange);
+$('#clear-file').click(clearFile);
$('#load-load').click(function() {
var settings = {
type: 'POST',
- data: $('#load-box').val(),
+ data: fileContents == null ? $('#load-box').val() : fileContents,
success: updateResponseXML,
error: updateResponseError
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|