Automatically save last executed query to localStorage

This commit is contained in:
Dan Sosedoff 2015-07-30 22:29:08 -05:00
parent 2aacab44ec
commit fb13ce8b07
2 changed files with 14 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -291,6 +291,9 @@ function runQuery() {
return; return;
} }
// Automatically save last executed query so its not lost
localStorage.setItem("pgweb_query", query);
executeQuery(query, function(data) { executeQuery(query, function(data) {
buildTable(data); buildTable(data);
@ -360,6 +363,7 @@ function initEditor() {
editor.getSession().setMode("ace/mode/pgsql"); editor.getSession().setMode("ace/mode/pgsql");
editor.getSession().setTabSize(2); editor.getSession().setTabSize(2);
editor.getSession().setUseSoftTabs(true); editor.getSession().setUseSoftTabs(true);
editor.commands.addCommands([{ editor.commands.addCommands([{
name: "run_query", name: "run_query",
bindKey: { bindKey: {
@ -379,6 +383,12 @@ function initEditor() {
runExplain(); runExplain();
} }
}]); }]);
var query = localStorage.getItem("pgweb_query");
if (query && query.length > 0) {
editor.setValue(query);
editor.clearSelection();
}
} }
function addShortcutTooltips() { function addShortcutTooltips() {