From 85078fd328d50edeeec188eefd41481d6eb824cb Mon Sep 17 00:00:00 2001 From: "Cheng-Han, Wu" Date: Wed, 16 Mar 2016 12:46:29 +0800 Subject: [PATCH] Fixed minor bugs --- public/js/extra.js | 1 + public/js/index.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index 7b4eb0c..41b984d 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -366,6 +366,7 @@ function finishView(view) { }, dataType: "jsonp", success: function (data) { + if (!data.query || !data.query.results) return; var json = data.query.results.json; var html = json.html; var ratio = json.height / json.width; diff --git a/public/js/index.js b/public/js/index.js index 79c2af0..94ccc32 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -292,11 +292,19 @@ var statusLength = null; var statusKeymap = null; var statusIndent = null; -$.get(serverurl + '/views/statusbar.html', function (template) { - statusBarTemplate = template; -}); +function getStatusBarTemplate(callback) { + $.get(serverurl + '/views/statusbar.html', function (template) { + statusBarTemplate = template; + if (callback) callback(); + }); +} +getStatusBarTemplate(); function addStatusBar() { + if (!statusBarTemplate) { + getStatusBarTemplate(addStatusBar); + return; + } statusBar = $(statusBarTemplate); statusCursor = statusBar.find('.status-cursor'); statusFile = statusBar.find('.status-file'); @@ -1469,7 +1477,7 @@ socket.on('info', function (data) { }); socket.on('error', function (data) { console.error(data); - if (data.message.indexOf('AUTH failed') === 0) + if (data.message && data.message.indexOf('AUTH failed') === 0) location.href = "./403"; }); socket.on('disconnect', function (data) {