Commit 8b31725c7b6e3814f1e7c95edca03076e09da10e

Authored by Amrita Vishnoi
1 parent 451a434d

Body View worker is introduced.

400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -56,6 +56,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
56 56 $scope.previousSelectedTermList = [];
57 57 $scope.runningWorkers = [];
58 58 $scope.runningSearchWorkers = [];
  59 + $scope.runningBodyViewWorkers =[];
59 60  
60 61 // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false.
61 62 $scope.machedIcolorInBodyRegion = [];
... ... @@ -318,6 +319,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
318 319  
319 320 //0.1
320 321 var currentBodyViewId = localStorage.getItem("currentBodyViewId");
  322 +
  323 + console.log('currentBodyViewId pickjed from localStorage: ' + currentBodyViewId);
  324 +
321 325 var openViews;
322 326 if ($rootScope.openViews != null || $rootScope.openViews != undefined) {
323 327 if ($rootScope.openViews.length > 0) {
... ... @@ -390,41 +394,18 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
390 394  
391 395 $('#daBodyview').css("width", $(window).outerWidth());
392 396  
393   - //1. load navigator man first
394   -
  397 + //1. load navigator man first
395 398 $scope.LoadBodyViewNavigatorImage();
396   -
397   - //2. load bodyRegion data
398   - $rootScope.isLoading = true;
399   - $rootScope.voId = localStorage.getItem("currentBodyViewId");
400 399  
401   - var bodyRegionjsonPath = '~/../content/data/json/da/da_dat_brview.json';
402   - var brViewdata = DataService.getJson(bodyRegionjsonPath)
  400 + //2.
403 401  
404   - var layerJsonPath = null;
405   -
406   - brViewdata.then(
407   - function (result) {
  402 + console.log('currentBodyViewId just before sending: ' + currentBodyViewId);
  403 + $scope.loadBodyViewData(currentBodyViewId);
408 404  
409   - $rootScope.BodyRegionData = result;
410   - $scope.isBodyRegionDataLoaded = true;
411   -
412   - //3.
413   - $scope.loadLayerDataForCurrentBodyView();
414   -
415   - },
416   - function (error) {
417   -
418   - //1.
419   - console.log('DATA.NOT.LOADED FOR: ' + bodyRegionjsonPath + ' , ERROR:' + error.statusText);
420   -
421   -
422   - //2.
423   - $scope.openBodyView();
424   - }
425   - );
426   -
427   - // debugger
  405 + //2. load bodyRegion data
  406 + $rootScope.isLoading = true;
  407 + $rootScope.voId = localStorage.getItem("currentBodyViewId");
  408 +
428 409 $('#daBodyview').css("height", $(window).outerHeight());
429 410  
430 411 $('#daBodyview').css("width", $(window).outerWidth());
... ... @@ -493,42 +474,41 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
493 474  
494 475 }
495 476  
496   - $scope.loadLayerDataForCurrentBodyView = function () {
497   - //1.
498   - var bgArtJsonPath = '';
499   - var CommonViewId = 0;
500   - var currentBodyViewId = localStorage.getItem("currentBodyViewId");
  477 + $scope.loadBodyViewData = function (currentVoid)
  478 + {
  479 + console.log('caller of worker sending currentVoid: ' + currentVoid);
501 480  
  481 + var bodyViewWorker = new Worker('body-view-wp.js');
502 482  
503   - //2.
504   - var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json';
505   - DataService.getAnotherJson(layerJsonPath)
506   - .then(
507   - function (result) {
  483 + //push workers in array to further used the refernece to delete the workers
  484 + $scope.runningBodyViewWorkers.push({ 'workerName': bodyViewWorker })
508 485  
509   - $rootScope.BodyLayerData = result;
510   - $scope.isBodylayerdataLoaded = true;
  486 + bodyViewWorker.postMessage({
511 487  
512   - //3.
513   - $scope.LoadDefaultLayerImage();
  488 + 'currentViewId': currentVoid
514 489  
515   - //4.
516   - $scope.isVisibleTermddl = false;
517   -
518   - },
519   - function (error) {
  490 + });
520 491  
521   - //1.
522   - console.log('DATA.NOT.LOADED FOR: ' + layerJsonPath +' , ERROR:' + error.statusText);
  492 + bodyViewWorker.onmessage = function (e)
  493 + {
  494 + console.log('callback in extr');
  495 +
  496 + $rootScope.BodyRegionData = e.data.bodyRegionData;
  497 + $rootScope.bgartData = e.data.bodyArtData;
  498 + $rootScope.BodyLayerData = e.data.bodyLayerData;
523 499  
524   - //2.
525   - $scope.loadLayerDataForCurrentBodyView();
  500 + $scope.isBodylayerdataLoaded = true;
526 501  
  502 + $scope.LoadDefaultLayerImage();
527 503  
528   - }
529   - );
530 504  
  505 +
  506 + }
  507 + bodyViewWorker.onerror = function (e) {
  508 + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
  509 + };
531 510 }
  511 +
532 512  
533 513 //Code for displaying NavigatorImage for BodyView
534 514 $scope.LoadBodyViewNavigatorImage = function ()
... ... @@ -634,24 +614,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
634 614 else if ($rootScope.voId == 12) {
635 615 $scope.viewOrientationId = 6;
636 616 }
  617 +
  618 + $scope.CalculateImageCordinates($scope.viewOrientationId);
637 619  
638   - // debugger;
639   - var bgArtJsonPath = '';
640   -
641   - bgArtJsonPath = '~/../content/data/json/da/da_dat_bgart.json';
642   -
643   - var bgartdata = DataService.getJson(bgArtJsonPath)
644   - bgartdata.then(
645   - function (result) {
646   - //debugger;
647   - $rootScope.bgartData = result;
648   - $scope.CalculateImageCordinates($scope.viewOrientationId);
649   -
650   - },
651   - function (error) {
652   - // handle errors here
653   - console.log(' $rootScope.bgartData = ' + error.statusText);
654   - });
  620 +
655 621 };
656 622  
657 623  
... ... @@ -1548,6 +1514,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1548 1514 $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
1549 1515 }
1550 1516 else {
  1517 +
  1518 + $scope.annotationTextArray = [];
  1519 +
  1520 + console.log('1. annotationText: ' + annotationText);
  1521 +
1551 1522 if ($('#dot').length > 0) {
1552 1523 $('#dot').remove();
1553 1524  
... ... @@ -1559,16 +1530,23 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1559 1530  
1560 1531 // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
1561 1532  
1562   - $scope.annotationTextArray = [];
  1533 +
1563 1534 $scope.annotationTextArray.push(annotationText);
  1535 +
  1536 + console.log('2. annotationText: ' + annotationText + ' , length: ' + $scope.annotationTextArray.length);
  1537 +
1564 1538 $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
1565 1539  
1566 1540 }
1567 1541 else {
1568 1542  
1569   - // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1543 +
  1544 +
1570 1545 $scope.annotationTextArray = [];
1571 1546 $scope.annotationTextArray.push(annotationText);
  1547 +
  1548 + console.log('3. annotationText: ' + annotationText + ' , length: ' + $scope.annotationTextArray.length);
  1549 +
1572 1550 $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
1573 1551 }
1574 1552  
... ... @@ -2406,9 +2384,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2406 2384 + '<div style="position:absolute;border:1px solid #000;display:none;z-index:9000;" id="bord">'
2407 2385 + '</div>';
2408 2386 $('#canvasDiv').append(sppechBubbleDotHTML);
2409   - for (var i = 0; i <= $scope.annotationTextArray.length - 1; i++) {
2410   - var MultipleLanguage = $scope.annotationTextArray[i];
2411   - $("#sppeachBubble").append("<p style='margin-bottom:2px;'>" + MultipleLanguage + "</p>");
  2387 +
  2388 + if ($scope.annotationTextArray.length > 0) {
  2389 + for (var i = 0; i <= $scope.annotationTextArray.length - 1; i++) {
  2390 + var MultipleLanguage = $scope.annotationTextArray[i];
  2391 + $("#sppeachBubble").append("<p style='margin-bottom:2px;'>" + MultipleLanguage + "</p>");
  2392 + }
  2393 + }
  2394 + else
  2395 + {
  2396 + console.log('annotationTextArray.length is :' + $scope.annotationTextArray.length)
2412 2397 }
2413 2398  
2414 2399 if ($scope.longest.length <= 10) {
... ...
400-SOURCECODE/AIAHTML5.Web/body-view-wp.js
1   -๏ปฟ
  1 +๏ปฟvar bodyRegionData;
  2 +var bodyLayerData;
  3 +var bodyArtData;
  4 +
2 5 loadBodyViewData = function (currentBodyViewId)
3 6 {
4 7 //1.
5 8 var bodyRegionjsonPath = '~/../content/data/json/da/da_dat_brview.json';
6 9  
7   - var bodyRegionData;
  10 +
  11 +
  12 + var req = new XMLHttpRequest();
  13 + req.open("GET", bodyRegionjsonPath, true);
  14 + req.setRequestHeader("Content-type", "application/json");
8 15  
9   - var AJAX_req = new XMLHttpRequest();
10   - AJAX_req.open("GET", bodyRegionjsonPath, true);
11   - AJAX_req.setRequestHeader("Content-type", "application/json");
  16 + req.onreadystatechange = function () {
  17 + if (req.readyState == 4 && req.status == 200)
  18 + {
  19 + bodyRegionData = JSON.parse(req.responseText);
12 20  
13   - AJAX_req.onreadystatechange = function () {
14   - if (AJAX_req.readyState == 4 && AJAX_req.status == 200) {
15   - bodyRegionData = JSON.parse(AJAX_req.responseText);
16   - console.log("data returned: " + bodyRegionData);
  21 + console.log("bodyRegionData returned: " + bodyRegionData);
17 22  
18 23 loadLayerDataForCurrentBodyView(currentBodyViewId)
19 24 }
20 25 }
21   - AJAX_req.send();
  26 + req.send();
22 27  
23 28 }
24 29  
... ... @@ -27,47 +32,58 @@ loadLayerDataForCurrentBodyView = function (currentBodyViewId) {
27 32 //1.
28 33 var bgArtJsonPath = '';
29 34 var CommonViewId = 0;
30   - var bodyLayerData;
  35 +
31 36  
32 37 //2.
33 38 var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json';
34 39  
35   - var AJAX_req = new XMLHttpRequest();
36   - AJAX_req.open("GET", layerJsonPath, true);
37   - AJAX_req.setRequestHeader("Content-type", "application/json");
  40 + var req = new XMLHttpRequest();
  41 + req.open("GET", layerJsonPath, true);
  42 + req.setRequestHeader("Content-type", "application/json");
38 43  
39   - AJAX_req.onreadystatechange = function () {
40   - if (AJAX_req.readyState == 4 && AJAX_req.status == 200) {
41   - bodyLayerData = JSON.parse(AJAX_req.responseText);
  44 + req.onreadystatechange = function () {
  45 + if (req.readyState == 4 && req.status == 200) {
  46 + bodyLayerData = JSON.parse(req.responseText);
42 47  
43 48 console.log("data returned: " + bodyLayerData);
44 49  
45 50 loadBodyArtData();
46 51 }
47 52 }
48   - AJAX_req.send();
49   -
  53 + req.send();
50 54  
51 55 }
52 56  
53 57 loadBodyArtData = function () {
54 58  
55 59 var bgArtJsonPath = '';
56   - var bodyArtData;
57 60  
58   - bgArtJsonPath = '~/../content/data/json/da/da_dat_bgart.json';
59 61  
60   - var AJAX_req = new XMLHttpRequest();
61   - AJAX_req.open("GET", bgArtJsonPath, true);
62   - AJAX_req.setRequestHeader("Content-type", "application/json");
  62 + bgArtJsonPath = '~/../content/data/json/da/da_dat_bgart.json';
63 63  
64   - AJAX_req.onreadystatechange = function () {
65   - if (AJAX_req.readyState == 4 && AJAX_req.status == 200) {
66   - bodyArtData = JSON.parse(AJAX_req.responseText);
  64 + var req = new XMLHttpRequest();
  65 + req.open("GET", bgArtJsonPath, true);
  66 + req.setRequestHeader("Content-type", "application/json");
67 67  
  68 + req.onreadystatechange = function () {
  69 + if (req.readyState == 4 && req.status == 200) {
  70 + bodyArtData = JSON.parse(req.responseText);
68 71 console.log("data returned: " + bodyArtData);
  72 +
  73 + self.postMessage({
  74 + 'bodyRegionData': bodyRegionData,
  75 + 'bodyLayerData': bodyLayerData,
  76 + 'bodyArtData': bodyArtData
  77 +
  78 + });
  79 +
69 80 }
70 81 }
71   - AJAX_req.send();
  82 + req.send();
72 83 };
73 84  
  85 +self.onmessage = function (e) {
  86 +
  87 + loadBodyViewData(e.data.currentViewId);
  88 +
  89 +}
74 90 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.Web/search-wp.js
... ... @@ -72,9 +72,7 @@ loadTermTextData = function (TermNumberData) {
72 72 }
73 73 AJAX_req.send();
74 74  
75   -
76   - //})
77   -
  75 +
78 76 }
79 77  
80 78  
... ...