From: <tob...@us...> - 2014-05-02 18:03:10
|
Revision: 8167 http://sourceforge.net/p/bigdata/code/8167 Author: tobycraig Date: 2014-05-02 18:03:07 +0000 (Fri, 02 May 2014) Log Message: ----------- Changed Load to Update Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-02 16:52:45 UTC (rev 8166) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-02 18:03:07 UTC (rev 8167) @@ -229,12 +229,12 @@ margin: 20px auto; } -#load-load { +#update-update { margin: 0 auto; display: block; } -#load-buttons { +#update-buttons { text-align: center; } @@ -250,7 +250,7 @@ border: none; } -#advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #load-response, #load-clear-container, #explore-results, #namespace-properties { +#advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties { display: none; } @@ -271,7 +271,7 @@ float: right; } -#load-box, #query-box { +#update-box, #query-box { background-color: transparent; padding: 2px; border-width: 1px; @@ -279,13 +279,13 @@ } /* these should have the same typography so the error highlighting matches up with the query text */ -#load-box, #load-errors, #query-box, #query-errors { +#update-box, #update-errors, #query-box, #query-errors { font-family: sans-serif; font-size: 90%; line-height: normal; } -#load-errors, #query-errors { +#update-errors, #query-errors { position: absolute; z-index: -1; padding: 8px 3px; @@ -349,7 +349,7 @@ text-align: right; } -#load-clear-container { +#update-clear-container { text-align: right; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-02 16:52:45 UTC (rev 8166) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-02 18:03:07 UTC (rev 8167) @@ -21,7 +21,7 @@ <div id="tab-selector"> <a data-target="query" class="active">Query</a> - <a data-target="load">Load</a> + <a data-target="update">Update</a> <a data-target="explore">Explore</a> <a data-target="status">Status</a> <a data-target="performance">Performance</a> @@ -29,7 +29,7 @@ <p>Current namespace: <span id="current-namespace"></span></p> </div> - <div class="tab" id="load-tab"> + <div class="tab" id="update-tab"> <div class="box"> @@ -37,14 +37,14 @@ </div> <div> - <div id="load-errors"></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> + <div id="update-errors"></div> + <textarea id="update-box" placeholder="(Type in or drag a file containing RDF data, a SPARQL update or a file path or URL)"></textarea> </div> <p id="large-file-message">Your file <span id="filename"></span> 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"> + <input type="file" id="update-file"><br> + <label for="update-type">Type:</label> + <select id="update-type"> <option value="sparql" selected="selected">SPARQL Update</option> <option value="rdf">RDF Data</option> <option value="path">File Path or URL</option> @@ -62,16 +62,16 @@ </select> </p> <hr class="shadow"> - <button id="load-load">Load</button> + <button id="update-update">Update</button> </div> - <div class="box" id="load-response"> + <div class="box" id="update-response"> <pre></pre> </div> - <div class="box" id="load-clear-container"> - <button id="load-clear">Clear output</button> + <div class="box" id="update-clear-container"> + <button id="update-clear">Clear output</button> </div> </div> @@ -96,7 +96,7 @@ <hr class="shadow"> - <div id="load-buttons"> + <div id="update-buttons"> <input type="submit" value="Execute"> <input type="reset" value="Clear"> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-02 16:52:45 UTC (rev 8166) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-02 18:03:07 UTC (rev 8167) @@ -220,7 +220,7 @@ }); -/* Load */ +/* Update */ function handleDragOver(e) { e.stopPropagation(); @@ -248,38 +248,38 @@ // if file is too large, tell user to supply local path if(f.size > 1048576 * 100) { alert('File too large, enter local path to file'); - $('#load-box').val('/path/to/' + f.name); + $('#update-box').val('/path/to/' + f.name); setType('path'); - $('#load-box').prop('disabled', false) + $('#update-box').prop('disabled', false) $('#large-file-message, #clear-file').hide(); } else { var fr = new FileReader(); fr.onload = function(e2) { if(f.size > 10240) { // do not use textarea - $('#load-box').prop('disabled', true) + $('#update-box').prop('disabled', true) $('#filename').html(f.name); $('#large-file-message, #clear-file').show() - $('#load-box').val(''); + $('#update-box').val(''); FILE_CONTENTS = e2.target.result; } else { // display file contents in the textarea clearFile(); - $('#load-box').val(e2.target.result); + $('#update-box').val(e2.target.result); } guessType(f.name.split('.').pop().toLowerCase(), e2.target.result); }; fr.readAsText(f); } - $('#load-file').val(''); + $('#update-file').val(''); } function clearFile(e) { if(e) { e.preventDefault(); } - $('#load-box').prop('disabled', false) + $('#update-box').prop('disabled', false) $('#large-file-message, #clear-file').hide() FILE_CONTENTS = null; } @@ -332,7 +332,7 @@ } function setType(type, format) { - $('#load-type').val(type); + $('#update-type').val(type); if(type == 'rdf') { $('#rdf-type').val(format); } @@ -364,28 +364,28 @@ var sparql_update_commands = ['INSERT', 'DELETE']; -$('#load-file').change(handleFile); -$('#load-box').on('dragover', handleDragOver) +$('#update-file').change(handleFile); +$('#update-box').on('dragover', handleDragOver) .on('drop', handleFile) .on('paste', handlePaste) - .on('input propertychange', function() { $('#load-errors').hide(); }) - .bind('keydown', 'ctrl+return', submitLoad); + .on('input propertychange', function() { $('#update-errors').hide(); }) + .bind('keydown', 'ctrl+return', submitUpdate); $('#clear-file').click(clearFile); -$('#load-load').click(submitLoad); +$('#update-update').click(submitUpdate); -function submitLoad(e) { +function submitUpdate(e) { e.preventDefault(); var settings = { type: 'POST', - data: FILE_CONTENTS == null ? $('#load-box').val() : FILE_CONTENTS, + data: FILE_CONTENTS == null ? $('#update-box').val() : FILE_CONTENTS, success: updateResponseXML, error: updateResponseError } // determine action based on type - switch($('#load-type').val()) { + switch($('#update-type').val()) { case 'sparql': settings.data = 'update=' + encodeURIComponent(settings.data); settings.success = updateResponseHTML; @@ -407,15 +407,15 @@ break; } - $('#load-response').show(); - $('#load-response pre').html('Data loading...'); + $('#update-response').show(); + $('#update-response pre').html('Data loading...'); $.ajax(NAMESPACE_URL, settings); } -$('#load-clear').click(function() { - $('#load-response, #load-clear').hide(); - $('#load-response pre').text(''); +$('#update-clear').click(function() { + $('#update-response, #update-clear').hide(); + $('#update-response pre').text(''); }); $('#advanced-features-toggle').click(function() { @@ -424,21 +424,21 @@ }); function updateResponseHTML(data) { - $('#load-response, #load-clear').show(); - $('#load-response pre').html(data); + $('#update-response, #update-clear').show(); + $('#update-response pre').html(data); } function updateResponseXML(data) { var modified = data.childNodes[0].attributes['modified'].value; var milliseconds = data.childNodes[0].attributes['milliseconds'].value; - $('#load-response, #load-clear').show(); - $('#load-response pre').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); + $('#update-response, #update-clear').show(); + $('#update-response pre').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); } function updateResponseError(jqXHR, textStatus, errorThrown) { - $('#load-response, #load-clear').show(); - $('#load-response pre').text('Error! ' + textStatus + ' ' + jqXHR.statusText); - highlightError(jqXHR.statusText, 'load'); + $('#update-response, #update-clear').show(); + $('#update-response pre').text('Error! ' + textStatus + ' ' + jqXHR.statusText); + highlightError(jqXHR.statusText, 'update'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-05-02 18:43:47
|
Revision: 8168 http://sourceforge.net/p/bigdata/code/8168 Author: tobycraig Date: 2014-05-02 18:43:45 +0000 (Fri, 02 May 2014) Log Message: ----------- Added Details option to Explain query Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-02 18:03:07 UTC (rev 8167) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-02 18:43:45 UTC (rev 8168) @@ -90,6 +90,7 @@ <div id="advanced-features"> <input type="checkbox" id="query-explain"> <label for="query-explain">Explain</label> + <input type="checkbox" id="query-details"> <label for="query-explain">(Details)</label> <input type="checkbox" name="analytic" value="true" id="query-analytic"> <label for="query-analytic">Analytic</label> <input type="checkbox" name="RTO" value="true" id="query-rto"> <label for="query-rto">Runtime Query Optimizer</label> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-02 18:03:07 UTC (rev 8167) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-02 18:43:45 UTC (rev 8168) @@ -448,6 +448,18 @@ .on('input propertychange', function() { $('#query-errors').hide(); }); $('#query-form').submit(submitQuery); +$('#query-explain').change(function() { + if(!this.checked) { + $('#query-details').prop('checked', false); + } +}); + +$('#query-details').change(function() { + if(this.checked) { + $('#query-explain').prop('checked', true); + } +}); + function submitQuery(e) { e.preventDefault(); @@ -468,7 +480,7 @@ if($('#query-explain').is(':checked')) { settings = { type: 'POST', - data: $(this).serialize() + '&explain=details', + data: $(this).serialize() + '&explain=' + ($('#query-details').is(':checked') ? 'details' : 'true'), dataType: 'html', success: showQueryExplanation, error: queryResultsError This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-05-03 01:14:51
|
Revision: 8170 http://sourceforge.net/p/bigdata/code/8170 Author: tobycraig Date: 2014-05-03 01:14:48 +0000 (Sat, 03 May 2014) Log Message: ----------- Quick fix for status tab in HA mode. Ideally data would be sent as JSON rather than HTML. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-02 22:50:59 UTC (rev 8169) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-03 01:14:48 UTC (rev 8170) @@ -172,10 +172,7 @@ <div class="tab" id="status-tab"> <div class="box"> - <p>Accepted query count: <span id="accepted-query-count"></span></p> - <p>Running query count: <span id="running-query-count"></span></p> - <p>Show <a href="#" id="show-queries">queries</a>, <a href="#" id="show-query-details">query details</a>.</p> - <pre id="status-numbers"></pre> + <div id="status-text"></div> <ul id="running-queries"></ul> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-02 22:50:59 UTC (rev 8169) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-03 01:14:48 UTC (rev 8170) @@ -1063,12 +1063,9 @@ } function getStatusNumbers(data) { - var accepted = data.text().match(/Accepted query count=(\d+)/)[1]; - var running = data.text().match(/Running query count=(\d+)/)[1]; - var numbers = $(data).find('pre')[0].textContent; - $('#accepted-query-count').html(accepted); - $('#running-query-count').html(running); - $('#status-numbers').html(numbers); + $('#status-text').html(data); + $('#status-text a').eq(1).click(function(e) { e.preventDefault(); showQueries(false); return false; }); + $('#status-text a').eq(2).click(function(e) { e.preventDefault(); showQueries(true); return false; }); } $('#show-queries').click(function(e) { @@ -1100,6 +1097,10 @@ e = $(e); // get numbers string, which includes cancel link var form = e.next(); + // HA mode has h1 before running queries + if(form[0].tagName != 'FORM') { + return; + } var numbers = form.find('p')[0].textContent; // remove cancel link numbers = numbers.substring(0, numbers.lastIndexOf(',')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-05-06 00:30:31
|
Revision: 8204 http://sourceforge.net/p/bigdata/code/8204 Author: tobycraig Date: 2014-05-06 00:30:25 +0000 (Tue, 06 May 2014) Log Message: ----------- Advanced commands (monitor and analytic) enabled for update Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-05 19:47:44 UTC (rev 8203) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-06 00:30:25 UTC (rev 8204) @@ -250,7 +250,7 @@ border: none; } -#advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties { +.advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties { display: none; } @@ -353,3 +353,10 @@ text-align: right; } +iframe { + display: none; + width: 100%; + height: 300px; + border: 1px solid #e1e1e1; + box-sizing: border-box; +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-05 19:47:44 UTC (rev 8203) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-06 00:30:25 UTC (rev 8204) @@ -50,7 +50,7 @@ <option value="path">File Path or URL</option> </select> <label for="rdf-type">Format:</label> - <select id="rdf-type"> + <select id="rdf-type" disabled> <option value="n-quads">N-Quads</option> <option value="n-triples">N-Triples</option> <option value="n3">Notation3</option> @@ -61,6 +61,11 @@ <option value="turtle">Turtle</option> </select> </p> + <a href="#" class="advanced-features-toggle">Advanced features</a> + <div class="advanced-features"> + <input type="checkbox" id="update-analytic"> <label for="update-analytic">Analytic</label> + <input type="checkbox" id="update-monitor"> <label for="update-monitor">Monitor</label> + </div> <hr class="shadow"> <button id="update-update">Update</button> @@ -68,6 +73,7 @@ <div class="box" id="update-response"> <pre></pre> + <iframe name="update-response-container"></iframe> </div> <div class="box" id="update-clear-container"> @@ -86,9 +92,9 @@ <div id="query-errors"></div> <textarea id="query-box" name="query" placeholder="(Input a SPARQL query)"></textarea> - <a href="#" id="advanced-features-toggle">Advanced features</a> + <a href="#" class="advanced-features-toggle">Advanced features</a> - <div id="advanced-features"> + <div class="advanced-features"> <input type="checkbox" id="query-explain"> <label for="query-explain">Explain</label> <input type="checkbox" id="query-details"> <label for="query-explain">(Details)</label> <input type="checkbox" name="analytic" value="true" id="query-analytic"> <label for="query-analytic">Analytic</label> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-05 19:47:44 UTC (rev 8203) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-06 00:30:25 UTC (rev 8204) @@ -340,8 +340,16 @@ if(type == 'rdf') { $('#rdf-type').val(format); } + showUpdateOptions(type); } +$('#update-type').change(function() { showUpdateOptions(this.value) }); + +function showUpdateOptions(type) { + $('#rdf-type, label[for="rdf-type"]').attr('disabled', type != 'rdf'); + $('#update-tab .advanced-features input').attr('disabled', type != 'sparql'); +} + // .xml is used for both RDF and TriX, assume it's RDF // We could check the parent element to see which it is var rdf_types = {'nq': 'n-quads', @@ -379,8 +387,14 @@ $('#update-update').click(submitUpdate); function submitUpdate(e) { + // Updates are submitted as a regular form for SPARQL updates in monitor mode, and via AJAX for non-monitor SPARQL, RDF & file path updates. + // When submitted as a regular form, the output is sent to an iframe. This is to allow monitor mode to work. + // jQuery only gives us data when the request is complete, so we wouldn't see monitor results as they come in. + e.preventDefault(); + $('#update-response').show(); + var settings = { type: 'POST', data: FILE_CONTENTS == null ? $('#update-box').val() : FILE_CONTENTS, @@ -391,7 +405,25 @@ // determine action based on type switch($('#update-type').val()) { case 'sparql': + // see if monitor mode is on + if($('#update-monitor').is(':checked')) { + // create form and submit it, sending output to the iframe + var form = $('<form method="POST" target="update-response-container">') + .attr('action', NAMESPACE_URL) + .append($('<input name="update">').val(settings.data)) + .append('<input name="monitor" value="true">'); + if($('#update-analytic').is(':checked')) { + form.append('<input name="analytic" value="true">') + } + form.submit(); + $('#update-response iframe, #update-clear-container').show(); + $('#update-response pre').hide(); + return; + } settings.data = 'update=' + encodeURIComponent(settings.data); + if($('#update-analytic').is(':checked')) { + settings.data += '&analytic=true'; + } settings.success = updateResponseHTML; break; case 'rdf': @@ -411,36 +443,39 @@ break; } - $('#update-response').show(); - $('#update-response pre').html('Data loading...'); + $('#update-response pre').show().html('Data loading...'); $.ajax(NAMESPACE_URL, settings); } $('#update-clear').click(function() { - $('#update-response, #update-clear').hide(); + $('#update-response, #update-clear-container').hide(); $('#update-response pre').text(''); + $('#update-response iframe').attr('src', 'about:blank'); }); -$('#advanced-features-toggle').click(function() { - $('#advanced-features').toggle(); +$('.advanced-features-toggle').click(function() { + $(this).next('.advanced-features').toggle(); return false; }); function updateResponseHTML(data) { - $('#update-response, #update-clear').show(); + $('#update-response, #update-clear-container').show(); + $('#update-response iframe').attr('src', 'about:blank').hide(); $('#update-response pre').html(data); } function updateResponseXML(data) { var modified = data.childNodes[0].attributes['modified'].value; var milliseconds = data.childNodes[0].attributes['milliseconds'].value; - $('#update-response, #update-clear').show(); + $('#update-response, #update-clear-container').show(); + $('#update-response iframe').attr('src', 'about:blank').hide(); $('#update-response pre').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); } function updateResponseError(jqXHR, textStatus, errorThrown) { - $('#update-response, #update-clear').show(); + $('#update-response, #update-clear-container').show(); + $('#update-response iframe').attr('src', 'about:blank').hide(); $('#update-response pre').text('Error! ' + textStatus + ' ' + jqXHR.statusText); highlightError(jqXHR.statusText, 'update'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-05-08 23:17:43
|
Revision: 8240 http://sourceforge.net/p/bigdata/code/8240 Author: tobycraig Date: 2014-05-08 23:17:39 +0000 (Thu, 08 May 2014) Log Message: ----------- Added basic CodeMirror editor Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/codemirror.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/placeholder.js branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/codemirror.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-08 23:17:07 UTC (rev 8239) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-05-08 23:17:39 UTC (rev 8240) @@ -209,6 +209,10 @@ color: #ededed; } +#query-form, #load-box-container { + clear: both; +} + #large-file-message { display: none; margin: 5px 0; @@ -221,6 +225,15 @@ box-sizing: border-box; } +.CodeMirror { + margin: 5px 0; + border: 1px solid #e1e1e1; +} + +.CodeMirror-placeholder { + font-style: italic; +} + hr { background: #929292; border: none; @@ -271,36 +284,6 @@ float: right; } -#update-box, #query-box { - background-color: transparent; - padding: 2px; - border-width: 1px; - border-color: #e1e1e1; -} - -/* these should have the same typography so the error highlighting matches up with the query text */ -#update-box, #update-errors, #query-box, #query-errors { - font-family: sans-serif; - font-size: 90%; - line-height: normal; -} - -#update-errors, #query-errors { - position: absolute; - z-index: -1; - padding: 8px 3px; - color: transparent; - white-space: pre; -} - -.error-line { - background-color: lightgreen; -} - -.error-character { - background-color: red; -} - #running-queries li { margin: 10px 0; } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/codemirror.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/codemirror.css (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/codemirror.css 2014-05-08 23:17:39 UTC (rev 8240) @@ -0,0 +1,272 @@ +/* BASICS */ + +.CodeMirror { + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; +} +.CodeMirror-scroll { + /* Set scrolling behaviour here */ + overflow: auto; +} + +/* PADDING */ + +.CodeMirror-lines { + padding: 4px 0; /* Vertical padding around content */ +} +.CodeMirror pre { + padding: 0 4px; /* Horizontal padding of content */ +} + +.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + background-color: white; /* The little square between H and V scrollbars */ +} + +/* GUTTER */ + +.CodeMirror-gutters { + border-right: 1px solid #ddd; + background-color: #f7f7f7; + white-space: nowrap; +} +.CodeMirror-linenumbers {} +.CodeMirror-linenumber { + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +/* CURSOR */ + +.CodeMirror div.CodeMirror-cursor { + border-left: 1px solid black; +} +/* Shown when moving in bi-directional text */ +.CodeMirror div.CodeMirror-secondarycursor { + border-left: 1px solid silver; +} +.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { + width: auto; + border: 0; + background: #7e7; +} +/* Can style cursor different in overwrite (non-insert) mode */ +div.CodeMirror-overwrite div.CodeMirror-cursor {} + +.cm-tab { display: inline-block; } + +.CodeMirror-ruler { + border-left: 1px solid #ccc; + position: absolute; +} + +/* DEFAULT THEME */ + +.cm-s-default .cm-keyword {color: #708;} +.cm-s-default .cm-atom {color: #219;} +.cm-s-default .cm-number {color: #164;} +.cm-s-default .cm-def {color: #00f;} +.cm-s-default .cm-variable, +.cm-s-default .cm-punctuation, +.cm-s-default .cm-property, +.cm-s-default .cm-operator {} +.cm-s-default .cm-variable-2 {color: #05a;} +.cm-s-default .cm-variable-3 {color: #085;} +.cm-s-default .cm-comment {color: #a50;} +.cm-s-default .cm-string {color: #a11;} +.cm-s-default .cm-string-2 {color: #f50;} +.cm-s-default .cm-meta {color: #555;} +.cm-s-default .cm-qualifier {color: #555;} +.cm-s-default .cm-builtin {color: #30a;} +.cm-s-default .cm-bracket {color: #997;} +.cm-s-default .cm-tag {color: #170;} +.cm-s-default .cm-attribute {color: #00c;} +.cm-s-default .cm-header {color: blue;} +.cm-s-default .cm-quote {color: #090;} +.cm-s-default .cm-hr {color: #999;} +.cm-s-default .cm-link {color: #00c;} + +.cm-negative {color: #d44;} +.cm-positive {color: #292;} +.cm-header, .cm-strong {font-weight: bold;} +.cm-em {font-style: italic;} +.cm-link {text-decoration: underline;} + +.cm-s-default .cm-error {color: #f00;} +.cm-invalidchar {color: #f00;} + +div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} +.CodeMirror-activeline-background {background: #e8f2ff;} + +/* STOP */ + +/* The rest of this file contains styles related to the mechanics of + the editor. You probably shouldn't touch them. */ + +.CodeMirror { + line-height: 1; + position: relative; + overflow: hidden; + background: white; + color: black; +} + +.CodeMirror-scroll { + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror */ + margin-bottom: -30px; margin-right: -30px; + padding-bottom: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.CodeMirror-sizer { + position: relative; + border-right: 30px solid transparent; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +/* The fake, visible scrollbars. Used to force redraw during scrolling + before actuall scrolling happens, thus preventing shaking and + flickering artifacts. */ +.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + position: absolute; + z-index: 6; + display: none; +} +.CodeMirror-vscrollbar { + right: 0; top: 0; + overflow-x: hidden; + overflow-y: scroll; +} +.CodeMirror-hscrollbar { + bottom: 0; left: 0; + overflow-y: hidden; + overflow-x: scroll; +} +.CodeMirror-scrollbar-filler { + right: 0; bottom: 0; +} +.CodeMirror-gutter-filler { + left: 0; bottom: 0; +} + +.CodeMirror-gutters { + position: absolute; left: 0; top: 0; + padding-bottom: 30px; + z-index: 3; +} +.CodeMirror-gutter { + white-space: normal; + height: 100%; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding-bottom: 30px; + margin-bottom: -32px; + display: inline-block; + /* Hack to make IE7 behave */ + *zoom:1; + *display:inline; +} +.CodeMirror-gutter-elt { + position: absolute; + cursor: default; + z-index: 4; +} + +.CodeMirror-lines { + cursor: text; +} +.CodeMirror pre { + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; +} +.CodeMirror-wrap pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; +} + +.CodeMirror-linebackground { + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 0; +} + +.CodeMirror-linewidget { + position: relative; + z-index: 2; + overflow: auto; +} + +.CodeMirror-widget {} + +.CodeMirror-wrap .CodeMirror-scroll { + overflow-x: hidden; +} + +.CodeMirror-measure { + position: absolute; + width: 100%; + height: 0; + overflow: hidden; + visibility: hidden; +} +.CodeMirror-measure pre { position: static; } + +.CodeMirror div.CodeMirror-cursor { + position: absolute; + border-right: none; + width: 0; +} + +div.CodeMirror-cursors { + visibility: hidden; + position: relative; + z-index: 1; +} +.CodeMirror-focused div.CodeMirror-cursors { + visibility: visible; +} + +.CodeMirror-selected { background: #d9d9d9; } +.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } +.CodeMirror-crosshair { cursor: crosshair; } + +.cm-searching { + background: #ffa; + background: rgba(255, 255, 0, .4); +} + +/* IE7 hack to prevent it from returning funny offsetTops on the spans */ +.CodeMirror span { *vertical-align: text-bottom; } + +/* Used to force a border model for a node */ +.cm-force-border { padding-right: .1px; } + +@media print { + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursors { + visibility: hidden; + } +} Property changes on: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/vendor/codemirror.css ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-08 23:17:07 UTC (rev 8239) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-08 23:17:39 UTC (rev 8240) @@ -7,6 +7,7 @@ <!-- meta charset="utf-8" --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <title>Bigdata Workbench</title> + <link rel="stylesheet" href="/bigdata/html/css/vendor/codemirror.css"> <link rel="stylesheet" href="/bigdata/html/css/style.css"> <!-- junit test marker: index.html --> </head> @@ -36,8 +37,7 @@ <div class="namespace-shortcuts"> </div> - <div> - <div id="update-errors"></div> + <div id="update-box-container"> <textarea id="update-box" placeholder="(Type in or drag a file containing RDF data, a SPARQL update or a file path or URL)"></textarea> </div> <p id="large-file-message">Your file <span id="filename"></span> is too large to display here, but will be uploaded as normal. <a href="#" id="clear-file">Remove file</a></p> @@ -89,7 +89,6 @@ </div> <form id="query-form"> - <div id="query-errors"></div> <textarea id="query-box" name="query" placeholder="(Input a SPARQL query)"></textarea> <a href="#" class="advanced-features-toggle">Advanced features</a> @@ -220,6 +219,8 @@ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="/bigdata/html/js/vendor/jquery.min.js"><\/script>')</script> <script src="/bigdata/html/js/vendor/jquery.hotkeys.js"></script> + <script src="/bigdata/html/js/vendor/codemirror.js"></script> + <script src="/bigdata/html/js/vendor/cm-addons/placeholder.js"></script> <script src="/bigdata/html/js/workbench.js"></script> </body> </html> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/placeholder.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/placeholder.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/placeholder.js 2014-05-08 23:17:39 UTC (rev 8240) @@ -0,0 +1,55 @@ +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + CodeMirror.defineOption("placeholder", "", function(cm, val, old) { + var prev = old && old != CodeMirror.Init; + if (val && !prev) { + cm.on("blur", onBlur); + cm.on("change", onChange); + onChange(cm); + } else if (!val && prev) { + cm.off("blur", onBlur); + cm.off("change", onChange); + clearPlaceholder(cm); + var wrapper = cm.getWrapperElement(); + wrapper.className = wrapper.className.replace(" CodeMirror-empty", ""); + } + + if (val && !cm.hasFocus()) onBlur(cm); + }); + + function clearPlaceholder(cm) { + if (cm.state.placeholder) { + cm.state.placeholder.parentNode.removeChild(cm.state.placeholder); + cm.state.placeholder = null; + } + } + function setPlaceholder(cm) { + clearPlaceholder(cm); + var elt = cm.state.placeholder = document.createElement("pre"); + elt.style.cssText = "height: 0; overflow: visible"; + elt.className = "CodeMirror-placeholder"; + elt.appendChild(document.createTextNode(cm.getOption("placeholder"))); + cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild); + } + + function onBlur(cm) { + if (isEmpty(cm)) setPlaceholder(cm); + } + function onChange(cm) { + var wrapper = cm.getWrapperElement(), empty = isEmpty(cm); + wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : ""); + + if (empty) setPlaceholder(cm); + else clearPlaceholder(cm); + } + + function isEmpty(cm) { + return (cm.lineCount() === 1) && (cm.getLine(0) === ""); + } +}); Property changes on: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/placeholder.js ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/codemirror.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/codemirror.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/codemirror.js 2014-05-08 23:17:39 UTC (rev 8240) @@ -0,0 +1,7526 @@ +// This is CodeMirror (http://codemirror.net), a code editor +// implemented in JavaScript on top of the browser's DOM. +// +// You can find some technical background for some of the code below +// at http://marijnhaverbeke.nl/blog/#cm-internals . + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + module.exports = mod(); + else if (typeof define == "function" && define.amd) // AMD + return define([], mod); + else // Plain browser env + this.CodeMirror = mod(); +})(function() { + "use strict"; + + // BROWSER SNIFFING + + // Kludges for bugs and behavior differences that can't be feature + // detected are enabled based on userAgent etc sniffing. + + var gecko = /gecko\/\d/i.test(navigator.userAgent); + // ie_uptoN means Internet Explorer version N or lower + var ie_upto10 = /MSIE \d/.test(navigator.userAgent); + var ie_upto7 = ie_upto10 && (document.documentMode == null || document.documentMode < 8); + var ie_upto8 = ie_upto10 && (document.documentMode == null || document.documentMode < 9); + var ie_upto9 = ie_upto10 && (document.documentMode == null || document.documentMode < 10); + var ie_11up = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent); + var ie = ie_upto10 || ie_11up; + var webkit = /WebKit\//.test(navigator.userAgent); + var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); + var chrome = /Chrome\//.test(navigator.userAgent); + var presto = /Opera\//.test(navigator.userAgent); + var safari = /Apple Computer/.test(navigator.vendor); + var khtml = /KHTML\//.test(navigator.userAgent); + var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); + var phantom = /PhantomJS/.test(navigator.userAgent); + + var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); + // This is woefully incomplete. Suggestions for alternative methods welcome. + var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); + var mac = ios || /Mac/.test(navigator.platform); + var windows = /win/i.test(navigator.platform); + + var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); + if (presto_version) presto_version = Number(presto_version[1]); + if (presto_version && presto_version >= 15) { presto = false; webkit = true; } + // Some browsers use the wrong event properties to signal cmd/ctrl on OS X + var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); + var captureRightClick = gecko || (ie && !ie_upto8); + + // Optimize some code when these features are not used. + var sawReadOnlySpans = false, sawCollapsedSpans = false; + + // EDITOR CONSTRUCTOR + + // A CodeMirror instance represents an editor. This is the object + // that user code is usually dealing with. + + function CodeMirror(place, options) { + if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); + + this.options = options = options || {}; + // Determine effective options based on given values and defaults. + copyObj(defaults, options, false); + setGuttersForLineNumbers(options); + + var doc = options.value; + if (typeof doc == "string") doc = new Doc(doc, options.mode); + this.doc = doc; + + var display = this.display = new Display(place, doc); + display.wrapper.CodeMirror = this; + updateGutters(this); + themeChanged(this); + if (options.lineWrapping) + this.display.wrapper.className += " CodeMirror-wrap"; + if (options.autofocus && !mobile) focusInput(this); + + this.state = { + keyMaps: [], // stores maps added by addKeyMap + overlays: [], // highlighting overlays, as added by addOverlay + modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info + overwrite: false, focused: false, + suppressEdits: false, // used to disable editing during key handlers when in readOnly mode + pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput + draggingText: false, + highlight: new Delayed() // stores highlight worker timeout + }; + + // Override magic textarea content restore that IE sometimes does + // on our hidden textarea on reload + if (ie_upto10) setTimeout(bind(resetInput, this, true), 20); + + registerEventHandlers(this); + + var cm = this; + runInOp(this, function() { + cm.curOp.forceUpdate = true; + attachDoc(cm, doc); + + if ((options.autofocus && !mobile) || activeElt() == display.input) + setTimeout(bind(onFocus, cm), 20); + else + onBlur(cm); + + for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt)) + optionHandlers[opt](cm, options[opt], Init); + for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm); + }); + } + + // DISPLAY CONSTRUCTOR + + // The display handles the DOM integration, both for input reading + // and content drawing. It holds references to DOM nodes and + // display-related state. + + function Display(place, doc) { + var d = this; + + // The semihidden textarea that is focused when the editor is + // focused, and receives input. + var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); + // The textarea is kept positioned near the cursor to prevent the + // fact that it'll be scrolled into view on input from scrolling + // our fake cursor out of view. On webkit, when wrap=off, paste is + // very slow. So make the area wide instead. + if (webkit) input.style.width = "1000px"; + else input.setAttribute("wrap", "off"); + // If border: 0; -- iOS fails to open keyboard (issue #1287) + if (ios) input.style.border = "1px solid black"; + input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false"); + + // Wraps and hides input textarea + d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); + // The fake scrollbar elements. + d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); + d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); + // Covers bottom-right square when both scrollbars are present. + d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); + // Covers bottom of gutter when coverGutterNextToScrollbar is on + // and h scrollbar is present. + d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); + // Will contain the actual code, positioned to cover the viewport. + d.lineDiv = elt("div", null, "CodeMirror-code"); + // Elements are added to these to represent selection and cursors. + d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); + d.cursorDiv = elt("div", null, "CodeMirror-cursors"); + // A visibility: hidden element used to find the size of things. + d.measure = elt("div", null, "CodeMirror-measure"); + // When lines outside of the viewport are measured, they are drawn in this. + d.lineMeasure = elt("div", null, "CodeMirror-measure"); + // Wraps everything that needs to exist inside the vertically-padded coordinate system + d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], + null, "position: relative; outline: none"); + // Moved around its parent to cover visible view. + d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); + // Set to the height of the document, allowing scrolling. + d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); + // Behavior of elts with overflow: auto and padding is + // inconsistent across browsers. This is used to ensure the + // scrollable area is big enough. + d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;"); + // Will contain the gutters, if any. + d.gutters = elt("div", null, "CodeMirror-gutters"); + d.lineGutter = null; + // Actual scrollable element. + d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); + d.scroller.setAttribute("tabIndex", "-1"); + // The element in which the editor lives. + d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV, + d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); + + // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) + if (ie_upto7) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } + // Needed to hide big blue blinking cursor on Mobile Safari + if (ios) input.style.width = "0px"; + if (!webkit) d.scroller.draggable = true; + // Needed to handle Tab key in KHTML + if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; } + // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). + if (ie_upto7) d.scrollbarH.style.minHeight = d.scrollbarV.style.minWidth = "18px"; + + if (place.appendChild) place.appendChild(d.wrapper); + else place(d.wrapper); + + // Current rendered range (may be bigger than the view window). + d.viewFrom = d.viewTo = doc.first; + // Information about the rendered lines. + d.view = []; + // Holds info about a single rendered line when it was rendered + // for measurement, while not in view. + d.externalMeasured = null; + // Empty space (in pixels) above the view + d.viewOffset = 0; + d.lastSizeC = 0; + d.updateLineNumbers = null; + + // Used to only resize the line number gutter when necessary (when + // the amount of lines crosses a boundary that makes its width change) + d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; + // See readInput and resetInput + d.prevInput = ""; + // Set to true when a non-horizontal-scrolling line widget is + // added. As an optimization, line widget aligning is skipped when + // this is false. + d.alignWidgets = false; + // Flag that indicates whether we expect input to appear real soon + // now (after some event like 'keypress' or 'input') and are + // polling intensively. + d.pollingFast = false; + // Self-resetting timeout for the poller + d.poll = new Delayed(); + + d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; + + // Tracks when resetInput has punted to just putting a short + // string into the textarea instead of the full selection. + d.inaccurateSelection = false; + + // Tracks the maximum line length so that the horizontal scrollbar + // can be kept static when scrolling. + d.maxLine = null; + d.maxLineLength = 0; + d.maxLineChanged = false; + + // Used for measuring wheel scrolling granularity + d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; + + // True when shift is held down. + d.shift = false; + } + + // STATE UPDATES + + // Used to get the editor into a consistent state again when options change. + + function loadMode(cm) { + cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption); + resetModeState(cm); + } + + function resetModeState(cm) { + cm.doc.iter(function(line) { + if (line.stateAfter) line.stateAfter = null; + if (line.styles) line.styles = null; + }); + cm.doc.frontier = cm.doc.first; + startWorker(cm, 100); + cm.state.modeGen++; + if (cm.curOp) regChange(cm); + } + + function wrappingChanged(cm) { + if (cm.options.lineWrapping) { + addClass(cm.display.wrapper, "CodeMirror-wrap"); + cm.display.sizer.style.minWidth = ""; + } else { + rmClass(cm.display.wrapper, "CodeMirror-wrap"); + findMaxLine(cm); + } + estimateLineHeights(cm); + regChange(cm); + clearCaches(cm); + setTimeout(function(){updateScrollbars(cm);}, 100); + } + + // Returns a function that estimates the height of a line, to use as + // first approximation until the line becomes visible (and is thus + // properly measurable). + function estimateHeight(cm) { + var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; + var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); + return function(line) { + if (lineIsHidden(cm.doc, line)) return 0; + + var widgetsHeight = 0; + if (line.widgets) for (var i = 0; i < line.widgets.length; i++) { + if (line.widgets[i].height) widgetsHeight += line.widgets[i].height; + } + + if (wrapping) + return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; + else + return widgetsHeight + th; + }; + } + + function estimateLineHeights(cm) { + var doc = cm.doc, est = estimateHeight(cm); + doc.iter(function(line) { + var estHeight = est(line); + if (estHeight != line.height) updateLineHeight(line, estHeight); + }); + } + + function keyMapChanged(cm) { + var map = keyMap[cm.options.keyMap], style = map.style; + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") + + (style ? " cm-keymap-" + style : ""); + } + + function themeChanged(cm) { + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); + clearCaches(cm); + } + + function guttersChanged(cm) { + updateGutters(cm); + regChange(cm); + setTimeout(function(){alignHorizontally(cm);}, 20); + } + + // Rebuild the gutter elements, ensure the margin to the left of the + // code matches their width. + function updateGutters(cm) { + var gutters = cm.display.gutters, specs = cm.options.gutters; + removeChildren(gutters); + for (var i = 0; i < specs.length; ++i) { + var gutterClass = specs[i]; + var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); + if (gutterClass == "CodeMirror-linenumbers") { + cm.display.lineGutter = gElt; + gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; + } + } + gutters.style.display = i ? "" : "none"; + updateGutterSpace(cm); + } + + function updateGutterSpace(cm) { + var width = cm.display.gutters.offsetWidth; + cm.display.sizer.style.marginLeft = width + "px"; + cm.display.scrollbarH.style.left = cm.options.fixedGutter ? width + "px" : 0; + } + + // Compute the character length of a line, taking into account + // collapsed ranges (see markText) that might hide parts, and join + // other lines onto it. + function lineLength(line) { + if (line.height == 0) return 0; + var len = line.text.length, merged, cur = line; + while (merged = collapsedSpanAtStart(cur)) { + var found = merged.find(0, true); + cur = found.from.line; + len += found.from.ch - found.to.ch; + } + cur = line; + while (merged = collapsedSpanAtEnd(cur)) { + var found = merged.find(0, true); + len -= cur.text.length - found.from.ch; + cur = found.to.line; + len += cur.text.length - found.to.ch; + } + return len; + } + + // Find the longest line in the document. + function findMaxLine(cm) { + var d = cm.display, doc = cm.doc; + d.maxLine = getLine(doc, doc.first); + d.maxLineLength = lineLength(d.maxLine); + d.maxLineChanged = true; + doc.iter(function(line) { + var len = lineLength(line); + if (len > d.maxLineLength) { + d.maxLineLength = len; + d.maxLine = line; + } + }); + } + + // Make sure the gutters options contains the element + // "CodeMirror-linenumbers" when the lineNumbers option is true. + function setGuttersForLineNumbers(options) { + var found = indexOf(options.gutters, "CodeMirror-linenumbers"); + if (found == -1 && options.lineNumbers) { + options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]); + } else if (found > -1 && !options.lineNumbers) { + options.gutters = options.gutters.slice(0); + options.gutters.splice(found, 1); + } + } + + // SCROLLBARS + + // Prepare DOM reads needed to update the scrollbars. Done in one + // shot to minimize update/measure roundtrips. + function measureForScrollbars(cm) { + var scroll = cm.display.scroller; + return { + clientHeight: scroll.clientHeight, + barHeight: cm.display.scrollbarV.clientHeight, + scrollWidth: scroll.scrollWidth, clientWidth: scroll.clientWidth, + barWidth: cm.display.scrollbarH.clientWidth, + docHeight: Math.round(cm.doc.height + paddingVert(cm.display)) + }; + } + + // Re-synchronize the fake scrollbars with the actual size of the + // content. + function updateScrollbars(cm, measure) { + if (!measure) measure = measureForScrollbars(cm); + var d = cm.display; + var scrollHeight = measure.docHeight + scrollerCutOff; + var needsH = measure.scrollWidth > measure.clientWidth; + var needsV = scrollHeight > measure.clientHeight; + if (needsV) { + d.scrollbarV.style.display = "block"; + d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0"; + // A bug in IE8 can cause this value to be negative, so guard it. + d.scrollbarV.firstChild.style.height = + Math.max(0, scrollHeight - measure.clientHeight + (measure.barHeight || d.scrollbarV.clientHeight)) + "px"; + } else { + d.scrollbarV.style.display = ""; + d.scrollbarV.firstChild.style.height = "0"; + } + if (needsH) { + d.scrollbarH.style.display = "block"; + d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0"; + d.scrollbarH.firstChild.style.width = + (measure.scrollWidth - measure.clientWidth + (measure.barWidth || d.scrollbarH.clientWidth)) + "px"; + } else { + d.scrollbarH.style.display = ""; + d.scrollbarH.firstChild.style.width = "0"; + } + if (needsH && needsV) { + d.scrollbarFiller.style.display = "block"; + d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px"; + } else d.scrollbarFiller.style.display = ""; + if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { + d.gutterFiller.style.display = "block"; + d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px"; + d.gutterFiller.style.width = d.gutters.offsetWidth + "px"; + } else d.gutterFiller.style.display = ""; + + if (!cm.state.checkedOverlayScrollbar && measure.clientHeight > 0) { + if (scrollbarWidth(d.measure) === 0) { + var w = mac && !mac_geMountainLion ? "12px" : "18px"; + d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = w; + var barMouseDown = function(e) { + if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH) + operation(cm, onMouseDown)(e); + }; + on(d.scrollbarV, "mousedown", barMouseDown); + on(d.scrollbarH, "mousedown", barMouseDown); + } + cm.state.checkedOverlayScrollbar = true; + } + } + + // Compute the lines that are visible in a given viewport (defaults + // the the current scroll position). viewPort may contain top, + // height, and ensure (see op.scrollToPos) properties. + function visibleLines(display, doc, viewPort) { + var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop; + top = Math.floor(top - paddingTop(display)); + var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight; + + var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); + // Ensure is a {from: {line, ch}, to: {line, ch}} object, and + // forces those lines into the viewport (if possible). + if (viewPort && viewPort.ensure) { + var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line; + if (ensureFrom < from) + return {from: ensureFrom, + to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)}; + if (Math.min(ensureTo, doc.lastLine()) >= to) + return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight), + to: ensureTo}; + } + return {from: from, to: to}; + } + + // LINE NUMBERS + + // Re-align line numbers and gutter marks to compensate for + // horizontal scrolling. + function alignHorizontally(cm) { + var display = cm.display, view = display.view; + if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return; + var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; + var gutterW = display.gutters.offsetWidth, left = comp + "px"; + for (var i = 0; i < view.length; i++) if (!view[i].hidden) { + if (cm.options.fixedGutter && view[i].gutter) + view[i].gutter.style.left = left; + var align = view[i].alignable; + if (align) for (var j = 0; j < align.length; j++) + align[j].style.left = left; + } + if (cm.options.fixedGutter) + display.gutters.style.left = (comp + gutterW) + "px"; + } + + // Used to ensure that the line number gutter is still the right + // size for the current document size. Returns true when an update + // is needed. + function maybeUpdateLineNumberWidth(cm) { + if (!cm.options.lineNumbers) return false; + var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; + if (last.length != display.lineNumChars) { + var test = display.measure.appendChild(elt("div", [elt("div", last)], + "CodeMirror-linenumber CodeMirror-gutter-elt")); + var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; + display.lineGutter.style.width = ""; + display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding); + display.lineNumWidth = display.lineNumInnerWidth + padding; + display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; + display.lineGutter.style.width = display.lineNumWidth + "px"; + updateGutterSpace(cm); + return true; + } + return false; + } + + function lineNumberFor(options, i) { + return String(options.lineNumberFormatter(i + options.firstLineNumber)); + } + + // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, + // but using getBoundingClientRect to get a sub-pixel-accurate + // result. + function compensateForHScroll(display) { + return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; + } + + // DISPLAY DRAWING + + // Updates the display, selection, and scrollbars, using the + // information in display.view to find out which nodes are no longer + // up-to-date. Tries to bail out early when no changes are needed, + // unless forced is true. + // Returns true if an actual update happened, false otherwise. + function updateDisplay(cm, viewPort, forced) { + var oldFrom = cm.display.viewFrom, oldTo = cm.display.viewTo, updated; + var visible = visibleLines(cm.display, cm.doc, viewPort); + for (var first = true;; first = false) { + var oldWidth = cm.display.scroller.clientWidth; + if (!updateDisplayInner(cm, visible, forced)) break; + updated = true; + + // If the max line changed since it was last measured, measure it, + // and ensure the document's width matches it. + if (cm.display.maxLineChanged && !cm.options.lineWrapping) + adjustContentWidth(cm); + + var barMeasure = measureForScrollbars(cm); + updateSelection(cm); + setDocumentHeight(cm, barMeasure); + updateScrollbars(cm, barMeasure); + if (webkit && cm.options.lineWrapping) + checkForWebkitWidthBug(cm, barMeasure); // (Issue #2420) + if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) { + forced = true; + continue; + } + forced = false; + + // Clip forced viewport to actual scrollable area. + if (viewPort && viewPort.top != null) + viewPort = {top: Math.min(barMeasure.docHeight - scrollerCutOff - barMeasure.clientHeight, viewPort.top)}; + // Updated line heights might result in the drawn area not + // actually covering the viewport. Keep looping until it does. + visible = visibleLines(cm.display, cm.doc, viewPort); + if (visible.from >= cm.display.viewFrom && visible.to <= cm.display.viewTo) + break; + } + + cm.display.updateLineNumbers = null; + if (updated) { + signalLater(cm, "update", cm); + if (cm.display.viewFrom != oldFrom || cm.display.viewTo != oldTo) + signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); + } + return updated; + } + + // Does the actual updating of the line display. Bails out + // (returning false) when there is nothing to be done and forced is + // false. + function updateDisplayInner(cm, visible, forced) { + var display = cm.display, doc = cm.doc; + if (!display.wrapper.offsetWidth) { + resetView(cm); + return; + } + + // Bail out if the visible area is already rendered and nothing changed. + if (!forced && visible.from >= display.viewFrom && visible.to <= display.viewTo && + countDirtyView(cm) == 0) + return; + + if (maybeUpdateLineNumberWidth(cm)) + resetView(cm); + var dims = getDimensions(cm); + + // Compute a suitable new viewport (from & to) + var end = doc.first + doc.size; + var from = Math.max(visible.from - cm.options.viewportMargin, doc.first); + var to = Math.min(end, visible.to + cm.options.viewportMargin); + if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom); + if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo); + if (sawCollapsedSpans) { + from = visualLineNo(cm.doc, from); + to = visualLineEndNo(cm.doc, to); + } + + var different = from != display.viewFrom || to != display.viewTo || + display.lastSizeC != display.wrapper.clientHeight; + adjustView(cm, from, to); + + display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); + // Position the mover div to align with the current scroll position + cm.display.mover.style.top = display.viewOffset + "px"; + + var toUpdate = countDirtyView(cm); + if (!different && toUpdate == 0 && !forced) return; + + // For big changes, we hide the enclosing element during the + // update, since that speeds up the operations on most browsers. + var focused = activeElt(); + if (toUpdate > 4) display.lineDiv.style.display = "none"; + patchDisplay(cm, display.updateLineNumbers, dims); + if (toUpdate > 4) display.lineDiv.style.display = ""; + // There might have been a widget with a focused element that got + // hidden or updated, if so re-focus it. + if (focused && activeElt() != focused && focused.offsetHeight) focused.focus(); + + // Prevent selection and cursors from interfering with the scroll + // width. + removeChildren(display.cursorDiv); + removeChildren(display.selectionDiv); + + if (different) { + display.lastSizeC = display.wrapper.clientHeight; + startWorker(cm, 400); + } + + updateHeightsInViewport(cm); + + return true; + } + + function adjustContentWidth(cm) { + var display = cm.display; + var width = measureChar(cm, display.maxLine, display.maxLine.text.length).left; + display.maxLineChanged = false; + var minWidth = Math.max(0, width + 3); + var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + minWidth + scrollerCutOff - display.scroller.clientWidth); + display.sizer.style.minWidth = minWidth + "px"; + if (maxScrollLeft < cm.doc.scrollLeft) + setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true); + } + + function setDocumentHeight(cm, measure) { + cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = measure.docHeight + "px"; + cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px"; + } + + + function checkForWebkitWidthBug(cm, measure) { + // Work around Webkit bug where it sometimes reserves space for a + // non-existing phantom scrollbar in the scroller (Issue #2420) + if (cm.display.sizer.offsetWidth + cm.display.gutters.offsetWidth < cm.display.scroller.clientWidth - 1) { + cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = "0px"; + cm.display.gutters.style.height = measure.docHeight + "px"; + } + } + + // Read the actual heights of the rendered lines, and update their + // stored heights to match. + function updateHeightsInViewport(cm) { + var display = cm.display; + var prevBottom = display.lineDiv.offsetTop; + for (var i = 0; i < display.view.length; i++) { + var cur = display.view[i], height; + if (cur.hidden) continue; + if (ie_upto7) { + var bot = cur.node.offsetTop + cur.node.offsetHeight; + height = bot - prevBottom; + prevBottom = bot; + } else { + var box = cur.node.getBoundingClientRect(); + height = box.bottom - box.top; + } + var diff = cur.line.height - height; + if (height < 2) height = textHeight(display); + if (diff > .001 || diff < -.001) { + updateLineHeight(cur.line, height); + updateWidgetHeight(cur.line); + if (cur.rest) for (var j = 0; j < cur.rest.length; j++) + updateWidgetHeight(cur.rest[j]); + } + } + } + + // Read and store the height of line widgets associated with the + // given line. + function updateWidgetHeight(line) { + if (line.widgets) for (var i = 0; i < line.widgets.length; ++i) + line.widgets[i].height = line.widgets[i].node.offsetHeight; + } + + // Do a bulk-read of the DOM positions and sizes needed to draw the + // view, so that we don't interleave reading and writing to the DOM. + function getDimensions(cm) { + var d = cm.display, left = {}, width = {}; + for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { + left[cm.options.gutters[i]] = n.offsetLeft; + width[cm.options.gutters[i]] = n.offsetWidth; + } + return {fixedPos: compensateForHScroll(d), + gutterTotalWidth: d.gutters.offsetWidth, + gutterLeft: left, + gutterWidth: width, + wrapperWidth: d.wrapper.clientWidth}; + } + + // Sync the actual display DOM structure with display.view, removing + // nodes for lines that are no longer in view, and creating the ones + // that are not there yet, and updating the ones that are out of + // date. + function patchDisplay(cm, updateNumbersFrom, dims) { + var display = cm.display, lineNumbers = cm.options.lineNumbers; + var container = display.lineDiv, cur = container.firstChild; + + function rm(node) { + var next = node.nextSibling; + // Works around a throw-scroll bug in OS X Webkit + if (webkit && mac && cm.display.currentWheelTarget == node) + node.style.display = "none"; + else + node.parentNode.removeChild(node); + return next; + } + + var view = display.view, lineN = display.viewFrom; + // Loop over the elements in the view, syncing cur (the DOM nodes + // in display.lineDiv) with the view as we go. + for (var i = 0; i < view.length; i++) { + var lineView = view[i]; + if (lineView.hidden) { + } else if (!lineView.node) { // Not drawn yet + var node = buildLineElement(cm, lineView, lineN, dims); + container.insertBefore(node, cur); + } else { // Already drawn + while (cur != lineView.node) cur = rm(cur); + var updateNumber = lineNumbers && updateNumbersFrom != null && + updateNumbersFrom <= lineN && lineView.lineNumber; + if (lineView.changes) { + if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false; + updateLineForChanges(cm, lineView, lineN, dims); + } + if (updateNumber) { + removeChildren(lineView.lineNumber); + lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); + } + cur = lineView.node.nextSibling; + } + lineN += lineView.size; + } + while (cur) cur = rm(cur); + } + + // When an aspect of a line changes, a string is added to + // lineView.changes. This updates the relevant part of the line's + // DOM structure. + function updateLineForChanges(cm, lineView, lineN, dims) { + for (var j = 0; j < lineView.changes.length; j++) { + var type = lineView.changes[j]; + if (type == "text") updateLineText(cm, lineView); + else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims); + else if (type == "class") updateLineClasses(lineView); + else if (type == "widget") updateLineWidgets(lineView, dims); + } + lineView.changes = null; + } + + // Lines with gutter elements, widgets or a background class need to + // be wrapped, and have the extra elements added to the wrapper div + function ensureLineWrapped(lineView) { + if (lineView.node == lineView.text) { + lineView.node = elt("div", null, null, "position: relative"); + if (lineView.text.parentNode) + lineView.text.parentNode.replaceChild(lineView.node, lineView.text); + lineView.node.appendChild(lineView.text); + if (ie_upto7) lineView.node.style.zIndex = 2; + } + return lineView.node; + } + + function updateLineBackground(lineView) { + var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; + if (cls) cls += " CodeMirror-linebackground"; + if (lineView.background) { + if (cls) lineView.background.className = cls; + else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } + } else if (cls) { + var wrap = ensureLineWrapped(lineView); + lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); + } + } + + // Wrapper around buildLineContent which will reuse the structure + // in display.externalMeasured when possible. + function getLineContent(cm, lineView) { + var ext = cm.display.externalMeasured; + if (ext && ext.line == lineView.line) { + cm.display.externalMeasured = null; + lineView.measure = ext.measure; + return ext.built; + } + return buildLineContent(cm, lineView); + } + + // Redraw the line's text. Interacts with the background and text + // classes because the mode may output tokens that influence these + // classes. + function updateLineText(cm, lineView) { + var cls = lineView.text.className; + var built = getLineContent(cm, lineView); + if (lineView.text == lineView.node) lineView.node = built.pre; + lineView.text.parentNode.replaceChild(built.pre, lineView.text); + lineView.text = built.pre; + if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { + lineView.bgClass = built.bgClass; + lineView.textClass = built.textClass; + updateLineClasses(lineView); + } else if (cls) { + lineView.text.className = cls; + } + } + + function updateLineClasses(lineView) { + updateLineBackground(lineView); + if (lineView.line.wrapClass) + ensureLineWrapped(lineView).className = lineView.line.wrapClass; + else if (lineView.node != lineView.text) + lineView.node.className = ""; + var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; + lineView.text.className = textClass || ""; + } + + function updateLineGutter(cm, lineView, lineN, dims) { + if (lineView.gutter) { + lineView.node.removeChild(lineView.gutter); + lineView.gutter = null; + } + var markers = lineView.line.gutterMarkers; + if (cm.options.lineNumbers || markers) { + var wrap = ensureLineWrapped(lineView); + var gutterWrap = lineView.gutter = + wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " + + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"), + lineView.text); + if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) + lineView.lineNumber = gutterWrap.appendChild( + elt("div", lineNumberFor(cm.options, lineN), + "CodeMirror-linenumber CodeMirror-gutter-elt", + "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + + cm.display.lineNumInnerWidth + "px")); + if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) { + var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; + if (found) + gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); + } + } + } + + function updateLineWidgets(lineView, dims) { + if (lineView.alignable) lineView.alignable = null; + for (var node = lineView.node.firstChild, next; node; node = next) { + var next = node.nextSibling; + if (node.className == "CodeMirror-linewidget") + lineView.node.removeChild(node); + } + insertLineWidgets(lineView, dims); + } + + // Build a line's DOM representation from scratch + function buildLineElement(cm, lineView, lineN, dims) { + var built = getLineContent(cm, lineView); + lineView.text = lineView.node = built.pre; + if (built.bgClass) lineView.bgClass = built.bgClass; + if (built.textClass) lineView.textClass = built.textClass; + + updateLineClasses(lineView); + updateLineGutter(cm, lineView, lineN, dims); + insertLineWidgets(lineView, dims); + return lineView.node; + } + + // A lineView may contain multiple logical lines (when merged by + // collapsed spans). The widgets for all of them need to be drawn. + function insertLineWidgets(lineView, dims) { + insertLineWidgetsFor(lineView.line, lineView, dims, true); + if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) + insertLineWidgetsFor(lineView.rest[i], lineView, dims, false); + } + + function insertLineWidgetsFor(line, lineView, dims, allowAbove) { + if (!line.widgets) return; + var wrap = ensureLineWrapped(lineView); + for (var i = 0, ws = line.widgets; i < ws.length; ++i) { + var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget"); + if (!widget.handleMouseEvents) node.ignoreEvents = true; + positionLineWidget(widget, node, lineView, dims); + if (allowAbove && widget.above) + wrap.insertBefore(node, lineView.gutter || lineView.text); + else + wrap.appendChild(node); + signalLater(widget, "redraw"); + } + } + + function positionLineWidget(widget, node, lineView, dims) { + if (widget.noHScroll) { + (lineView.alignable || (lineView.alignable = [])).push(node); + var width = dims.wrapperWidth; + node.style.left = dims.fixedPos + "px"; + if (!widget.coverGutter) { + width -= dims.gutterTotalWidth; + node.style.paddingLeft = dims.gutterTotalWidth + "px"; + } + node.style.width = width + "px"; + } + if (widget.coverGutter) { + node.style.zIndex = 5; + node.style.position = "relative"; + if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px"; + } + } + + // POSITION OBJECT + + // A Pos instance represents a position within the text. + var Pos = CodeMirror.Pos = function(line, ch) { + if (!(this instanceof Pos)) return new Pos(line, ch); + this.line = line; this.ch = ch; + }; + + // Compare two positions, return 0 if they are the same, a negative + // number when a is less, and a positive number otherwise. + var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; }; + + function copyPos(x) {return Pos(x.line, x.ch);} + function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; } + function minPos(a, b) { return cmp(a, b) < 0 ? a : b; } + + // SELECTION / CURSOR + + // Selection objects are immutable. A new one is created every time + // the selection changes. A selection is one or more non-overlapping + // (and non-touching) ranges, sorted, and an integer that indicates + // which one is the primary selection (the one that's scrolled into + // view, that getCursor returns, etc). + function Selection(ranges, primIndex) { + this.ranges = ranges; + this.primIndex = primIndex; + } + + Selection.prototype = { + primary: function() { return this.ranges[this.primIndex]; }, + equals: function(other) { + if (other == this) return true; + if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false; + for (var i = 0; i < this.ranges.length; i++) { + var here = this.ranges[i], there = other.ranges[i]; + if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false; + } + return true; + }, + deepCopy: function() { + for (var out = [], i = 0; i < this.ranges.length; i++) + out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); + return new Selection(out, this.primIndex); + }, + somethingSelected: function() { + for (var i = 0; i < this.ranges.length; i++) + if (!this.ranges[i].empty()) return true; + return false; + }, + contains: function(pos, end) { + if (!end) end = pos; + for (var i = 0; i < this.ranges.length; i++) { + var range = this.ranges[i]; + if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) + return i; + } + return -1; + } + }; + + function Range(anchor, head) { + this.anchor = anchor; this.head = head; + } + + Range.prototype = { + from: function() { return minPos(this.anchor, this.head); }, + to: function() { return maxPos(this.anchor, this.head); }, + empty: function() { + return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; + } + }; + + // Take an unsorted, potentially overlapping set of ranges, and + // build a selection out of it. 'Consumes' ranges array (modifying + // it). + function normalizeSelection(ranges, primIndex) { + var prim = ranges[primIndex]; + ranges.sort(function(a, b) { return cmp(a.from(), b.from()); }); + primIndex = indexOf(ranges, prim); + for (var i = 1; i < ranges.length; i++) { + var cur = ranges[i], prev = ranges[i - 1]; + if (cmp(prev.to(), cur.from()) >= 0) { + var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); + var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; + if (i <= primIndex) --primIndex; + ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); + } + } + return new Selection(ranges, primIndex); + } + + function simpleSelection(anchor, head) { + return new Selection([new Range(anchor, head || anchor)], 0); + } + + // Most of the external API clips given positions to make sure they + // actually exist within the document. + function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));} + function clipPos(doc, pos) { + if (pos.line < doc.first) return Pos(doc.first, 0); + var last = doc.first + doc.size - 1; + if (pos.line > last) return Pos(last, getLine(doc, last).text.length); + return clipToLen(pos, getLine(doc, pos.line).text.length); + } + function clipToLen(pos, linelen) { + var ch = pos.ch; + if (ch == null || ch > linelen) return Pos(pos.line, linelen); + else if (ch < 0) return Pos(pos.line, 0); + else return pos; + } + function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} + function clipPosArray(doc, array) { + for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); + return out; + } + + // SELECTION UPDATES + + // The 'scroll' parameter given to many of these indicated whether + // the new cursor position should be scrolled into view after + // modifying the selection. + + // If shift is held or the extend flag is set, extends a range to + // include a given position (and optionally a second position). + // Otherwise, simply returns the range between the given positions. + // Used for cursor motion and such. + function extendRange(doc, range, head, other) { + if (doc.cm && doc.cm.display.shift || doc.extend) { + var anchor = range.anchor; + if (other) { + var posBefore = cmp(head, anchor) < 0; + if (posBefore != (cmp(other, anchor) < 0)) { + anchor = head; + head = other; + } else if (posBefore != (cmp(head, other) < 0)) { + head = other; + } + } + return new Range(anchor, head); + } else { + return new Range(other || head, head); + } + } + + // Extend the primary selection range, discard the rest. + function extendSelection(doc, head, other, options) { + setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options); + } + + // Extend all selections (pos is an array of selections with length + // equal the number of selections) + function extendSelections(doc, heads, options) { + for (var out = [], i = 0; i < doc.sel.ranges.length; i++) + ... [truncated message content] |
From: <tob...@us...> - 2014-05-09 11:33:55
|
Revision: 8244 http://sourceforge.net/p/bigdata/code/8244 Author: tobycraig Date: 2014-05-09 11:33:52 +0000 (Fri, 09 May 2014) Log Message: ----------- Added SPARQL syntax highlighting for query panel Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/sparql.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-09 11:14:35 UTC (rev 8243) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-09 11:33:52 UTC (rev 8244) @@ -221,6 +221,7 @@ <script src="/bigdata/html/js/vendor/jquery.hotkeys.js"></script> <script src="/bigdata/html/js/vendor/codemirror.js"></script> <script src="/bigdata/html/js/vendor/cm-addons/placeholder.js"></script> + <script src="/bigdata/html/js/vendor/cm-modes/sparql.js"></script> <script src="/bigdata/html/js/workbench.js"></script> </body> </html> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/sparql.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/sparql.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/sparql.js 2014-05-09 11:33:52 UTC (rev 8244) @@ -0,0 +1,157 @@ +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("sparql", function(config) { + var indentUnit = config.indentUnit; + var curPunc; + + function wordRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$", "i"); + } + var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri", + "isblank", "isliteral", "a"]); + var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe", + "ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional", + "graph", "by", "asc", "desc", "as", "having", "undef", "values", "group", + "minus", "in", "not", "service", "silent", "using", "insert", "delete", "union", + "data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]); + var operatorChars = /[*+\-<>=&|]/; + + function tokenBase(stream, state) { + var ch = stream.next(); + curPunc = null; + if (ch == "$" || ch == "?") { + stream.match(/^[\w\d]*/); + return "variable-2"; + } + else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) { + stream.match(/^[^\s\u00a0>]*>?/); + return "atom"; + } + else if (ch == "\"" || ch == "'") { + state.tokenize = tokenLiteral(ch); + return state.tokenize(stream, state); + } + else if (/[{}\(\),\.;\[\]]/.test(ch)) { + curPunc = ch; + return null; + } + else if (ch == "#") { + stream.skipToEnd(); + return "comment"; + } + else if (operatorChars.test(ch)) { + stream.eatWhile(operatorChars); + return null; + } + else if (ch == ":") { + stream.eatWhile(/[\w\d\._\-]/); + return "atom"; + } + else { + stream.eatWhile(/[_\w\d]/); + if (stream.eat(":")) { + stream.eatWhile(/[\w\d_\-]/); + return "atom"; + } + var word = stream.current(); + if (ops.test(word)) + return null; + else if (keywords.test(word)) + return "keyword"; + else + return "variable"; + } + } + + function tokenLiteral(quote) { + return function(stream, state) { + var escaped = false, ch; + while ((ch = stream.next()) != null) { + if (ch == quote && !escaped) { + state.tokenize = tokenBase; + break; + } + escaped = !escaped && ch == "\\"; + } + return "string"; + }; + } + + function pushContext(state, type, col) { + state.context = {prev: state.context, indent: state.indent, col: col, type: type}; + } + function popContext(state) { + state.indent = state.context.indent; + state.context = state.context.prev; + } + + return { + startState: function() { + return {tokenize: tokenBase, + context: null, + indent: 0, + col: 0}; + }, + + token: function(stream, state) { + if (stream.sol()) { + if (state.context && state.context.align == null) state.context.align = false; + state.indent = stream.indentation(); + } + if (stream.eatSpace()) return null; + var style = state.tokenize(stream, state); + + if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") { + state.context.align = true; + } + + if (curPunc == "(") pushContext(state, ")", stream.column()); + else if (curPunc == "[") pushContext(state, "]", stream.column()); + else if (curPunc == "{") pushContext(state, "}", stream.column()); + else if (/[\]\}\)]/.test(curPunc)) { + while (state.context && state.context.type == "pattern") popContext(state); + if (state.context && curPunc == state.context.type) popContext(state); + } + else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state); + else if (/atom|string|variable/.test(style) && state.context) { + if (/[\}\]]/.test(state.context.type)) + pushContext(state, "pattern", stream.column()); + else if (state.context.type == "pattern" && !state.context.align) { + state.context.align = true; + state.context.col = stream.column(); + } + } + + return style; + }, + + indent: function(state, textAfter) { + var firstChar = textAfter && textAfter.charAt(0); + var context = state.context; + if (/[\]\}]/.test(firstChar)) + while (context && context.type == "pattern") context = context.prev; + + var closing = context && firstChar == context.type; + if (!context) + return 0; + else if (context.type == "pattern") + return context.col; + else if (context.align) + return context.col + (closing ? 0 : 1); + else + return context.indent + (closing ? 0 : indentUnit); + } + }; +}); + +CodeMirror.defineMIME("application/x-sparql-query", "sparql"); + +}); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-09 11:14:35 UTC (rev 8243) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-09 11:33:52 UTC (rev 8244) @@ -510,7 +510,7 @@ } }); -QUERY_EDITOR = CodeMirror.fromTextArea($('#query-box')[0], {lineNumbers: true}); +QUERY_EDITOR = CodeMirror.fromTextArea($('#query-box')[0], {lineNumbers: true, mode: 'sparql'}); function submitQuery(e) { e.preventDefault(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-05-09 11:55:24
|
Revision: 8245 http://sourceforge.net/p/bigdata/code/8245 Author: tobycraig Date: 2014-05-09 11:55:20 +0000 (Fri, 09 May 2014) Log Message: ----------- Added support for syntax highlighting to update panel, switching mode according to selected type/format Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/javascript.js branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/ntriples.js branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/turtle.js branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/xml.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-09 11:33:52 UTC (rev 8244) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-05-09 11:55:20 UTC (rev 8245) @@ -221,7 +221,11 @@ <script src="/bigdata/html/js/vendor/jquery.hotkeys.js"></script> <script src="/bigdata/html/js/vendor/codemirror.js"></script> <script src="/bigdata/html/js/vendor/cm-addons/placeholder.js"></script> + <script src="/bigdata/html/js/vendor/cm-modes/javascript.js"></script> + <script src="/bigdata/html/js/vendor/cm-modes/ntriples.js"></script> <script src="/bigdata/html/js/vendor/cm-modes/sparql.js"></script> + <script src="/bigdata/html/js/vendor/cm-modes/turtle.js"></script> + <script src="/bigdata/html/js/vendor/cm-modes/xml.js"></script> <script src="/bigdata/html/js/workbench.js"></script> </body> </html> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/javascript.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/javascript.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/javascript.js 2014-05-09 11:55:20 UTC (rev 8245) @@ -0,0 +1,660 @@ +// TODO actually recognize syntax of TypeScript constructs + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("javascript", function(config, parserConfig) { + var indentUnit = config.indentUnit; + var statementIndent = parserConfig.statementIndent; + var jsonldMode = parserConfig.jsonld; + var jsonMode = parserConfig.json || jsonldMode; + var isTS = parserConfig.typescript; + + // Tokenizer + + var keywords = function(){ + function kw(type) {return {type: type, style: "keyword"};} + var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); + var operator = kw("operator"), atom = {type: "atom", style: "atom"}; + + var jsKeywords = { + "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, + "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C, + "var": kw("var"), "const": kw("var"), "let": kw("var"), + "function": kw("function"), "catch": kw("catch"), + "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), + "in": operator, "typeof": operator, "instanceof": operator, + "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, + "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"), + "yield": C, "export": kw("export"), "import": kw("import"), "extends": C + }; + + // Extend the 'normal' keywords with the TypeScript language extensions + if (isTS) { + var type = {type: "variable", style: "variable-3"}; + var tsKeywords = { + // object-like things + "interface": kw("interface"), + "extends": kw("extends"), + "constructor": kw("constructor"), + + // scope modifiers + "public": kw("public"), + "private": kw("private"), + "protected": kw("protected"), + "static": kw("static"), + + // types + "string": type, "number": type, "bool": type, "any": type + }; + + for (var attr in tsKeywords) { + jsKeywords[attr] = tsKeywords[attr]; + } + } + + return jsKeywords; + }(); + + var isOperatorChar = /[+\-*&%=<>!?|~^]/; + var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; + + function readRegexp(stream) { + var escaped = false, next, inSet = false; + while ((next = stream.next()) != null) { + if (!escaped) { + if (next == "/" && !inSet) return; + if (next == "[") inSet = true; + else if (inSet && next == "]") inSet = false; + } + escaped = !escaped && next == "\\"; + } + } + + // Used as scratch variables to communicate multiple values without + // consing up tons of objects. + var type, content; + function ret(tp, style, cont) { + type = tp; content = cont; + return style; + } + function tokenBase(stream, state) { + var ch = stream.next(); + if (ch == '"' || ch == "'") { + state.tokenize = tokenString(ch); + return state.tokenize(stream, state); + } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) { + return ret("number", "number"); + } else if (ch == "." && stream.match("..")) { + return ret("spread", "meta"); + } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { + return ret(ch); + } else if (ch == "=" && stream.eat(">")) { + return ret("=>", "operator"); + } else if (ch == "0" && stream.eat(/x/i)) { + stream.eatWhile(/[\da-f]/i); + return ret("number", "number"); + } else if (/\d/.test(ch)) { + stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); + return ret("number", "number"); + } else if (ch == "/") { + if (stream.eat("*")) { + state.tokenize = tokenComment; + return tokenComment(stream, state); + } else if (stream.eat("/")) { + stream.skipToEnd(); + return ret("comment", "comment"); + } else if (state.lastType == "operator" || state.lastType == "keyword c" || + state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) { + readRegexp(stream); + stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla + return ret("regexp", "string-2"); + } else { + stream.eatWhile(isOperatorChar); + return ret("operator", "operator", stream.current()); + } + } else if (ch == "`") { + state.tokenize = tokenQuasi; + return tokenQuasi(stream, state); + } else if (ch == "#") { + stream.skipToEnd(); + return ret("error", "error"); + } else if (isOperatorChar.test(ch)) { + stream.eatWhile(isOperatorChar); + return ret("operator", "operator", stream.current()); + } else { + stream.eatWhile(/[\w\$_]/); + var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; + return (known && state.lastType != ".") ? ret(known.type, known.style, word) : + ret("variable", "variable", word); + } + } + + function tokenString(quote) { + return function(stream, state) { + var escaped = false, next; + if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){ + state.tokenize = tokenBase; + return ret("jsonld-keyword", "meta"); + } + while ((next = stream.next()) != null) { + if (next == quote && !escaped) break; + escaped = !escaped && next == "\\"; + } + if (!escaped) state.tokenize = tokenBase; + return ret("string", "string"); + }; + } + + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while (ch = stream.next()) { + if (ch == "/" && maybeEnd) { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch == "*"); + } + return ret("comment", "comment"); + } + + function tokenQuasi(stream, state) { + var escaped = false, next; + while ((next = stream.next()) != null) { + if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) { + state.tokenize = tokenBase; + break; + } + escaped = !escaped && next == "\\"; + } + return ret("quasi", "string-2", stream.current()); + } + + var brackets = "([{}])"; + // This is a crude lookahead trick to try and notice that we're + // parsing the argument patterns for a fat-arrow function before we + // actually hit the arrow token. It only works if the arrow is on + // the same line as the arguments and there's no strange noise + // (comments) in between. Fallback is to only notice when we hit the + // arrow, and not declare the arguments as locals for the arrow + // body. + function findFatArrow(stream, state) { + if (state.fatArrowAt) state.fatArrowAt = null; + var arrow = stream.string.indexOf("=>", stream.start); + if (arrow < 0) return; + + var depth = 0, sawSomething = false; + for (var pos = arrow - 1; pos >= 0; --pos) { + var ch = stream.string.charAt(pos); + var bracket = brackets.indexOf(ch); + if (bracket >= 0 && bracket < 3) { + if (!depth) { ++pos; break; } + if (--depth == 0) break; + } else if (bracket >= 3 && bracket < 6) { + ++depth; + } else if (/[$\w]/.test(ch)) { + sawSomething = true; + } else if (sawSomething && !depth) { + ++pos; + break; + } + } + if (sawSomething && !depth) state.fatArrowAt = pos; + } + + // Parser + + var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true}; + + function JSLexical(indented, column, type, align, prev, info) { + this.indented = indented; + this.column = column; + this.type = type; + this.prev = prev; + this.info = info; + if (align != null) this.align = align; + } + + function inScope(state, varname) { + for (var v = state.localVars; v; v = v.next) + if (v.name == varname) return true; + for (var cx = state.context; cx; cx = cx.prev) { + for (var v = cx.vars; v; v = v.next) + if (v.name == varname) return true; + } + } + + function parseJS(state, style, type, content, stream) { + var cc = state.cc; + // Communicate our context to the combinators. + // (Less wasteful than consing up a hundred closures on every call.) + cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; + + if (!state.lexical.hasOwnProperty("align")) + state.lexical.align = true; + + while(true) { + var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement; + if (combinator(type, content)) { + while(cc.length && cc[cc.length - 1].lex) + cc.pop()(); + if (cx.marked) return cx.marked; + if (type == "variable" && inScope(state, content)) return "variable-2"; + return style; + } + } + } + + // Combinator utils + + var cx = {state: null, column: null, marked: null, cc: null}; + function pass() { + for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); + } + function cont() { + pass.apply(null, arguments); + return true; + } + function register(varname) { + function inList(list) { + for (var v = list; v; v = v.next) + if (v.name == varname) return true; + return false; + } + var state = cx.state; + if (state.context) { + cx.marked = "def"; + if (inList(state.localVars)) return; + state.localVars = {name: varname, next: state.localVars}; + } else { + if (inList(state.globalVars)) return; + if (parserConfig.globalVars) + state.globalVars = {name: varname, next: state.globalVars}; + } + } + + // Combinators + + var defaultVars = {name: "this", next: {name: "arguments"}}; + function pushcontext() { + cx.state.context = {prev: cx.state.context, vars: cx.state.localVars}; + cx.state.localVars = defaultVars; + } + function popcontext() { + cx.state.localVars = cx.state.context.vars; + cx.state.context = cx.state.context.prev; + } + function pushlex(type, info) { + var result = function() { + var state = cx.state, indent = state.indented; + if (state.lexical.type == "stat") indent = state.lexical.indented; + state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info); + }; + result.lex = true; + return result; + } + function poplex() { + var state = cx.state; + if (state.lexical.prev) { + if (state.lexical.type == ")") + state.indented = state.lexical.indented; + state.lexical = state.lexical.prev; + } + } + poplex.lex = true; + + function expect(wanted) { + function exp(type) { + if (type == wanted) return cont(); + else if (wanted == ";") return pass(); + else return cont(exp); + }; + return exp; + } + + function statement(type, value) { + if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex); + if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex); + if (type == "keyword b") return cont(pushlex("form"), statement, poplex); + if (type == "{") return cont(pushlex("}"), block, poplex); + if (type == ";") return cont(); + if (type == "if") { + if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) + cx.state.cc.pop()(); + return cont(pushlex("form"), expression, statement, poplex, maybeelse); + } + if (type == "function") return cont(functiondef); + if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); + if (type == "variable") return cont(pushlex("stat"), maybelabel); + if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), + block, poplex, poplex); + if (type == "case") return cont(expression, expect(":")); + if (type == "default") return cont(expect(":")); + if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), + statement, poplex, popcontext); + if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex); + if (type == "class") return cont(pushlex("form"), className, objlit, poplex); + if (type == "export") return cont(pushlex("form"), afterExport, poplex); + if (type == "import") return cont(pushlex("form"), afterImport, poplex); + return pass(pushlex("stat"), expression, expect(";"), poplex); + } + function expression(type) { + return expressionInner(type, false); + } + function expressionNoComma(type) { + return expressionInner(type, true); + } + function expressionInner(type, noComma) { + if (cx.state.fatArrowAt == cx.stream.start) { + var body = noComma ? arrowBodyNoComma : arrowBody; + if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext); + else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext); + } + + var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; + if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); + if (type == "function") return cont(functiondef, maybeop); + if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression); + if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop); + if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); + if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); + if (type == "{") return contCommasep(objprop, "}", null, maybeop); + if (type == "quasi") { return pass(quasi, maybeop); } + return cont(); + } + function maybeexpression(type) { + if (type.match(/[;\}\)\],]/)) return pass(); + return pass(expression); + } + function maybeexpressionNoComma(type) { + if (type.match(/[;\}\)\],]/)) return pass(); + return pass(expressionNoComma); + } + + function maybeoperatorComma(type, value) { + if (type == ",") return cont(expression); + return maybeoperatorNoComma(type, value, false); + } + function maybeoperatorNoComma(type, value, noComma) { + var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma; + var expr = noComma == false ? expression : expressionNoComma; + if (value == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); + if (type == "operator") { + if (/\+\+|--/.test(value)) return cont(me); + if (value == "?") return cont(expression, expect(":"), expr); + return cont(expr); + } + if (type == "quasi") { return pass(quasi, me); } + if (type == ";") return; + if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); + if (type == ".") return cont(property, me); + if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me); + } + function quasi(type, value) { + if (type != "quasi") return pass(); + if (value.slice(value.length - 2) != "${") return cont(quasi); + return cont(expression, continueQuasi); + } + function continueQuasi(type) { + if (type == "}") { + cx.marked = "string-2"; + cx.state.tokenize = tokenQuasi; + return cont(quasi); + } + } + function arrowBody(type) { + findFatArrow(cx.stream, cx.state); + if (type == "{") return pass(statement); + return pass(expression); + } + function arrowBodyNoComma(type) { + findFatArrow(cx.stream, cx.state); + if (type == "{") return pass(statement); + return pass(expressionNoComma); + } + function maybelabel(type) { + if (type == ":") return cont(poplex, statement); + return pass(maybeoperatorComma, expect(";"), poplex); + } + function property(type) { + if (type == "variable") {cx.marked = "property"; return cont();} + } + function objprop(type, value) { + if (type == "variable") { + cx.marked = "property"; + if (value == "get" || value == "set") return cont(getterSetter); + } else if (type == "number" || type == "string") { + cx.marked = jsonldMode ? "property" : (type + " property"); + } else if (type == "[") { + return cont(expression, expect("]"), afterprop); + } + if (atomicTypes.hasOwnProperty(type)) return cont(afterprop); + } + function getterSetter(type) { + if (type != "variable") return pass(afterprop); + cx.marked = "property"; + return cont(functiondef); + } + function afterprop(type) { + if (type == ":") return cont(expressionNoComma); + if (type == "(") return pass(functiondef); + } + function commasep(what, end) { + function proceed(type) { + if (type == ",") { + var lex = cx.state.lexical; + if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; + return cont(what, proceed); + } + if (type == end) return cont(); + return cont(expect(end)); + } + return function(type) { + if (type == end) return cont(); + return pass(what, proceed); + }; + } + function contCommasep(what, end, info) { + for (var i = 3; i < arguments.length; i++) + cx.cc.push(arguments[i]); + return cont(pushlex(end, info), commasep(what, end), poplex); + } + function block(type) { + if (type == "}") return cont(); + return pass(statement, block); + } + function maybetype(type) { + if (isTS && type == ":") return cont(typedef); + } + function typedef(type) { + if (type == "variable"){cx.marked = "variable-3"; return cont();} + } + function vardef() { + return pass(pattern, maybetype, maybeAssign, vardefCont); + } + function pattern(type, value) { + if (type == "variable") { register(value); return cont(); } + if (type == "[") return contCommasep(pattern, "]"); + if (type == "{") return contCommasep(proppattern, "}"); + } + function proppattern(type, value) { + if (type == "variable" && !cx.stream.match(/^\s*:/, false)) { + register(value); + return cont(maybeAssign); + } + if (type == "variable") cx.marked = "property"; + return cont(expect(":"), pattern, maybeAssign); + } + function maybeAssign(_type, value) { + if (value == "=") return cont(expressionNoComma); + } + function vardefCont(type) { + if (type == ",") return cont(vardef); + } + function maybeelse(type, value) { + if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); + } + function forspec(type) { + if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex); + } + function forspec1(type) { + if (type == "var") return cont(vardef, expect(";"), forspec2); + if (type == ";") return cont(forspec2); + if (type == "variable") return cont(formaybeinof); + return pass(expression, expect(";"), forspec2); + } + function formaybeinof(_type, value) { + if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); } + return cont(maybeoperatorComma, forspec2); + } + function forspec2(type, value) { + if (type == ";") return cont(forspec3); + if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); } + return pass(expression, expect(";"), forspec3); + } + function forspec3(type) { + if (type != ")") cont(expression); + } + function functiondef(type, value) { + if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} + if (type == "variable") {register(value); return cont(functiondef);} + if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext); + } + function funarg(type) { + if (type == "spread") return cont(funarg); + return pass(pattern, maybetype); + } + function className(type, value) { + if (type == "variable") {register(value); return cont(classNameAfter);} + } + function classNameAfter(_type, value) { + if (value == "extends") return cont(expression); + } + function objlit(type) { + if (type == "{") return contCommasep(objprop, "}"); + } + function afterModule(type, value) { + if (type == "string") return cont(statement); + if (type == "variable") { register(value); return cont(maybeFrom); } + } + function afterExport(_type, value) { + if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } + if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } + return pass(statement); + } + function afterImport(type) { + if (type == "string") return cont(); + return pass(importSpec, maybeFrom); + } + function importSpec(type, value) { + if (type == "{") return contCommasep(importSpec, "}"); + if (type == "variable") register(value); + return cont(); + } + function maybeFrom(_type, value) { + if (value == "from") { cx.marked = "keyword"; return cont(expression); } + } + function arrayLiteral(type) { + if (type == "]") return cont(); + return pass(expressionNoComma, maybeArrayComprehension); + } + function maybeArrayComprehension(type) { + if (type == "for") return pass(comprehension, expect("]")); + if (type == ",") return cont(commasep(expressionNoComma, "]")); + return pass(commasep(expressionNoComma, "]")); + } + function comprehension(type) { + if (type == "for") return cont(forspec, comprehension); + if (type == "if") return cont(expression, comprehension); + } + + // Interface + + return { + startState: function(basecolumn) { + var state = { + tokenize: tokenBase, + lastType: "sof", + cc: [], + lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), + localVars: parserConfig.localVars, + context: parserConfig.localVars && {vars: parserConfig.localVars}, + indented: 0 + }; + if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") + state.globalVars = parserConfig.globalVars; + return state; + }, + + token: function(stream, state) { + if (stream.sol()) { + if (!state.lexical.hasOwnProperty("align")) + state.lexical.align = false; + state.indented = stream.indentation(); + findFatArrow(stream, state); + } + if (state.tokenize != tokenComment && stream.eatSpace()) return null; + var style = state.tokenize(stream, state); + if (type == "comment") return style; + state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type; + return parseJS(state, style, type, content, stream); + }, + + indent: function(state, textAfter) { + if (state.tokenize == tokenComment) return CodeMirror.Pass; + if (state.tokenize != tokenBase) return 0; + var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical; + // Kludge to prevent 'maybelse' from blocking lexical scope pops + if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { + var c = state.cc[i]; + if (c == poplex) lexical = lexical.prev; + else if (c != maybeelse) break; + } + if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev; + if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") + lexical = lexical.prev; + var type = lexical.type, closing = firstChar == type; + + if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0); + else if (type == "form" && firstChar == "{") return lexical.indented; + else if (type == "form") return lexical.indented + indentUnit; + else if (type == "stat") + return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0); + else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false) + return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit); + else if (lexical.align) return lexical.column + (closing ? 0 : 1); + else return lexical.indented + (closing ? 0 : indentUnit); + }, + + electricChars: ":{}", + blockCommentStart: jsonMode ? null : "/*", + blockCommentEnd: jsonMode ? null : "*/", + lineComment: jsonMode ? null : "//", + fold: "brace", + + helperType: jsonMode ? "json" : "javascript", + jsonldMode: jsonldMode, + jsonMode: jsonMode + }; +}); + +CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/); + +CodeMirror.defineMIME("text/javascript", "javascript"); +CodeMirror.defineMIME("text/ecmascript", "javascript"); +CodeMirror.defineMIME("application/javascript", "javascript"); +CodeMirror.defineMIME("application/ecmascript", "javascript"); +CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); +CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); +CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); + +}); Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/ntriples.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/ntriples.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/ntriples.js 2014-05-09 11:55:20 UTC (rev 8245) @@ -0,0 +1,183 @@ +/********************************************************** +* This script provides syntax highlighting support for +* the Ntriples format. +* Ntriples format specification: +* http://www.w3.org/TR/rdf-testcases/#ntriples +***********************************************************/ + +/* + The following expression defines the defined ASF grammar transitions. + + pre_subject -> + { + ( writing_subject_uri | writing_bnode_uri ) + -> pre_predicate + -> writing_predicate_uri + -> pre_object + -> writing_object_uri | writing_object_bnode | + ( + writing_object_literal + -> writing_literal_lang | writing_literal_type + ) + -> post_object + -> BEGIN + } otherwise { + -> ERROR + } +*/ + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("ntriples", function() { + + var Location = { + PRE_SUBJECT : 0, + WRITING_SUB_URI : 1, + WRITING_BNODE_URI : 2, + PRE_PRED : 3, + WRITING_PRED_URI : 4, + PRE_OBJ : 5, + WRITING_OBJ_URI : 6, + WRITING_OBJ_BNODE : 7, + WRITING_OBJ_LITERAL : 8, + WRITING_LIT_LANG : 9, + WRITING_LIT_TYPE : 10, + POST_OBJ : 11, + ERROR : 12 + }; + function transitState(currState, c) { + var currLocation = currState.location; + var ret; + + // Opening. + if (currLocation == Location.PRE_SUBJECT && c == '<') ret = Location.WRITING_SUB_URI; + else if(currLocation == Location.PRE_SUBJECT && c == '_') ret = Location.WRITING_BNODE_URI; + else if(currLocation == Location.PRE_PRED && c == '<') ret = Location.WRITING_PRED_URI; + else if(currLocation == Location.PRE_OBJ && c == '<') ret = Location.WRITING_OBJ_URI; + else if(currLocation == Location.PRE_OBJ && c == '_') ret = Location.WRITING_OBJ_BNODE; + else if(currLocation == Location.PRE_OBJ && c == '"') ret = Location.WRITING_OBJ_LITERAL; + + // Closing. + else if(currLocation == Location.WRITING_SUB_URI && c == '>') ret = Location.PRE_PRED; + else if(currLocation == Location.WRITING_BNODE_URI && c == ' ') ret = Location.PRE_PRED; + else if(currLocation == Location.WRITING_PRED_URI && c == '>') ret = Location.PRE_OBJ; + else if(currLocation == Location.WRITING_OBJ_URI && c == '>') ret = Location.POST_OBJ; + else if(currLocation == Location.WRITING_OBJ_BNODE && c == ' ') ret = Location.POST_OBJ; + else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '"') ret = Location.POST_OBJ; + else if(currLocation == Location.WRITING_LIT_LANG && c == ' ') ret = Location.POST_OBJ; + else if(currLocation == Location.WRITING_LIT_TYPE && c == '>') ret = Location.POST_OBJ; + + // Closing typed and language literal. + else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '@') ret = Location.WRITING_LIT_LANG; + else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '^') ret = Location.WRITING_LIT_TYPE; + + // Spaces. + else if( c == ' ' && + ( + currLocation == Location.PRE_SUBJECT || + currLocation == Location.PRE_PRED || + currLocation == Location.PRE_OBJ || + currLocation == Location.POST_OBJ + ) + ) ret = currLocation; + + // Reset. + else if(currLocation == Location.POST_OBJ && c == '.') ret = Location.PRE_SUBJECT; + + // Error + else ret = Location.ERROR; + + currState.location=ret; + } + + return { + startState: function() { + return { + location : Location.PRE_SUBJECT, + uris : [], + anchors : [], + bnodes : [], + langs : [], + types : [] + }; + }, + token: function(stream, state) { + var ch = stream.next(); + if(ch == '<') { + transitState(state, ch); + var parsedURI = ''; + stream.eatWhile( function(c) { if( c != '#' && c != '>' ) { parsedURI += c; return true; } return false;} ); + state.uris.push(parsedURI); + if( stream.match('#', false) ) return 'variable'; + stream.next(); + transitState(state, '>'); + return 'variable'; + } + if(ch == '#') { + var parsedAnchor = ''; + stream.eatWhile(function(c) { if(c != '>' && c != ' ') { parsedAnchor+= c; return true; } return false;}); + state.anchors.push(parsedAnchor); + return 'variable-2'; + } + if(ch == '>') { + transitState(state, '>'); + return 'variable'; + } + if(ch == '_') { + transitState(state, ch); + var parsedBNode = ''; + stream.eatWhile(function(c) { if( c != ' ' ) { parsedBNode += c; return true; } return false;}); + state.bnodes.push(parsedBNode); + stream.next(); + transitState(state, ' '); + return 'builtin'; + } + if(ch == '"') { + transitState(state, ch); + stream.eatWhile( function(c) { return c != '"'; } ); + stream.next(); + if( stream.peek() != '@' && stream.peek() != '^' ) { + transitState(state, '"'); + } + return 'string'; + } + if( ch == '@' ) { + transitState(state, '@'); + var parsedLang = ''; + stream.eatWhile(function(c) { if( c != ' ' ) { parsedLang += c; return true; } return false;}); + state.langs.push(parsedLang); + stream.next(); + transitState(state, ' '); + return 'string-2'; + } + if( ch == '^' ) { + stream.next(); + transitState(state, '^'); + var parsedType = ''; + stream.eatWhile(function(c) { if( c != '>' ) { parsedType += c; return true; } return false;} ); + state.types.push(parsedType); + stream.next(); + transitState(state, '>'); + return 'variable'; + } + if( ch == ' ' ) { + transitState(state, ch); + } + if( ch == '.' ) { + transitState(state, ch); + } + } + }; +}); + +CodeMirror.defineMIME("text/n-triples", "ntriples"); + +}); Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/turtle.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/turtle.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/turtle.js 2014-05-09 11:55:20 UTC (rev 8245) @@ -0,0 +1,157 @@ +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("turtle", function(config) { + var indentUnit = config.indentUnit; + var curPunc; + + function wordRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$", "i"); + } + var ops = wordRegexp([]); + var keywords = wordRegexp(["@prefix", "@base", "a"]); + var operatorChars = /[*+\-<>=&|]/; + + function tokenBase(stream, state) { + var ch = stream.next(); + curPunc = null; + if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) { + stream.match(/^[^\s\u00a0>]*>?/); + return "atom"; + } + else if (ch == "\"" || ch == "'") { + state.tokenize = tokenLiteral(ch); + return state.tokenize(stream, state); + } + else if (/[{}\(\),\.;\[\]]/.test(ch)) { + curPunc = ch; + return null; + } + else if (ch == "#") { + stream.skipToEnd(); + return "comment"; + } + else if (operatorChars.test(ch)) { + stream.eatWhile(operatorChars); + return null; + } + else if (ch == ":") { + return "operator"; + } else { + stream.eatWhile(/[_\w\d]/); + if(stream.peek() == ":") { + return "variable-3"; + } else { + var word = stream.current(); + + if(keywords.test(word)) { + return "meta"; + } + + if(ch >= "A" && ch <= "Z") { + return "comment"; + } else { + return "keyword"; + } + } + var word = stream.current(); + if (ops.test(word)) + return null; + else if (keywords.test(word)) + return "meta"; + else + return "variable"; + } + } + + function tokenLiteral(quote) { + return function(stream, state) { + var escaped = false, ch; + while ((ch = stream.next()) != null) { + if (ch == quote && !escaped) { + state.tokenize = tokenBase; + break; + } + escaped = !escaped && ch == "\\"; + } + return "string"; + }; + } + + function pushContext(state, type, col) { + state.context = {prev: state.context, indent: state.indent, col: col, type: type}; + } + function popContext(state) { + state.indent = state.context.indent; + state.context = state.context.prev; + } + + return { + startState: function() { + return {tokenize: tokenBase, + context: null, + indent: 0, + col: 0}; + }, + + token: function(stream, state) { + if (stream.sol()) { + if (state.context && state.context.align == null) state.context.align = false; + state.indent = stream.indentation(); + } + if (stream.eatSpace()) return null; + var style = state.tokenize(stream, state); + + if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") { + state.context.align = true; + } + + if (curPunc == "(") pushContext(state, ")", stream.column()); + else if (curPunc == "[") pushContext(state, "]", stream.column()); + else if (curPunc == "{") pushContext(state, "}", stream.column()); + else if (/[\]\}\)]/.test(curPunc)) { + while (state.context && state.context.type == "pattern") popContext(state); + if (state.context && curPunc == state.context.type) popContext(state); + } + else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state); + else if (/atom|string|variable/.test(style) && state.context) { + if (/[\}\]]/.test(state.context.type)) + pushContext(state, "pattern", stream.column()); + else if (state.context.type == "pattern" && !state.context.align) { + state.context.align = true; + state.context.col = stream.column(); + } + } + + return style; + }, + + indent: function(state, textAfter) { + var firstChar = textAfter && textAfter.charAt(0); + var context = state.context; + if (/[\]\}]/.test(firstChar)) + while (context && context.type == "pattern") context = context.prev; + + var closing = context && firstChar == context.type; + if (!context) + return 0; + else if (context.type == "pattern") + return context.col; + else if (context.align) + return context.col + (closing ? 0 : 1); + else + return context.indent + (closing ? 0 : indentUnit); + } + }; +}); + +CodeMirror.defineMIME("text/turtle", "turtle"); + +}); Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/xml.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/xml.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-modes/xml.js 2014-05-09 11:55:20 UTC (rev 8245) @@ -0,0 +1,381 @@ +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("xml", function(config, parserConfig) { + var indentUnit = config.indentUnit; + var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1; + var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag; + if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true; + + var Kludges = parserConfig.htmlMode ? { + autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, + 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, + 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, + 'track': true, 'wbr': true}, + implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, + 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, + 'th': true, 'tr': true}, + contextGrabbers: { + 'dd': {'dd': true, 'dt': true}, + 'dt': {'dd': true, 'dt': true}, + 'li': {'li': true}, + 'option': {'option': true, 'optgroup': true}, + 'optgroup': {'optgroup': true}, + 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, + 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, + 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, + 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, + 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, + 'rp': {'rp': true, 'rt': true}, + 'rt': {'rp': true, 'rt': true}, + 'tbody': {'tbody': true, 'tfoot': true}, + 'td': {'td': true, 'th': true}, + 'tfoot': {'tbody': true}, + 'th': {'td': true, 'th': true}, + 'thead': {'tbody': true, 'tfoot': true}, + 'tr': {'tr': true} + }, + doNotIndent: {"pre": true}, + allowUnquoted: true, + allowMissing: true, + caseFold: true + } : { + autoSelfClosers: {}, + implicitlyClosed: {}, + contextGrabbers: {}, + doNotIndent: {}, + allowUnquoted: false, + allowMissing: false, + caseFold: false + }; + var alignCDATA = parserConfig.alignCDATA; + + // Return variables for tokenizers + var type, setStyle; + + function inText(stream, state) { + function chain(parser) { + state.tokenize = parser; + return parser(stream, state); + } + + var ch = stream.next(); + if (ch == "<") { + if (stream.eat("!")) { + if (stream.eat("[")) { + if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); + else return null; + } else if (stream.match("--")) { + return chain(inBlock("comment", "-->")); + } else if (stream.match("DOCTYPE", true, true)) { + stream.eatWhile(/[\w\._\-]/); + return chain(doctype(1)); + } else { + return null; + } + } else if (stream.eat("?")) { + stream.eatWhile(/[\w\._\-]/); + state.tokenize = inBlock("meta", "?>"); + return "meta"; + } else { + type = stream.eat("/") ? "closeTag" : "openTag"; + state.tokenize = inTag; + return "tag bracket"; + } + } else if (ch == "&") { + var ok; + if (stream.eat("#")) { + if (stream.eat("x")) { + ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); + } else { + ok = stream.eatWhile(/[\d]/) && stream.eat(";"); + } + } else { + ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); + } + return ok ? "atom" : "error"; + } else { + stream.eatWhile(/[^&<]/); + return null; + } + } + + function inTag(stream, state) { + var ch = stream.next(); + if (ch == ">" || (ch == "/" && stream.eat(">"))) { + state.tokenize = inText; + type = ch == ">" ? "endTag" : "selfcloseTag"; + return "tag bracket"; + } else if (ch == "=") { + type = "equals"; + return null; + } else if (ch == "<") { + state.tokenize = inText; + state.state = baseState; + state.tagName = state.tagStart = null; + var next = state.tokenize(stream, state); + return next ? next + " error" : "error"; + } else if (/[\'\"]/.test(ch)) { + state.tokenize = inAttribute(ch); + state.stringStartCol = stream.column(); + return state.tokenize(stream, state); + } else { + stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); + return "word"; + } + } + + function inAttribute(quote) { + var closure = function(stream, state) { + while (!stream.eol()) { + if (stream.next() == quote) { + state.tokenize = inTag; + break; + } + } + return "string"; + }; + closure.isInAttribute = true; + return closure; + } + + function inBlock(style, terminator) { + return function(stream, state) { + while (!stream.eol()) { + if (stream.match(terminator)) { + state.tokenize = inText; + break; + } + stream.next(); + } + return style; + }; + } + function doctype(depth) { + return function(stream, state) { + var ch; + while ((ch = stream.next()) != null) { + if (ch == "<") { + state.tokenize = doctype(depth + 1); + return state.tokenize(stream, state); + } else if (ch == ">") { + if (depth == 1) { + state.tokenize = inText; + break; + } else { + state.tokenize = doctype(depth - 1); + return state.tokenize(stream, state); + } + } + } + return "meta"; + }; + } + + function Context(state, tagName, startOfLine) { + this.prev = state.context; + this.tagName = tagName; + this.indent = state.indented; + this.startOfLine = startOfLine; + if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) + this.noIndent = true; + } + function popContext(state) { + if (state.context) state.context = state.context.prev; + } + function maybePopContext(state, nextTagName) { + var parentTagName; + while (true) { + if (!state.context) { + return; + } + parentTagName = state.context.tagName; + if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) || + !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { + return; + } + popContext(state); + } + } + + function baseState(type, stream, state) { + if (type == "openTag") { + state.tagStart = stream.column(); + return tagNameState; + } else if (type == "closeTag") { + return closeTagNameState; + } else { + return baseState; + } + } + function tagNameState(type, stream, state) { + if (type == "word") { + state.tagName = stream.current(); + setStyle = "tag"; + return attrState; + } else { + setStyle = "error"; + return tagNameState; + } + } + function closeTagNameState(type, stream, state) { + if (type == "word") { + var tagName = stream.current(); + if (state.context && state.context.tagName != tagName && + Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName)) + popContext(state); + if (state.context && state.context.tagName == tagName) { + setStyle = "tag"; + return closeState; + } else { + setStyle = "tag error"; + return closeStateErr; + } + } else { + setStyle = "error"; + return closeStateErr; + } + } + + function closeState(type, _stream, state) { + if (type != "endTag") { + setStyle = "error"; + return closeState; + } + popContext(state); + return baseState; + } + function closeStateErr(type, stream, state) { + setStyle = "error"; + return closeState(type, stream, state); + } + + function attrState(type, _stream, state) { + if (type == "word") { + setStyle = "attribute"; + return attrEqState; + } else if (type == "endTag" || type == "selfcloseTag") { + var tagName = state.tagName, tagStart = state.tagStart; + state.tagName = state.tagStart = null; + if (type == "selfcloseTag" || + Kludges.autoSelfClosers.hasOwnProperty(tagName)) { + maybePopContext(state, tagName); + } else { + maybePopContext(state, tagName); + state.context = new Context(state, tagName, tagStart == state.indented); + } + return baseState; + } + setStyle = "error"; + return attrState; + } + function attrEqState(type, stream, state) { + if (type == "equals") return attrValueState; + if (!Kludges.allowMissing) setStyle = "error"; + return attrState(type, stream, state); + } + function attrValueState(type, stream, state) { + if (type == "string") return attrContinuedState; + if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;} + setStyle = "error"; + return attrState(type, stream, state); + } + function attrContinuedState(type, stream, state) { + if (type == "string") return attrContinuedState; + return attrState(type, stream, state); + } + + return { + startState: function() { + return {tokenize: inText, + state: baseState, + indented: 0, + tagName: null, tagStart: null, + context: null}; + }, + + token: function(stream, state) { + if (!state.tagName && stream.sol()) + state.indented = stream.indentation(); + + if (stream.eatSpace()) return null; + type = null; + var style = state.tokenize(stream, state); + if ((style || type) && style != "comment") { + setStyle = null; + state.state = state.state(type || style, stream, state); + if (setStyle) + style = setStyle == "error" ? style + " error" : setStyle; + } + return style; + }, + + indent: function(state, textAfter, fullLine) { + var context = state.context; + // Indent multi-line strings (e.g. css). + if (state.tokenize.isInAttribute) { + if (state.tagStart == state.indented) + return state.stringStartCol + 1; + else + return state.indented + indentUnit; + } + if (context && context.noIndent) return CodeMirror.Pass; + if (state.tokenize != inTag && state.tokenize != inText) + return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; + // Indent the starts of attribute names. + if (state.tagName) { + if (multilineTagIndentPastTag) + return state.tagStart + state.tagName.length + 2; + else + return state.tagStart + indentUnit * multilineTagIndentFactor; + } + if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0; + var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter); + if (tagAfter && tagAfter[1]) { // Closing tag spotted + while (context) { + if (context.tagName == tagAfter[2]) { + context = context.prev; + break; + } else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) { + context = context.prev; + } else { + break; + } + } + } else if (tagAfter) { // Opening tag spotted + while (context) { + var grabbers = Kludges.contextGrabbers[context.tagName]; + if (grabbers && grabbers.hasOwnProperty(tagAfter[2])) + context = context.prev; + else + break; + } + } + while (context && !context.startOfLine) + context = context.prev; + if (context) return context.indent + indentUnit; + else return 0; + }, + + electricInput: /<\/[\s\w:]+>$/, + blockCommentStart: "<!--", + blockCommentEnd: "-->", + + configuration: parserConfig.htmlMode ? "html" : "xml", + helperType: parserConfig.htmlMode ? "html" : "xml" + }; +}); + +CodeMirror.defineMIME("text/xml", "xml"); +CodeMirror.defineMIME("application/xml", "xml"); +if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) + CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); + +}); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-09 11:33:52 UTC (rev 8244) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-05-09 11:55:20 UTC (rev 8245) @@ -349,16 +349,31 @@ if(type == 'rdf') { $('#rdf-type').val(format); } - showUpdateOptions(type); + setUpdateSettings(type); } -$('#update-type').change(function() { showUpdateOptions(this.value) }); +$('#update-type').change(function() { setUpdateSettings(this.value); }); +$('#rdf-type').change(function() { setUpdateMode('rdf'); }); -function showUpdateOptions(type) { +function setUpdateSettings(type) { $('#rdf-type, label[for="rdf-type"]').attr('disabled', type != 'rdf'); $('#update-tab .advanced-features input').attr('disabled', type != 'sparql'); + setUpdateMode(type); } +function setUpdateMode(type) { + var mode = ''; + if(type == 'sparql') { + mode = 'sparql'; + } else if(type == 'rdf') { + type = $('#rdf-type').val(); + if(type in rdf_modes) { + mode = rdf_modes[type]; + } + } + UPDATE_EDITOR.setOption('mode', mode); +} + // .xml is used for both RDF and TriX, assume it's RDF // We could check the parent element to see which it is var rdf_types = {'nq': 'n-quads', @@ -383,6 +398,9 @@ 'trix': 'application/trix', 'turtle': 'application/x-turtle'}; +// key is value of RDF type selector, value is name of CodeMirror mode +var rdf_modes = {'n-triples': 'ntriples', 'rdf/xml': 'xml', 'json': 'json', 'turtle': 'turtle'}; + var sparql_update_commands = ['INSERT', 'DELETE', 'LOAD', 'CLEAR']; $('#update-file').change(handleFile); @@ -395,7 +413,7 @@ $('#update-update').click(submitUpdate); -UPDATE_EDITOR = CodeMirror.fromTextArea($('#update-box')[0], {lineNumbers: true}); +UPDATE_EDITOR = CodeMirror.fromTextArea($('#update-box')[0], {lineNumbers: true, mode: 'sparql'}); function submitUpdate(e) { // Updates are submitted as a regular form for SPARQL updates in monitor mode, and via AJAX for non-monitor SPARQL, RDF & file path updates. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-06-04 20:32:23
|
Revision: 8446 http://sourceforge.net/p/bigdata/code/8446 Author: tobycraig Date: 2014-06-04 20:32:18 +0000 (Wed, 04 Jun 2014) Log Message: ----------- Merged in new workbench features Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-04 15:37:13 UTC (rev 8445) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-04 20:32:18 UTC (rev 8446) @@ -188,31 +188,15 @@ overflow: hidden; } +#query-form, #update-box-container { + clear: both; +} + .namespace-shortcuts { float: right; margin-bottom: 20px; } -.namespace-shortcuts li { - display: inline-block; - border: 1px solid #e4e4e4; - padding: 5px; - margin-left: 5px; - cursor: pointer; - width: 40px; - text-align: center; -} - -.namespace-shortcuts li:hover { - border-color: #b7b7b7; - background-color: #b7b7b7; - color: #ededed; -} - -#query-form, #update-box-container { - clear: both; -} - #large-file-message { display: none; margin: 5px 0; @@ -228,7 +212,6 @@ .CodeMirror { margin: 5px 0; border: 1px solid #e1e1e1; - font-size: 125%; } .CodeMirror-placeholder { @@ -281,6 +264,19 @@ font-family: monospace; } +/* make cursor visible in error highlighting */ +div.CodeMirror-cursors { + z-index: 3; +} + +.error-line { + background: red; +} + +.error-character { + background: green; +} + #page-selector { float: right; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-04 15:37:13 UTC (rev 8445) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-04 20:32:18 UTC (rev 8446) @@ -204,7 +204,14 @@ </div> <div class="box"> - <form id="namespace-create"><input type="text"> <input type="submit" value="Create namespace"></form> + <h1>Create namespace</h1> + <form id="namespace-create"> + <label for="new-namespace-name">Name:</label> <input type="text" id="new-namespace-name"><br> + <label for="new-namespace-index">Index:</label> <input type="checkbox" id="new-namespace-index"><br> + <label for="new-namespace-truth-maintenance">Truth maintenance:</label> <input type="checkbox" id="new-namespace-truth-maintenance"><br> + <label for="new-namespace-quads">Quads:</label> <input type="checkbox" id="new-namespace-quads"><br> + <input type="submit" value="Create namespace"> + </form> </div> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-04 15:37:13 UTC (rev 8445) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-04 20:32:18 UTC (rev 8446) @@ -1,10 +1,29 @@ $(function() { // global variables -var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACE_URL, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS; -var QUERY_EDITOR, UPDATE_EDITOR; +var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS; +// LBS URLs do not currently work with non-HA and HA1 setups. Set this to true to use LBS URLs +if(false) { + var RW_URL_PREFIX = '/bigdata/LBS/leader/', RO_URL_PREFIX = '/bigdata/LBS/read/'; +} else { + var RW_URL_PREFIX = '/bigdata/', RO_URL_PREFIX = '/bigdata/'; +} +var CODEMIRROR_DEFAULTS, EDITORS = {}, ERROR_LINE_MARKERS = {}, ERROR_CHARACTER_MARKERS = {}; var PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE; +var NAMESPACE_PARAMS = { + 'name': 'com.bigdata.rdf.sail.namespace', + 'index': 'com.bigdata.search.FullTextIndex.fieldsEnabled', + 'truthMaintenance': 'com.bigdata.rdf.sail.truthMaintenance', + 'quads': 'com.bigdata.rdf.store.AbstractTripleStore.quads' +}; + +CODEMIRROR_DEFAULTS = { + lineNumbers: true, + mode: 'sparql', + extraKeys: {'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight} +}; + // debug to access closure variables $('html, textarea, select').bind('keydown', 'ctrl+d', function() { debugger; }); @@ -29,7 +48,7 @@ return; } var query = 'select ?s ?p ?o { ?o bds:search "' + term + '" . ?s ?p ?o . }' - $('#query-box').val(query); + EDITORS.query.setValue(query); $('#query-errors').hide(); $('#query-form').submit(); showTab('query'); @@ -49,10 +68,8 @@ if(!nohash && window.location.hash.substring(1).indexOf(tab) != 0) { window.location.hash = tab; } - if(tab == 'query') { - QUERY_EDITOR.refresh(); - } else if(tab == 'update') { - UPDATE_EDITOR.refresh(); + if(EDITORS[tab]) { + EDITORS[tab].refresh(); } } @@ -89,7 +106,7 @@ /* Namespaces */ function getNamespaces() { - $.get('/bigdata/namespace?describe-each-named-graph=false', function(data) { + $.get(RO_URL_PREFIX + 'namespace?describe-each-named-graph=false', function(data) { $('#namespaces-list').empty(); var rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; var namespaces = namespaces = data.getElementsByTagNameNS(rdf, 'Description') @@ -103,11 +120,11 @@ } else { use = '<a href="#" class="use-namespace">Use</a>'; } - $('#namespaces-list').append('<li data-name="' + title + '" data-url="' + url + '">' + titleText + ' - ' + use + ' - <a href="#" class="delete-namespace">Delete</a> - <a href="#" class="namespace-properties">Properties</a> - <a href="/bigdata/namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></li>'); + $('#namespaces-list').append('<li data-name="' + title + '">' + titleText + ' - ' + use + ' - <a href="#" class="delete-namespace">Delete</a> - <a href="#" class="namespace-properties">Properties</a> - <a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></li>'); } $('.use-namespace').click(function(e) { e.preventDefault(); - useNamespace($(this).parent().data('name'), $(this).parent().data('url')); + useNamespace($(this).parent().data('name')); }); $('.delete-namespace').click(function(e) { e.preventDefault(); @@ -117,6 +134,14 @@ e.preventDefault(); getNamespaceProperties($(this).parent().data('name')); }); + $('.namespace-properties-java').click(function(e) { + e.preventDefault(); + getNamespaceProperties($(this).parent().data('name'), 'java'); + }); + $('.clone-namespace').click(function(e) { + e.preventDefault(); + cloneNamespace($(this).parent().data('name')); + }); $('.namespace-service-description').click(function(e) { return confirm('This can be an expensive operation. Proceed anyway?'); }); @@ -133,10 +158,9 @@ } } -function useNamespace(name, url) { +function useNamespace(name) { $('#current-namespace').html(name); NAMESPACE = name; - NAMESPACE_URL = url; getNamespaces(); } @@ -151,7 +175,7 @@ if(namespace == NAMESPACE) { // FIXME: what is the desired behaviour when deleting the current namespace? } - var url = '/bigdata/namespace/' + namespace; + var url = RW_URL_PREFIX + 'namespace/' + namespace; var settings = { type: 'DELETE', success: getNamespaces, @@ -161,46 +185,84 @@ } } -function getNamespaceProperties(namespace) { - $('#namespace-properties h1').html(namespace); - $('#namespace-properties table').empty(); - $('#namespace-properties').show(); - var url = '/bigdata/namespace/' + namespace + '/properties'; +function getNamespaceProperties(namespace, download) { + var url = RO_URL_PREFIX + 'namespace/' + namespace + '/properties'; + if(!download) { + $('#namespace-properties h1').html(namespace); + $('#namespace-properties table').empty(); + $('#namespace-properties').show(); + } $.get(url, function(data) { + var java = ''; $.each(data.getElementsByTagName('entry'), function(i, entry) { - $('#namespace-properties table').append('<tr><td>' + entry.getAttribute('key') + '</td><td>' + entry.textContent + '</td></tr>'); + if(download) { + java += entry.getAttribute('key') + '=' + entry.textContent + '\n'; + } else { + $('#namespace-properties table').append('<tr><td>' + entry.getAttribute('key') + '</td><td>' + entry.textContent + '</td></tr>'); + } }); + if(download) { + downloadFile(java, 'text/x-java-properties', this.url.split('/')[3] + '.properties'); + } }); } +function cloneNamespace(namespace) { + var url = RO_URL_PREFIX + 'namespace/' + namespace + '/properties'; + $.get(url, function(data) { + var reversed_params = {}; + for(var key in NAMESPACE_PARAMS) { + reversed_params[NAMESPACE_PARAMS[key]] = key; + } + $.each(data.getElementsByTagName('entry'), function(i, entry) { + var key = entry.getAttribute('key'); + if(reversed_params[key] == 'name') { + return; + } + if(key in reversed_params) { + $('#new-namespace-' + reversed_params[key]).prop('checked', entry.textContent.trim() == 'true'); + } + }); + $('#new-namespace-name').focus(); + }); +} + function createNamespace(e) { e.preventDefault(); - var input = $(this).find('input[type=text]'); - var namespace = input.val(); - if(!namespace) { + // get new namespace name and config options + var params = {}; + params.name = $('#new-namespace-name').val().trim(); + if(!params.name) { return; } + params.index = $('#new-namespace-index').is(':checked'); + params.truthMaintenance = $('#new-namespace-truth-maintenance').is(':checked'); + params.quads = $('#new-namespace-quads').is(':checked'); // TODO: validate namespace // TODO: allow for other options to be specified - var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n<entry key="com.bigdata.rdf.sail.namespace">' + namespace + '</entry>\n</properties>'; + var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n'; + for(key in NAMESPACE_PARAMS) { + data += '<entry key="' + NAMESPACE_PARAMS[key] + '">' + params[key] + '</entry>\n'; + } + data += '</properties>'; var settings = { type: 'POST', data: data, contentType: 'application/xml', - success: function() { input.val(''); getNamespaces(); }, - error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.statusText); } + success: function() { $('#new-namespace-name').val(''); getNamespaces(); }, + error: function(jqXHR, textStatus, errorThrown) { debugger;alert(jqXHR.responseText); } }; - $.ajax('/bigdata/namespace', settings); + $.ajax(RW_URL_PREFIX + 'namespace', settings); } $('#namespace-create').submit(createNamespace); function getDefaultNamespace() { - $.get('/bigdata/namespace?describe-each-named-graph=false&describe-default-namespace=true', function(data) { + $.get(RO_URL_PREFIX + 'namespace?describe-each-named-graph=false&describe-default-namespace=true', function(data) { // Chrome does not work with rdf\:Description, so look for Description too var defaultDataset = $(data).find('rdf\\:Description, Description'); DEFAULT_NAMESPACE = defaultDataset.find('title')[0].textContent; var url = defaultDataset.find('sparqlEndpoint')[0].attributes['rdf:resource'].textContent; - useNamespace(DEFAULT_NAMESPACE, url); + useNamespace(DEFAULT_NAMESPACE); }); } @@ -210,34 +272,51 @@ /* Namespace shortcuts */ NAMESPACE_SHORTCUTS = { - 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', - 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#', - 'owl': 'http://www.w3.org/2002/07/owl#', - 'bd': 'http://www.bigdata.com/rdf#', - 'bds': 'http://www.bigdata.com/rdf/search#', - 'gas': 'http://www.bigdata.com/rdf/gas#', - 'foaf': 'http://xmlns.com/foaf/0.1/', - 'hint': 'http://www.bigdata.com/queryHints#', - 'dc': 'http://purl.org/dc/elements/1.1/', - 'xsd': 'http://www.w3.org/2001/XMLSchema#' + 'Bigdata': { + 'bd': 'http://www.bigdata.com/rdf#', + 'bds': 'http://www.bigdata.com/rdf/search#', + 'gas': 'http://www.bigdata.com/rdf/gas#', + 'hint': 'http://www.bigdata.com/queryHints#' + }, + 'W3C': { + 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#', + 'owl': 'http://www.w3.org/2002/07/owl#', + 'skos': 'http://www.w3.org/2004/02/skos/core#', + 'xsd': 'http://www.w3.org/2001/XMLSchema#' + }, + 'Dublic Core': { + 'dc': 'http://purl.org/dc/elements/1.1/', + 'dcterm': 'http://purl.org/dc/terms/', + 'void': 'http://rdfs.org/ns/void#' + }, + 'Social/Other': { + 'foaf': 'http://xmlns.com/foaf/0.1/', + 'schema': 'http://schema.org/', + 'sioc': 'http://rdfs.org/sioc/ns#' + } }; -$('.namespace-shortcuts').html('<ul>'); -for(var ns in NAMESPACE_SHORTCUTS) { - // cannot use data-ns attribute on li, as jQuery mangles namespaces that don't end with #, adding </li> to them - var li = $('<li>' + ns.toUpperCase() + '</li>'); - li.data('ns', 'prefix ' + ns + ': <' + NAMESPACE_SHORTCUTS[ns] + '>'); - li.appendTo('.namespace-shortcuts ul'); +$('.namespace-shortcuts').html(''); +for(var category in NAMESPACE_SHORTCUTS) { + var select = $('<select><option>' + category + '</option></select>').appendTo($('.namespace-shortcuts')); + for(var ns in NAMESPACE_SHORTCUTS[category]) { + select.append('<option value="' + NAMESPACE_SHORTCUTS[category][ns] + '">' + ns + '</option>'); + } } -$('.namespace-shortcuts li').click(function() { - var textarea = $(this).parents('.tab').find('textarea'); - var current = textarea.val(); - var ns = $(this).data('ns'); +$('.namespace-shortcuts select').change(function() { + var uri = this.value; + var tab = $(this).parents('.tab').attr('id').split('-')[0]; + var current = EDITORS[tab].getValue(); - if(current.indexOf(ns) == -1) { - textarea.val(ns + '\n' + current); + if(current.indexOf(uri) == -1) { + var ns = $(this).find(':selected').text(); + EDITORS[tab].setValue('prefix ' + ns + ': <' + uri + '>\n' + current); } + + // reselect group label + this.selectedIndex = 0; }); @@ -379,7 +458,7 @@ mode = rdf_modes[type]; } } - UPDATE_EDITOR.setOption('mode', mode); + EDITORS.update.setOption('mode', mode); } // .xml is used for both RDF and TriX, assume it's RDF @@ -420,9 +499,14 @@ $('#update-update').click(submitUpdate); -UPDATE_EDITOR = CodeMirror.fromTextArea($('#update-box')[0], {lineNumbers: true, mode: 'sparql', - extraKeys: {'Ctrl-Enter': submitUpdate, 'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight} +EDITORS.update = CodeMirror.fromTextArea($('#update-box')[0], CODEMIRROR_DEFAULTS); +EDITORS.update.on('change', function() { + if(ERROR_LINE_MARKERS.update) { + ERROR_LINE_MARKERS.update.clear(); + ERROR_CHARACTER_MARKERS.update.clear(); + } }); +EDITORS.update.addKeyMap({'Ctrl-Enter': submitUpdate}); function submitUpdate(e) { // Updates are submitted as a regular form for SPARQL updates in monitor mode, and via AJAX for non-monitor SPARQL, RDF & file path updates. @@ -435,9 +519,10 @@ $('#update-response').show(); + var url = RW_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql'; var settings = { type: 'POST', - data: FILE_CONTENTS == null ? UPDATE_EDITOR.getValue() : FILE_CONTENTS, + data: FILE_CONTENTS == null ? EDITORS.update.getValue() : FILE_CONTENTS, success: updateResponseXML, error: updateResponseError } @@ -449,7 +534,7 @@ if($('#update-monitor').is(':checked')) { // create form and submit it, sending output to the iframe var form = $('<form method="POST" target="update-response-container">') - .attr('action', NAMESPACE_URL) + .attr('action', url) .append($('<input name="update">').val(settings.data)) .append('<input name="monitor" value="true">'); if($('#update-analytic').is(':checked')) { @@ -485,7 +570,7 @@ $('#update-response pre').show().html('Data loading...'); - $.ajax(NAMESPACE_URL, settings); + $.ajax(url, settings); } $('#update-clear').click(function() { @@ -538,9 +623,14 @@ } }); -QUERY_EDITOR = CodeMirror.fromTextArea($('#query-box')[0], {lineNumbers: true, mode: 'sparql', - extraKeys: {'Ctrl-Enter': submitQuery, 'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight} +EDITORS.query = CodeMirror.fromTextArea($('#query-box')[0], CODEMIRROR_DEFAULTS); +EDITORS.query.on('change', function() { + if(ERROR_LINE_MARKERS.query) { + ERROR_LINE_MARKERS.query.clear(); + ERROR_CHARACTER_MARKERS.query.clear(); + } }); +EDITORS.query.addKeyMap({'Ctrl-Enter': submitQuery}); function submitQuery(e) { try { @@ -548,8 +638,14 @@ } catch(e) {} // transfer CodeMirror content to textarea - QUERY_EDITOR.save(); + EDITORS.query.save(); + // do nothing if query is empty + if($('#query-box').val().trim() == '') { + return; + } + + var url = RO_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql'; var settings = { type: 'POST', data: $('#query-form').serialize(), @@ -561,7 +657,7 @@ $('#query-response').show().html('Query running...'); $('#query-pagination').hide(); - $.ajax(NAMESPACE_URL, settings); + $.ajax(url, settings); $('#query-explanation').empty(); if($('#query-explain').is(':checked')) { @@ -572,7 +668,7 @@ success: showQueryExplanation, error: queryResultsError }; - $.ajax(NAMESPACE_URL, settings); + $.ajax(url, settings); } else { $('#query-explanation').hide(); } @@ -630,7 +726,7 @@ success: function() { downloadFile(data, dataType, filename); }, error: downloadRDFError }; - $.ajax('/bigdata/sparql?workbench&convert', settings); + $.ajax(RO_URL_PREFIX + 'sparql?workbench&convert', settings); } else { // not RDF export_extensions[dataType][3](filename); @@ -811,21 +907,9 @@ if(match) { // highlight character at error position var line = match[1] - 1; - var column = match[2] - 1; - var input = $('#' + pane + '-box').val(); - var lines = input.split('\n'); - var container = '#' + pane + '-errors'; - $(container).html(''); - for(var i=0; i<line; i++) { - var p = $('<p>').text(lines[i]); - $(container).append(p); - } - $(container).append('<p class="error-line">'); - $(container + ' .error-line').append(document.createTextNode(lines[line].substr(0, column))); - $(container + ' .error-line').append($('<span class="error-character">').text(lines[line].charAt(column) || ' ')); - $(container + ' .error-line').append(document.createTextNode(lines[line].substr(column + 1))); - $(container).show(); - $('#' + pane + '-box').scrollTop(0); + var character = match[2] - 1; + ERROR_LINE_MARKERS[pane] = EDITORS.query.doc.markText({line: line, ch: 0}, {line: line}, {className: 'error-line'}); + ERROR_CHARACTER_MARKERS[pane] = EDITORS.query.doc.markText({line: line, ch: character}, {line: line, ch: character + 1}, {className: 'error-character'}); } } @@ -925,8 +1009,16 @@ $('#explore-form').submit(function(e) { e.preventDefault(); - var uri = $(this).find('input').val(); + var uri = $(this).find('input[type="text"]').val().trim(); if(uri) { + // add < > if they're not present and this is not a namespaced URI + if(uri[0] != '<' && uri.match(/^\w+:\//)) { + uri = '<' + uri; + if(uri.slice(-1) != '>') { + uri += '>'; + } + $(this).find('input[type="text"]').val(uri); + } loadURI(uri); // if this is a SID, make the components clickable @@ -1015,7 +1107,7 @@ success: updateExploreStart, error: updateExploreError }; - $.ajax(NAMESPACE_URL, settings); + $.ajax(RO_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql', settings); } function updateExploreStart(data) { @@ -1142,7 +1234,7 @@ if(e) { e.preventDefault(); } - $.get('/bigdata/status', function(data) { + $.get(RO_URL_PREFIX + 'status', function(data) { // get data inside a jQuery object data = $('<div>').append(data); getStatusNumbers(data); @@ -1151,8 +1243,8 @@ function getStatusNumbers(data) { $('#status-text').html(data); - $('#status-text a[href*="status"]').eq(0).click(function(e) { e.preventDefault(); showQueries(false); return false; }); - $('#status-text a[href*="status"]').eq(1).click(function(e) { e.preventDefault(); showQueries(true); return false; }); + $('#status-text a').eq(1).click(function(e) { e.preventDefault(); showQueries(false); return false; }); + $('#status-text a').eq(2).click(function(e) { e.preventDefault(); showQueries(true); return false; }); } $('#show-queries').click(function(e) { @@ -1166,7 +1258,7 @@ }); function showQueries(details) { - var url = '/bigdata/status?showQueries'; + var url = RO_URL_PREFIX + 'status?showQueries'; if(details) { url += '=details'; } @@ -1218,7 +1310,7 @@ e.preventDefault(); if(confirm('Cancel query?')) { var id = $(this).data('queryId'); - $.post('/bigdata/status?cancelQuery&queryId=' + id, function() { getStatus(); }); + $.post(RW_URL_PREFIX + 'status?cancelQuery&queryId=' + id, function() { getStatus(); }); $(this).parents('li').remove(); } } @@ -1226,7 +1318,7 @@ function getQueryDetails(e) { e.preventDefault(); var id = $(this).data('queryId'); - $.ajax({url: '/bigdata/status?showQueries=details&queryId=' + id, + $.ajax({url: RO_URL_PREFIX + 'status?showQueries=details&queryId=' + id, success: function(data) { // get data inside a jQuery object data = $('<div>').append(data); @@ -1247,7 +1339,7 @@ /* Performance */ $('#tab-selector a[data-target=performance]').click(function(e) { - $.get('/bigdata/counters', function(data) { + $.get(RO_URL_PREFIX + 'counters', function(data) { $('#performance-tab .box').html(data); }); }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-06-17 19:02:39
|
Revision: 8498 http://sourceforge.net/p/bigdata/code/8498 Author: tobycraig Date: 2014-06-17 19:02:35 +0000 (Tue, 17 Jun 2014) Log Message: ----------- Added LBS toggle Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-17 18:51:24 UTC (rev 8497) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-17 19:02:35 UTC (rev 8498) @@ -65,6 +65,7 @@ <div class="advanced-features"> <input type="checkbox" id="update-analytic"> <label for="update-analytic">Analytic</label> <input type="checkbox" id="update-monitor"> <label for="update-monitor">Monitor</label> + <input type="checkbox" id="use-lbs-update" class="use-lbs"> <label for="use-lbs-update">LBS</label> </div> <hr class="shadow"> <button id="update-update">Update</button> @@ -98,6 +99,7 @@ <input type="checkbox" id="query-details"> <label for="query-explain">(Details)</label> <input type="checkbox" name="analytic" value="true" id="query-analytic"> <label for="query-analytic">Analytic</label> <input type="checkbox" name="RTO" value="true" id="query-rto"> <label for="query-rto">Runtime Query Optimizer</label> + <input type="checkbox" id="use-lbs-query" class="use-lbs"> <label for="use-lbs-query">LBS</label> </div> <hr class="shadow"> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-17 18:51:24 UTC (rev 8497) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-17 19:02:35 UTC (rev 8498) @@ -1,13 +1,7 @@ $(function() { // global variables -var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS; -// LBS URLs do not currently work with non-HA and HA1 setups. Set this to true to use LBS URLs -if(false) { - var RW_URL_PREFIX = '/bigdata/LBS/leader/', RO_URL_PREFIX = '/bigdata/LBS/read/'; -} else { - var RW_URL_PREFIX = '/bigdata/', RO_URL_PREFIX = '/bigdata/'; -} +var RW_URL_PREFIX, RO_URL_PREFIX, DEFAULT_NAMESPACE, NAMESPACE, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS; var CODEMIRROR_DEFAULTS, EDITORS = {}, ERROR_LINE_MARKERS = {}, ERROR_CHARACTER_MARKERS = {}; var PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE; var NAMESPACE_PARAMS = { @@ -27,6 +21,19 @@ // debug to access closure variables $('html, textarea, select').bind('keydown', 'ctrl+d', function() { debugger; }); +function useLBS() { + if(this.checked) { + RW_URL_PREFIX = '/bigdata/LBS/leader/'; + RO_URL_PREFIX = '/bigdata/LBS/read/'; + } else { + RW_URL_PREFIX = '/bigdata/'; + RO_URL_PREFIX = '/bigdata/'; + } + $('.use-lbs').prop('checked', this.checked); +} +useLBS(true); +$('.use-lbs').change(useLBS); + /* Modal functions */ function showModal(id) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-06-25 01:22:56
|
Revision: 8504 http://sourceforge.net/p/bigdata/code/8504 Author: tobycraig Date: 2014-06-25 01:22:52 +0000 (Wed, 25 Jun 2014) Log Message: ----------- #975 - Added colour to health page Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-24 19:14:03 UTC (rev 8503) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-25 01:22:52 UTC (rev 8504) @@ -340,3 +340,15 @@ border: 1px solid #e1e1e1; box-sizing: border-box; } + +.health-good { + background-color: lightgreen; +} + +.health-warning { + background-color: orange; +} + +.health-bad { + background-color: red; +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-24 19:14:03 UTC (rev 8503) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-25 01:22:52 UTC (rev 8504) @@ -1360,6 +1360,9 @@ var date = new Date(data[key]); data[key] = date.toString(); } + if(key == 'status') { + $('#health-overview').removeClass('health-good health-warning health-bad').addClass('health-' + data[key].toLowerCase()); + } $('#health-' + key + ' span').html(data[key]); } }) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-06-27 21:26:57
|
Revision: 8506 http://sourceforge.net/p/bigdata/code/8506 Author: tobycraig Date: 2014-06-27 21:26:52 +0000 (Fri, 27 Jun 2014) Log Message: ----------- Merged query history into 1.3 branch Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-26 22:47:58 UTC (rev 8505) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-27 21:26:52 UTC (rev 8506) @@ -158,7 +158,6 @@ .modal { display: none; - z-index: 1; position: fixed; top: 0; left: 0; @@ -167,6 +166,7 @@ margin-left: 25%; background-color: white; padding: 20px; + z-index: 4; } #overlay { @@ -178,6 +178,7 @@ height: 100%; background-color: grey; opacity: 0.5; + z-index: 3; } .modal-open #overlay { @@ -248,7 +249,7 @@ border: none; } -.advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties { +.advanced-features, #query-response, #query-pagination, #query-explanation, #query-history, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties { display: none; } @@ -353,3 +354,8 @@ .health-bad { background-color: red; } + +#links { + text-align: center; + margin-top: 20px; +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-26 22:47:58 UTC (rev 8505) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-27 21:26:52 UTC (rev 8506) @@ -135,6 +135,20 @@ <div id="query-explanation" class="box"> </div> + <div id="query-history" class="box"> + <table> + <thead> + <tr> + <th>Time</th> + <th>Namespace</th> + <th>Query</th> + <th>Results</th> + </tr> + </thead> + <tbody></tbody> + </table> + </div> + <div id="query-export-container" class="box"> <button id="query-export">Export</button> <button id="query-response-clear">Clear</button> @@ -231,7 +245,7 @@ </div> - <div class="clear"> </div> + <div id="links"><a href="http://www.bigdata.com" target="_blank">Bigdata</a> - <a href="http://wiki.bigdata.com/" target="_blank">Wiki</a></div> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-26 22:47:58 UTC (rev 8505) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-27 21:26:52 UTC (rev 8506) @@ -261,7 +261,7 @@ data: data, contentType: 'application/xml', success: function() { $('#new-namespace-name').val(''); getNamespaces(); }, - error: function(jqXHR, textStatus, errorThrown) { debugger;alert(jqXHR.responseText); } + error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText); } }; $.ajax(RW_URL_PREFIX + 'namespace', settings); } @@ -333,22 +333,28 @@ /* Update */ -function handleDragOver(e) { +function handleDragOver(cm, e) { e.stopPropagation(); e.preventDefault(); - e.originalEvent.dataTransfer.dropEffect = 'copy'; + e.dataTransfer.dropEffect = 'copy'; } -function handleFile(e) { +function handleDrop(cm, e) { e.stopPropagation(); e.preventDefault(); + var files = e.dataTransfer.files; + handleFile(files); +} - if(e.type == 'drop') { - var files = e.originalEvent.dataTransfer.files; - } else { - var files = e.originalEvent.target.files; - } - +function handleFileInput(e) { + e.stopPropagation(); + e.preventDefault(); + var files = e.originalEvent.target.files; + handleFile(files); + $('#update-file').val(''); +} + +function handleFile(files) { // only one file supported if(files.length > 1) { alert('Ignoring all but first file'); @@ -359,31 +365,29 @@ // if file is too large, tell user to supply local path if(f.size > 1048576 * 100) { alert('File too large, enter local path to file'); - $('#update-box').val('/path/to/' + f.name); + EDITORS.update.setValue('/path/to/' + f.name); setType('path'); - $('#update-box').prop('disabled', false) + EDITORS.update.setOption('readOnly', false) $('#large-file-message, #clear-file').hide(); } else { var fr = new FileReader(); - fr.onload = function(e2) { + fr.onload = function(e) { if(f.size > 10240) { // do not use textarea - $('#update-box').prop('disabled', true) + EDITORS.update.setOption('readOnly', true) $('#filename').html(f.name); $('#large-file-message, #clear-file').show() - $('#update-box').val(''); - FILE_CONTENTS = e2.target.result; + EDITORS.update.setValue(''); + FILE_CONTENTS = e.target.result; } else { // display file contents in the textarea clearFile(); - $('#update-box').val(e2.target.result); + EDITORS.update.setValue(e.target.result); } - guessType(f.name.split('.').pop().toLowerCase(), e2.target.result); + guessType(f.name.split('.').pop().toLowerCase(), e.target.result); }; fr.readAsText(f); } - - $('#update-file').val(''); } function clearFile(e) { @@ -501,11 +505,11 @@ var sparql_update_commands = ['INSERT', 'DELETE', 'LOAD', 'CLEAR']; -$('#update-file').change(handleFile); -$('#update-box').on('dragover', handleDragOver) - .on('drop', handleFile) - .on('paste', handlePaste) - .on('input propertychange', function() { $('#update-errors').hide(); }); +$('#update-file').change(handleFileInput); +// $('#update-box').on('dragover', handleDragOver) +// .on('drop', handleFile) +// .on('paste', handlePaste) +// .on('input propertychange', function() { $('#update-errors').hide(); }); $('#clear-file').click(clearFile); $('#update-update').click(submitUpdate); @@ -517,6 +521,9 @@ ERROR_CHARACTER_MARKERS.update.clear(); } }); +EDITORS.update.on('dragover', handleDragOver); +EDITORS.update.on('drop', handleDrop); +EDITORS.update.on('paste', handlePaste); EDITORS.update.addKeyMap({'Ctrl-Enter': submitUpdate}); function submitUpdate(e) { @@ -645,6 +652,14 @@ }); EDITORS.query.addKeyMap({'Ctrl-Enter': submitQuery}); +$('#query-history').on('click', '.query', loadHistory); + +function loadHistory() { + EDITORS.query.setValue(this.innerText); + useNamespace($(this).prev('.query-namespace').text()); + EDITORS.query.focus(); +} + function submitQuery(e) { try { e.preventDefault(); @@ -654,10 +669,39 @@ EDITORS.query.save(); // do nothing if query is empty - if($('#query-box').val().trim() == '') { + var query = $('#query-box').val().trim(); + if(query == '') { return; } + var queryExists = false; + + // see if this query is already in the history + $('#query-history tbody tr').each(function(i, row) { + if($(row).find('.query')[0].innerText == query && $(row).find('.query-namespace').text() == NAMESPACE) { + // clear the old results and set the time to now + $(row).find('.query-time').text(new Date().toISOString()); + $(row).find('.query-results').text('...'); + // move it to the top + $(row).prependTo('#query-history tbody'); + queryExists = true; + return false; + } + }); + + if(!queryExists) { + // add this query to the history + var row = $('<tr>').prependTo($('#query-history tbody')); + row.append('<td class="query-time">' + new Date().toISOString() + '</td>'); + row.append('<td class="query-namespace">' + NAMESPACE + '</td>'); + var cell = $('<td class="query">').appendTo(row); + cell.text(query); + cell.html(cell.html().replace('\n', '<br>')); + row.append('<td class="query-results">...</td>'); + } + + $('#query-history').show(); + var url = RO_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql'; var settings = { type: 'POST', @@ -817,6 +861,10 @@ $('#download-link').remove(); } +function updateResultCount(count) { + $('#query-history tbody tr:first td.query-results').text(count); +} + function showQueryResults(data) { $('#query-response').empty(); $('#query-export-rdf').hide(); @@ -846,6 +894,7 @@ table.append(tr); } } + updateResultCount(rows.length); } else { // JSON // save data for export and pagination @@ -854,6 +903,7 @@ if(typeof(data.boolean) != 'undefined') { // ASK query table.append('<tr><td>' + data.boolean + '</td></tr>').addClass('boolean'); + updateResultCount('' + data.boolean); return; } @@ -895,6 +945,7 @@ table.append(thead); $('#total-results').html(data.results.bindings.length); + updateResultCount(data.results.bindings.length); setNumberOfPages(); showPage(1); @@ -1138,10 +1189,10 @@ } else { var uri = col.value; if(col.type == 'uri') { - uri = '<' + uri + '>'; + uri = abbreviate(uri); } } - output = escapeHTML(uri).replace(/\n/g, '<br>'); + var output = escapeHTML(uri).replace(/\n/g, '<br>'); if(col.type == 'uri' || col.type == 'sid') { output = '<a href="' + buildExploreHash(uri) + '">' + output + '</a>'; } @@ -1383,9 +1434,11 @@ } function abbreviate(uri) { - for(var ns in NAMESPACE_SHORTCUTS) { - if(uri.indexOf(NAMESPACE_SHORTCUTS[ns]) == 0) { - return uri.replace(NAMESPACE_SHORTCUTS[ns], ns + ':'); + for(var nsGroup in NAMESPACE_SHORTCUTS) { + for(var ns in NAMESPACE_SHORTCUTS[nsGroup]) { + if(uri.indexOf(NAMESPACE_SHORTCUTS[nsGroup][ns]) == 0) { + return uri.replace(NAMESPACE_SHORTCUTS[nsGroup][ns], ns + ':'); + } } } return '<' + uri + '>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-02 22:44:36
|
Revision: 8520 http://sourceforge.net/p/bigdata/code/8520 Author: tobycraig Date: 2014-07-02 22:44:27 +0000 (Wed, 02 Jul 2014) Log Message: ----------- Added padding to health boxes Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-02 22:33:22 UTC (rev 8519) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-02 22:44:27 UTC (rev 8520) @@ -203,11 +203,13 @@ <div class="tab" id="health-tab"> <div class="box" id="health-overview"> - <h1>Overview</h1> - <p class="health-status">Status: <span></span></p> - <p class="health-details">Details: <span></span></p> - <p class="health-version">Version: <span></span></p> - <p class="health-timestamp">Timestamp: <span></span></p> + <div class="box"> + <h1>Overview</h1> + <p class="health-status">Status: <span></span></p> + <p class="health-details">Details: <span></span></p> + <p class="health-version">Version: <span></span></p> + <p class="health-timestamp">Timestamp: <span></span></p> + </div> </div> <div id="health-services"></div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-02 22:33:22 UTC (rev 8519) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-02 22:44:27 UTC (rev 8520) @@ -1421,7 +1421,9 @@ $('#health-services div').remove(); for(var i=0; i<data.services.length; i++) { - var div = $('<div>'); + var container = $('<div>'); + var div = $('<div class="box">'); + div.appendTo(container); div.append('<p>ID: ' + data.services[i].id + '</p>'); div.append('<p>Status: ' + data.services[i].status + '</p>'); var health; @@ -1436,8 +1438,8 @@ default: health = 'warning'; } - div.addClass('box health-' + health); - div.appendTo($('#health-services')); + container.addClass('box health-' + health); + container.appendTo($('#health-services')); } }) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-03 17:37:38
|
Revision: 8522 http://sourceforge.net/p/bigdata/code/8522 Author: tobycraig Date: 2014-07-03 17:37:27 +0000 (Thu, 03 Jul 2014) Log Message: ----------- Added query history delete, made queries obviously clickable Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-03 10:21:20 UTC (rev 8521) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-03 17:37:27 UTC (rev 8522) @@ -327,6 +327,10 @@ border: 1px solid #e1e1e1; } +#query-history .query { + white-space: pre; +} + #query-export-container { text-align: right; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-03 10:21:20 UTC (rev 8521) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-03 17:37:27 UTC (rev 8522) @@ -140,9 +140,9 @@ <thead> <tr> <th>Time</th> - <th>Namespace</th> <th>Query</th> <th>Results</th> + <th>Delete</th> </tr> </thead> <tbody></tbody> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-03 10:21:20 UTC (rev 8521) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-03 17:37:27 UTC (rev 8522) @@ -652,14 +652,23 @@ }); EDITORS.query.addKeyMap({'Ctrl-Enter': submitQuery}); -$('#query-history').on('click', '.query', loadHistory); +$('#query-history').on('click', '.query a', loadHistory); +$('#query-history').on('click', '.query-delete a', deleteHistoryRow) -function loadHistory() { +function loadHistory(e) { + e.preventDefault(); EDITORS.query.setValue(this.innerText); - useNamespace($(this).prev('.query-namespace').text()); EDITORS.query.focus(); } +function deleteHistoryRow(e) { + e.preventDefault(); + $(this).parents('tr').remove(); + if($('#query-history tbody tr').length == 0) { + $('#query-history').hide(); + } +} + function submitQuery(e) { try { e.preventDefault(); @@ -669,8 +678,8 @@ EDITORS.query.save(); // do nothing if query is empty - var query = $('#query-box').val().trim(); - if(query == '') { + var query = $('#query-box').val(); + if(query.trim() == '') { return; } @@ -693,11 +702,12 @@ // add this query to the history var row = $('<tr>').prependTo($('#query-history tbody')); row.append('<td class="query-time">' + new Date().toISOString() + '</td>'); - row.append('<td class="query-namespace">' + NAMESPACE + '</td>'); var cell = $('<td class="query">').appendTo(row); - cell.text(query); - cell.html(cell.html().replace('\n', '<br>')); + var a = $('<a href="#">').appendTo(cell); + a.text(query); + a.html(a.html().replace(/\n/g, '<br>')); row.append('<td class="query-results">...</td>'); + row.append('<td class="query-delete"><a href="#">X</a></td>') } $('#query-history').show(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-11 23:29:28
|
Revision: 8536 http://sourceforge.net/p/bigdata/code/8536 Author: tobycraig Date: 2014-07-11 23:29:20 +0000 (Fri, 11 Jul 2014) Log Message: ----------- #961 - Added clone namespace and validation of namespace creation form Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-10 19:33:29 UTC (rev 8535) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-11 23:29:20 UTC (rev 8536) @@ -244,11 +244,13 @@ <h1>Create namespace</h1> <form id="namespace-create"> <label for="new-namespace-name">Name:</label> <input type="text" id="new-namespace-name"><br> - <label for="new-namespace-index">Index:</label> <input type="checkbox" id="new-namespace-index"><br> + <label for="new-namespace-index">Full text index:</label> <input type="checkbox" id="new-namespace-index"><br> <label for="new-namespace-truth-maintenance">Truth maintenance:</label> <input type="checkbox" id="new-namespace-truth-maintenance"><br> <label for="new-namespace-quads">Quads:</label> <input type="checkbox" id="new-namespace-quads"><br> + <label for="new-namespace-rdr">RDR:</label> <input type="checkbox" id="new-namespace-rdr"><br> <input type="submit" value="Create namespace"> </form> + <ul id="namespace-create-errors"></ul> </div> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-10 19:33:29 UTC (rev 8535) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-11 23:29:20 UTC (rev 8536) @@ -6,12 +6,12 @@ var PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE; var NAMESPACE_PARAMS = { 'name': 'com.bigdata.rdf.sail.namespace', - 'index': 'com.bigdata.search.FullTextIndex.fieldsEnabled', + 'index': 'com.bigdata.rdf.store.AbstractTripleStore.textIndex', 'truthMaintenance': 'com.bigdata.rdf.sail.truthMaintenance', - 'quads': 'com.bigdata.rdf.store.AbstractTripleStore.quads' + 'quads': 'com.bigdata.rdf.store.AbstractTripleStore.quads', + 'rdr': 'com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers' }; - CODEMIRROR_DEFAULTS = { lineNumbers: true, mode: 'sparql', @@ -131,7 +131,7 @@ } else { use = '<a href="#" class="use-namespace">Use</a>'; } - $('#namespaces-list').append('<li data-name="' + title + '">' + titleText + ' - ' + use + ' - <a href="#" class="delete-namespace">Delete</a> - <a href="#" class="namespace-properties">Properties</a> - <a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></li>'); + $('#namespaces-list').append('<li data-name="' + title + '">' + titleText + ' - ' + use + ' - <a href="#" class="delete-namespace">Delete</a> - <a href="#" class="namespace-properties">Properties</a> - <a href="#" class="clone-namespace">Clone</a> - <a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></li>'); } $('.use-namespace').click(function(e) { e.preventDefault(); @@ -152,6 +152,7 @@ $('.clone-namespace').click(function(e) { e.preventDefault(); cloneNamespace($(this).parent().data('name')); + $('#namespace-create-errors').html(''); }); $('.namespace-service-description').click(function(e) { return confirm('This can be an expensive operation. Proceed anyway?'); @@ -238,17 +239,45 @@ }); } +function validateNamespaceOptions() { + var errors = []; + if(!$('#new-namespace-name').val().trim()) { + errors.push('Enter a name'); + } + if($('#new-namespace-truth-maintenance').is(':checked') && $('#new-namespace-quads').is(':checked')) { + errors.push('You may not select both truth maintenance and quads'); + } + if($('#new-namespace-rdr').is(':checked') && $('#new-namespace-quads').is(':checked')) { + errors.push('You may not select both RDR and quads'); + } + $('#namespace-create-errors').html(''); + for(var i=0; i<errors.length; i++) { + $('#namespace-create-errors').append('<li>' + errors[i] + '</li>'); + } + var valid = errors.length == 0; + if(valid) { + $('#namespace-create input[type=submit]').removeAttr('disabled'); + } else { + $('#namespace-create input[type=submit]').attr('disabled', 'disabled'); + } + return errors.length == 0; +} + +$('#namespace-create input').change(validateNamespaceOptions); +$('#namespace-create input').keyup(validateNamespaceOptions); + function createNamespace(e) { e.preventDefault(); + if(!validateNamespaceOptions()) { + return; + } // get new namespace name and config options var params = {}; params.name = $('#new-namespace-name').val().trim(); - if(!params.name) { - return; - } params.index = $('#new-namespace-index').is(':checked'); params.truthMaintenance = $('#new-namespace-truth-maintenance').is(':checked'); params.quads = $('#new-namespace-quads').is(':checked'); + params.rdr = $('#new-namespace-rdr').is(':checked'); // TODO: validate namespace // TODO: allow for other options to be specified var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-14 20:08:33
|
Revision: 8546 http://sourceforge.net/p/bigdata/code/8546 Author: tobycraig Date: 2014-07-14 20:08:31 +0000 (Mon, 14 Jul 2014) Log Message: ----------- Added execution time to query history Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-14 13:38:43 UTC (rev 8545) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-14 20:08:31 UTC (rev 8546) @@ -142,6 +142,7 @@ <th>Time</th> <th>Query</th> <th>Results</th> + <th>Execution Time</th> <th>Delete</th> </tr> </thead> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-14 13:38:43 UTC (rev 8545) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-14 20:08:31 UTC (rev 8546) @@ -720,6 +720,7 @@ // clear the old results and set the time to now $(row).find('.query-time').text(new Date().toISOString()); $(row).find('.query-results').text('...'); + $(row).find('.query-execution-time').text('...'); // move it to the top $(row).prependTo('#query-history tbody'); queryExists = true; @@ -736,6 +737,7 @@ a.text(query); a.html(a.html().replace(/\n/g, '<br>')); row.append('<td class="query-results">...</td>'); + row.append('<td class="query-execution-time">...</td>'); row.append('<td class="query-delete"><a href="#">X</a></td>') } @@ -900,8 +902,27 @@ $('#download-link').remove(); } -function updateResultCount(count) { +function updateresultCountAndExecutionTime(count) { $('#query-history tbody tr:first td.query-results').text(count); + + var ms = Date.now() - Date.parse($('#query-history tbody tr:first td.query-time').html()); + var sec = Math.floor(ms / 1000); + ms = ms % 1000; + var min = Math.floor(sec / 60); + min = min % 60; + var hr = Math.floor(min / 60); + var executionTime = ''; + if(hr > 0) { + executionTime += hr + 'hr, '; + } + if(min > 0) { + executionTime += min + 'min, '; + } + if(sec > 0) { + executionTime += sec + 'sec, '; + } + executionTime += ms + 'ms'; + $('#query-history tbody tr:first td.query-execution-time').html(executionTime); } function showQueryResults(data) { @@ -933,7 +954,7 @@ table.append(tr); } } - updateResultCount(rows.length); + updateresultCountAndExecutionTime(rows.length); } else { // JSON // save data for export and pagination @@ -942,7 +963,7 @@ if(typeof(data.boolean) != 'undefined') { // ASK query table.append('<tr><td>' + data.boolean + '</td></tr>').addClass('boolean'); - updateResultCount('' + data.boolean); + updateresultCountAndExecutionTime('' + data.boolean); return; } @@ -984,7 +1005,7 @@ table.append(thead); $('#total-results').html(data.results.bindings.length); - updateResultCount(data.results.bindings.length); + updateresultCountAndExecutionTime(data.results.bindings.length); setNumberOfPages(); showPage(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-16 21:41:17
|
Revision: 8561 http://sourceforge.net/p/bigdata/code/8561 Author: tobycraig Date: 2014-07-16 21:41:09 +0000 (Wed, 16 Jul 2014) Log Message: ----------- #837 - Improved namespace creation and cloning Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-16 18:38:15 UTC (rev 8560) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-16 21:41:09 UTC (rev 8561) @@ -359,6 +359,11 @@ background-color: tomato; } +#inference-quads-incompatible { + display: none; + font-style: italic; +} + #links { text-align: center; margin-top: 20px; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-16 18:38:15 UTC (rev 8560) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-16 21:41:09 UTC (rev 8561) @@ -244,11 +244,23 @@ <div class="box"> <h1>Create namespace</h1> <form id="namespace-create"> - <label for="new-namespace-name">Name:</label> <input type="text" id="new-namespace-name"><br> - <label for="new-namespace-index">Full text index:</label> <input type="checkbox" id="new-namespace-index"><br> - <label for="new-namespace-truth-maintenance">Truth maintenance:</label> <input type="checkbox" id="new-namespace-truth-maintenance"><br> - <label for="new-namespace-quads">Quads:</label> <input type="checkbox" id="new-namespace-quads"><br> - <label for="new-namespace-rdr">RDR:</label> <input type="checkbox" id="new-namespace-rdr"><br> + <label for="new-namespace-name">Name:</label> + <input type="text" id="new-namespace-name"> + <br> + <label for="new-namespace-mode">Mode:</label> + <select id="new-namespace-mode"> + <option>triples</option> + <option>rdr</option> + <option>quads</option> + </select> + <br> + <label for="new-namespace-inference">Inference:</label> + <input type="checkbox" id="new-namespace-inference"> + <span id="inference-quads-incompatible">Inference is incompatible with quads mode</span> + <br> + <label for="new-namespace-index">Full text index:</label> + <input type="checkbox" id="new-namespace-index"> + <br> <input type="submit" value="Create namespace"> </form> <ul id="namespace-create-errors"></ul> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-16 18:38:15 UTC (rev 8560) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-16 21:41:09 UTC (rev 8561) @@ -9,7 +9,8 @@ 'index': 'com.bigdata.rdf.store.AbstractTripleStore.textIndex', 'truthMaintenance': 'com.bigdata.rdf.sail.truthMaintenance', 'quads': 'com.bigdata.rdf.store.AbstractTripleStore.quads', - 'rdr': 'com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers' + 'rdr': 'com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers', + 'axioms': 'com.bigdata.rdf.store.AbstractTripleStore.axiomsClass' }; CODEMIRROR_DEFAULTS = { @@ -222,49 +223,64 @@ function cloneNamespace(namespace) { var url = RO_URL_PREFIX + 'namespace/' + namespace + '/properties'; $.get(url, function(data) { - var reversed_params = {}; - for(var key in NAMESPACE_PARAMS) { - reversed_params[NAMESPACE_PARAMS[key]] = key; - } + // collect params from namespace to be cloned + var params = {}; $.each(data.getElementsByTagName('entry'), function(i, entry) { - var key = entry.getAttribute('key'); - if(reversed_params[key] == 'name') { - return; - } - if(key in reversed_params) { - $('#new-namespace-' + reversed_params[key]).prop('checked', entry.textContent.trim() == 'true'); - } + params[entry.getAttribute('key')] = entry.textContent.trim(); }); + + // set up new namespace form with collected params + var mode, quads, rdr; + quads = params[NAMESPACE_PARAMS.quads] == 'true'; + rdr = params[NAMESPACE_PARAMS.rdr] == 'true'; + if(!quads && !rdr) { + mode = 'triples'; + } else if(!quads && rdr) { + mode = 'rdr'; + } else if(quads && !rdr) { + mode = 'quads'; + } else { + alert('Incompatible set of namespace parameters'); + return; + } + $('#new-namespace-mode').val(mode); + $('#new-namespace-inference').prop('checked', params[NAMESPACE_PARAMS.axioms] == 'com.bigdata.rdf.axioms.OwlAxioms'); + $('#new-namespace-index').prop('checked', params[NAMESPACE_PARAMS.index] == 'true'); + $('#new-namespace-name').focus(); }); } function validateNamespaceOptions() { var errors = []; - if(!$('#new-namespace-name').val().trim()) { + var name = $('#new-namespace-name').val().trim(); + if(!name) { errors.push('Enter a name'); } - if($('#new-namespace-truth-maintenance').is(':checked') && $('#new-namespace-quads').is(':checked')) { - errors.push('You may not select both truth maintenance and quads'); + $('#namespaces-list li').each(function() { + if(name == $(this).data('name')) { + errors.push('Name already in use'); + return false; + } + }); + if($('#new-namespace-mode').val() == 'quads' && $('#new-namespace-inference').is(':checked')) { + errors.push('Inference is incompatible with quads mode'); } - if($('#new-namespace-rdr').is(':checked') && $('#new-namespace-quads').is(':checked')) { - errors.push('You may not select both RDR and quads'); - } $('#namespace-create-errors').html(''); for(var i=0; i<errors.length; i++) { $('#namespace-create-errors').append('<li>' + errors[i] + '</li>'); } - var valid = errors.length == 0; - if(valid) { - $('#namespace-create input[type=submit]').removeAttr('disabled'); - } else { - $('#namespace-create input[type=submit]').attr('disabled', 'disabled'); - } return errors.length == 0; } -$('#namespace-create input').change(validateNamespaceOptions); -$('#namespace-create input').keyup(validateNamespaceOptions); +$('#new-namespace-mode').change(function() { + var quads = this.value == 'quads'; + $('#new-namespace-inference').prop('disabled', quads); + $('#inference-quads-incompatible').toggle(quads); + if(quads) { + $('#new-namespace-inference').prop('checked', false); + } +}); function createNamespace(e) { e.preventDefault(); @@ -273,18 +289,38 @@ } // get new namespace name and config options var params = {}; + params.name = $('#new-namespace-name').val().trim(); params.index = $('#new-namespace-index').is(':checked'); - params.truthMaintenance = $('#new-namespace-truth-maintenance').is(':checked'); - params.quads = $('#new-namespace-quads').is(':checked'); - params.rdr = $('#new-namespace-rdr').is(':checked'); - // TODO: validate namespace + + var mode = $('#new-namespace-mode').val(); + if(mode == 'triples') { + params.quads = false; + params.rdr = false; + params.truthMaintenance = true; + } else if(mode == 'rdr') { + params.quads = false; + params.rdr = true; + params.truthMaintenance = true; + } else { // quads + params.quads = true; + params.rdr = false; + params.truthMaintenance = false; + } + + if($('#new-namespace-inference').is(':checked')) { + params.axioms = 'com.bigdata.rdf.axioms.OwlAxioms'; + } else { + params.axioms = 'com.bigdata.rdf.axioms.NoAxioms'; + } + // TODO: allow for other options to be specified var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n'; for(key in NAMESPACE_PARAMS) { data += '<entry key="' + NAMESPACE_PARAMS[key] + '">' + params[key] + '</entry>\n'; } data += '</properties>'; + var settings = { type: 'POST', data: data, @@ -1358,6 +1394,7 @@ if(e) { e.preventDefault(); } + showQueries(true); $.get(RO_URL_PREFIX + 'status', function(data) { // get data inside a jQuery object data = $('<div>').append(data); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-17 19:08:55
|
Revision: 8570 http://sourceforge.net/p/bigdata/code/8570 Author: tobycraig Date: 2014-07-17 19:08:47 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Tidied up namespaces list into table Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-17 17:09:31 UTC (rev 8569) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-17 19:08:47 UTC (rev 8570) @@ -231,7 +231,7 @@ <div class="box"> <h1>Namespaces</h1> - <ul id="namespaces-list"></ul> + <table id="namespaces-list"></table> <br> <a href="/bigdata/namespace">Download VoID description of all namespaces</a> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-17 17:09:31 UTC (rev 8569) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-17 19:08:47 UTC (rev 8570) @@ -132,27 +132,27 @@ } else { use = '<a href="#" class="use-namespace">Use</a>'; } - $('#namespaces-list').append('<li data-name="' + title + '">' + titleText + ' - ' + use + ' - <a href="#" class="delete-namespace">Delete</a> - <a href="#" class="namespace-properties">Properties</a> - <a href="#" class="clone-namespace">Clone</a> - <a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></li>'); + $('#namespaces-list').append('<tr data-name="' + title + '">><td>' + titleText + '</td><td>' + use + '</td><td><a href="#" class="delete-namespace">Delete</a></td><td><a href="#" class="namespace-properties">Properties</a></td><td><a href="#" class="clone-namespace">Clone</a></td><td><a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></td></tr>'); } $('.use-namespace').click(function(e) { e.preventDefault(); - useNamespace($(this).parent().data('name')); + useNamespace($(this).parents('tr').data('name')); }); $('.delete-namespace').click(function(e) { e.preventDefault(); - deleteNamespace($(this).parent().data('name')); + deleteNamespace($(this).parents('tr').data('name')); }); $('.namespace-properties').click(function(e) { e.preventDefault(); - getNamespaceProperties($(this).parent().data('name')); + getNamespaceProperties($(this).parents('tr').data('name')); }); $('.namespace-properties-java').click(function(e) { e.preventDefault(); - getNamespaceProperties($(this).parent().data('name'), 'java'); + getNamespaceProperties($(this).parents('tr').data('name'), 'java'); }); $('.clone-namespace').click(function(e) { e.preventDefault(); - cloneNamespace($(this).parent().data('name')); + cloneNamespace($(this).parents('tr').data('name')); $('#namespace-create-errors').html(''); }); $('.namespace-service-description').click(function(e) { @@ -167,7 +167,7 @@ if(!NAMESPACES_READY) { setTimeout(function() { selectNamespace(name); }, 10); } else { - $('#namespaces-list li[data-name=' + name + '] a.use-namespace').click(); + $('#namespaces-list tr[data-name=' + name + '] a.use-namespace').click(); } } @@ -257,12 +257,9 @@ if(!name) { errors.push('Enter a name'); } - $('#namespaces-list li').each(function() { - if(name == $(this).data('name')) { - errors.push('Name already in use'); - return false; - } - }); + if($('#namespaces-list tr[data-name=' + name + ']').length != 0) { + errors.push('Name already in use'); + } if($('#new-namespace-mode').val() == 'quads' && $('#new-namespace-inference').is(':checked')) { errors.push('Inference is incompatible with quads mode'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-17 19:26:41
|
Revision: 8571 http://sourceforge.net/p/bigdata/code/8571 Author: tobycraig Date: 2014-07-17 19:26:38 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Hide health tab for standalone deployments Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-17 19:08:47 UTC (rev 8570) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-17 19:26:38 UTC (rev 8571) @@ -347,6 +347,11 @@ box-sizing: border-box; } +/* workbench checks if we're in HA mode and shows health tab if we are */ +#tab-selector a[data-target=health] { + display: none; +} + .health-good { background-color: lightgreen; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-17 19:08:47 UTC (rev 8570) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-17 19:26:38 UTC (rev 8571) @@ -1545,6 +1545,15 @@ }) } +function showHealthTab() { + $.get('/status?health', function(data) { + if(data.deployment == 'HA') { + $('#tab-selector a[data-target=health]').show(); + } + }); +} +showHealthTab(); + /* Performance */ $('#tab-selector a[data-target=performance]').click(loadPerformance); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-22 17:10:18
|
Revision: 8585 http://sourceforge.net/p/bigdata/code/8585 Author: tobycraig Date: 2014-07-22 17:10:08 +0000 (Tue, 22 Jul 2014) Log Message: ----------- Added show datatype/language checkboxes to query results Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-22 00:33:17 UTC (rev 8584) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-22 17:10:08 UTC (rev 8585) @@ -327,6 +327,11 @@ border: 1px solid #e1e1e1; } +.datatype, .language { + font-style: italic; + color: grey; +} + #query-history .query { white-space: pre; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-22 00:33:17 UTC (rev 8584) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-22 17:10:08 UTC (rev 8585) @@ -130,6 +130,10 @@ Page <input type="text" id="current-page"> of <span id="result-pages"></span> <button id="next-page">▶</button> </div> + <div id="query-datatypes"> + <input type="checkbox" id="show-datatypes"> <label for="show-datatypes">Show datatypes</label> + <input type="checkbox" id="show-languages"> <label for="show-languages">Show languages</label> + </div> </div> <div id="query-explanation" class="box"> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-22 00:33:17 UTC (rev 8584) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-22 17:10:08 UTC (rev 8585) @@ -1084,7 +1084,27 @@ } } +function showDatatypes() { + if(this.checked) { + $('#query-response td[data-datatype]').each(function(i, el) { + $(this).html($(this).html() + ' <span class="datatype">' + $(this).data('datatype').split('#')[1] + '</span>'); + }); + } else { + $('#query-response table .datatype').remove(); + } +} +function showLanguages() { + if(this.checked) { + $('#query-response td[data-lang]').each(function(i, el) { + $(this).html($(this).html() + ' <span class="language">' + $(this).data('lang') + '</span>'); + }); + } else { + $('#query-response table .language').remove(); + } +} + + /* Query result pagination */ function setNumberOfPages() { @@ -1670,6 +1690,8 @@ $('#previous-page').click(function() { showPage(CURRENT_PAGE - 1); }); $('#next-page').click(function() { showPage(CURRENT_PAGE + 1); }); $('#current-page').keyup(handlePageSelector); + $('#show-datatypes').click(showDatatypes); + $('#show-languages').click(showLanguages); $('#explore-form').submit(exploreSubmit); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-22 18:16:26
|
Revision: 8586 http://sourceforge.net/p/bigdata/code/8586 Author: tobycraig Date: 2014-07-22 18:16:22 +0000 (Tue, 22 Jul 2014) Log Message: ----------- Adjusted datatype and language rendering Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-22 17:10:08 UTC (rev 8585) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-07-22 18:16:22 UTC (rev 8586) @@ -327,11 +327,6 @@ border: 1px solid #e1e1e1; } -.datatype, .language { - font-style: italic; - color: grey; -} - #query-history .query { white-space: pre; } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-22 17:10:08 UTC (rev 8585) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-22 18:16:22 UTC (rev 8586) @@ -1087,20 +1087,26 @@ function showDatatypes() { if(this.checked) { $('#query-response td[data-datatype]').each(function(i, el) { - $(this).html($(this).html() + ' <span class="datatype">' + $(this).data('datatype').split('#')[1] + '</span>'); + $(this).html('"' + $(this).html() + '"<span class="datatype">^^' + abbreviate($(this).data('datatype')) + '</span>'); }); } else { - $('#query-response table .datatype').remove(); + $('#query-response table td[data-datatype]').each(function(i, el) { + $(this).find('.datatype').remove(); + $(this).html($(this).html().slice(1, -1)); + }); } } function showLanguages() { if(this.checked) { $('#query-response td[data-lang]').each(function(i, el) { - $(this).html($(this).html() + ' <span class="language">' + $(this).data('lang') + '</span>'); + $(this).html('"' + $(this).html() + '"<span class="language">@' + $(this).data('lang') + '</span>'); }); } else { - $('#query-response table .language').remove(); + $('#query-response table td[data-lang]').each(function(i, el) { + $(this).find('.language').remove(); + $(this).html($(this).html().slice(1, -1)); + }); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-25 21:01:03
|
Revision: 8593 http://sourceforge.net/p/bigdata/code/8593 Author: tobycraig Date: 2014-07-25 21:00:55 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Added query history storage between sessions Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-24 23:36:30 UTC (rev 8592) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-25 21:00:55 UTC (rev 8593) @@ -152,6 +152,7 @@ </thead> <tbody></tbody> </table> + <button id="query-history-clear">Clear history</button> </div> <div id="query-export-container" class="box"> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-24 23:36:30 UTC (rev 8592) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-25 21:00:55 UTC (rev 8593) @@ -759,14 +759,53 @@ EDITORS.query.focus(); } +function addQueryHistoryRow(time, query, results, executionTime) { + var row = $('<tr>').prependTo($('#query-history tbody')); + row.append('<td class="query-time">' + time + '</td>'); + var cell = $('<td class="query">').appendTo(row); + var a = $('<a href="#">').appendTo(cell); + a.text(query); + a.html(a.html().replace(/\n/g, '<br>')); + row.append('<td class="query-results">' + results + '</td>'); + row.append('<td class="query-execution-time">' + executionTime + '</td>'); + row.append('<td class="query-delete"><a href="#">X</a></td>'); +} + +function storeQueryHistory() { + // clear existing store + for(var i=0; i<localStorage.historyCount; i++) { + localStorage.removeItem('history.time.' + i); + localStorage.removeItem('history.query.' + i); + localStorage.removeItem('history.results.' + i); + localStorage.removeItem('history.executionTime.' + i); + } + + // output each current row + $('#query-history tbody tr').each(function(i, el) { + localStorage['history.time.' + i] = $(el).find('.query-time').html(); + localStorage['history.query.' + i] = $(el).find('.query a')[0].innerText; + localStorage['history.results.' + i] = $(el).find('.query-results').html(); + localStorage['history.executionTime.' + i] = $(el).find('.query-execution-time').html(); + }); + + localStorage.historyCount = $('#query-history tbody tr').length; +} + function deleteHistoryRow(e) { e.preventDefault(); $(this).parents('tr').remove(); if($('#query-history tbody tr').length === 0) { $('#query-history').hide(); } + storeQueryHistory(); } +function clearHistory(e) { + $('#query-history tbody tr').remove(); + $('#query-history').hide(); + storeQueryHistory(); +} + function submitQuery(e) { try { e.preventDefault(); @@ -798,18 +837,11 @@ }); if(!queryExists) { - // add this query to the history - var row = $('<tr>').prependTo($('#query-history tbody')); - row.append('<td class="query-time">' + new Date().toISOString() + '</td>'); - var cell = $('<td class="query">').appendTo(row); - var a = $('<a href="#">').appendTo(cell); - a.text(query); - a.html(a.html().replace(/\n/g, '<br>')); - row.append('<td class="query-results">...</td>'); - row.append('<td class="query-execution-time">...</td>'); - row.append('<td class="query-delete"><a href="#">X</a></td>'); + addQueryHistoryRow(new Date().toISOString(), query, '...', '...', true); } + storeQueryHistory(); + $('#query-history').show(); var url = RO_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql'; @@ -982,6 +1014,8 @@ } executionTime += ms + 'ms'; $('#query-history tbody tr:first td.query-execution-time').html(executionTime); + + storeQueryHistory(); } function showQueryResults(data) { @@ -1683,7 +1717,19 @@ } } +function loadQueryHistory() { + if(typeof localStorage.historyCount === 'undefined') { + localStorage.historyCount = 0; + } else { + for(var i=localStorage.historyCount - 1; i>=0; i--) { + addQueryHistoryRow(localStorage['history.time.' + i], localStorage['history.query.' + i], + localStorage['history.results.' + i], localStorage['history.executionTime.' + i], false); + } + $('#query-history').show(); + } +} + /* Startup functions */ function setupHandlers() { @@ -1727,6 +1773,7 @@ $('#query-details').change(handleDetails); $('#query-history').on('click', '.query a', loadHistory); $('#query-history').on('click', '.query-delete a', deleteHistoryRow); + $('#query-history-clear').click(clearHistory); $('#query-response-clear').click(clearQueryResponse); $('#query-export').click(showQueryExportModal); $('#query-download').click(queryExport); @@ -1759,9 +1806,10 @@ createQueryEditor(); createExportOptions(); - // restore last used namespace and explored URI + // restore last used namespace, last explored URI and query history loadLastExplore(); loadLastNamespace(); + loadQueryHistory(); } startup(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-28 23:05:32
|
Revision: 8596 http://sourceforge.net/p/bigdata/code/8596 Author: tobycraig Date: 2014-07-28 23:05:24 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Fixed bug submitting updates and changed error message Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-28 21:13:57 UTC (rev 8595) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-28 23:05:24 UTC (rev 8596) @@ -74,7 +74,7 @@ </div> <div class="box" id="update-response"> - <pre></pre> + <span></span> <iframe name="update-response-container"></iframe> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-28 21:13:57 UTC (rev 8595) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-28 23:05:24 UTC (rev 8596) @@ -21,7 +21,7 @@ 'json': 'json', 'turtle': 'turtle' }; -var FILE_CONTENTS; +var FILE_CONTENTS = null; // file/update editor type handling // .xml is used for both RDF and TriX, assume it's RDF // We could check the parent element to see which it is @@ -639,7 +639,7 @@ var url = RW_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql'; var settings = { type: 'POST', - data: FILE_CONTENTS === null ? EDITORS.update.getValue() : FILE_CONTENTS, + data: FILE_CONTENTS == null ? EDITORS.update.getValue() : FILE_CONTENTS, success: updateResponseXML, error: updateResponseError }; @@ -661,7 +661,7 @@ form.submit(); $('#update-monitor-form').remove(); $('#update-response iframe, #update-clear-container').show(); - $('#update-response pre').hide(); + $('#update-response span').hide(); return; } settings.data = 'update=' + encodeURIComponent(settings.data); @@ -687,14 +687,14 @@ break; } - $('#update-response pre').show().html('Running update...'); + $('#update-response span').show().html('Running update...'); $.ajax(url, settings); } function clearUpdateOutput() { $('#update-response, #update-clear-container').hide(); - $('#update-response pre').text(''); + $('#update-response span').text(''); $('#update-response iframe').attr('src', 'about:blank'); } @@ -707,7 +707,7 @@ function updateResponseHTML(data) { $('#update-response, #update-clear-container').show(); $('#update-response iframe').attr('src', 'about:blank').hide(); - $('#update-response pre').html(data); + $('#update-response span').html(data); } function updateResponseXML(data) { @@ -715,14 +715,23 @@ var milliseconds = data.childNodes[0].attributes.milliseconds.value; $('#update-response, #update-clear-container').show(); $('#update-response iframe').attr('src', 'about:blank').hide(); - $('#update-response pre').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); + $('#update-response span').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); } function updateResponseError(jqXHR, textStatus, errorThrown) { $('#update-response, #update-clear-container').show(); $('#update-response iframe').attr('src', 'about:blank').hide(); - $('#update-response pre').text('Error! ' + textStatus + ' ' + jqXHR.statusText); - highlightError(jqXHR.statusText, 'update'); + + var message = 'ERROR: '; + if(jqXHR.status === 0) { + message += 'Could not contact server'; + } else { + var response = $('<div>').append(jqXHR.responseText); + message += response.find('pre').text(); + highlightError(jqXHR.responseText, 'update'); + } + + $('#update-response span').text(message); } @@ -787,7 +796,7 @@ localStorage['history.results.' + i] = $(el).find('.query-results').html(); localStorage['history.executionTime.' + i] = $(el).find('.query-execution-time').html(); }); - + localStorage.historyCount = $('#query-history tbody tr').length; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-07-31 22:18:41
|
Revision: 8599 http://sourceforge.net/p/bigdata/code/8599 Author: tobycraig Date: 2014-07-31 22:18:34 +0000 (Thu, 31 Jul 2014) Log Message: ----------- #996 - Added support for creating custom namespace shortcuts Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-30 23:23:45 UTC (rev 8598) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-07-31 22:18:34 UTC (rev 8599) @@ -182,6 +182,16 @@ </p> </div> + <div id="custom-namespace-modal" class="modal"> + <h1>Custom namespaces</h1> + <ul></ul> + <label for="custom-namespace-namespace">Namespace: </label><input type="text" id="custom-namespace-namespace"><br> + <label for="custom-namespace-uri">URI: </label><input type="text" id="custom-namespace-uri"><br> + <p></p> + <button id="add-custom-namespace">Add</button> + <button class="modal-cancel">Close</button> + </div> + <div class="tab" id="explore-tab"> <div class="box"> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-30 23:23:45 UTC (rev 8598) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-31 22:18:34 UTC (rev 8599) @@ -95,7 +95,8 @@ 'foaf': 'http://xmlns.com/foaf/0.1/', 'schema': 'http://schema.org/', 'sioc': 'http://rdfs.org/sioc/ns#' - } + }, + 'Custom': {} }; // data export @@ -444,28 +445,72 @@ /* Namespace shortcuts */ -function createNamespaceShortcuts() { +function selectNamespace() { + var uri = this.value; + var tab = $(this).parents('.tab').attr('id').split('-')[0]; + var current = EDITORS[tab].getValue(); + + if(current.indexOf(uri) == -1) { + var ns = $(this).find(':selected').text(); + EDITORS[tab].setValue('prefix ' + ns + ': <' + uri + '>\n' + current); + } + + // reselect group label + this.selectedIndex = 0; +} + +function showCustomNamespacesModal() { + showModal('custom-namespace-modal'); +} + +function createNamespaceShortcut() { + var ns = $('#custom-namespace-namespace').val().trim(); + var uri = $('#custom-namespace-uri').val().trim(); + + // check namespace & URI are not empty, and namespace does not already exist + if(ns === '' || uri === '') { + return; + } + for(var category in NAMESPACE_SHORTCUTS) { + for(var oldNS in NAMESPACE_SHORTCUTS[category]) { + if(ns === oldNS) { + $('#custom-namespace-modal p').html(ns + ' is already in use for the URI ' + NAMESPACE_SHORTCUTS[category][ns]); + return; + } + } + } + + // add namespace & URI, and clear form & error message + NAMESPACE_SHORTCUTS.Custom[ns] = uri; + $('#custom-namespace-modal p').html(''); + $(this).siblings('input').val(''); + populateNamespaceShortcuts(); + $(this).siblings('.modal-cancel').click(); +} + +function populateNamespaceShortcuts() { + // add namespaces to dropdowns, and add namespaces to modal to allow deletion $('.namespace-shortcuts').html('Namespace shortcuts: '); + $('#custom-namespace-modal li').remove(); for(var category in NAMESPACE_SHORTCUTS) { var select = $('<select><option>' + category + '</option></select>').appendTo($('.namespace-shortcuts')); for(var ns in NAMESPACE_SHORTCUTS[category]) { select.append('<option value="' + NAMESPACE_SHORTCUTS[category][ns] + '">' + ns + '</option>'); + if(category === 'Custom') { + // add custom namespaces to list for editing + $('#custom-namespace-modal ul').append('<li>' + ns + ' (' + NAMESPACE_SHORTCUTS[category][ns] + ') <a href="#" data-ns="' + ns + '"">Delete</a>'); + } } } + var edit = $('<button>Edit</button>').appendTo($('.namespace-shortcuts')); +} - $('.namespace-shortcuts select').change(function() { - var uri = this.value; - var tab = $(this).parents('.tab').attr('id').split('-')[0]; - var current = EDITORS[tab].getValue(); - - if(current.indexOf(uri) == -1) { - var ns = $(this).find(':selected').text(); - EDITORS[tab].setValue('prefix ' + ns + ': <' + uri + '>\n' + current); - } - - // reselect group label - this.selectedIndex = 0; - }); +function deleteCustomNamespace(e) { + e.preventDefault(); + if(confirm('Delete this namespace shortcut?')) { + delete NAMESPACE_SHORTCUTS.Custom[$(this).data('ns')]; + populateNamespaceShortcuts(); + } } @@ -1776,6 +1821,11 @@ $('#tab-selector a[data-target=health], #health-refresh').click(getHealth); $('#tab-selector a[data-target=performance]').click(loadPerformance); + $('.namespace-shortcuts').on('change', 'select', selectNamespace); + $('#custom-namespace-modal ul').on('click', 'a', deleteCustomNamespace); + $('#add-custom-namespace').click(createNamespaceShortcut); + $('.namespace-shortcuts').on('click', 'button', showCustomNamespacesModal); + $('#new-namespace-mode').change(changeNamespaceMode); $('#namespace-create').submit(createNamespace); @@ -1825,11 +1875,11 @@ showHealthTab(); // complete setup - setupHandlers(); - createNamespaceShortcuts(); + populateNamespaceShortcuts(); createUpdateEditor(); createQueryEditor(); createExportOptions(); + setupHandlers(); // restore last used namespace, last explored URI and query history loadLastExplore(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-08-27 21:08:22
|
Revision: 8624 http://sourceforge.net/p/bigdata/code/8624 Author: tobycraig Date: 2014-08-27 21:08:13 +0000 (Wed, 27 Aug 2014) Log Message: ----------- Added bracket matching in query editors Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/matchbrackets.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-08-25 16:18:12 UTC (rev 8623) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-08-27 21:08:13 UTC (rev 8624) @@ -294,6 +294,7 @@ <script>window.jQuery || document.write('<script src="/bigdata/html/js/vendor/jquery.min.js"><\/script>')</script> <script src="/bigdata/html/js/vendor/jquery.hotkeys.js"></script> <script src="/bigdata/html/js/vendor/codemirror.js"></script> + <script src="/bigdata/html/js/vendor/cm-addons/matchbrackets.js"></script> <script src="/bigdata/html/js/vendor/cm-addons/placeholder.js"></script> <script src="/bigdata/html/js/vendor/cm-modes/javascript.js"></script> <script src="/bigdata/html/js/vendor/cm-modes/ntriples.js"></script> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/matchbrackets.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/matchbrackets.js (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/vendor/cm-addons/matchbrackets.js 2014-08-27 21:08:13 UTC (rev 8624) @@ -0,0 +1,120 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && + (document.documentMode == null || document.documentMode < 8); + + var Pos = CodeMirror.Pos; + + var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"}; + + function findMatchingBracket(cm, where, strict, config) { + var line = cm.getLineHandle(where.line), pos = where.ch - 1; + var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)]; + if (!match) return null; + var dir = match.charAt(1) == ">" ? 1 : -1; + if (strict && (dir > 0) != (pos == where.ch)) return null; + var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); + + var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); + if (found == null) return null; + return {from: Pos(where.line, pos), to: found && found.pos, + match: found && found.ch == match.charAt(0), forward: dir > 0}; + } + + // bracketRegex is used to specify which type of bracket to scan + // should be a regexp, e.g. /[[\]]/ + // + // Note: If "where" is on an open bracket, then this bracket is ignored. + // + // Returns false when no bracket was found, null when it reached + // maxScanLines and gave up + function scanForBracket(cm, where, dir, style, config) { + var maxScanLen = (config && config.maxScanLineLength) || 10000; + var maxScanLines = (config && config.maxScanLines) || 1000; + + var stack = []; + var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/; + var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) + : Math.max(cm.firstLine() - 1, where.line - maxScanLines); + for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { + var line = cm.getLine(lineNo); + if (!line) continue; + var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; + if (line.length > maxScanLen) continue; + if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); + for (; pos != end; pos += dir) { + var ch = line.charAt(pos); + if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { + var match = matching[ch]; + if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch); + else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; + else stack.pop(); + } + } + } + return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; + } + + function matchBrackets(cm, autoclear, config) { + // Disable brace matching in long lines, since it'll cause hugely slow updates + var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; + var marks = [], ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config); + if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { + var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; + marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); + if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) + marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); + } + } + + if (marks.length) { + // Kludge to work around the IE bug from issue #1193, where text + // input stops going to the textare whever this fires. + if (ie_lt8 && cm.state.focused) cm.display.input.focus(); + + var clear = function() { + cm.operation(function() { + for (var i = 0; i < marks.length; i++) marks[i].clear(); + }); + }; + if (autoclear) setTimeout(clear, 800); + else return clear; + } + } + + var currentlyHighlighted = null; + function doMatchBrackets(cm) { + cm.operation(function() { + if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;} + currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); + }); + } + + CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) + cm.off("cursorActivity", doMatchBrackets); + if (val) { + cm.state.matchBrackets = typeof val == "object" ? val : {}; + cm.on("cursorActivity", doMatchBrackets); + } + }); + + CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); + CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){ + return findMatchingBracket(this, pos, strict, config); + }); + CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ + return scanForBracket(this, pos, dir, style, config); + }); +}); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-08-25 16:18:12 UTC (rev 8623) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-08-27 21:08:13 UTC (rev 8624) @@ -12,6 +12,7 @@ var EDITORS = {}, ERROR_LINE_MARKERS = {}, ERROR_CHARACTER_MARKERS = {}; var CODEMIRROR_DEFAULTS = { lineNumbers: true, + matchBrackets: true, mode: 'sparql', extraKeys: {'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight} }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-08-27 21:49:59
|
Revision: 8625 http://sourceforge.net/p/bigdata/code/8625 Author: tobycraig Date: 2014-08-27 21:49:55 +0000 (Wed, 27 Aug 2014) Log Message: ----------- Added documentation links above query/update editors Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-08-27 21:08:13 UTC (rev 8624) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-08-27 21:49:55 UTC (rev 8625) @@ -193,6 +193,10 @@ clear: both; } +.links { + float: left; +} + .namespace-shortcuts { float: right; margin-bottom: 20px; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-08-27 21:08:13 UTC (rev 8624) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-08-27 21:49:55 UTC (rev 8625) @@ -35,6 +35,11 @@ <div class="box"> + <div class="links"> + <a href="http://wiki.bigdata.com/wiki/index.php/Main_Page">Wiki</a> - + <a href="http://www.w3.org/TR/sparql11-update/">SPARQL Update</a> + </div> + <div class="namespace-shortcuts"> </div> @@ -87,6 +92,11 @@ <div class="tab" id="query-tab"> <div class="box"> + <div class="links"> + <a href="http://wiki.bigdata.com/wiki/index.php/Main_Page">Wiki</a> - + <a href="http://www.w3.org/TR/sparql11-query/">SPARQL Query</a> + </div> + <div class="namespace-shortcuts"> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |