PageSourceSearch

https://levarne.github.io/specmyride/js/controllers.js

js levarne.github.io collected 2026-10-03 09:30:32 UTC 8,631 bytes, 271 lines download raw bytes

1/**
2 * Created by user on 15/06/16.
3 */
4
5angular.module('specmyride.controller', [])
6
7    .controller('bodyCtrl', function($scope, $ionicSideMenuDelegate, $window, $ionicHistory){
8
9        $scope.aboutAlert = function(){
10            alert("Developed By: Levarne Sobotker");
11        }
12
13        /*
14            exit app
15        */
16        $scope.exitApp = function(){
17            ionic.Platform.exitApp();
18        }
19
20        //change theme
21        var selectedTheme = window.localStorage.SpecMyRideTheme;
22        if(selectedTheme){
23            $scope.appTheme = selectedTheme;
24        }else{
25            $scope.appTheme = 'themeRetro';
26        }
27
28        //else add theme to storage
29        $scope.changeTheme = function(theme){
30            window.localStorage.SpecMyRideTheme = theme;
31            $window.location = '';
32        }
33
34        //global mini-loader
35        $scope.miniLoaderShow = function(){
36            $scope.miniLoader = 'miniLoader';
37        }
38
39        $scope.miniLoaderHide = function(){
40            $scope.miniLoader = 'miniLoaderOff';
41        }
42
43        $scope.toggleLeftMenu = function(){
44            $ionicSideMenuDelegate.toggleLeft();
45        }
46
47        $scope.toggleTitle = function(title){
48            if(title){
49                $scope.PageTitle = title.toUpperCase();
50            }else{
51                $scope.PageTitle = "CATEGORIES";
52            }
53        }
54
55        $scope.myGoBack = function(){
56            var backViewObj, titleStr
57
58            $ionicHistory.goBack();
59
60            backViewObj = $ionicHistory.backView();
61
62            //remove the title name from tab.
63            titleStr = backViewObj.url;
64            titleStr = titleStr.substring(titleStr.lastIndexOf("/") + 1, titleStr.length);
65
66            $scope.toggleTitle(titleStr);
67        }
68
69        $scope.catView = [
70            'grid',
71            'list'
72        ]
73
74        var selectedView = $window.localStorage.appView;
75
76        if(selectedView){
77            $scope.appView = selectedView;
78            //change button icon to its corresponting layout
79            switch(selectedView){
80                case 'grid':
81                    $scope.viewClass = 'ion-android-list';
82                    //ion-ios-drag
83                    //ion-ios-list-outline
84                    //ion-android-list
85                    break;
86                case 'list':
87                    $scope.viewClass = 'ion-grid';
88            }
89        }else{
90            $scope.appView = 'grid';
91            $scope.viewClass = 'ion-grid';
92        }
93
94        $scope.viewChange = function(){
95            if($window.localStorage.appView == 'list'){
96                $window.localStorage.appView = 'grid';
97            }else{
98                $window.localStorage.appView = 'list';
99            }
100
101            $window.location = '';
102        }
103    })
104
105    //categories page, my main page
106    .controller('categoriesCtrl', function($scope, CategoryData){
107        $scope.toggleTitle();
108        var data = CategoryData.getAllMakes();
109
110        $scope.vehicleMakeData = data;
111    })
112
113    .controller('vehicleModelCtrl', function($scope, $stateParams, $ionicPopup,CategoryData, $location) {
114        $scope.globalMakeName = $stateParams.makeName;
115        $scope.toggleTitle($scope.globalMakeName);
116
117        $scope.panes = [
118            {active:false, disabled:true},
119            {active:false, disabled:true},
120            {active:false, disabled:true},
121            {active:false, disabled:true}
122        ];
123
124         //remove this when writing your sqli database
125        $scope.makeIDModel = $stateParams.makeId;
126
127        $scope.categroyModelData = CategoryData.getAllModels($stateParams.makeId);
128
129        //CategoryData.getAllModels($stateParams.makeId).then(function(value){
130        //   $scope.categroyModelData = value;
131        // });
132
133        $scope.selectModel = function(MakeNiceName, model_niceName){
134            $scope.miniLoaderShow();
135            //$scope.modelFullDetails = CategoryData.getAllModelFull(MakeNiceName,model_niceName);
136
137            var myData = CategoryData.getAllModelFull(MakeNiceName,model_niceName);
138
139            myData.then(function(result) {
140                $scope.miniLoaderHide();
141
142                $scope.modelFullDetails = result['data']['models'];
143            });
144
145            $scope.modelYear = {text: "text"};
146            $scope.modelStyleID = {text: "text"};
147            $ionicPopup.show({
148                //title: "Select You'r Model Specifics",
149                cssClass: 'settingsPopup',
150                templateUrl: 'templates/model.year.trimLevel.html',
151                scope: $scope,
152                buttons: [
153                    {
154                        text: 'Ok',
155                        type: 'button-balanced',
156                        onTap: function(e){
157                            var makeName = $scope.globalMakeName;
158                            var modelStyleID = $scope.modelStyleID.text;
159
160                            $location.path('/tab/categories-model-showcase/' + makeName + '/' + modelStyleID);
161                        }
162                    },
163                    {
164                        text: 'Cancel',
165                        type: 'button-assertive'
166                    }]
167            });
168        }
169    })
170
171
172//main showcase page
173    .controller('ModelShowcaseCtrl', function($scope, $stateParams, CategoryData) {
174        $scope.toggleTitle($stateParams.makeName);
175        $scope.modelShowcasePhotos = [];
176        var resultSet = CategoryData.getModelFullStyleDetails($stateParams.styleId);
177
178        resultSet.then(function (result) {
179
180            $scope.modelShowCase = result;
181
182            var Arraydata = [result['make']['niceName'],
183                result['model']['niceName'],
184                result['year']['year']];
185
186            CategoryData.setModelParamdata(Arraydata);
187
188            var filter = ["fq", "rq"]
189
190            var photos = CategoryData.getModelPhotos($stateParams.styleId);
191
192            photos.then(function (result) {
193                var resultLength = result.length
194                for (var i = 0; i < resultLength; i++) {
195                    for (var j = 0; j < result[i].photoSrcs.length; j++) {
196                        if (result[i].photoSrcs[j].indexOf("600.jpg") > -1) {
197                            $scope.modelShowcasePhotos[i] = "http://media.ed.edmunds-media.com" + result[i].photoSrcs[j];
198                        }
199                    }
200                }
201                $scope.slideCounter = 0;
202            })
203
204        });
205    })
206
207    .controller('ModelArticleCtrl', function($scope, $sanitize, CategoryData) {
208        $scope.$on('$ionicView.enter', function() {
209
210            tempParamdata = CategoryData.getModelParamdata();
211
212            if(tempParamdata.length > 0) {
213                var articleDataset = CategoryData.getModelArticle(tempParamdata[0], tempParamdata[1], tempParamdata[2]);
214
215                articleDataset.then(function (result) {
216
217                   //console.log('Article ', result.data);
218
219                    $scope.articleData = result.data;
220                });
221            }
222        })
223    })
224
225    .controller('ModelReviewCtrl', function($scope, CategoryData) {
226        $scope.$on('$ionicView.enter', function() {
227            tempParamdata = CategoryData.getModelParamdata();
228
229            if(tempParamdata.length > 0){
230                var artcileDataSet = CategoryData.getModelReview(tempParamdata[0], tempParamdata[1], tempParamdata[2]);
231
232                artcileDataSet.then(function (result) {
233
234                    //console.log('Review ', result.data);
235
236                    $scope.reviewData = result.data.editorial;
237
238                });
239            }
240        })
241    })
242
243    .controller('disableTabs', function(testTab){
244        //console.log('disable tabs');
245        if(testTab == true){
246            $scope.project = true;
247        }else {
248            $scope.project = false;
249        }
250    })
251
252    .directive('specDropdown', ['$animate', function($document){
253         return {
254                    link: function(scope, element, attr){
255                            element.on('click', function(){
256                                    if(element.attr('class').indexOf('clicked') >= 0){
257                                        element.removeClass('clicked');
258                                    }else{
259                                        element.addClass('clicked');
260                                    }
261                            });
262                    }
263                }
264    }])
265
266    .filter("sanitize", ['$sce', function($sce) {
267        return function(htmlCode){
268            return angular.element('<div>'+htmlCode+'</div>').text();
269        }
270    }]);
271

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.