$scope.fetch = function()

in synergy/client/app/js/controllers.js [2908:2977]


        $scope.fetch = function () {
            var action = window.location + "";
            action = action.substring(action.lastIndexOf("/") + 1);
            switch (action) {
                case "create":
                    if (parseInt($scope.c_specificationId, 10) > 0) {
                        specificationHttp.get($scope, true, $scope.c_specificationId, function (data) {
                            setLastSuiteOrder(data);
                            setProject(data);
                            $scope.c_specification = data;
                            loadProducts();
                        }, $scope.generalHttpFactoryError);
                    }
                    break;
                case "1":
                    if ($scope.id < 0) {
                        return;
                    }
                    var cachedSuite = specificationCache.getCurrentSuite(parseInt($scope.id, 10));
                    if (cachedSuite) {
                        $scope.suite = cachedSuite;
                        $scope.project = specificationCache.getCurrentProjectName();
                        $scope.$emit("updateBreadcrumbs", {link: "suite/" + $scope.id + "/v/1", title: $scope.suite.title});
                        try {
                            if ($scope.suite.controls.length > 0) {
                                $scope.rights = 1;
                            }
                        } catch (e) {
                        }
                        return;
                    }



                    suiteHttp.get($scope, true, $scope.id, function (data) {
                        $scope.suite = data;
                        setProject(data);
                        $scope.$emit("updateBreadcrumbs", {link: "suite/" + $scope.id + "/v/1", title: data.title});
                        try {
                            if (data.controls.length > 0) {
                                $scope.rights = 1;
                            }
                        } catch (e) {
                        }
                    }, $scope.generalHttpFactoryError);
                    break;
                default :
                    if ($scope.id < 0) {
                        return;
                    }
                    if (typeof $scope.SYNERGY.session.session_id === "undefined" || $scope.SYNERGY.session.session_id.length < 1) {
                        break;
                    }
                    suiteHttp.get($scope, false, $scope.id, function (data) {
                        $scope.suite = data;
                        setProject(data);
                        $scope.refreshCodemirror = true;
                        try {
                            if (data.controls.length > 0) {
                                $scope.rights = 1;
                            }
                        } catch (e) {
                        }

                        loadProducts();

                    }, $scope.generalHttpFactoryError);
                    break;
            }
        };