Commits

Kirill Simonov  committed ab65a9e

Update browser title.

  • Participants
  • Parent commits 1e52982

Comments (0)

Files changed (1)

File 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();