♻️ Some clean-up

This commit is contained in:
Gina Häußge committed 2020-10-15 14:34:52 +02:00
1 parent 79814905fa
commit 8294eae6d9
2 files changed
+13 -20

No files matched your search

+2 -5
View File
@@ -301,6 +301,8 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
var type = event.data["type"];
var payload = event.data["payload"];
var title, text, severity;
log.debug("Got event " + type + " with payload: " + JSON.stringify(payload));
if (type === "PrintCancelling" && payload.firmwareError) {
@@ -319,9 +321,6 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
hide: false
});
} else if (type === "Error" && payload.error) {
var title = undefined,
text = undefined;
switch (payload.reason) {
case "firmware": {
title = gettext("Error reported by printer");
@@ -393,8 +392,6 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
});
}
} else if (type === "PrinterReset") {
var severity = undefined,
text = undefined;
if (payload.idle) {
text = gettext(
"It looks like your printer reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."
@@ -62,7 +62,7 @@ $(function () {
var regex = self.filterRegex();
var lineVisible = function (entry) {
return regex == undefined || !entry.line.match(regex);
return regex === undefined || !entry.line.match(regex);
};
var filtered = false;
@@ -95,7 +95,7 @@ $(function () {
var regex = self.filterRegex();
var lineVisible = function (entry) {
return regex == undefined || !entry.line.match(regex);
return regex === undefined || !entry.line.match(regex);
};
var lines = self.log();
@@ -237,7 +237,7 @@ $(function () {
var last = self.plainLogLines()[self.plainLogLines().length - 1];
var disabled =
"--- client too slow, log output disabled while printing ---";
if (last != disabled) {
if (last !== disabled) {
self.plainLogLines.push(disabled);
}
return;
@@ -265,7 +265,7 @@ $(function () {
return self._toInternalFormat(line);
})
);
if (newData.length != data.length) {
if (newData.length !== data.length) {
var cutoff = "--- too many lines to buffer, cut off ---";
newLog.push(self._toInternalFormat(cutoff, "cut"));
}
@@ -280,11 +280,7 @@ $(function () {
self._processHistoryLogData = function (data) {
self.plainLogLines(data);
self.log(
_.map(data, function (line) {
return self._toInternalFormat(line);
})
);
self.log(_.map(data, self._toInternalFormat));
self.updateOutput();
};
@@ -322,7 +318,7 @@ $(function () {
self.updateFilterRegex = function () {
var filterRegexStr = self.activeFilters().join("|").trim();
if (filterRegexStr == "") {
if (filterRegexStr === "") {
self.filterRegex(undefined);
} else {
self.filterRegex(new RegExp(filterRegexStr));
@@ -461,15 +457,15 @@ $(function () {
self.handleKeyDown = function (event) {
var keyCode = event.keyCode;
if (keyCode == 38 || keyCode == 40) {
if (keyCode === 38 || keyCode === 40) {
if (
keyCode == 38 &&
keyCode === 38 &&
self.cmdHistory.length > 0 &&
self.cmdHistoryIdx > 0
) {
self.cmdHistoryIdx--;
} else if (
keyCode == 40 &&
keyCode === 40 &&
self.cmdHistoryIdx < self.cmdHistory.length - 1
) {
self.cmdHistoryIdx++;
@@ -493,7 +489,7 @@ $(function () {
};
self.handleKeyUp = function (event) {
if (event.keyCode == 13) {
if (event.keyCode === 13) {
self.sendCommand();
}
@@ -502,7 +498,7 @@ $(function () {
};
self.onAfterTabChange = function (current, previous) {
self.tabActive = current == "#term";
self.tabActive = current === "#term";
self.updateOutput();
};