<commit_before>/*
 * Copyright 2013 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

angular.module('techGallery').controller('techListController',
        function($scope, $http, $location, $routeParams, $timeout, $rootScope) {

            $scope.showLogin = true;

            $scope.login = function() {
                $timeout(function() {
                    jsUtils.checkAuth(successFunction);
                }, 200);
            }

            var successFunction = function() {
                $timeout(function() {
                    getTechList();
                }, 200);
                $scope.showLogin = false;
            }

            $timeout(function() {
                jsUtils.checkAuth(successFunction);
            }, 200);

            $scope.redirectUrl = function(techId) {
                var protocol = location.protocol + '//';
                var host = protocol + location.host;
                var path = location.pathname;
                if (path === '/') {
                    path = '';
                }
                var servletRedirect = '/viewTech'
                var queryString = '?id=';
                return host + path + servletRedirect + queryString + techId;
            };

            function getTechList() {
                var protocol = location.protocol + '//';
                var host = location.host;
                var complement = '/_ah/api/';
                var rootUrl = protocol + host + complement;
                gapi.client.load('rest', 'v1', callBackLoaded, rootUrl);
                //                        $scope.techList = jsUtils.mockTechList();
            }

            function callBackLoaded() {
                gapi.client.rest.getTechnologies().execute(function(data) {
                    $scope.techList = data.technologies;
                    $scope.$apply();
                });
            }
        });

angular
        .module('techGallery')
        .controller(
                'techDetailsController',
                function($scope, $http, $location, $routeParams, $timeout,
                        $rootScope) {

                    $scope.idTechnology = jsUtils.getParameterByName('id');
                    
                    //Fill this property with the domain of your choice
                    $scope.domain = "@ciandt.com";

                    var alerts = jsUtils.alerts;

                    $scope.endorse = function() {
                        var req = {};
                        req.endorsed = $scope.endorsed + $scope.domain;
                        req.technology = $scope.idTechnology;
                        if ($scope.endorsed) {
                            console.log(req);
                            $scope.alert = alerts.caution;
                            $scope.endorsed = '';
                        }
                    }

                    var successFunction = function() {
                        $timeout(function() {
                            var protocol = location.protocol + '//';
                            var host = location.host;
                            var complement = '/_ah/api/';
                            var rootUrl = protocol + host + complement;
                            gapi.client.load('rest', 'v1', callBackLoaded,
                                    rootUrl);
//                            fillTechnology(jsUtils.mockTechnology());
                        }, 200);
                    }

                    $timeout(function() {
                        jsUtils.checkAuth(successFunction);
                    }, 200);

                    function callBackLoaded() {
                        var idTech = $scope.idTechnology;
                        var req = {
                            id : idTech
                        };
                        gapi.client.rest
                                .getTechnology(req)
                                .execute(
                                        function(data) {
                                            fillTechnology(data);
                                            $scope.$apply();
                                        });
                    }
                    
                    function fillTechnology(technology){
                        $scope.name = technology.name;
                        $scope.description = technology.description;
                        $scope.recommendation = technology.recommendation;
                        $scope.image = technology.image;
                    }

                    $scope.closeAlert = function() {
                        $scope.alert = undefined;
                    }
                });<commit_msg>code review adjusts timeout<commit_after>/*
 * Copyright 2013 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

angular.module('techGallery').controller('techListController',
        function($scope, $http, $location, $routeParams, $timeout, $rootScope) {

            $scope.showLogin = true;

            var executeAuth = function() {
                $timeout(function() {
                    jsUtils.checkAuth(successFunction);
                }, 200);
            }

            $scope.login = function() {
                executeAuth();
            }

            var successFunction = function() {
                getTechList();
                $scope.showLogin = false;
            }

            executeAuth();

            $scope.redirectUrl = function(techId) {
                var protocol = location.protocol + '//';
                var host = protocol + location.host;
                var path = location.pathname;
                if (path === '/') {
                    path = '';
                }
                var servletRedirect = '/viewTech'
                var queryString = '?id=';
                return host + path + servletRedirect + queryString + techId;
            };

            function getTechList() {
                var protocol = location.protocol + '//';
                var host = location.host;
                var complement = '/_ah/api/';
                var rootUrl = protocol + host + complement;
                gapi.client.load('rest', 'v1', callBackLoaded, rootUrl);
                //                        $scope.techList = jsUtils.mockTechList();
            }

            function callBackLoaded() {
                gapi.client.rest.getTechnologies().execute(function(data) {
                    $scope.techList = data.technologies;
                    $scope.$apply();
                });
            }
        });

angular.module('techGallery').controller('techDetailsController',
        function($scope, $http, $location, $routeParams, $timeout, $rootScope) {

            $scope.idTechnology = jsUtils.getParameterByName('id');

            //Fill this property with the domain of your choice
            $scope.domain = <EMAIL>";

            var alerts = jsUtils.alerts;

            $scope.endorse = function() {
                var req = {};
                req.endorsed = $scope.endorsed + $scope.domain;
                req.technology = $scope.idTechnology;
                if ($scope.endorsed) {
                    console.log(req);
                    $scope.alert = alerts.caution;
                    $scope.endorsed = '';
                }
            }

            var successFunction = function() {
                var protocol = location.protocol + '//';
                var host = location.host;
                var complement = '/_ah/api/';
                var rootUrl = protocol + host + complement;
                gapi.client.load('rest', 'v1', callBackLoaded, rootUrl);
                //                            fillTechnology(jsUtils.mockTechnology());
            }

            $timeout(function() {
                jsUtils.checkAuth(successFunction);
            }, 200);

            function callBackLoaded() {
                var idTech = $scope.idTechnology;
                var req = {
                    id : idTech
                };
                gapi.client.rest.getTechnology(req).execute(function(data) {
                    fillTechnology(data);
                    $scope.$apply();
                });
            }

            function fillTechnology(technology) {
                $scope.name = technology.name;
                $scope.description = technology.description;
                $scope.recommendation = technology.recommendation;
                $scope.image = technology.image;
            }

            $scope.closeAlert = function() {
                $scope.alert = undefined;
            }
        });
{'fraction_non_alphanumeric': 0.0994332818134982, 'fraction_numerical': 0.00422462648119526, 'mean_word_length': 1.202405264352167, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5196200', 'n_tokens_mistral': 2343, 'n_tokens_neox': 2114, 'n_words': 519}