2013-02-20 18:33:05 -07:00
|
|
|
|
var LogPage = {
|
|
|
|
|
|
|
|
|
|
onPageShow: function () {
|
|
|
|
|
|
2013-11-30 11:32:39 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
LogPage.startLine = 0;
|
|
|
|
|
|
2013-11-30 11:32:39 -07:00
|
|
|
|
$('#logContents', page).html('');
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-03-22 21:04:36 -07:00
|
|
|
|
$(ApiClient).on("websocketmessage", LogPage.onWebSocketMessage).on("websocketopen", LogPage.onWebSocketConnectionChange).on("websocketerror", LogPage.onWebSocketConnectionChange).on("websocketclose", LogPage.onWebSocketConnectionChange);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
LogPage.startInterval();
|
|
|
|
|
|
|
|
|
|
var autoScroll = localStorage.getItem("autoScrollLogPage");
|
|
|
|
|
|
|
|
|
|
if (autoScroll == "true") {
|
|
|
|
|
LogPage.updateAutoScroll(true);
|
|
|
|
|
}
|
|
|
|
|
else if (autoScroll == "false") {
|
|
|
|
|
LogPage.updateAutoScroll(false);
|
|
|
|
|
}
|
2013-11-30 11:32:39 -07:00
|
|
|
|
|
|
|
|
|
ApiClient.getSystemInfo().done(function(systemInfo) {
|
|
|
|
|
|
|
|
|
|
$('#logPath', page).html(systemInfo.LogPath);
|
|
|
|
|
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPageHide: function () {
|
|
|
|
|
|
2013-03-22 21:04:36 -07:00
|
|
|
|
$(ApiClient).off("websocketmessage", LogPage.onWebSocketMessage).off("websocketopen", LogPage.onWebSocketConnectionChange).off("websocketerror", LogPage.onWebSocketConnectionChange).off("websocketclose", LogPage.onWebSocketConnectionChange);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
LogPage.stopInterval();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
startInterval: function () {
|
|
|
|
|
|
2013-03-22 21:04:36 -07:00
|
|
|
|
if (ApiClient.isWebSocketOpen()) {
|
|
|
|
|
ApiClient.sendWebSocketMessage("LogFileStart", "0,2000");
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
stopInterval: function () {
|
|
|
|
|
|
2013-03-22 21:04:36 -07:00
|
|
|
|
if (ApiClient.isWebSocketOpen()) {
|
|
|
|
|
ApiClient.sendWebSocketMessage("LogFileStop");
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onWebSocketConnectionChange: function () {
|
|
|
|
|
LogPage.stopInterval();
|
|
|
|
|
LogPage.startInterval();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onWebSocketMessage: function (e, msg) {
|
|
|
|
|
|
|
|
|
|
if (msg.MessageType == "LogFile") {
|
|
|
|
|
LogPage.appendLines(msg.Data);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
appendLines: function (lines) {
|
|
|
|
|
|
|
|
|
|
if (!lines.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogPage.startLine += lines.length;
|
|
|
|
|
|
|
|
|
|
lines = lines.join('\n') + '\n';
|
|
|
|
|
|
|
|
|
|
var elem = $('#logContents', $.mobile.activePage).append(lines)[0];
|
|
|
|
|
|
|
|
|
|
elem.style.height = (elem.scrollHeight) + 'px';
|
|
|
|
|
|
|
|
|
|
if ($('#chkAutoScroll', $.mobile.activePage).checked()) {
|
|
|
|
|
$('html, body').animate({ scrollTop: $(document).height() }, 'slow');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateAutoScroll: function (value) {
|
|
|
|
|
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
|
|
|
|
$('#chkAutoScrollBottom', page).checked(value).checkboxradio('refresh');
|
|
|
|
|
$('#chkAutoScroll', page).checked(value).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
localStorage.setItem("autoScrollLogPage", value.toString());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).on('pageshow', "#logPage", LogPage.onPageShow).on('pagehide', "#logPage", LogPage.onPageHide);
|