Commit 5b23cade4e0c341ff70f529899a586637f42541d
1 parent
2ddd840c
implemented synchronous http calls to load json data
Showing
8 changed files
with
212 additions
and
114 deletions
300-PROTOTYPES/bottomLeftArrow.png
0 → 100644
1.54 KB
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", | |
4 | -function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam) { | |
3 | +AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService", | |
4 | +function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, GetJsonService) { | |
5 | 5 | |
6 | 6 | $scope.genderId = ""; |
7 | 7 | $scope.BodyViewData; |
... | ... | @@ -19,6 +19,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
19 | 19 | $scope.layerNumber; |
20 | 20 | $scope.daCounter = 1; |
21 | 21 | |
22 | + $scope.isBodylayerdataLoaded = false; | |
23 | + $scope.isBodyRegionDataLoaded = false; | |
22 | 24 | |
23 | 25 | //get the DA body view list based on selected gender |
24 | 26 | $scope.getDAViewList = function ($event) { |
... | ... | @@ -147,101 +149,138 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
147 | 149 | //da-body-view functions |
148 | 150 | |
149 | 151 | $scope.openBodyView = function () { |
152 | + //debugger; | |
150 | 153 | |
154 | + //load bodyRegion data | |
155 | + var brViewdata = GetJsonService.getJson('~/../content/data/json/da_dat_brview.json') | |
156 | + brViewdata.then( | |
157 | + function (result) { | |
158 | + // debugger; | |
159 | + $scope.BodyRegionData = result; | |
160 | + $scope.isBodyRegionDataLoaded = true; | |
161 | + // alert('da_dat_brview= ' + result) | |
151 | 162 | |
152 | - //load json | |
153 | - $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { | |
154 | - $scope.TermNumberData = data; | |
155 | - }) | |
156 | - .error(function (data, status, headers, config) { | |
157 | - console.log(data); | |
158 | - }); | |
163 | + //get layer data for body view | |
164 | + GetJsonService.getAnotherJson('~/../content/data/json/da_dat_layer_1.json') | |
165 | + .then( | |
166 | + function (result) { | |
167 | + //debugger; | |
168 | + | |
169 | + $scope.BodyLayerData = result; | |
170 | + $scope.isBodylayerdataLoaded = true; | |
159 | 171 | |
172 | + //load json for annotations | |
173 | + $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { | |
174 | + $scope.TermNumberData = data; | |
175 | + }) | |
176 | + .error(function (data, status, headers, config) { | |
177 | + console.log(data); | |
178 | + }); | |
160 | 179 | |
161 | - //load vocabterm data | |
162 | - $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) { | |
163 | - $scope.VocabTermData = data; | |
164 | - }) | |
165 | - .error(function (data, status, headers, config) { | |
166 | - console.log(data); | |
167 | - }); | |
180 | + //load vocabterm data | |
181 | + $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) { | |
182 | + $scope.VocabTermData = data; | |
183 | + }) | |
184 | + .error(function (data, status, headers, config) { | |
185 | + console.log(data); | |
186 | + }); | |
168 | 187 | |
169 | 188 | |
170 | 189 | |
171 | - var openViews; | |
172 | - var currentBodyViewId = localStorage.getItem("currentBodyViewId"); | |
173 | - // debugger; | |
174 | - if ($rootScope.openViews.length > 0) { | |
175 | - openViews = new jinqJs() | |
176 | - .from($rootScope.openViews) | |
177 | - .where("BodyViewId==" + currentBodyViewId) | |
178 | - .select(); | |
179 | - } | |
180 | - var counter = 1; | |
190 | + var openViews; | |
181 | 191 | |
182 | - // var tittle = $rootScope.ViewTitle; | |
183 | - var tittle = localStorage.getItem("currentViewTitleFromJson"); | |
192 | + var currentBodyViewId = localStorage.getItem("currentBodyViewId"); | |
193 | + // debugger; | |
194 | + if ($rootScope.openViews.length > 0) { | |
195 | + openViews = new jinqJs() | |
196 | + .from($rootScope.openViews) | |
197 | + .where("BodyViewId==" + currentBodyViewId) | |
198 | + .select(); | |
199 | + } | |
200 | + var counter = 1; | |
184 | 201 | |
185 | - if (openViews != null && openViews.length > 0) { | |
186 | - angular.forEach(openViews, function (value, key) { | |
202 | + // var tittle = $rootScope.ViewTitle; | |
203 | + var tittle = localStorage.getItem("currentViewTitleFromJson"); | |
187 | 204 | |
188 | - if (value.BodyView == tittle) { | |
189 | - tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; | |
190 | - $rootScope.currentActiveViewTitle = tittle; | |
191 | - localStorage.setItem("currentViewTitle", tittle); | |
192 | - } | |
193 | - | |
194 | - }); | |
195 | - } | |
196 | - else { | |
197 | - localStorage.setItem("currentViewTitle", tittle); | |
198 | - } | |
205 | + if (openViews != null && openViews.length > 0) { | |
206 | + angular.forEach(openViews, function (value, key) { | |
199 | 207 | |
208 | + if (value.BodyView == tittle) { | |
209 | + tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; | |
210 | + $rootScope.currentActiveViewTitle = tittle; | |
211 | + localStorage.setItem("currentViewTitle", tittle); | |
212 | + } | |
200 | 213 | |
214 | + }); | |
215 | + } | |
216 | + else { | |
217 | + localStorage.setItem("currentViewTitle", tittle); | |
218 | + } | |
201 | 219 | |
202 | - $.jsPanel({ | |
203 | - id: 'daImagePanel', | |
204 | - selector: '.daBodyView', | |
205 | - theme: 'success', | |
206 | - ajax: { | |
207 | - url: 'app/views/da/da-view.html' | |
208 | - }, | |
209 | - title: localStorage.getItem("currentViewTitle"), | |
210 | - position: { | |
211 | - top: 70, | |
212 | - left: 1, | |
213 | - }, | |
214 | 220 | |
215 | - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, | |
221 | + $.jsPanel({ | |
222 | + id: 'daImagePanel', | |
223 | + selector: '.daBodyView', | |
224 | + theme: 'success', | |
225 | + ajax: { | |
226 | + url: 'app/views/da/da-view.html' | |
227 | + }, | |
228 | + title: localStorage.getItem("currentViewTitle"), | |
229 | + position: { | |
230 | + top: 70, | |
231 | + left: 1, | |
232 | + }, | |
216 | 233 | |
217 | - }); | |
234 | + size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, | |
218 | 235 | |
236 | + }); | |
219 | 237 | |
220 | 238 | |
221 | 239 | |
222 | 240 | |
223 | - $scope.LoadDefaultLayerImage(); | |
224 | - // $rootScope.openViewsDA.push({ "ViewId": 1 }); | |
225 | - $rootScope.currentSlug = 'da-body-view'; | |
226 | 241 | |
227 | - //hide scrollbar | |
228 | 242 | |
243 | + // $rootScope.openViewsDA.push({ "ViewId": 1 }); | |
244 | + $rootScope.currentSlug = 'da-body-view'; | |
229 | 245 | |
230 | - $rootScope.openViews.push( | |
231 | - { | |
232 | - "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, | |
233 | - "slug": $rootScope.currentSlug | |
234 | - } | |
235 | - ); | |
236 | - // debugger; | |
246 | + //hide scrollbar | |
237 | 247 | |
238 | - var e1 = angular.element(document.getElementById("daBodyview")); | |
239 | - $timeout(function () { $compile(e1.contents())($scope) }, 250); | |
240 | - // $compile(e1.contents())($scope); | |
241 | 248 | |
242 | - $('#daBodyview').css("height", $(window).outerHeight()); | |
243 | - | |
244 | - $('#daBodyview').css("width", $(window).outerWidth()); | |
249 | + $rootScope.openViews.push( | |
250 | + { | |
251 | + "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, | |
252 | + "slug": $rootScope.currentSlug | |
253 | + } | |
254 | + ); | |
255 | + // debugger; | |
256 | + | |
257 | + var e1 = angular.element(document.getElementById("daBodyview")); | |
258 | + $timeout(function () { $compile(e1.contents())($scope) }, 250); | |
259 | + // $compile(e1.contents())($scope); | |
260 | + | |
261 | + $('#daBodyview').css("height", $(window).outerHeight()); | |
262 | + | |
263 | + $('#daBodyview').css("width", $(window).outerWidth()); | |
264 | + | |
265 | + // debugger | |
266 | + if ($scope.isBodylayerdataLoaded) { | |
267 | + $timeout(function () { $scope.LoadDefaultLayerImage() }, 350); | |
268 | + } | |
269 | + }, | |
270 | + function (error) { | |
271 | + // handle errors here | |
272 | + console.log(' $scope.BodyLayerData= ' + error.statusText); | |
273 | + } | |
274 | + ); | |
275 | + }, | |
276 | + function (error) { | |
277 | + // handle errors here | |
278 | + console.log(' $scope.BodyRegionData = ' + error.statusText); | |
279 | + } | |
280 | + ); | |
281 | + | |
282 | + // debugger | |
283 | + | |
245 | 284 | } |
246 | 285 | |
247 | 286 | angular.element(document).ready(function () { |
... | ... | @@ -258,26 +297,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
258 | 297 | |
259 | 298 | $scope.LoadDefaultLayerImage = function () { |
260 | 299 | // debugger; |
261 | - $http({ method: 'GET', url: '~/../content/data/json/da_dat_brview.json' }).success(function (data) { | |
262 | - | |
263 | - $scope.BodyRegionData = data; | |
264 | - console.log($scope.BodyRegionData); | |
265 | - }) | |
266 | - .error(function (data, status, headers, config) { | |
267 | - console.log(data); | |
268 | - }); | |
269 | - | |
270 | 300 | |
271 | - // Load Layer data | |
272 | - $http({ method: 'GET', url: '~/../content/data/json/da_dat_layer_1.json' }).success(function (data) { | |
273 | - // debugger | |
274 | - $scope.BodyLayerData = data; | |
275 | - console.log($scope.BodyLayerData); | |
276 | - | |
277 | - }) | |
278 | - .error(function (data, status, headers, config) { | |
279 | - console.log(data); | |
280 | - }); | |
281 | 301 | |
282 | 302 | // debugger; |
283 | 303 | |
... | ... | @@ -285,16 +305,42 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
285 | 305 | $scope.layerNumber = 0; |
286 | 306 | $scope.skinTone = DA[0].ethnicity; |
287 | 307 | |
288 | - $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 250); | |
289 | - | |
308 | + // $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 350); | |
290 | 309 | |
310 | + $scope.CalculateImageCordinates($scope.voId); | |
291 | 311 | }; |
292 | 312 | |
293 | 313 | |
294 | 314 | //calculate coordinates for body region images |
295 | 315 | $scope.CalculateImageCordinates = function (viewOrientationId) { |
296 | 316 | |
297 | - // debugger; | |
317 | + // debugger; | |
318 | + //load json data | |
319 | + // $http({ method: 'GET', url: '~/../content/data/json/da_dat_brview.json' }).success(function (data) { | |
320 | + // alert('da_dat_brview.json') | |
321 | + // $scope.BodyRegionData = data; | |
322 | + // alert(data) | |
323 | + // // console.log($scope.BodyRegionData); | |
324 | + // }) | |
325 | + //.error(function (data, status, headers, config) { | |
326 | + // console.log(data); | |
327 | + //}); | |
328 | + | |
329 | + | |
330 | + // // Load Layer data | |
331 | + // $http({ method: 'GET', url: '~/../content/data/json/da_dat_layer_1.json' }).success(function (data) { | |
332 | + // // debugger | |
333 | + // $scope.BodyLayerData = data; | |
334 | + // console.log($scope.BodyLayerData); | |
335 | + | |
336 | + // }) | |
337 | + // .error(function (data, status, headers, config) { | |
338 | + // console.log(data); | |
339 | + // }); | |
340 | + | |
341 | + | |
342 | + | |
343 | + | |
298 | 344 | //set height of canvas div and left tool bar as per window size |
299 | 345 | $scope.BodyRegionCordinatesData = []; // create an empty array |
300 | 346 | |
... | ... | @@ -453,7 +499,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
453 | 499 | |
454 | 500 | |
455 | 501 | $scope.GetImageSource = function (bodyRegionId) { |
456 | - // debugger; | |
502 | + // debugger; | |
457 | 503 | var dataLength = $scope.BodyLayerData.Layers.DataLayer.length; |
458 | 504 | |
459 | 505 | //set max for LayerNumber input |
... | ... | @@ -664,7 +710,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
664 | 710 | imgCanvas.addEventListener('click', function (evt) { |
665 | 711 | |
666 | 712 | |
667 | - // debugger; | |
713 | + // debugger; | |
668 | 714 | var context = imgCanvas.getContext("2d"); |
669 | 715 | |
670 | 716 | |
... | ... | @@ -770,7 +816,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
770 | 816 | |
771 | 817 | //get annotation from term number |
772 | 818 | $scope.GetAnnotationText = function (termNumber) { |
773 | - // debugger; | |
819 | + // debugger; | |
774 | 820 | |
775 | 821 | var annotationText; |
776 | 822 | //0 |
... | ... | @@ -801,7 +847,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
801 | 847 | } |
802 | 848 | |
803 | 849 | $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo) { |
804 | - // debugger; | |
850 | + // debugger; | |
805 | 851 | |
806 | 852 | var Annotation; |
807 | 853 | $scope.ActualTermNo = actualTermNo; |
... | ... | @@ -822,7 +868,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
822 | 868 | |
823 | 869 | //layer change function |
824 | 870 | $scope.LayerChange = function () { |
825 | - | |
871 | + | |
826 | 872 | var canvasDiv = document.getElementById('canvasDiv'); |
827 | 873 | $scope.imageVerticalScrollPosition = canvasDiv.scrollTop; |
828 | 874 | $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft; |
... | ... | @@ -908,7 +954,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
908 | 954 | } |
909 | 955 | |
910 | 956 | |
911 | - $scope.createSpeechBubble = function(event, text, x, y) { | |
957 | + $scope.createSpeechBubble = function (event, text, x, y) { | |
912 | 958 | |
913 | 959 | $('#canvasDiv').css('cursor', 'pointer'); |
914 | 960 | $('<div id="speechBubble" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px;"> <div class="">' |
... | ... | @@ -972,6 +1018,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
972 | 1018 | |
973 | 1019 | }] |
974 | 1020 | |
1021 | +); | |
975 | 1022 | |
976 | - | |
977 | -); | |
978 | 1023 | \ No newline at end of file |
1024 | +//DAController.$inject = ["$scope", "$rootScope", "$q", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService"]; | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/services/GetJsonService.js
0 → 100644
1 | +AIA.service("GetJsonService", function ($http, $q) { | |
2 | + | |
3 | + var deferred = $q.defer(); | |
4 | + | |
5 | + this.getJson = function (url) { | |
6 | + var deferred = $q.defer(); | |
7 | + return $http.get(url) | |
8 | + .then(function (response) { | |
9 | + // promise is fulfilled | |
10 | + // debugger; | |
11 | + deferred.resolve(response.data); | |
12 | + // promise is returned | |
13 | + return deferred.promise; | |
14 | + }, function (response) { | |
15 | + // the following line rejects the promise | |
16 | + deferred.reject(response); | |
17 | + // promise is returned | |
18 | + return deferred.promise; | |
19 | + }) | |
20 | + ; | |
21 | + }; | |
22 | + | |
23 | + this.getAnotherJson = function (url1) { | |
24 | + var deferred1 = $q.defer(); | |
25 | + return $http.get(url1) | |
26 | + .then(function (response1) { | |
27 | + // promise is fulfilled | |
28 | + // debugger; | |
29 | + deferred1.resolve(response1.data); | |
30 | + // promise is returned | |
31 | + return deferred1.promise; | |
32 | + }, function (response1) { | |
33 | + // the following line rejects the promise | |
34 | + deferred1.reject(response1); | |
35 | + // promise is returned | |
36 | + return deferred1.promise; | |
37 | + }) | |
38 | + ; | |
39 | + }; | |
40 | +}); | |
41 | + | |
42 | + | |
43 | + | |
44 | +//AIA.factory('GetJsonService', function ($http) { | |
45 | +// return { | |
46 | +// // 1st function | |
47 | +// getJson: function (url) { | |
48 | +// debugger; | |
49 | +// return $http.get(url).then(function (response) { | |
50 | +// alert(response.data); | |
51 | +// return response.data; | |
52 | +// }); | |
53 | +// }, | |
54 | +// // 2nd function | |
55 | +// getAnotherJson: function (url) { | |
56 | +// return $http.get(url).then(function (response) { | |
57 | +// alert(response.data); | |
58 | +// return response.data; | |
59 | +// }); } | |
60 | +// }; | |
61 | +//}) | |
0 | 62 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/services/load-json-service.js deleted
400-SOURCECODE/AIAHTML5.Web/index.html
... | ... | @@ -147,8 +147,7 @@ |
147 | 147 | <script src="content/js/custom/custom.js"></script> |
148 | 148 | <script src="app/controllers/DAController.js"></script> |
149 | 149 | <script src="app/controllers/HomeController.js"></script> |
150 | - | |
151 | - | |
150 | + <script src="app/services/GetJsonService.js"></script> | |
152 | 151 | |
153 | 152 | |
154 | 153 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/libs/jquery/jquery_plugin/SpeechBubble/images/bubble/bottomLeftArrow.png
400-SOURCECODE/AIAHTML5.Web/libs/jquery/jquery_plugin/SpeechBubble/images/bubble/bottomLeftArrow_old.png
0 → 100644
880 Bytes
400-SOURCECODE/AIAHTML5.Web/themes/default/css/bootstrap/3.3.6/main.css