Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:

        $scope.showLocalChanged = function (folder) {
            $scope.localChangedFolder = folder;
            $scope.localChanged = $scope.refreshLocalChanged(1, 10);
            $('#localChanged').modal().one('hidden.bs.modal', function () {
                $scope.localChanged = {};
                $scope.localChangedFolder = undefined;
            });
        };

        $scope.canRevert = function (folder) {
            var f = $scope.model[folder];
            if (!f) {
                return false;
            }
            return $scope.model[folder].receiveOnlyTotalItems > 0;
        };

        $scope.revertOverride = function () {
            $http.post(
                urlbase + "/db/" + $scope.revertOverrideParams.operation +"?folder="
                +encodeURIComponent($scope.revertOverrideParams.folderID));
        };

        $scope.revertOverrideConfirmationModal = function (type, folderID) {
            var params = {};
            params.type = type;
            params.folderID = folderID;
            switch (type) {
                case "override":
                    params.heading = $translate.instant("Override");
                    params.operation = "override";
                    break;
                case "revert":
                    params.heading = $translate.instant("Revert");
                    params.operation = "revert";
                    break;
                case "deleteEnc":
                    params.heading = $translate.instant("Delete Unexpected Items");
                    params.operation = "revert";
                    break;
            }
            $scope.revertOverrideParams = params;
            $('#revert-override-confirmation').modal('show');
        };

        $scope.advanced = function () {
            $scope.advancedConfig = angular.copy($scope.config);
            $scope.advancedConfig.devices.sort(deviceCompare);
            $scope.advancedConfig.folders.sort(folderCompare);
            $('#advanced').modal('show');

Review comment (suggestion):
Specific reason why you create the object empty first, instead of specifying the values in the initializer? (`type` and `folderID`)

Code after:

        $scope.showLocalChanged = function (folder) {
            $scope.localChangedFolder = folder;
            $scope.localChanged = $scope.refreshLocalChanged(1, 10);
            $('#localChanged').modal().one('hidden.bs.modal', function () {
                $scope.localChanged = {};
                $scope.localChangedFolder = undefined;
            });
        };

        $scope.canRevert = function (folder) {
            var f = $scope.model[folder];
            if (!f) {
                return false;
            }
            return $scope.model[folder].receiveOnlyTotalItems > 0;
        };

        $scope.revertOverride = function () {
            $http.post(
                urlbase + "/db/" + $scope.revertOverrideParams.operation +"?folder="
                +encodeURIComponent($scope.revertOverrideParams.folderID));
        };

        $scope.revertOverrideConfirmationModal = function (type, folderID) {
            var params = {
                type: type,
                folderID: folderID,
            };
            switch (type) {
                case "override":
                    params.heading = $translate.instant("Override");
                    params.operation = "override";
                    break;
                case "revert":
                    params.heading = $translate.instant("Revert");
                    params.operation = "revert";
                    break;
                case "deleteEnc":
                    params.heading = $translate.instant("Delete Unexpected Items");
                    params.operation = "revert";
                    break;
            }
            $scope.revertOverrideParams = params;
            $('#revert-override-confirmation').modal('show');
        };

        $scope.advanced = function () {
            $scope.advancedConfig = angular.copy($scope.config);
            $scope.advancedConfig.devices.sort(deviceCompare);
            $scope.advancedConfig.folders.sort(folderCompare);