2013-02-20 18:33:05 -07:00
|
|
|
|
var LogPage = {
|
|
|
|
|
|
|
|
|
|
onPageShow: function () {
|
|
|
|
|
|
|
|
|
|
LogPage.startLine = 0;
|
|
|
|
|
|
|
|
|
|
$('#logContents', this).html('');
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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);
|