$scope.fetch = function()

in synergy/client/app/js/controllers.js [3293:3362]


        $scope.fetch = function (useCache) {
            var action = window.location + "";
            action = action.substring(action.lastIndexOf("/") + 1);
            switch (action) {
                case "create":
                    $scope.testCase.steps = "<ol>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<ol>";
                    $scope.testCase.duration = 1;
                    if (parseInt($scope.parentSuite, 10) > 0) {
                        suiteHttp.get($scope, useCache, $scope.parentSuite, function (data) {
                            setProject(data);
                            setLastCaseOrder(data);

                            $scope.c_suite = data;
                        }, $scope.generalHttpFactoryError);
                    }
                    break;
                case "1":
                    if ($scope.id < 0) {
                        return;
                    }
                    var cachedCase = specificationCache.getCurrentCase(parseInt($scope.id, 10), parseInt($scope.parentSuite, 10));
                    if (cachedCase) {
                        $scope.testCase = cachedCase;
                        $scope.project = specificationCache.getCurrentProjectName();
                        $scope.$emit("updateBreadcrumbs", {link: "case/" + $scope.id + "/suite/" + $scope.parentSuite + "/v/1", title: $scope.testCase.title});
                        try {
                            if ($scope.testCase.controls.length > 0) {
                                $scope.rights = 1;
                            }
                        } catch (e) {
                        }
                        return;
                    }

                    caseHttp.get($scope, useCache, $scope.id, $scope.parentSuite, function (data) {
                        $scope.testCase = data;
                        setProject(data);
                        $scope.$emit("updateBreadcrumbs", {link: "case/" + $scope.id + "/suite/" + $scope.parentSuite + "/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;
                    }
                    caseHttp.get($scope, false, $scope.id, $scope.parentSuite, function (data) {
                        $scope.testCase = data;
                        setProject(data);
                        $scope.refreshCodemirror = true;
                        $scope.testCase.suiteId = $scope.parentSuite;
                        originalDuration = parseInt(data.duration, 10);
                        try {
                            if (data.controls.length > 0) {
                                $scope.rights = 1;
                            }
                        } catch (e) {
                        }
                    }, $scope.generalHttpFactoryError);
                    break;
            }
            // FIXME this is loaded twice on document load
        };