Skip to content

Commit

Permalink
Revert "Some long overdue == vs === view model cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 8a977e8.

Was causing at least one regression, to be redone for 1.3.7
  • Loading branch information
foosel committed Dec 12, 2017
1 parent 38a711a commit 8229842
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 155 deletions.
70 changes: 35 additions & 35 deletions src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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});
Expand All @@ -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;
};

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -447,7 +447,7 @@ $(function() {
return;
}

if (data.key === "pluginmanager") return;
if (data.key == "pluginmanager") return;

var onSuccess = function() {
self.requestData();
Expand All @@ -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)
Expand Down Expand Up @@ -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}));

Expand Down Expand Up @@ -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;
}

Expand All @@ -645,7 +645,7 @@ $(function() {
}

var notices = self.config_noticesUrl();
if (notices !== undefined && notices.trim() === "") {
if (notices != undefined && notices.trim() == "") {
notices = null;
}

Expand All @@ -657,7 +657,7 @@ $(function() {
}

var pipArgs = self.config_pipAdditionalArgs();
if (pipArgs !== undefined && pipArgs.trim() === "") {
if (pipArgs != undefined && pipArgs.trim() == "") {
pipArgs = null;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -862,15 +862,15 @@ $(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;
};

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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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>";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -1094,7 +1094,7 @@ $(function() {
};

self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin !== "pluginmanager") {
if (plugin != "pluginmanager") {
return;
}

Expand All @@ -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;
Expand Down Expand Up @@ -1172,35 +1172,35 @@ $(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});
}
}
} 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});
}
}
}

} else if (action === "uninstall") {
} else if (action == "uninstall") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
14 changes: 7 additions & 7 deletions src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
};

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;
opts = params.opts;
}

entries = entries || [];
if (typeof entries === "string") {
if (typeof entries == "string") {
entries = [entries];
}

Expand All @@ -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;
Expand All @@ -47,15 +47,15 @@
};

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;
opts = params.opts;
}

entries = entries || [];
if (typeof entries === "string") {
if (typeof entries == "string") {
entries = [entries];
}

Expand All @@ -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;
Expand Down Expand Up @@ -551,7 +551,7 @@ $(function() {
});
self._updateClicked = false;
} else {
self.forceUpdate = (force === true);
self.forceUpdate = (force == true);
self.confirmationDialog.modal("show");
}

Expand Down
Loading

0 comments on commit 8229842

Please sign in to comment.