Kirill Simonov avatar Kirill Simonov committed ab65a9e

Update browser title.

Comments (0)

Files changed (1)

src/htsql_tweak/shell/static/shell.js

         return editor;
     }
 
+    function updateTitle(message) {
+        if (!message) {
+            message = '['+config.databaseName+']';
+        }
+        else {
+            message = message+' ['+config.databaseName+']';
+        }
+        $('title').text(message);
+    }
+
     function setQuery(query) {
         editor.setValue(query);
         editor.setCursor(editor.lineCount(), 0);
         if (state.$panel)
             state.$panel.hide();
         state.$panel = $failurePanel.show();
+        updateTitle();
     }
 
     function handleSuccess(output) {
                                              ch: output.last_column },
                                            'marker');
         }
+        updateTitle($error.text());
     }
 
     function handleUnsupported(output) {
             var url = config.serverRoot+escape(state.lastQuery);
             window.open(url, "_blank");
         }
+        updateTitle();
     }
 
     function handleEmpty(output) {
         if (state.$panel)
             state.$panel.hide();
         state.$panel = null;
+        updateTitle();
     }
 
     function handleSql(output) {
             state.$panel.hide();
         state.$panel = $sqlPanel.show();
         $sql.html(output.sql);
+        updateTitle();
     }
 
     function handleProduct(output) {
             state.$panel.hide();
         state.$panel = $productPanel.show();
         setTimeout(addTable, 0);
+        var title = '';
+        if (head.length > 0) {
+            for (var i = 0; i < head[0].length; i ++) {
+                if (title)
+                    title += ', ';
+                title += head[0][i][0].replace(/&lt;/g, '<')
+                                      .replace(/&gt;/g, '>')
+                                      .replace(/&amp;/g, '&');
+            }
+        }
+        updateTitle(title);
     }
 
     function showWaiting() {
     $('#help').hide();
     $('#close-sql').hide();
 
-    $('title').text(config.databaseName);
     $($database).text(config.databaseName);
+    updateTitle();
 
     if (config.evaluateOnStart) {
         $('#run').click();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.