added execution of selected text to frontend

This commit is contained in:
Pedro 2015-01-07 14:02:14 +01:00
parent 2f110b8168
commit e7764eae7a
2 changed files with 25 additions and 6 deletions

View File

@ -32,12 +32,14 @@ PREPARE select_test: SELECT * FROM students WHERE grade = ?;
# EXECUTE 1 # EXECUTE 1
EXECUTE select_test(2.0); EXECUTE select_test(2.0);
# PREPARE 2 # PREPARE 2
PREPARE insert_test: PREPARE insert_test {
INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (?, 0, 0);
INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (?, 0, 0);
INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (?, 0, 0);
INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (?, 0, 0);
INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (?, 0, 0);
};
EXECUTE insert_test(1, 2, 3, 4 ,5);
SELECT * FROM test; SELECT * FROM test;
# EXECUTE 2 # EXECUTE 2
EXECUTE insert_test(1, 2, 3, 4, 5); EXECUTE insert_test(1, 2, 3, 4, 5);

View File

@ -12,6 +12,13 @@ $(function() {
var endpointUrl = $('#endpointInput').val(); var endpointUrl = $('#endpointInput').val();
var query = $('#queryInput').val(); var query = $('#queryInput').val();
// Check whether a part of the query has been selected
var selectedText = getSelectedText();
if (query.indexOf(selectedText) >= 0) {
query = selectedText;
}
var hyrise = new HyriseSQLConnector(endpointUrl); var hyrise = new HyriseSQLConnector(endpointUrl);
hyrise.executeSQLQuery(query, function(result) { hyrise.executeSQLQuery(query, function(result) {
@ -43,6 +50,16 @@ $(function() {
}); });
function getSelectedText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return (text === "") ? null : text;
}
function loadSampleQueries(url) { function loadSampleQueries(url) {
$.get(url, function(data) { $.get(url, function(data) {