Some long overdue == vs === view model cleanup

This commit is contained in:
Gina Häußge 2017-11-21 10:18:46 +01:00
parent 65753a0539
commit 8a977e8777
13 changed files with 155 additions and 155 deletions

View file

@ -196,8 +196,8 @@ $(function() {
return;
}
var restartSpec = _.filter(lastResponse.core, function(spec) { return spec.action == "restart" });
self.restartCommandSpec = restartSpec != undefined && restartSpec.length > 0 ? restartSpec[0] : undefined;
var restartSpec = _.filter(lastResponse.core, function(spec) { return spec.action === "restart" });
self.restartCommandSpec = restartSpec !== undefined && restartSpec.length > 0 ? restartSpec[0] : undefined;
});
self.notifications = [];
@ -207,9 +207,9 @@ $(function() {
self.noticeCountText = ko.pureComputed(function() {
var count = self.noticeCount();
if (count == 0) {
if (count === 0) {
return gettext("There are no plugin notices. Great!");
} else if (count == 1) {
} else if (count === 1) {
return gettext("There is a plugin notice for one of your installed plugins.");
} else {
return _.sprintf(gettext("There are %(count)d plugin notices for one or more of your installed plugins."), {count: count});
@ -224,15 +224,15 @@ $(function() {
var command = self._getToggleCommand(data);
var not_safemode_victim = !data.safe_mode_victim || data.safe_mode_enabled;
var not_blacklisted = !data.blacklisted;
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
return self.enableManagement() && (command === "disable" || (not_safemode_victim && not_blacklisted)) && data.key !== 'pluginmanager';
};
self.enableUninstall = function(data) {
return self.enableManagement()
&& (data.origin != "entry_point" || self.pipAvailable())
&& (data.origin !== "entry_point" || self.pipAvailable())
&& data.managable
&& !data.bundled
&& data.key != 'pluginmanager'
&& data.key !== 'pluginmanager'
&& !data.pending_uninstall;
};
@ -299,7 +299,7 @@ $(function() {
maxNumberOfFiles: 1,
autoUpload: false,
add: function(e, data) {
if (data.files.length == 0) {
if (data.files.length === 0) {
return false;
}
@ -341,7 +341,7 @@ $(function() {
self.performRepositorySearch = function() {
var query = self.repositorySearchQuery();
if (query !== undefined && query.trim() != "") {
if (query !== undefined && query.trim() !== "") {
query = query.toLocaleLowerCase();
self.repositoryplugins.changeSearchFunction(function(entry) {
return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1);
@ -447,7 +447,7 @@ $(function() {
return;
}
if (data.key == "pluginmanager") return;
if (data.key === "pluginmanager") return;
var onSuccess = function() {
self.requestData();
@ -461,7 +461,7 @@ $(function() {
})
};
if (self._getToggleCommand(data) == "enable") {
if (self._getToggleCommand(data) === "enable") {
if (data.safe_mode_victim && !data.safe_mode_enabled) return;
OctoPrint.plugins.pluginmanager.enable(data.key)
.done(onSuccess)
@ -582,7 +582,7 @@ $(function() {
}
if (data.bundled) return;
if (data.key == "pluginmanager") return;
if (data.key === "pluginmanager") return;
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
@ -633,7 +633,7 @@ $(function() {
self.savePluginSettings = function() {
var repository = self.config_repositoryUrl();
if (repository != undefined && repository.trim() == "") {
if (repository !== undefined && repository.trim() === "") {
repository = null;
}
@ -645,7 +645,7 @@ $(function() {
}
var notices = self.config_noticesUrl();
if (notices != undefined && notices.trim() == "") {
if (notices !== undefined && notices.trim() === "") {
notices = null;
}
@ -657,7 +657,7 @@ $(function() {
}
var pipArgs = self.config_pipAdditionalArgs();
if (pipArgs != undefined && pipArgs.trim() == "") {
if (pipArgs !== undefined && pipArgs.trim() === "") {
pipArgs = null;
}
@ -709,7 +709,7 @@ $(function() {
};
if (response.result) {
if (action == "install" && response.plugin && response.plugin.blacklisted) {
if (action === "install" && response.plugin && response.plugin.blacklisted) {
notification = new PNotify({
title: titleSuccess,
text: textSuccess,
@ -862,7 +862,7 @@ $(function() {
};
self.toggleButtonCss = function(data) {
var icon = self._getToggleCommand(data) == "enable" ? "fa fa-toggle-off" : "fa fa-toggle-on";
var icon = self._getToggleCommand(data) === "enable" ? "fa fa-toggle-off" : "fa fa-toggle-on";
var disabled = (self.enableToggle(data)) ? "" : " disabled";
return icon + disabled;
@ -870,7 +870,7 @@ $(function() {
self.toggleButtonTitle = function(data) {
var command = self._getToggleCommand(data);
if (command == "enable") {
if (command === "enable") {
if (data.blacklisted) {
return gettext("Blacklisted");
} else if (data.safe_mode_victim && !data.safe_mode_enabled) {
@ -884,7 +884,7 @@ $(function() {
};
self.showPluginNotifications = function(plugin) {
if (!plugin.notifications || plugin.notifications.length == 0) return;
if (!plugin.notifications || plugin.notifications.length === 0) return;
self._removeAllNoticeNotificationsForPlugin(plugin.key);
_.each(plugin.notifications, function(notification) {
@ -893,7 +893,7 @@ $(function() {
};
self.showPluginNotificationsLinkText = function(plugins) {
if (!plugins.notifications || plugins.notifications.length == 0) return;
if (!plugins.notifications || plugins.notifications.length === 0) return;
var count = plugins.notifications.length;
var importantCount = _.filter(plugins.notifications, function(notification) { return notification.important }).length;
@ -929,7 +929,7 @@ $(function() {
var text = "";
if (notification.versions && notification.versions.length > 0) {
var versions = _.map(notification.versions, function(v) { return (v == version) ? "<strong>" + v + "</strong>" : v; }).join(", ");
var versions = _.map(notification.versions, function(v) { return (v === version) ? "<strong>" + v + "</strong>" : v; }).join(", ");
text += "<small>" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: versions}) + "</small>";
} else {
text += "<small>" + gettext("Affected versions: all") + "</small>";
@ -1005,7 +1005,7 @@ $(function() {
self._isNoticeNotificationHidden = function(key, date) {
if (!self.hiddenNoticeNotifications[key]) return false;
return _.any(_.map(self.hiddenNoticeNotifications[key], function(d) { return date == d; }));
return _.any(_.map(self.hiddenNoticeNotifications[key], function(d) { return date === d; }));
};
var noticeLocalStorageKey = "plugin.pluginmanager.seen_notices";
@ -1039,7 +1039,7 @@ $(function() {
if (!Modernizr.localstorage)
return false;
if (localStorage[noticeLocalStorageKey] == undefined)
if (localStorage[noticeLocalStorageKey] === undefined)
return false;
var knownData = JSON.parse(localStorage[noticeLocalStorageKey]);
@ -1094,7 +1094,7 @@ $(function() {
};
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin != "pluginmanager") {
if (plugin !== "pluginmanager") {
return;
}
@ -1108,21 +1108,21 @@ $(function() {
var messageType = data.type;
if (messageType == "loglines" && self.working()) {
if (messageType === "loglines" && self.working()) {
_.each(data.loglines, function(line) {
self.loglines.push(self._preprocessLine(line));
});
self._scrollWorkingOutputToEnd();
} else if (messageType == "result") {
} else if (messageType === "result") {
var titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError;
var action = data.action;
var name = "Unknown";
if (action == "install") {
if (action === "install") {
var unknown = false;
if (data.hasOwnProperty("plugin")) {
if (data.plugin == "unknown") {
if (data.plugin === "unknown") {
unknown = true;
} else {
name = data.plugin.name;
@ -1172,13 +1172,13 @@ $(function() {
if (data.hasOwnProperty("reason")) {
if (data.was_reinstalled) {
if (sourceType == "path") {
if (sourceType === "path") {
textError = _.sprintf(gettext("Reinstalling the plugin from file failed: %(reason)s"), {reason: data.reason});
} else {
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
}
} else {
if (sourceType == "path") {
if (sourceType === "path") {
textError = _.sprintf(gettext("Installing the plugin from file failed: %(reason)s"), {reason: data.reason});
} else {
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
@ -1186,13 +1186,13 @@ $(function() {
}
} else {
if (data.was_reinstalled) {
if (sourceType == "path") {
if (sourceType === "path") {
textError = gettext("Reinstalling the plugin from file failed, please see the log for details.");
} else {
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
}
} else {
if (sourceType == "path") {
if (sourceType === "path") {
textError = gettext("Installing the plugin from file failed, please see the log for details.");
} else {
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
@ -1200,7 +1200,7 @@ $(function() {
}
}
} else if (action == "uninstall") {
} else if (action === "uninstall") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
@ -1218,7 +1218,7 @@ $(function() {
textError = gettext("Uninstalling the plugin failed, please see the log for details.");
}
} else if (action == "enable") {
} else if (action === "enable") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
@ -1236,7 +1236,7 @@ $(function() {
textError = gettext("Toggling the plugin failed, please see the log for details.");
}
} else if (action == "disable") {
} else if (action === "disable") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}

View file

@ -14,7 +14,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
var params = arguments[0];
entries = params.entries;
force = params.force;
@ -22,7 +22,7 @@
}
entries = entries || [];
if (typeof entries == "string") {
if (typeof entries === "string") {
entries = [entries];
}
@ -37,7 +37,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
var params = arguments[0];
force = params.force;
opts = params.opts;
@ -47,7 +47,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.update = function(entries, force, opts) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
var params = arguments[0];
entries = params.entries;
force = params.force;
@ -55,7 +55,7 @@
}
entries = entries || [];
if (typeof entries == "string") {
if (typeof entries === "string") {
entries = [entries];
}
@ -67,7 +67,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
var params = arguments[0];
force = params.force;
opts = params.opts;
@ -551,7 +551,7 @@ $(function() {
});
self._updateClicked = false;
} else {
self.forceUpdate = (force == true);
self.forceUpdate = (force === true);
self.confirmationDialog.modal("show");
}

View file

@ -50,7 +50,7 @@ $(function() {
});
self.webcamRatioClass = ko.pureComputed(function() {
if (self.settings.webcam_streamRatio() == "4:3") {
if (self.settings.webcam_streamRatio() === "4:3") {
return "ratio43";
} else {
return "ratio169";
@ -156,7 +156,7 @@ $(function() {
if (control.hasOwnProperty("children")) {
control.children = ko.observableArray(self._processControls(control.children));
if (!control.hasOwnProperty("layout") || !(control.layout == "vertical" || control.layout == "horizontal" || control.layout == "horizontal_grid")) {
if (!control.hasOwnProperty("layout") || !(control.layout === "vertical" || control.layout === "horizontal" || control.layout === "horizontal_grid")) {
control.layout = "vertical";
}
@ -371,23 +371,23 @@ $(function() {
};
self._enableWebcam = function() {
if (OctoPrint.coreui.selectedTab != "#control" || !OctoPrint.coreui.browserTabVisible) {
if (OctoPrint.coreui.selectedTab !== "#control" || !OctoPrint.coreui.browserTabVisible) {
return;
}
if (self.webcamDisableTimeout != undefined) {
if (self.webcamDisableTimeout !== undefined) {
clearTimeout(self.webcamDisableTimeout);
}
var webcamImage = $("#webcam_image");
var currentSrc = webcamImage.attr("src");
// safari bug doesn't release the mjpeg stream, so we just set it up the once
if (OctoPrint.coreui.browser.safari && currentSrc != undefined) {
if (OctoPrint.coreui.browser.safari && currentSrc !== undefined) {
return;
}
var newSrc = self.settings.webcam_streamUrl();
if (currentSrc != newSrc) {
if (currentSrc !== newSrc) {
if (newSrc.lastIndexOf("?") > -1) {
newSrc += "&";
} else {
@ -416,9 +416,9 @@ $(function() {
};
self.onTabChange = function (current, previous) {
if (current == "#control") {
if (current === "#control") {
self._enableWebcam();
} else if (previous == "#control") {
} else if (previous === "#control") {
self._disableWebcam();
}
};

View file

@ -194,7 +194,7 @@ $(function() {
});
self._retrieveBedDimensions = function(currentProfileData) {
if (currentProfileData == undefined) {
if (currentProfileData === undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@ -202,7 +202,7 @@ $(function() {
var x = undefined, y = undefined, r = undefined, circular = false, centeredOrigin = false;
var formFactor = currentProfileData.volume.formFactor();
if (formFactor == "circular") {
if (formFactor === "circular") {
r = currentProfileData.volume.width() / 2;
circular = true;
centeredOrigin = true;
@ -210,7 +210,7 @@ $(function() {
x = currentProfileData.volume.width();
y = currentProfileData.volume.depth();
if (currentProfileData.volume.origin) {
centeredOrigin = currentProfileData.volume.origin() == "center";
centeredOrigin = currentProfileData.volume.origin() === "center";
}
}
@ -227,7 +227,7 @@ $(function() {
};
self._retrieveToolOffsets = function(currentProfileData) {
if (currentProfileData == undefined) {
if (currentProfileData === undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@ -246,7 +246,7 @@ $(function() {
};
self._retrieveAxesConfiguration = function(currentProfileData) {
if (currentProfileData == undefined) {
if (currentProfileData === undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@ -380,7 +380,7 @@ $(function() {
self.loadFile = function(path, date){
self.enableReload(false);
self.needsLoad = false;
if (self.status == "idle" && self.errorCount < 3) {
if (self.status === "idle" && self.errorCount < 3) {
self.status = "request";
OctoPrint.files.download("local", path)
.done(function(response, rstatus) {
@ -408,10 +408,10 @@ $(function() {
GCODE.renderer.clear();
GCODE.gCodeReader.loadFile(par);
if (self.layerSlider != undefined) {
if (self.layerSlider !== undefined) {
self.layerSlider.slider("disable");
}
if (self.layerCommandSlider != undefined) {
if (self.layerCommandSlider !== undefined) {
self.layerCommandSlider.slider("disable");
}
};
@ -436,10 +436,10 @@ $(function() {
GCODE.renderer.render(cmdIndex.layer, 0, cmdIndex.cmd);
GCODE.ui.updateLayerInfo(cmdIndex.layer);
if (self.layerSlider != undefined) {
if (self.layerSlider !== undefined) {
self.layerSlider.slider("setValue", cmdIndex.layer);
}
if (self.layerCommandSlider != undefined) {
if (self.layerCommandSlider !== undefined) {
self.layerCommandSlider.slider("setValue", [0, cmdIndex.cmd]);
}
};
@ -461,17 +461,17 @@ $(function() {
self.currentlyPrinting = data.state.flags && (data.state.flags.printing || data.state.flags.paused);
if(self.loadedFilepath
&& self.loadedFilepath == data.job.file.path
&& self.loadedFileDate == data.job.file.date) {
&& self.loadedFilepath === data.job.file.path
&& self.loadedFileDate === data.job.file.date) {
if (OctoPrint.coreui.browserTabVisible && self.tabActive && self.currentlyPrinting && self.renderer_syncProgress() && !self.waitForApproval()) {
self._renderPercentage(data.progress.completion);
}
self.errorCount = 0
} else {
self.clear();
if (data.job.file.path && data.job.file.origin != "sdcard"
&& self.status != "request"
&& (!self.waitForApproval() || self.selectedFile.path() != data.job.file.path || self.selectedFile.date() != data.job.file.date)) {
if (data.job.file.path && data.job.file.origin !== "sdcard"
&& self.status !== "request"
&& (!self.waitForApproval() || self.selectedFile.path() !== data.job.file.path || self.selectedFile.date() !== data.job.file.date)) {
self.selectedFile.path(data.job.file.path);
self.selectedFile.date(data.job.file.date);
self.selectedFile.size(data.job.file.size);
@ -511,7 +511,7 @@ $(function() {
self._onModelLoaded = function(model) {
if (!model) {
self.ui_modelInfo("");
if (self.layerSlider != undefined) {
if (self.layerSlider !== undefined) {
self.layerSlider.slider("disable");
self.layerSlider.slider("setMax", 1);
self.layerSlider.slider("setValue", 0);
@ -531,7 +531,7 @@ $(function() {
self.ui_modelInfo(output.join("<br>"));
self.maxLayer = model.layersPrinted - 1;
if (self.layerSlider != undefined) {
if (self.layerSlider !== undefined) {
self.layerSlider.slider("enable");
self.layerSlider.slider("setMax", self.maxLayer);
self.layerSlider.slider("setValue", 0);
@ -545,7 +545,7 @@ $(function() {
self._onLayerSelected = function(layer) {
if (!layer) {
self.ui_layerInfo("");
if (self.layerCommandSlider != undefined) {
if (self.layerCommandSlider !== undefined) {
self.layerCommandSlider.slider("disable");
self.layerCommandSlider.slider("setMax", 1);
self.layerCommandSlider.slider("setValue", [0, 1]);
@ -559,8 +559,8 @@ $(function() {
output.push(gettext("Layer number") + ": " + (layer.number + 1));
output.push(gettext("Layer height") + " (mm): " + layer.height);
output.push(gettext("GCODE commands") + ": " + layer.commands);
if (layer.filament != undefined) {
if (layer.filament.length == 1) {
if (layer.filament !== undefined) {
if (layer.filament.length === 1) {
output.push(gettext("Filament") + ": " + layer.filament[0].toFixed(2) + "mm");
} else {
for (var i = 0; i < layer.filament.length; i++) {
@ -572,7 +572,7 @@ $(function() {
self.ui_layerInfo(output.join("<br>"));
if (self.layerCommandSlider != undefined) {
if (self.layerCommandSlider !== undefined) {
self.layerCommandSlider.slider("enable");
self.layerCommandSlider.slider("setMax", layer.commands - 1);
self.layerCommandSlider.slider("setValue", [0, layer.commands - 1]);
@ -587,11 +587,11 @@ $(function() {
if (!options) return;
for (var opt in options) {
if (opt == "zoomInOnModel" && options[opt] != self.renderer_zoomOnModel()) {
if (opt === "zoomInOnModel" && options[opt] !== self.renderer_zoomOnModel()) {
self.renderer_zoomOnModel(false);
} else if (opt == "centerViewport" && options[opt] != self.renderer_centerViewport()) {
} else if (opt === "centerViewport" && options[opt] !== self.renderer_centerViewport()) {
self.renderer_centerViewport(false);
} else if (opt == "moveModel" && options[opt] != self.renderer_centerModel()) {
} else if (opt === "moveModel" && options[opt] !== self.renderer_centerModel()) {
self.renderer_centerModel(false);
}
}
@ -601,7 +601,7 @@ $(function() {
if (self.currentlyPrinting && self.renderer_syncProgress()) self.renderer_syncProgress(false);
var value = event.value;
if (self.currentLayer !== undefined && self.currentLayer == value) return;
if (self.currentLayer !== undefined && self.currentLayer === value) return;
self.currentLayer = value;
GCODE.ui.changeSelectedLayer(value);
@ -641,7 +641,7 @@ $(function() {
if (self.currentlyPrinting && self.renderer_syncProgress()) self.renderer_syncProgress(false);
var tuple = event.value;
if (self.currentCommand !== undefined && self.currentCommand[0] == tuple[0] && self.currentCommand[1] == tuple[1]) return;
if (self.currentCommand !== undefined && self.currentCommand[0] === tuple[0] && self.currentCommand[1] === tuple[1]) return;
self.currentCommand = tuple;
GCODE.ui.changeSelectedCommands(self.layerSlider.slider("getValue"), tuple[0], tuple[1]);
@ -656,14 +656,14 @@ $(function() {
};
self.onTabChange = function(current, previous) {
self.tabActive = current == "#gcode";
self.tabActive = current === "#gcode";
if (self.tabActive && self.needsLoad) {
self.loadFile(self.selectedFile.path(), self.selectedFile.date());
}
};
self.shiftLayer = function(value){
if (value != self.currentLayer) {
if (value !== self.currentLayer) {
self.layerSlider.slider('setValue', value);
value = self.layerSlider.slider('getValue');
//This sets the scroll bar to the appropriate position.

View file

@ -98,7 +98,7 @@ $(function() {
self.login = function(u, p, r) {
var username = u || self.loginUser();
var password = p || self.loginPass();
var remember = (r != undefined ? r : self.loginRemember());
var remember = (r !== undefined ? r : self.loginRemember());
return OctoPrint.browser.login(username, password, remember)
.done(function(response) {

View file

@ -51,7 +51,7 @@ $(function() {
self.volumeOrigin = ko.observable();
self.volumeFormFactor.subscribe(function(value) {
if (value == "circular") {
if (value === "circular") {
self.volumeOrigin("center");
}
});
@ -123,10 +123,10 @@ $(function() {
data = placeholder;
}
var validCharacters = (data && (data == self._sanitize(data)));
var validCharacters = (data && (data === self._sanitize(data)));
var existingProfile = self.profiles.getItem(function(item) {return item.id == data});
return !data || !validCharacters || (self.isNew() && existingProfile != undefined);
var existingProfile = self.profiles.getItem(function(item) {return item.id === data});
return !data || !validCharacters || (self.isNew() && existingProfile !== undefined);
});
self.identifierInvalidText = ko.pureComputed(function() {
@ -136,7 +136,7 @@ $(function() {
if (!self.identifier() && !self.identifierPlaceholder()) {
return gettext("Identifier must be set");
} else if (self.identifier() != self._sanitize(self.identifier())) {
} else if (self.identifier() !== self._sanitize(self.identifier())) {
return gettext("Invalid characters, only a-z, A-Z, 0-9, -, ., _, ( and ) are allowed")
} else {
return gettext("A profile with such an identifier already exists");
@ -170,9 +170,9 @@ $(function() {
};
var keys = [];
if (formFactor == "rectangular") {
if (formFactor === "rectangular") {
keys = ["lowerleft", "center"];
} else if (formFactor == "circular") {
} else if (formFactor === "circular") {
keys = ["center"];
}
@ -312,7 +312,7 @@ $(function() {
}
}
if (profile.volume.formFactor == "circular") {
if (profile.volume.formFactor === "circular") {
profile.volume.depth = profile.volume.width;
}
@ -320,7 +320,7 @@ $(function() {
};
self.defaultBoundingBox = function(width, depth, height, origin) {
if (origin == "center") {
if (origin === "center") {
var halfWidth = width / 2.0;
var halfDepth = depth / 2.0;
@ -519,7 +519,7 @@ $(function() {
})
.fail(function(xhr) {
var text;
if (xhr.status == 409) {
if (xhr.status === 409) {
text = gettext("Cannot delete the default profile or the currently active profile.");
} else {
text = gettext("There was unexpected error while removing the printer profile, please consult the logs.");
@ -534,7 +534,7 @@ $(function() {
};
self.updateProfile = function(profile, callback) {
if (profile == undefined) {
if (profile === undefined) {
profile = self.editor.toProfileData();
}

View file

@ -16,7 +16,7 @@ $(function() {
self.isSdReady = ko.observable(undefined);
self.enablePrint = ko.pureComputed(function() {
return self.isOperational() && self.isReady() && !self.isPrinting() && self.loginState.isUser() && self.filename() != undefined;
return self.isOperational() && self.isReady() && !self.isPrinting() && self.loginState.isUser() && self.filename() !== undefined;
});
self.enablePause = ko.pureComputed(function() {
return self.isOperational() && (self.isPrinting() || self.isPaused()) && self.loginState.isUser();
@ -77,7 +77,7 @@ $(function() {
return formatDuration(self.printTime());
});
self.printTimeLeftString = ko.pureComputed(function() {
if (self.printTimeLeft() == undefined) {
if (self.printTimeLeft() === undefined) {
if (!self.printTime() || !(self.isPrinting() || self.isPaused())) {
return "-";
} else {
@ -156,9 +156,9 @@ $(function() {
return "-";
var type = timelapse["type"];
if (type == "zchange") {
if (type === "zchange") {
return gettext("On Z Change");
} else if (type == "timed") {
} else if (type === "timed") {
return gettext("Timed") + " (" + timelapse["options"]["interval"] + " " + gettext("sec") + ")";
} else {
return "-";
@ -197,7 +197,7 @@ $(function() {
self.isReady(data.flags.ready);
self.isSdReady(data.flags.sdReady);
if (self.isPaused() != prevPaused) {
if (self.isPaused() !== prevPaused) {
if (self.isPaused()) {
self.titlePrintButton(self.TITLE_PRINT_BUTTON_PAUSED);
self.titlePauseButton(self.TITLE_PAUSE_BUTTON_PAUSED);
@ -214,7 +214,7 @@ $(function() {
self.filepath(data.file.path);
self.filesize(data.file.size);
self.filedisplay(data.file.display);
self.sd(data.file.origin == "sdcard");
self.sd(data.file.origin === "sdcard");
} else {
self.filename(undefined);
self.filepath(undefined);
@ -227,7 +227,7 @@ $(function() {
self.lastPrintTime(data.lastPrintTime);
var result = [];
if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) {
if (data.filament && typeof(data.filament) === "object" && _.keys(data.filament).length > 0) {
var keys = _.keys(data.filament);
keys.sort();
_.each(keys, function(key) {

View file

@ -38,7 +38,7 @@ $(function() {
});
self.enableTranslationUpload = ko.pureComputed(function() {
var name = self.translationUploadFilename();
return name !== undefined && name.trim() != "" && !self.invalidTranslationArchive();
return name !== undefined && name.trim() !== "" && !self.invalidTranslationArchive();
});
self.translations = new ItemListHelper(
@ -414,7 +414,7 @@ $(function() {
autoUpload: false,
headers: OctoPrint.getRequestHeaders(),
add: function(e, data) {
if (data.files.length == 0) {
if (data.files.length === 0) {
return false;
}
@ -443,14 +443,14 @@ $(function() {
self.settingsDialog.on('show', function(event) {
OctoPrint.coreui.settingsOpen = true;
if (event.target.id == "settings_dialog") {
if (event.target.id === "settings_dialog") {
self.requestTranslationData();
callViewModels(allViewModels, "onSettingsShown");
}
});
self.settingsDialog.on('hidden', function(event) {
OctoPrint.coreui.settingsOpen = false;
if (event.target.id == "settings_dialog") {
if (event.target.id === "settings_dialog") {
callViewModels(allViewModels, "onSettingsHidden");
}
});
@ -524,11 +524,11 @@ $(function() {
self.requestData = function(local) {
// handle old parameter format
var callback = undefined;
if (arguments.length == 2 || _.isFunction(local)) {
if (arguments.length === 2 || _.isFunction(local)) {
var exc = new Error();
log.warn("The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead. Stacktrace:", (exc.stack || exc.stacktrace || "<n/a>"));
if (arguments.length == 2) {
if (arguments.length === 2) {
callback = arguments[0];
local = arguments[1];
} else {
@ -625,8 +625,8 @@ $(function() {
var translations = [];
_.each(translationsByLocale, function(item) {
item["packs"].sort(function(a, b) {
if (a.identifier == "_core") return -1;
if (b.identifier == "_core") return 1;
if (a.identifier === "_core") return -1;
if (b.identifier === "_core") return 1;
if (a.display < b.display) return -1;
if (a.display > b.display) return 1;
@ -639,7 +639,7 @@ $(function() {
};
self.languagePackDisplay = function(item) {
return item.display + ((item.english != undefined) ? ' (' + item.english + ')' : '');
return item.display + ((item.english !== undefined) ? ' (' + item.english + ')' : '');
};
self.languagePacksAvailable = ko.pureComputed(function() {
@ -656,7 +656,7 @@ $(function() {
*/
self.getLocalData = function() {
var data = {};
if (self.settings != undefined) {
if (self.settings !== undefined) {
data = ko.mapping.toJS(self.settings);
}
@ -664,8 +664,8 @@ $(function() {
var specialMappings = {
feature: {
externalHeatupDetection: function() { return !self.feature_disableExternalHeatupDetection()},
alwaysSendChecksum: function() { return self.feature_sendChecksum() == "always"},
neverSendChecksum: function() { return self.feature_sendChecksum() == "never"}
alwaysSendChecksum: function() { return self.feature_sendChecksum() === "always"},
neverSendChecksum: function() { return self.feature_sendChecksum() === "never"}
},
serial: {
additionalPorts : function() { return commentableLinesToArray(self.serial_additionalPorts()) },
@ -706,7 +706,7 @@ $(function() {
// process all key-value-pairs here
_.forOwn(data, function(value, key) {
var observable = key;
if (keyPrefix != undefined) {
if (keyPrefix !== undefined) {
observable = keyPrefix + "_" + observable;
}
@ -716,7 +716,7 @@ $(function() {
} else if (_.isPlainObject(value)) {
// value is another object, we'll dive deeper
var subresult = mapFromObservables(value, (mapping && mapping[key]) ? mapping[key] : undefined, observable);
if (subresult != undefined) {
if (subresult !== undefined) {
// we only set something on our result if we got something back
result[key] = subresult;
flag = true;
@ -800,7 +800,7 @@ $(function() {
// process all key-value-pairs here
_.forOwn(data, function(value, key) {
var observable = key;
if (keyPrefix != undefined) {
if (keyPrefix !== undefined) {
observable = keyPrefix + "_" + observable;
}
@ -831,16 +831,16 @@ $(function() {
} else {
options = {
success: successCallback,
sending: (setAsSending == true)
sending: (setAsSending === true)
}
}
self.settingsDialog.trigger("beforeSave");
self.sawUpdateEventWhileSending = false;
self.sending(data == undefined || options.sending || false);
self.sending(data === undefined || options.sending || false);
if (data == undefined) {
if (data === undefined) {
// we also only send data that actually changed when no data is specified
data = getOnlyChangedData(self.getLocalData(), self.lastReceivedSettings);
}
@ -919,7 +919,7 @@ $(function() {
};
self.selectTab = function(tab) {
if (tab != undefined) {
if (tab !== undefined) {
if (!_.startsWith(tab, "#")) {
tab = "#" + tab;
}

View file

@ -41,10 +41,10 @@ $(function() {
};
self.profilesForSlicer = function(key) {
if (key == undefined) {
if (key === undefined) {
key = self.slicer();
}
if (key == undefined || !self.data.hasOwnProperty(key)) {
if (key === undefined || !self.data.hasOwnProperty(key)) {
return;
}
var slicer = self.data[key];
@ -53,7 +53,7 @@ $(function() {
self.profiles.removeAll();
_.each(_.values(slicer.profiles), function(profile) {
var name = profile.displayName;
if (name == undefined) {
if (name === undefined) {
name = profile.key;
}
@ -77,7 +77,7 @@ $(function() {
};
self.metadataForSlicer = function(key) {
if (key == undefined || !self.data.hasOwnProperty(key)) {
if (key === undefined || !self.data.hasOwnProperty(key)) {
return;
}
@ -100,7 +100,7 @@ $(function() {
var containsSlicer = function(key) {
return _.any(slicers, function(slicer) {
return slicer.key == key;
return slicer.key === key;
});
};
@ -134,7 +134,7 @@ $(function() {
}
var filename = file;
if (filename.lastIndexOf("/") != 0) {
if (filename.lastIndexOf("/") !== 0) {
path = path || filename.substr(0, filename.lastIndexOf("/"));
filename = filename.substr(filename.lastIndexOf("/") + 1);
}
@ -173,10 +173,10 @@ $(function() {
};
self.enableSliceButton = ko.pureComputed(function() {
return self.destinationFilename() != undefined
&& self.destinationFilename().trim() != ""
&& self.slicer() != undefined
&& self.profile() != undefined
return self.destinationFilename() !== undefined
&& self.destinationFilename().trim() !== ""
&& self.slicer() !== undefined
&& self.profile() !== undefined
&& (!(self.printerState.isPrinting() || self.printerState.isPaused()) || !self.slicerSameDevice());
});
@ -227,7 +227,7 @@ $(function() {
self.slicers.removeAll();
_.each(_.values(data), function(slicer) {
var name = slicer.displayName;
if (name == undefined) {
if (name === undefined) {
name = slicer.key;
}
@ -276,13 +276,13 @@ $(function() {
destination: destinationFilename
};
if (self.path != undefined) {
if (self.path !== undefined) {
data["path"] = self.path;
}
if (self.afterSlicing() == "print") {
if (self.afterSlicing() === "print") {
data["print"] = true;
} else if (self.afterSlicing() == "select") {
} else if (self.afterSlicing() === "select") {
data["select"] = true;
}

View file

@ -57,7 +57,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;
@ -90,7 +90,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();
@ -204,7 +204,7 @@ $(function() {
if (!self.terminalLogDuringPrinting() && self.isPrinting()) {
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;
@ -225,7 +225,7 @@ $(function() {
}
var newLog = self.log().concat(_.map(newData, function(line) { 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"));
}
@ -245,7 +245,7 @@ $(function() {
};
self._toInternalFormat = function(line, type) {
if (type == undefined) {
if (type === undefined) {
type = "line";
}
return {line: escapeUnprintableCharacters(line), type: type}
@ -263,7 +263,7 @@ $(function() {
self.updateFilterRegex = function() {
var filterRegexStr = self.activeFilters().join("|").trim();
if (filterRegexStr == "") {
if (filterRegexStr === "") {
self.filterRegex(undefined);
} else {
self.filterRegex(new RegExp(filterRegexStr));
@ -356,10 +356,10 @@ $(function() {
self.handleKeyDown = function(event) {
var keyCode = event.keyCode;
if (keyCode == 38 || keyCode == 40) {
if (keyCode == 38 && self.cmdHistory.length > 0 && self.cmdHistoryIdx > 0) {
if (keyCode === 38 || keyCode === 40) {
if (keyCode === 38 && self.cmdHistory.length > 0 && self.cmdHistoryIdx > 0) {
self.cmdHistoryIdx--;
} else if (keyCode == 40 && self.cmdHistoryIdx < self.cmdHistory.length - 1) {
} else if (keyCode === 40 && self.cmdHistoryIdx < self.cmdHistory.length - 1) {
self.cmdHistoryIdx++;
}
@ -378,7 +378,7 @@ $(function() {
};
self.handleKeyUp = function(event) {
if (event.keyCode == 13) {
if (event.keyCode === 13) {
self.sendCommand();
}
@ -387,7 +387,7 @@ $(function() {
};
self.onAfterTabChange = function(current, previous) {
self.tabActive = current == "#term";
self.tabActive = current === "#term";
self.updateOutput();
};

View file

@ -54,7 +54,7 @@ $(function() {
});
self.editorPasswordMismatch = ko.pureComputed(function() {
return self.editorPassword() != self.editorRepeatedPassword();
return self.editorPassword() !== self.editorRepeatedPassword();
});
self.requestData = function() {
@ -185,7 +185,7 @@ $(function() {
throw OctoPrint.InvalidArgumentError("user must be set");
}
if (user.name == self.loginState.username()) {
if (user.name === self.loginState.username()) {
// we do not allow to delete ourselves
new PNotify({
title: gettext("Not possible"),

View file

@ -25,7 +25,7 @@ $(function() {
self.access_apikey(undefined);
self.interface_language("_default");
if (newUser != undefined) {
if (newUser !== undefined) {
self.access_apikey(newUser.apikey);
if (newUser.settings.hasOwnProperty("interface") && newUser.settings.interface.hasOwnProperty("language")) {
self.interface_language(newUser.settings.interface.language);
@ -34,13 +34,13 @@ $(function() {
});
self.passwordMismatch = ko.pureComputed(function() {
return self.access_password() != self.access_repeatedPassword();
return self.access_password() !== self.access_repeatedPassword();
});
self.show = function(user) {
if (!CONFIG_ACCESS_CONTROL) return;
if (user == undefined) {
if (user === undefined) {
user = self.loginState.currentUser();
}

View file

@ -72,13 +72,13 @@ $(function() {
return false;
},
onTabShow: function(tab, navigation, index) {
if (index < 0 || tab.length == 0) {
if (index < 0 || tab.length === 0) {
return true;
}
var total = self.wizardDialog.bootstrapWizard("navigationLength");
if (index == total) {
if (index === total) {
self.wizardDialog.find(".button-next").hide();
self.wizardDialog.find(".button-finish").show().removeClass("disabled");
} else {
@ -87,17 +87,17 @@ $(function() {
}
var active = tab[0].id;
if (active != undefined) {
if (active !== undefined) {
callViewModels(allViewModels, "onAfterWizardTabChange", [active]);
}
},
onTabChange: function(tab, navigation, index, nextTabIndex, nextTab) {
var current, next;
if (index == undefined || index < 0 ||
nextTabIndex == undefined || nextTabIndex < 0 ||
index == nextTabIndex ||
tab.length == 0 || nextTab.length == 0) {
if (index === undefined || index < 0 ||
nextTabIndex === undefined || nextTabIndex < 0 ||
index === nextTabIndex ||
tab.length === 0 || nextTab.length === 0) {
// let's ignore that nonsense
return;
}
@ -105,7 +105,7 @@ $(function() {
current = tab[0].id;
next = nextTab[0].id;
if (current != undefined && next != undefined) {
if (current !== undefined && next !== undefined) {
var result = true;
callViewModels(allViewModels, "onBeforeWizardTabChange", function(method) {
// we want to continue evaluating even if result becomes false
@ -145,7 +145,7 @@ $(function() {
// first, or it won't happen after the reload flag has been
// set once due to the || making further evaluation unnecessary
// then
reload = (method() == "reload") || reload;
reload = (method() === "reload") || reload;
});
self.finishWizard()
.done(function() {