Commit 321d39b426ac26bb9e944ebb73736bf16e6317e5

Authored by Amrita Vishnoi
1 parent 8de220fa

in progress

400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js
Changes suppressed. Click to show
1   -/// <reference path="../views/atlas-anatomy-detail.html" />
2   -/// <reference path="../views/atlas-anatomy-detail.html" />
  1 +
3 2 'use strict';
4 3  
5   -AIA.controller("TileViewListController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "$timeout", "Modules", "$routeParams", "DataService","ModuleService" ,
6   -function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, BodySystems, ViewOrientations, ImageTypes, $timeout, Modules, $routeParam, DataService,ModuleService)
7   -{
8   - var ATLAS_ANATOMY = 'Atlas Anatomy';
9   - var CLINICAL_ILLUSTRATION ='Clinical Illustrations';
10   - var CLINICAL_ANIMATION='Clinical Animations';
  4 +AIA.controller("TileViewListController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService",
  5 +function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService) {
11 6  
12   - var moduleData = [];
13 7  
14   - $scope.AllBodyRegion = [];
15   - $scope.AllBodySystem = [];
16   - $scope.AllOrientation = [];
17   - $scope.AllImageType = [];
18   - $scope.moduleData = [];
19   - $rootScope.moduleName;
20   - $rootScope.OpenItemImageName;
21   - $rootScope.OpenItemImagePath;
  8 + $scope.genderId = "";
  9 + $scope.BodyViewData;
  10 + $scope.selectedGenderBodyViewData;
  11 + $scope.imagePath = "";
  12 + $rootScope.BodyRegionData;
  13 + $rootScope.BodyRegionCordinatesData;
  14 + $scope.isTransparencyActivated = false;
  15 + $rootScope.BodyLayerData;
  16 + $rootScope.VocabTermData;
22 17  
23   - $scope.test;
  18 + $scope.VocabTermTxt;
  19 + $scope.CommonData
  20 + $rootScope.TermNumberData;
  21 + $rootScope.BodySystemData
  22 + $scope.bodyViewId = 0;
  23 + $rootScope.bgartData;
  24 + $scope.drawnBodyRegions;
  25 + //view specific constants
  26 + $rootScope.voId;
  27 + $scope.layerNumber;
  28 + $scope.daCounter = 1;
  29 + $scope.bagartDetails;
  30 + $scope.transNumber = 50;
  31 +
  32 + //for transarency scale
  33 + $scope.TBDrawStartX;
  34 + $scope.TBDrawStartY;
  35 + $rootScope.path = "~/../content/images/speeachBubbleClose.png";
  36 + $rootScope.isHighLight = false;
  37 + $rootScope.coloredImageCanvasList = [];
  38 + $rootScope.coloredImageMRCanvasList = [];
  39 + $rootScope.ColoredCanvasData = [];
  40 + $rootScope.grayImageDataList = [];
  41 + $rootScope.grayImageMRDataList = [];
  42 + $rootScope.updatedGrayDataList = [];
  43 + $rootScope.updatedGrayMRDataList = [];
  44 + $scope.isEligibleForHighlight = false;
  45 + $scope.doHighlightOrExtract = false;
  46 + $scope.isEligibleForHighlightBodyByTermList = false;
  47 +
  48 + // $scope.AnteriorView = "active";
  49 +
  50 + $scope.zoomInOut = 75;
  51 + $scope.speechBubbleCounter = 0;
  52 + $scope.j = 0;
  53 + $scope.speechbubbleList = [];
  54 + $scope.speachBubbleArrayAnnotation = [];
  55 + $rootScope.multiAnnotationIsON = false;
  56 + $scope.previousGrayImageDataVar;
  57 + $scope.previousGrayCanvas;
  58 + $rootScope.updatedImageDataList = [];
  59 + $rootScope.updatedImageMRDataList = [];
  60 +
  61 + $scope.previousSelectedTermList = [];
  62 + $scope.runningWorkers = [];
  63 + $scope.runningSearchWorkers = [];
  64 + $scope.runningBodyViewWorkers = [];
  65 +
  66 + // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false.
  67 + $scope.machedIcolorInBodyRegion = [];
  68 +
  69 + $rootScope.MaskCanvasData = [];
  70 +
  71 + //extract
  72 + $rootScope.isExtract = false;
  73 +
  74 +
  75 + $rootScope.whiteImageDataList = [];
  76 + $rootScope.whiteImageMRDataList = [];
  77 + $rootScope.previousHighlightList = [];
  78 +
  79 + $rootScope.isViewChange = false;
  80 + $rootScope.isGenderChnage = false;
  81 +
  82 + // to do it is setting but not using. need to check
  83 + $rootScope.updatedWhiteImageDataList = [];
  84 + $rootScope.updatedWhiteImageMRDataList = [];
  85 +
  86 + //normal mode
  87 + $rootScope.isNormalMode = true;
  88 + $rootScope.isZoomed = false;
  89 +
  90 + //navigator man functionality
  91 + $scope.navigatorImage;
  92 + $scope.NavigatorData;
  93 + $scope.navimgsrc;
  94 +
  95 + $scope.dragdivleft = 0;
  96 + $scope.dragdivtop = 0;
  97 +
  98 + $scope.IsSearchVisible = false;
  99 + $scope.shapesize = 1;
  100 + $scope.dragdivposition = {
  101 + "left": $scope.dragdivleft,
  102 + "top": $scope.dragdivtop
  103 + };
  104 +
  105 +
  106 + //array for bodyviewid correspoing to male female(used for gender change)
  107 + $scope.correspondingBodyViewIds = {
  108 + '1': '5',
  109 + '2': '6',
  110 + '3': '7',
  111 + '4': '8',
  112 + '9': '11',
  113 + '10': '12',
  114 +
  115 + '5': '1',
  116 + '6': '2',
  117 + '7': '3',
  118 + '8': '4',
  119 + '11': '9',
  120 + '12': '10',
  121 +
  122 + }
  123 +
  124 + $scope.bodyViews = {
  125 + 'Anterior': '1',
  126 + 'Lateral': '2',
  127 + 'Medial': '3',
  128 + 'Posterior': '4',
  129 + 'Lateral Arm': '5',
  130 + 'Medial Arm': '6'
  131 + }
  132 +
  133 + $scope.isBodylayerdataLoaded = false;
  134 + $scope.isBodyRegionDataLoaded = false;
  135 + //currentTitleFromJson shows the current BodyView Title
  136 + $scope.currentTitleFromJson;
  137 + $scope.showme = false;
  138 + $scope.IsVisible = function () {
  139 + $scope.scroll();
  140 +
  141 + }
  142 +
  143 + $scope.scroll = function () {
  144 + // $window.scrollTo(0, 0);
  145 + $("html,body").scrollTop(0);
  146 + //alert("scroll");
  147 + }
  148 +
  149 +
  150 + $scope.switchGender = function () {
  151 +
  152 + var retrievedObject = localStorage.getItem('currentViewTitle');
  153 +
  154 + if (retrievedObject == "Male Anterior") {
  155 + $scope.male = "active";
  156 + $scope.female = "";
  157 + }
  158 + else if (retrievedObject == "Female Anterior") {
  159 + $scope.male = "";
  160 + $scope.female = "active";
  161 + }
  162 + }
24 163  
25 164 $scope.loadForModuleById = function (moduleId) {
26 165  
  166 + alert('hi');
  167 +
27 168 $scope.moduleId = moduleId;
28 169  
29 170 console.log('loadForModuleById is called')
30 171 $rootScope.moduleName = Modules[moduleId].Name;
31 172 var promise = ModuleService.loadModuleDataBasedOnModuleName($scope.moduleName)
32   -
  173 +
33 174 .then(
34 175 function (result) {
35   - $scope.moduleLandingData = result;
  176 + $scope.moduleLandingData = result;
36 177  
37 178 console.log(JSON.stringify(result, null, 4));
38 179 },
... ... @@ -41,61 +182,306 @@ function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, Bod
41 182 console.log(' error: ' + error.statusText);
42 183 }
43 184 )
44   - },
  185 + }
45 186  
46   -
47   -
  187 + //get the DA body view list based on selected gender
  188 + //get the DA body view list based on selected gender
  189 + $scope.getDAViewList = function ($event) {
48 190  
49   - $scope.scroll = function () {
50   - $("html,body").scrollTop(0);
51   - }
52   -
53   - $scope.openModuleItem11 = function (event) {
54 191  
55   - alert('hi');
56   - //// debugger;
57   - var moduleItemDataToBeSaved = event.target.id;
58   -
59   - var OpendTileData = [];
  192 + if ($('#MainImage') != null) {
  193 + $('#MainImage').remove();
  194 + }
  195 + $rootScope.currentActiveModuleTitle = Modules[0].Name;
60 196  
61   - OpendTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData);
62   -
63   -
64   - $location.url('/atlas-anatomy-detail');
  197 + alert('mod name: ' + Modules[0].Name)
  198 +
  199 + $("#bodyViewList").empty();
  200 + //for default load
  201 + if ($event == null || $event == undefined) {
  202 + //if ((localStorage.getItem("genderId") != "")||(localStorage.getItem("genderId")!="null")) {
  203 + // $scope.genderId = localStorage.getItem("genderId");
  204 + //}
  205 + var selectedGender = localStorage.getItem("genderId");
  206 + if ((selectedGender == null)) {
  207 + $scope.genderId = "Male";
  208 + }
  209 + else
  210 + $scope.genderId = localStorage.getItem("genderId");
  211 +
  212 + }
  213 + else {
  214 + $scope.genderId = $event.currentTarget.id;
  215 + }
  216 +
  217 + localStorage.setItem("genderId", $scope.genderId);
  218 +
  219 + var selectedGender = localStorage.getItem("genderId");
  220 +
  221 + if (selectedGender != null) {
  222 + if (selectedGender == "Male") {
  223 + $('#Male').addClass('active');
  224 + $('#Female').removeClass("active");
  225 + }
  226 + else {
  227 + $('#Female').addClass('active');
  228 + $('#Male').removeClass("active");
  229 + }
  230 +
  231 + }
  232 +
  233 + $scope.selectedGenderBodyViewData = new jinqJs()
  234 + .from($scope.BodyViewData.BodyViews.view)
  235 + .where('_gender == ' + $scope.genderId)
  236 + .select();
  237 +
  238 + if ($scope.selectedGenderBodyViewData != null || $scope.selectedGenderBodyViewData != undefined) {
  239 + angular.forEach($scope.selectedGenderBodyViewData, function (value, key) {
  240 +
  241 +
  242 + var userEthnicity;
  243 + var userModestysettings;
  244 + var curentEthnicity = localStorage.getItem("globalEthnicity");
  245 + if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
  246 + userEthnicity = curentEthnicity;
  247 + }
  248 + else {
  249 + userEthnicity = $rootScope.globalSetting.ethnicity;
  250 + }
  251 +
  252 + var curentmodesty = localStorage.getItem("globalModesty");
  253 + if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) {
  254 + userModestysettings = curentmodesty;
  255 + }
  256 + else {
  257 + userModestysettings = $rootScope.globalSetting.modesty;
  258 + }
65 259  
66   - }
67 260  
68   - $scope.openModuleItemView = function(event)
69   - {
70   - //alert('openModuleItemView is called')
71   - var moduleItemDataToBeSaved = event.target.id;
72 261  
73   - var OpendTileData = [];
  262 + //var userSelectedSkintone = 'W';
  263 + //$scope.userModestySetting = 'Y'
  264 + var thumbnailImage;
  265 + if ((value._id == 1) || (value._id == 3) || (value._id == 5) || (value._id == 6) || (value._id == 7) || (value._id == 11))
  266 + thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity + userModestysettings)) + '.jpg';
  267 + else {
  268 + thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity)) + '.jpg';
74 269  
75   - OpendTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData);
  270 + }
76 271  
77   - $rootScope.imageName = OpendTileData[3];
  272 + $scope.imagePath = "~/../content/images/DA/" + $scope.zoomInOut + "/body-views/" + value._id + '/skintone/' + userEthnicity + '/' + thumbnailImage;
78 273  
79   - $rootScope.OpenItemImagePath = "../../../content/images/aa/images/" + OpendTileData[3];
80   - //alert('img Name: ' +$scope.OpenItemImageName);
  274 +
  275 + var $el = $('<div id=' + value._id + ' class="col-sm-3 col-lg-2" title = ' + value._title + ' data-ng-click="openView($event)"><div class="thumbnail" >'
  276 + + '<img class= "daImg" id="' + value._title + '" src="' + $scope.imagePath + '" alt="" title="" >'
  277 + + '<div class="caption"><p>' + value._title + '</p></div></a></div></div>').appendTo('#bodyViewList');
  278 +
  279 +
  280 + $compile($el)($scope);
  281 + $(".sidebar").mCustomScrollbar({
  282 + autoHideScrollbar: true,
  283 + //theme:"rounded"
  284 + });
  285 +
  286 + });
  287 + }
  288 +
  289 + };
  290 +
  291 +
  292 +
  293 + $scope.openView = function ($event) {
  294 +
  295 + $rootScope.MenuModuleName = "DA";
  296 + //alert($rootScope.MenuModuleName);
  297 + $rootScope.isLoading = true;
  298 + $('#spinner').css('visibility', 'visible');
  299 +
  300 + $rootScope.currentBodyViewId = $event.currentTarget.id;
  301 + $rootScope.ViewTitle = $event.currentTarget.textContent;
  302 +
  303 + localStorage.setItem("currentViewTitleFromJson", $event.currentTarget.textContent);
  304 + localStorage.setItem("currentViewTitle", $event.currentTarget.textContent);
  305 + localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
81 306  
82 307 var u = $location.url();
83   - $location.url('/module-item-view');
  308 + $location.url('/da-body-view');
  309 +
  310 + var view_list = angular.element($event.currentTarget);
  311 + var view_list_male_female = view_list.attr('title');
  312 +
  313 + if (($event.currentTarget.textContent == "Female Anterior" || $event.currentTarget.textContent == "Male Anterior")) {
  314 + $rootScope.AnteriorView = "active";
  315 + $rootScope.LateralView = "";
  316 + $rootScope.MedialView = "";
  317 + $rootScope.PosteriorView = "";
  318 + $rootScope.LateralArmView = "";
  319 + $rootScope.MedialArmView = "";
  320 + }
  321 + if (($event.currentTarget.textContent == "Female Lateral" || $event.currentTarget.textContent == "Male Lateral")) {
  322 + $rootScope.AnteriorView = "";
  323 + $rootScope.LateralView = "active";
  324 + $rootScope.MedialView = "";
  325 + $rootScope.PosteriorView = "";
  326 + $rootScope.LateralArmView = "";
  327 + $rootScope.MedialArmView = "";
  328 +
  329 +
  330 + }
  331 + if (($event.currentTarget.textContent == "Female Medial" || $event.currentTarget.textContent == "Male Medial")) {
  332 + $rootScope.AnteriorView = "";
  333 + $rootScope.LateralView = "";
  334 + $rootScope.MedialView = "active";
  335 + $rootScope.PosteriorView = "";
  336 + $rootScope.LateralArmView = "";
  337 + $rootScope.MedialArmView = "";
  338 +
  339 +
  340 + }
  341 + if (($event.currentTarget.textContent == "Female Posterior" || $event.currentTarget.textContent == "Male Posterior")) {
  342 + $rootScope.AnteriorView = "";
  343 + $rootScope.LateralView = "";
  344 + $rootScope.MedialView = "";
  345 + $rootScope.PosteriorView = "active";
  346 + $rootScope.LateralArmView = "";
  347 + $rootScope.MedialArmView = "";
  348 +
  349 + }
  350 + if (($event.currentTarget.textContent == "Female Lateral Arm" || $event.currentTarget.textContent == "Male Lateral Arm")) {
  351 + $rootScope.AnteriorView = "";
  352 + $rootScope.LateralView = "";
  353 + $rootScope.MedialView = "";
  354 + $rootScope.PosteriorView = "";
  355 + $rootScope.LateralArmView = "active";
  356 + $rootScope.MedialArmView = "";
  357 +
  358 +
  359 + }
  360 + if (($event.currentTarget.textContent == "Female Medial Arm" || $event.currentTarget.textContent == "Male Medial Arm")) {
  361 + $rootScope.AnteriorView = "";
  362 + $rootScope.LateralView = "";
  363 + $rootScope.MedialView = "";
  364 + $rootScope.PosteriorView = "";
  365 + $rootScope.LateralArmView = "";
  366 + $rootScope.MedialArmView = "active";
  367 +
  368 +
  369 + }
  370 +
  371 + //$rootScope.Normal = "LeftButtonsDefaultState";
  372 +
  373 + if (view_list_male_female == "Male") {
  374 +
  375 + $rootScope.male = "active";
  376 + $rootScope.female = "";
  377 + }
  378 + else {
  379 +
  380 + $rootScope.male = "";
  381 + $rootScope.female = "active";
  382 + }
  383 +
  384 +
  385 + }
  386 +
  387 +
  388 + //load json data for body view
  389 + $scope.loadDissectibleAnatomyData = function () {
  390 +
  391 + $rootScope.ClearIframe();
  392 +
  393 + //load common data
  394 + var commondataJsonPath = '~/../content/data/json/da/da_dat_common.json';
  395 +
  396 + DataService.getAnotherJson(commondataJsonPath)
  397 + .then(
  398 + function (result) {
  399 +
  400 + $rootScope.CommonData = result;
  401 + $http({ method: 'GET', url: '~/../content/data/json/da/da_dat_contentlist.json' }).success(function (data) {
  402 +
  403 + $scope.BodyViewData = data;
  404 +
  405 + $scope.getDAViewList();
  406 +
  407 + })
  408 + .error(function (data, status, headers, config) {
  409 + console.log(data);
  410 + });
  411 +
  412 +
  413 + },
  414 + function (error) {
  415 + console.log(error.statusText)
  416 + }
  417 + )
  418 + //load body-views data
  419 +
  420 +
  421 + // $('#daLoaderLabel').css('visibility', 'hidden')
  422 + $rootScope.isLoading = false;
  423 +
  424 +
  425 +
  426 + //push the details of open module in array $rootScope.openModules
  427 + $rootScope.openModules.push({ "ModuleId": 1 });
  428 +
  429 +
84 430 }
85 431  
  432 +
  433 + //da-body-views functions
  434 +
86 435 $scope.openBodyView = function () {
87 436  
88   -
  437 + //0. we will initially append container to load body
  438 +
  439 + //check if localstorage has any settings
  440 + var curentEthnicity = localStorage.getItem("globalEthnicity");
  441 + if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
  442 + $rootScope.globalSetting.ethnicity = curentEthnicity;
  443 + }
  444 +
  445 + var curentmodesty = localStorage.getItem("globalModesty");
  446 + if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) {
  447 + $rootScope.globalSetting.modesty = curentmodesty
  448 + }
  449 +
  450 + //0.1
  451 + var currentBodyViewId = localStorage.getItem("currentBodyViewId");
  452 +
  453 + $scope.loadSearchDataForBodyView();
  454 +
  455 +
  456 + console.log('currentBodyViewId pickjed from localStorage: ' + currentBodyViewId);
  457 +
  458 + var openViews;
  459 + if ($rootScope.openViews != null || $rootScope.openViews != undefined) {
  460 + if ($rootScope.openViews.length > 0) {
  461 + openViews = new jinqJs()
  462 + .from($rootScope.openViews)
  463 + .where("BodyViewId == " + currentBodyViewId)
  464 + .select();
  465 + }
  466 + }
  467 +
  468 + // 0.2 getting corresponding body view title
  469 + //var counter = 1;
  470 + var tittle = localStorage.getItem("currentViewTitleFromJson");
  471 + localStorage.setItem("currentViewTitle", tittle);
  472 +
  473 +
  474 +
89 475 $.jsPanel({
90 476 id: 'daImagePanel',
91 477 selector: '.daBodyView',
92 478 theme: 'success',
93 479 currentController: 'TileViewListController',
94   - parentSlug: 'tile-view-list',
  480 + parentSlug: 'tile-view',
95 481 ajax: {
96   - url: 'app/views/aa/atlas-anatomy-detail.html'
  482 + url: 'app/views/da/da-view.html'
97 483 },
98   - // title: localStorage.getItem("currentViewTitle"),
  484 + title: localStorage.getItem("currentViewTitle"),
99 485  
100 486 position: {
101 487 top: 70,
... ... @@ -107,147 +493,7659 @@ function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, Bod
107 493 });
108 494  
109 495 console.log('jsPanel loaded daImagePanel exist= ' + document.getElementById('daImagePanel'))
  496 + //0.1
  497 + $rootScope.currentSlug = 'tile-view';
110 498  
111   - var daBodyviewElement = angular.element(document.getElementById("aaDetailPageDiv"));
  499 + //0.2
  500 + $rootScope.openViews.push(
  501 + {
  502 + "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
  503 + "slug": $rootScope.currentSlug
  504 + }
  505 + );
112 506  
113   - $timeout(function () {
  507 + //0.3
  508 + var daBodyviewElement = angular.element(document.getElementById("daBodyview"));
114 509  
  510 + $timeout(function () {
115 511 $compile(daBodyviewElement.contents())($scope);
116 512  
117   - console.log('html is compiled' + document.getElementById('aaDetailPageDiv'))
118   - if (document.getElementById('aaDetailPageDiv') != null) {
  513 + console.log('html is compiled' + document.getElementById('daView'))
  514 + if (document.getElementById('daView') != null) {
119 515  
120 516 //0.4 added some stylesheets
121 517 $('#daBodyview').css("height", $(window).outerHeight());
122 518  
123 519 $('#daBodyview').css("width", $(window).outerWidth());
124 520  
125   -
126   - }
  521 + //1. load navigator man first
  522 + console.log('before LoadBodyViewNavigatorImage call')
  523 + $scope.LoadBodyViewNavigatorImage();
  524 +
  525 + //$scope.loadSearchDataForBodyView();
  526 +
  527 + $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
  528 +
  529 + $scope.layerNumber = 0;
  530 +
  531 + //2.
  532 +
  533 + console.log('currentBodyViewId just before sending: ' + currentBodyViewId);
  534 + $scope.loadBodyViewData(currentBodyViewId);
  535 +
  536 + //2. load bodyRegion data
  537 + $rootScope.isLoading = true;
  538 + $rootScope.voId = localStorage.getItem("currentBodyViewId");
  539 +
  540 + $('#daBodyview').css("height", $(window).outerHeight());
  541 +
  542 + $('#daBodyview').css("width", $(window).outerWidth());
  543 + }
127 544 }, 250);
128 545 }
129 546  
  547 + angular.element(document).ready(function (e) {
  548 + $("#daImagePanel").resize(function () {
  549 + $("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition);
  550 + $("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition);
  551 + });
130 552  
131   - $scope.getImgUrl = function () {
  553 + $(document).on("mouseover", "#termList option", function (e) {
  554 + $('#termList option[selected="selected"]').attr("selected", false);
  555 + $(this).attr("selected", true);
  556 + });
132 557  
133   - alert('called...')
134   - }
  558 + $(document).keypress(function (e) {
  559 + if ($('#termList option[selected="selected"]').attr("id") == "undefined") {
  560 + return false;
  561 + }
  562 + else {
  563 + var originator = e.keyCode || e.which;
  564 + // alert($('#termList option[selected="selected"]').attr("id"));
  565 + if ($('#termList option[selected="selected"]').attr("id")) {
  566 + if (e.keyCode == 13) {
  567 + onListManagerTermSelection($('#termList option[selected="selected"]').attr("id"));
  568 + }
  569 + }
  570 + }
  571 + });
  572 + })
135 573  
136   - $scope.openModuleItem = function (elSelector)
137   - {
138   - debugger;
  574 + $scope.loadSearchDataForBodyView = function () {
139 575  
140   - alert($rootScope.OpenItemImageName);
  576 + console.log('loadSearchDataForBodyView');
141 577  
142   - var OpendTileData = [];
  578 + var currentBodyViewId = localStorage.getItem("currentBodyViewId");
143 579  
144   - var url;
145 580  
  581 + var searchWorker = new Worker('search-wp.js');
146 582  
  583 + //push workers in array to further used the refernece to delete the workers
  584 + $scope.runningSearchWorkers.push({ 'workerName': searchWorker })
147 585  
148   - if ($rootScope.moduleName == ATLAS_ANATOMY)
149   - {
  586 + //console.log('for bodyRegionId = ' + bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
150 587  
151   - url = 'app/views/aa/atlas-anatomy-detail.html';
152   - $scope.test = url;
  588 + searchWorker.postMessage({
  589 + 'currentBodyViewId': currentBodyViewId,
  590 + })
153 591  
154   - $scope.showAllPins();
155   - }
156   - else if ($rootScope.moduleName == CLINICAL_ANIMATION) {
157   - //to do, in next phase of project
  592 + searchWorker.onmessage = function (e) {
  593 + //console.log('callback searchWorker , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
158 594  
159   - }
160   - else if ($rootScope.moduleName == CLINICAL_ILLUSTRATION) {
161   - //to do, in next phase of project
162 595  
  596 +
  597 + $rootScope.TermNumberData = e.data.TermNumberData,
  598 + $rootScope.VocabTermData = e.data.VocabTermData,
  599 + $scope.vocabTermTxt = e.data.vocabTermTxt
  600 +
  601 +
  602 + $scope.VocabTermTxt = new jinqJs()
  603 + .from($scope.vocabTermTxt)
  604 + .distinct('_TermText', '_ActualTermNumber')
  605 + .orderBy([{ field: '_TermText', sort: 'asc' }])
  606 + .select('_ActualTermNumber', '_TermText', '_cdId');
  607 +
  608 +
  609 + console.log('JlinqActivity , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
  610 +
  611 + if ($scope.runningSearchWorkers != null || $scope.runningSearchWorkers != undefined) {
  612 +
  613 + var workerCount = $scope.runningSearchWorkers.length;
  614 + if (workerCount > 0) {
  615 + for (var i = workerCount - 1; i >= 0; i--) {
  616 +
  617 +
  618 +
  619 + var runningWorker = $scope.runningSearchWorkers[i].workerName;
  620 + runningWorker.terminate();
  621 + $scope.runningSearchWorkers.splice(i, 1);
  622 + // workerCount--;
  623 + }
  624 + }
  625 + }
163 626 }
164 627  
165   - $.jsPanel({
166   - id: 'ImagePanel',
167   - selector: '.JsPannelContainer',
168   - theme: 'success',
169   - currentController: 'TileViewListController',
170   - parentSlug: 'tile-view-list',
171   - ajax: {
172   - url: url
173   - },
  628 + }
174 629  
175   - title: "AA page view",
  630 + $scope.loadBodyViewData = function (currentVoid) {
  631 + console.log('caller of worker sending currentVoid: ' + currentVoid);
176 632  
177   - position: {
178   - top: 70,
179   - left: 1,
180   - },
  633 + var bodyViewWorker = new Worker('body-view-wp.js');
181 634  
182   - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
  635 + //push workers in array to further used the refernece to delete the workers
  636 + $scope.runningBodyViewWorkers.push({ 'workerName': bodyViewWorker })
  637 +
  638 + bodyViewWorker.postMessage({
  639 +
  640 + 'currentViewId': currentVoid
183 641  
184 642 });
185 643  
  644 + bodyViewWorker.onmessage = function (e) {
  645 + //console.log('callback in extr');
186 646  
187   - var jsElement = angular.element(document.getElementById("JsPannelContainer"));
  647 + $rootScope.BodyRegionData = e.data.bodyRegionData;
  648 + $rootScope.bgartData = e.data.bodyArtData;
  649 + $rootScope.BodyLayerData = e.data.bodyLayerData;
188 650  
  651 + var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
189 652  
190   - $timeout(function () {
191   - $compile(jsElement.contents())($scope);
192   - if ($rootScope.moduleName == ATLAS_ANATOMY) {
193   - $scope.addPinDataCanvas();
194   - }
  653 + //set max for LayerNumber input
  654 + $rootScope.totalLayers = dataLength - 1;
  655 + // debugger
  656 + $('#txtLayerNumber').attr('max', $rootScope.totalLayers);
  657 + $('#layerChangeSlider').slider("option", "max", $rootScope.totalLayers);
195 658  
  659 + $scope.isBodylayerdataLoaded = true;
196 660  
197   - }, 250);
  661 + $scope.LoadDefaultLayerImage();
  662 +
  663 +
  664 +
  665 + }
  666 + bodyViewWorker.onerror = function (e) {
  667 + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
  668 + };
198 669 }
199 670  
200   -
201   - $scope.addPinDataCanvas = function()
202   - {
203   - //var pinDataCanvas = document.createElement('addPinDataCanvas');
204   - //pinDataCanvas.id = "addPinDataCanvas";
205   - //pinDataCanvas.height = 216;
206   - //pinDataCanvas.width = 216;
207   - //pinDataCanvas.style.position = "absolute";
208   - //pinDataCanvas.style.left = 0 + "px";
209   - //pinDataCanvas.style.top = 0 + "px";
210   - ////pinDataCanvas.style.background = "red";
211   - ////pinDataCanvas.style.border = "black 10px solid";
212 671  
213   - //var divReference = document.getElementById("imageDiv");
214   - //divReference.appendChild(pinDataCanvas);
  672 + //Code for displaying NavigatorImage for BodyView
  673 + $scope.LoadBodyViewNavigatorImage = function () {
  674 + console.log('insideLoadBodyViewNavigatorImage')
  675 + var NavigatorManJsonPath = '~/../content/data/json/da/da_dat_orient_image.json';
215 676  
216   - debugger;
217   - var pinLength1 = Math.sqrt((638 - 604) * (638 - 604) + (83 - 120) * (83 - 120));
218   - var pinLength = pinLength1.toPrecision(2);
219   -
220   - var pinData = '<div class="pin" style="border:1px dashed #000;position:absolute;left:604px;top:120px;width:' + pinLength + 'px;"><div style="border:1px dashed #000;position:absolute;left:604px;"><img src="~/content/images/img181.png"/></div></div>';
  677 + $http({ method: 'GET', url: NavigatorManJsonPath })
  678 + .success(function (data) {
  679 + $scope.NavigatorData = data;
221 680  
222   - // <div class="pin" style="border:1px dashed #000;position:absolute;left:604px;top:120px;width:50px;"><div style="/* border:1px dashed #000; */position:absolute;left: -22px;/* width: 0px; */top: -11px;"><img src="~/content/images/img181.png"></div></div>
  681 + $scope.skinTone = $rootScope.globalSetting.ethnicity;
223 682  
  683 + var navigatorManData = new jinqJs()
  684 + .from($scope.NavigatorData.Navigtor.ViewOrientation)
  685 + .where("_ViewOrientationId == " + $rootScope.currentBodyViewId)
  686 + .select();
224 687  
225   - // var divReference = document.getElementById("imageDiv");
226   - // divReference.appendChild(pinData);
227   - alert(pinData);
228   - $("#imageDiv").append(pinData);
  688 + if ((navigatorManData != null || navigatorManData != undefined) && (navigatorManData.length > 0)) {
229 689  
230   - }
231 690  
232   - $scope.showAllPins = function ()
233   - {
234   -
235   - var promise = ModuleService.getPinDataForImage($rootScope.imageName)
  691 + var imageInfoForNavigator = new jinqJs()
  692 + .from(navigatorManData[0].ImageInfo)
  693 + .where("_Ethnicity == " + $scope.skinTone)
  694 + .select();
  695 + }
  696 + else {
  697 + console.log('NAVIGATOR.DATA.NOT.FOUND FOR BODY VIEW: ' + $rootScope.currentBodyViewId);
  698 + }
236 699  
237   - .then(
238   - function (result) {
239   - $scope.aaPinData = result;
  700 + if (imageInfoForNavigator != null || imageInfoForNavigator != undefined) {
  701 + $scope.navigatorImage = imageInfoForNavigator;
240 702  
241   - console.log(JSON.stringify(result, null, 4));
242   - },
243   - function (error) {
244   - // handle errors here
245   - console.log(' error: ' + error.statusText);
246   - }
247   - )
248 703  
  704 + var navImageModesty;
  705 +
  706 + if (($scope.navigatorImage != null || $scope.navigatorImage != undefined) && ($scope.navigatorImage.length > 0)) {
  707 + angular.forEach($scope.navigatorImage, function (value, key) {
  708 +
  709 + if (value._HaveModesty === $rootScope.globalSetting.modesty) {
  710 + navImageModesty = value._ImageName;
  711 + }
  712 + })
  713 + }
  714 + if (typeof (navImageModesty) === "undefined" || navImageModesty === null) {
  715 +
  716 + navImageModesty = $scope.navigatorImage[0]._ImageName;
  717 + }
  718 +
  719 + $scope.navimgsrc = "~/../content/images/DA/ethnicity/body-views/" + $scope.voId + '/' + $scope.skinTone + '/navigator_images/' + navImageModesty;
  720 +
  721 + $('#navigatorDiv').css('visibility', 'visible');
  722 +
  723 + $('#containment - wrapper').css('visibility', 'visible');
  724 + }
  725 +
  726 + else {
  727 + console.log('NAVIGATOR.IMAGE.NOT.FOUND FOR BODY VIEW: ' + $rootScope.currentBodyViewId);
  728 + }
  729 + })
  730 +
  731 + .error(function (data, status, headers, config) {
  732 + //1.
  733 + console.log('DATA.NOT.LOADED FOR:' + NavigatorManJsonPath + ', ERROR: ' + data);
  734 + //2.
  735 + // $scope.LoadBodyViewNavigatorImage()
  736 + });
249 737 }
250   -
251   -
252   -}]);
  738 +
  739 +
  740 + $scope.LoadDefaultLayerImage = function () {
  741 + console.log('inside LoadDefaultLayerImage')
  742 + $rootScope.isNormalMode = true;
  743 +
  744 + $scope.layerNumber = 0;
  745 + $scope.skinTone = $rootScope.globalSetting.ethnicity;
  746 +
  747 + //viewOrientationId is to pic coordinates of view and void is to pic iamge name from resopective json
  748 + $rootScope.viewOrientationId = $rootScope.voId;
  749 + if ($rootScope.voId == 5) {
  750 + $rootScope.viewOrientationId = 1;
  751 + }
  752 + else if ($rootScope.voId == 6) {
  753 + $rootScope.viewOrientationId = 2;
  754 + }
  755 + else if ($rootScope.voId == 7) {
  756 + $rootScope.viewOrientationId = 3;
  757 + }
  758 + else if ($rootScope.voId == 8) {
  759 + $rootScope.viewOrientationId = 4;
  760 + }
  761 + else if ($rootScope.voId == 9) {
  762 + $rootScope.viewOrientationId = 5;
  763 + }
  764 + else if ($rootScope.voId == 10) {
  765 + $rootScope.viewOrientationId = 6;
  766 + }
  767 + else if ($rootScope.voId == 11) {
  768 + $rootScope.viewOrientationId = 5;
  769 + }
  770 + else if ($rootScope.voId == 12) {
  771 + $rootScope.viewOrientationId = 6;
  772 + }
  773 +
  774 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  775 +
  776 +
  777 + };
  778 +
  779 +
  780 + //calculate coordinates for body region images
  781 + $scope.CalculateImageCordinates = function (viewOrientationId) {
  782 +
  783 + $rootScope.isLoading = true;
  784 + $('#spinner').css('visibility', 'visible');
  785 + $scope.modestyImageInfo = [];
  786 + // annotation toolbar canvas
  787 + if ($("#canvasDiv").find("canvas[id='canvasPaint']").length == 0) {
  788 +
  789 + $("#canvasDiv").append('<canvas id="canvasPaint" width="2277" height="3248" class="canvas-annotationStyle1"></canvas><canvas id="canvas" width="2277" height="3248" class="canvas-annotationStyle"></canvas>');
  790 + $scope.BindCanvasDrawingListners();
  791 + // $rootScope.FreeStylePaint();
  792 +
  793 + }
  794 +
  795 +
  796 +
  797 + $scope.terminateCurrentlyRunningWPs();
  798 +
  799 + var drawnBodyRegionCount = [];
  800 +
  801 + if ($rootScope.MaskCanvasData != null || $rootScope.MaskCanvasData != undefined) {
  802 + var n = $rootScope.MaskCanvasData.length;
  803 +
  804 + if (n > 0) {
  805 + for (var i = n - 1; i >= 0; i--) {
  806 +
  807 + $rootScope.MaskCanvasData.splice(i, 1);
  808 + // workerCount--;
  809 + }
  810 +
  811 + $rootScope.MaskCanvasData = null;
  812 + $rootScope.MaskCanvasData = [];
  813 + }
  814 + }
  815 +
  816 + //set height of canvas div and left tool bar as per window size
  817 + $rootScope.BodyRegionCordinatesData = []; // create an empty array
  818 +
  819 + $('#daBodyview').css('width', '100%');
  820 + var canvasDIvHeight = parseInt($('#daImagePanel').outerHeight()) - 104;
  821 + $('#canvasDiv').css('height', canvasDIvHeight);
  822 + $('#leftToolBar').css('height', $('#daImagePanel').outerHeight())
  823 +
  824 +
  825 +
  826 + //calculate image coordinates and draw image
  827 + var bodyRegionCoordinates = $rootScope.BodyRegionData.BodyRegionViews;
  828 + // var viewOrientationId = String($rootScope.voId);
  829 +
  830 +
  831 + $scope.bodyRegionCoordinates = new jinqJs()
  832 + .from($rootScope.BodyRegionData.BodyRegionViews.BodyRegionCordinates)
  833 + .where('_ViewOrientationId == ' + viewOrientationId)
  834 + .select();
  835 +
  836 + console.log('viewOrientationId= ' + viewOrientationId + ', $scope.bodyRegionCoordinates length= ' + $scope.bodyRegionCoordinates.length)
  837 + // if ($rootScope.voId == 9 || $rootScope.voId == 11) {
  838 +
  839 + $scope.bagartDetails = new jinqJs()
  840 + .from($rootScope.bgartData.BackgroundArts.BackgroundArtDetail)
  841 + .where('_ViewOrientationId == ' + viewOrientationId)
  842 + .select();
  843 +
  844 + if ($scope.ColoredImageSRC != null && $scope.ColoredImageSRC.length > 0) {
  845 + $scope.ColoredImageSRC = null;
  846 + $scope.ColoredImageSRC = [];
  847 + $scope.flushCanvas();
  848 + }
  849 + else {
  850 + $scope.ColoredImageSRC = [];
  851 + }
  852 +
  853 + if ($scope.bodyRegionCoordinates != null || $scope.bodyRegionCoordinates != undefined) {
  854 + angular.forEach($scope.bodyRegionCoordinates, function (value, key) {
  855 +
  856 + if (value._HaveMirrorImage == 'Y') {
  857 +
  858 + //DrawMirroredImage
  859 +
  860 + //0. Scaling as per default zoom
  861 + var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
  862 +
  863 + //1.Get image source
  864 + var src = $scope.GetImageSource(value._BodyRegionId);
  865 +
  866 + $scope.imageSource = src;
  867 +
  868 + //2.Draw mirror image
  869 + $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
  870 + // debugger;
  871 + $rootScope.BodyRegionCordinatesData.push(
  872 + {
  873 + "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
  874 + "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'Yes'
  875 + }
  876 + );
  877 +
  878 + //3.GetMaskImageSource
  879 + var maskImageSrc = $scope.GetMaskImageSource($scope.imageSource);
  880 + // debugger;
  881 + //4 Draw Mask Mirror Image
  882 + $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y');
  883 +
  884 +
  885 + //Draw Normal Image
  886 +
  887 + //0. Scaling as per default zoom
  888 + var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, 0);
  889 +
  890 +
  891 + //1.Draw body region which have mirror image
  892 + $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
  893 + $scope.BodyRegionCordinatesData.push(
  894 + {
  895 + "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
  896 + "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No'
  897 + }
  898 + );
  899 +
  900 + //2.Draw body region for mask image
  901 + $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y');
  902 +
  903 +
  904 + }
  905 + else {
  906 +
  907 + //0.Scaling as per default zoom
  908 + var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
  909 +
  910 + //1.Get image source
  911 + if (value._IsPrimary == 'N') {
  912 + var src = $scope.GetBackgroundImgSource(value._BodyRegionId);
  913 + $scope.imageSource = src;
  914 + }
  915 + else {
  916 + var src = $scope.GetImageSource(value._BodyRegionId);
  917 + $scope.imageSource = src;
  918 + }
  919 +
  920 + //2.Draw body region which don't have mirror image
  921 + $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
  922 +
  923 + $scope.BodyRegionCordinatesData.push(
  924 + {
  925 + "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
  926 + "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No'
  927 + }
  928 + );
  929 +
  930 + //3.GetMaskImageSource
  931 + var maskSRC = $scope.GetMaskImageSource($scope.imageSource);
  932 +
  933 + //4.Draw body region for mask image
  934 + $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskSRC, value._BodyRegionId, 'Y');
  935 +
  936 +
  937 + //draw figLeaf for modesty
  938 +
  939 + $scope.figLaefImageName;
  940 + $scope.figLaefX;
  941 + $scope.figLaefY;
  942 + var gender;
  943 + if (localStorage.getItem("genderId") == 'Female') {
  944 + gender = 'F';
  945 +
  946 + }
  947 + else {
  948 + gender = 'M';
  949 + }
  950 + if (((localStorage.getItem("genderId") == 'Female') && (value._BodyRegionId == 2)) || (value._BodyRegionId == 3)) {
  951 +
  952 + if ($scope.bagartDetails != null || $scope.bagartDetails != undefined) {
  953 + var dtlOfBr = new jinqJs()
  954 + .from($scope.bagartDetails)
  955 + .where('_BodyRegionId == ' + value._BodyRegionId)
  956 + .select();
  957 + if (dtlOfBr != null || dtlOfBr != undefined) {
  958 +
  959 + var dtlOfGender = new jinqJs()
  960 + .from(dtlOfBr)
  961 + .where('_Gender == ' + gender)
  962 + .select();
  963 + if (dtlOfGender != null || dtlOfGender != undefined) {
  964 +
  965 + var dtlOfSktn = new jinqJs()
  966 + .from(dtlOfGender)
  967 + .where('_Skintone == +')
  968 + .select();
  969 +
  970 + //multiple conditions are not working in where clause of JinQ so need multiple filtered variables
  971 +
  972 +
  973 + if ((dtlOfSktn != null || dtlOfSktn != undefined) && (dtlOfSktn.length > 0)) {
  974 +
  975 + if ((parseInt(dtlOfSktn[0]._lns) <= parseInt($scope.layerNumber)) && (parseInt(dtlOfSktn[0]._lne) > parseInt($scope.layerNumber)) && (dtlOfSktn[0]._isfr == 'Y')) {
  976 + $scope.figLaefImageName = dtlOfSktn[0]._ImageId;
  977 + //$scope.figLaefX = filtereddata[0]._X;
  978 + //$scope.figLaefY = filtereddata[0]._Y;
  979 +
  980 + var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
  981 +
  982 +
  983 + var src = "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + value._BodyRegionId + "/" + $scope.figLaefImageName;
  984 +
  985 + $scope.DrawImage(rectangle.scaledHeight, rectangle.scaledWidth, rectangle.scaledX, rectangle.scaledY, src, 'modestyImg' + value._BodyRegionId, 'N')
  986 +
  987 + }
  988 + }
  989 + }
  990 + }
  991 +
  992 + }
  993 +
  994 +
  995 + }
  996 + }
  997 +
  998 +
  999 + });
  1000 +
  1001 + //$rootScope.isLoading = false;
  1002 + //$('#spinner').css('visibility', 'hidden');
  1003 + }
  1004 +
  1005 + if (($rootScope.globalSetting.modesty == 'Y')) {
  1006 + if ($('.modestyImg') != null) {
  1007 + $('.modestyImg').css('visibility', 'visible');
  1008 + }
  1009 + }
  1010 + //set scrollbars on canvas and hide loading label
  1011 + // debugger;
  1012 + // var isiOSSafari = (navigator.userAgent.match(/like Mac OS X/i)) ? true : false;
  1013 + var isiOSSafari = (navigator.userAgent.match(/iPad/i)) ? true : false;
  1014 +
  1015 + //set scrollbars on canvas and hide loading label
  1016 + $('#daLoaderLabel').css('visibility', 'hidden')
  1017 +
  1018 +
  1019 + $('#canvasDiv').css('overflow', 'scroll')
  1020 + if (isiOSSafari) {
  1021 + $('#canvasDiv').scrollLeft($('#canvasDiv').width() + 150)
  1022 +
  1023 + }
  1024 + else {
  1025 + $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2)
  1026 + }
  1027 +
  1028 +
  1029 + // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition)
  1030 + $('#canvasDiv').scrollTop(50)
  1031 + var abc = $rootScope.BodyRegionCordinatesData;
  1032 + //debugger;
  1033 + $('#layerChangeSlider').slider("option", "value", parseInt($rootScope.totalLayers) - parseInt($scope.layerNumber));
  1034 + // $('#spinner').css('visibility', 'hidden');
  1035 + $rootScope.isLoading = false;
  1036 + //Dated:16-07-2016 Issue #4957 :While selecting the Zoom-in\Zoom-out button scroll should be go on top.
  1037 + // #4976 :While changing gender male to female scroll bar is going on top.
  1038 + var canvasDiv = document.getElementById('canvasDiv');
  1039 + if (canvasDiv != null || canvasDiv != undefined) {
  1040 + canvasDiv.scrollTop = 0;
  1041 +
  1042 +
  1043 + //Navigator Code for dynamically calculating the height and width of Dragable Div on Navigator Image
  1044 +
  1045 + var dragdivh = Math.floor(($('#canvasDiv').height() / $('#canvasDiv')[0].scrollHeight) * 119) //119px is the height of the image
  1046 +
  1047 + if ($('#canvasDiv')[0].scrollWidth > $('#canvasDiv')[0].clientWidth) {
  1048 +
  1049 + var dragdivw = 42
  1050 + $scope.dragdivleft = 21;
  1051 + $scope.dragdivtop = 0;
  1052 +
  1053 + $scope.dragdivposition = {
  1054 + "left": 21,
  1055 + "top": 0
  1056 + };
  1057 + }
  1058 + else {
  1059 + var dragdivw = 83;
  1060 +
  1061 + $scope.dragdivleft = 0;
  1062 + $scope.dragdivtop = 0;
  1063 +
  1064 + $scope.dragdivposition = {
  1065 + "left": 0,
  1066 + "top": 0
  1067 +
  1068 + };
  1069 + }
  1070 + }
  1071 +
  1072 +
  1073 +
  1074 + $('#draggable').css('width', dragdivw);
  1075 + $('#draggable').css('height', dragdivh)
  1076 +
  1077 + }
  1078 +
  1079 + function scaleRectangle(x, y, height, width, mirrorValue) {
  1080 + var nzoom = $scope.zoomInOut;
  1081 + var existingZoon = 100;
  1082 +
  1083 + var X = 0;
  1084 + var scaledY = 0;
  1085 + var scaledHeight = 0;
  1086 + var scaledWidth = 0;
  1087 +
  1088 + if (mirrorValue != 0) {
  1089 + var mirroredX = parseInt(mirrorValue) + parseInt(x);
  1090 + var newX = (mirroredX * nzoom);
  1091 + mirroredX = (newX / existingZoon);
  1092 + X = mirroredX;
  1093 + }
  1094 + else {
  1095 + var newX = (x * nzoom);
  1096 + X = (newX / existingZoon);
  1097 + }
  1098 +
  1099 + var newY = (y * nzoom);
  1100 + var Y = (newY / existingZoon);
  1101 +
  1102 + var newHeight = (height * nzoom);
  1103 + var ht = (newHeight / existingZoon);
  1104 +
  1105 + var newWidth = (width * nzoom);
  1106 + var wt = (newWidth / existingZoon);
  1107 +
  1108 + return {
  1109 + scaledX: X,
  1110 + scaledY: Y,
  1111 + scaledHeight: ht,
  1112 + scaledWidth: wt
  1113 + }
  1114 + }
  1115 +
  1116 + $scope.GetMaskImageSource = function (src) {
  1117 +
  1118 + if (src != null || src != undefined) {
  1119 + if (src.match('.png')) {
  1120 + var mciImage = src.replace('.png', '_mci.png')
  1121 + }
  1122 + else {
  1123 + var mciImage = src.replace('.jpg', '_mci.png')
  1124 + }
  1125 + return mciImage;
  1126 +
  1127 + }
  1128 + else {
  1129 + console.log('IMAGE.SOURCE.NOLT.FOUND');
  1130 + }
  1131 + }
  1132 +
  1133 +
  1134 +
  1135 + $scope.GetImageSource = function (bodyRegionId) {
  1136 +
  1137 + var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
  1138 +
  1139 +
  1140 + // $('#layerChangeSlider').slider("option", "value",parseInt($rootScope.totalLayers)-parseInt($scope.layerNumber));
  1141 +
  1142 + $scope.one = 1;
  1143 +
  1144 + if ($rootScope.isListManagerSelected == true) {
  1145 + $scope.layerNumber = $('#txtlayerNumber').val();
  1146 + }
  1147 +
  1148 + $scope.userInput = parseInt($scope.layerNumber);
  1149 +
  1150 +
  1151 + $scope.skinTone = $rootScope.globalSetting.ethnicity;
  1152 +
  1153 + var SelectedLayerData = [];
  1154 + SelectedLayerData = $rootScope.BodyLayerData.Layers.DataLayer[dataLength - $scope.userInput - 1];
  1155 + if ((SelectedLayerData != null || SelectedLayerData != undefined))
  1156 +
  1157 + if ($scope.layerNumber == 0) {
  1158 + console.log('lNo: ' + $scope.layerNumber + ' and BodyRegion.length: ' + SelectedLayerData.BodyRegion.length);
  1159 +
  1160 + if (SelectedLayerData.BodyRegion.length > 0) {
  1161 + for (var z = 0; z < SelectedLayerData.BodyRegion.length; z++) {
  1162 +
  1163 + var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId;
  1164 + var bodyRegionSkinTone = SelectedLayerData.BodyRegion[z].Image._SkintTone;
  1165 +
  1166 + if ($rootScope.viewOrientationId == 3 && bodyRegionId == 1) {
  1167 + console.log('$rootScope.voId: ' + $rootScope.voId);
  1168 + if (bodyRegion == bodyRegionId && bodyRegionSkinTone == 'W') {
  1169 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/W/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
  1170 + }
  1171 + }
  1172 +
  1173 + else {
  1174 +
  1175 + if (bodyRegion == bodyRegionId && bodyRegionSkinTone == $scope.skinTone) {
  1176 +
  1177 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + $scope.skinTone + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
  1178 + }
  1179 + }
  1180 + }
  1181 + }
  1182 + }
  1183 + else {
  1184 + // debugger;
  1185 + //below 4 bodyviews have only single body region
  1186 + if (($rootScope.voId == '9') || ($rootScope.voId == '11') || ($rootScope.voId == '10') || ($rootScope.voId == '12')) {
  1187 + var bodyRegion = SelectedLayerData.BodyRegion._BodyRegionId;
  1188 +
  1189 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion.Image._ImageName;
  1190 +
  1191 + }
  1192 + else // it is for other body view which have multiple body regions and layer no > 0
  1193 + {
  1194 + // debugger;
  1195 + if (SelectedLayerData.BodyRegion.length > 0) {
  1196 + for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) {
  1197 + var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId;
  1198 + if (bodyRegion == bodyRegionId) {
  1199 +
  1200 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
  1201 +
  1202 +
  1203 + }
  1204 + }
  1205 + }
  1206 + }
  1207 + }
  1208 +
  1209 + }
  1210 +
  1211 + $scope.GetBackgroundImgSource = function (bodyRegionId) {
  1212 +
  1213 +
  1214 + var selectedGender;
  1215 + if (localStorage.getItem("genderId") == "Male") {
  1216 + selectedGender = 'M';
  1217 + }
  1218 + else {
  1219 + selectedGender = 'F';
  1220 +
  1221 + }
  1222 + //filter data based on bodyRegion
  1223 + $scope.bagartBodyRegionDetails = new jinqJs()
  1224 + .from($scope.bagartDetails)
  1225 + .where('_BodyRegionId == ' + bodyRegionId)
  1226 + .select();
  1227 + if ($scope.bagartBodyRegionDetails != null || $scope.bagartBodyRegionDetails != undefined) {
  1228 +
  1229 + //filter bodyRegion data basd on skintone
  1230 + $scope.skinTone = $rootScope.globalSetting.ethnicity
  1231 + $scope.bagartDetailsOnSktn = new jinqJs()
  1232 + .from($scope.bagartBodyRegionDetails)
  1233 + .where('_Skintone == ' + $scope.skinTone)
  1234 + .select();
  1235 +
  1236 + if ($scope.bagartDetailsOnSktn != null || $scope.bagartDetailsOnSktn != undefined) {
  1237 + //only brid=2 is having different male,female image, other bodr region have common images for male, female
  1238 + if (bodyRegionId == 2) {
  1239 + for (var z = 0; z <= $scope.bagartDetailsOnSktn.length; z++) {
  1240 + var gender = $scope.bagartDetailsOnSktn[z]._Gender;
  1241 + if (gender == selectedGender) {
  1242 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[z]._ImageId;
  1243 + }
  1244 + }
  1245 + }
  1246 +
  1247 + else {
  1248 + return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[0]._ImageId;
  1249 +
  1250 + }
  1251 + }
  1252 + }
  1253 + }
  1254 +
  1255 +
  1256 + $scope.DrawMirroredImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) {
  1257 +
  1258 + $rootScope.isLoading = true;
  1259 + $('#spinner').css('visibility', 'visible');
  1260 +
  1261 + var FlipedImgCanvas = document.createElement('canvas');
  1262 + FlipedImgCanvas.height = h;
  1263 + FlipedImgCanvas.width = w;
  1264 + FlipedImgCanvas.setAttribute("data-IsMirrored", "Y")
  1265 + FlipedImgCanvas.style.position = "absolute";
  1266 + FlipedImgCanvas.style.left = x + "px";
  1267 + FlipedImgCanvas.style.top = y + "px";
  1268 +
  1269 +
  1270 +
  1271 + if (isMaskImage == 'Y') {
  1272 +
  1273 + FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR_mci';
  1274 + FlipedImgCanvas.style.visibility = 'hidden';
  1275 +
  1276 +
  1277 + }
  1278 + else {
  1279 + FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR';
  1280 +
  1281 +
  1282 + if ($rootScope.isExtract == true) {
  1283 + FlipedImgCanvas.style.visibility = 'visible'
  1284 + }
  1285 + else {
  1286 + if ($rootScope.isHighLight == true && $rootScope.isZoomed == false) {
  1287 + FlipedImgCanvas.style.visibility = 'hidden';
  1288 + }
  1289 + }
  1290 + }
  1291 +
  1292 +
  1293 +
  1294 + FlipedImgCanvas.addEventListener('click', function (evt) {
  1295 +
  1296 +
  1297 + //to get correct data on multihighlight highlight
  1298 + if ($scope.isLayerChange == true) {
  1299 + $scope.isLayerChange = false;
  1300 + }
  1301 +
  1302 + if (evt.ctrlKey) {
  1303 + $rootScope.multiAnnotationIsON = true;
  1304 + }
  1305 + else {
  1306 + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
  1307 + $rootScope.previousHighlightList = [];
  1308 + }
  1309 +
  1310 + $rootScope.multiAnnotationIsON = false;
  1311 + }
  1312 +
  1313 + //get mouse coordinate of mirror image click
  1314 + var mousePos = $scope.getMousePos(evt);
  1315 +
  1316 + var context = FlipedImgCanvas.getContext("2d");
  1317 + var canvasId = context.canvas.getAttribute('id');
  1318 +
  1319 +
  1320 + var mirrorCanvasX = context.canvas.offsetLeft;
  1321 + var mirrorCanvasWidth = context.canvas.clientWidth;
  1322 +
  1323 + var maskCanvasId = (canvasId.replace('_MR', '')) + '_mci';
  1324 + var maskCanvas = document.getElementById(maskCanvasId);
  1325 + var maskCanvasContext = maskCanvas.getContext("2d");
  1326 +
  1327 +
  1328 + var canvasDiv = document.getElementById('canvasDiv');
  1329 + var verticalScrollPosition = canvasDiv.scrollTop;
  1330 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  1331 +
  1332 + var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135);
  1333 +
  1334 + var mirrorXOnNormalImage = parseInt(maskCanvasContext.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage);
  1335 +
  1336 + var actulalX = mirrorXOnNormalImage
  1337 + var actualY = mousePos.y + verticalScrollPosition
  1338 +
  1339 +
  1340 + var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - parseInt(maskCanvasContext.canvas.offsetLeft)), Math.round(actualY - y), 1, 1);
  1341 +
  1342 + pixelData.data[0] = pixelData.data[0] - 9;
  1343 + pixelData.data[1] = pixelData.data[1] - 9;
  1344 + pixelData.data[2] = pixelData.data[2] - 9
  1345 +
  1346 + var Red;
  1347 + var Green;
  1348 + var Blue;
  1349 + var zero = "0";
  1350 +
  1351 + if ((pixelData.data[0]).toString().length != 2) {
  1352 + Red = zero.concat((pixelData.data[0]).toString())
  1353 + }
  1354 + else {
  1355 + Red = (pixelData.data[0]).toString()
  1356 + }
  1357 + if ((pixelData.data[1]).toString().length != 2) {
  1358 + Green = zero.concat((pixelData.data[1]).toString())
  1359 + }
  1360 + else {
  1361 + Green = (pixelData.data[1]).toString()
  1362 +
  1363 + }
  1364 + if ((pixelData.data[2]).toString().length != 2) {
  1365 + Blue = zero.concat((pixelData.data[2]).toString())
  1366 + }
  1367 + else {
  1368 + Blue = (pixelData.data[2]).toString()
  1369 +
  1370 + }
  1371 + var RGBColor = (Red + Green + Blue);
  1372 +
  1373 + $rootScope.previousHighlightList.push(RGBColor);
  1374 +
  1375 +
  1376 + if ($rootScope.isHighLight) {
  1377 +
  1378 + if ($scope.machedIcolorInBodyRegion != null || $scope.machedIcolorInBodyRegion != undefined) {
  1379 + if ($scope.machedIcolorInBodyRegion.length > 0) {
  1380 + if ($rootScope.multiAnnotationIsON == false) {
  1381 + for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) {
  1382 + var bodyRegionId = $scope.machedIcolorInBodyRegion[i];
  1383 +
  1384 + var grayCanvasID = 'imageCanvas' + bodyRegionId;
  1385 + var grayCanvas = document.getElementById(grayCanvasID);
  1386 +
  1387 + var grayCanvasContext = grayCanvas.getContext("2d");
  1388 +
  1389 + if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
  1390 + var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1];
  1391 + grayCanvasContext.putImageData(grayImageData, 0, 0);
  1392 + }
  1393 +
  1394 + // for mirrored canvas
  1395 +
  1396 + if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) {
  1397 + var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
  1398 + var grayCanvasMR = document.getElementById(grayCanvasID);
  1399 +
  1400 + var grayCanvasContextMR = grayCanvasMR.getContext("2d");
  1401 + if ($rootScope.grayImageMRDataList[bodyRegionId] != null || grayImageMRDataList[bodyRegionId] != undefined) {
  1402 + var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId];
  1403 +
  1404 + grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0);
  1405 + }
  1406 + }
  1407 +
  1408 + }
  1409 + }
  1410 + }
  1411 + }
  1412 +
  1413 + // $rootScope.previousHighlightList.push(RGBColor);
  1414 +
  1415 + $scope.highLightBodyBasedOnIcolor(RGBColor);
  1416 + }
  1417 +
  1418 + //if ($rootScope.isNormalMode == true) {
  1419 +
  1420 +
  1421 + // $rootScope.previousHighlightList.push(RGBColor);
  1422 + //}
  1423 +
  1424 + //extarct clicked body part is extarct button is already enabled.
  1425 + // debugger;
  1426 + if ($rootScope.isExtract == true) {
  1427 + $scope.enableExtract(false);
  1428 + }
  1429 +
  1430 + var annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
  1431 +
  1432 + if ($('#speechBubbleTrns').length > 0)
  1433 + $('#speechBubbleTrns').remove();
  1434 +
  1435 + if ($rootScope.multiAnnotationIsON == true) {
  1436 +
  1437 + // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1438 + $scope.MultiLanguageAnnationArray = [];
  1439 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1440 +
  1441 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1442 + }
  1443 + else {
  1444 +
  1445 + if ($('#dot').length > 0) {
  1446 + $('#dot').remove();
  1447 + }
  1448 +
  1449 + if ($('#sppeachBubble').length > 0) {
  1450 + $('#sppeachBubble').remove();
  1451 +
  1452 +
  1453 + // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1454 + $scope.MultiLanguageAnnationArray = [];
  1455 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1456 +
  1457 +
  1458 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1459 + }
  1460 + else {
  1461 +
  1462 + // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1463 + $scope.MultiLanguageAnnationArray = [];
  1464 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1465 +
  1466 +
  1467 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1468 + }
  1469 +
  1470 +
  1471 + }
  1472 + }, false);
  1473 +
  1474 + FlipedImgCanvas.addEventListener('mousedown', function (evt) {
  1475 +
  1476 + //alert('mousedown')
  1477 + }, false);
  1478 +
  1479 +
  1480 + FlipedImgCanvas.addEventListener('mouseup', function (evt) {
  1481 + //alert('mouseup')
  1482 +
  1483 +
  1484 + }, false);
  1485 +
  1486 + var context = FlipedImgCanvas.getContext("2d");
  1487 +
  1488 + var PI = Math.PI;
  1489 + var PI2 = PI * 2;
  1490 + var cw, ch, imgW, imgH, mouseX, mouseY;
  1491 + var scaleFactor = 1.00;
  1492 +
  1493 + //$scaler = $("#scaler");
  1494 + //$scaler.val(scaleFactor);
  1495 + //$scaler.hide();
  1496 +
  1497 + var img = new Image();
  1498 + img.onload = start;
  1499 +
  1500 + // img.src = "~/../content/images/" + src;;
  1501 + img.src = src;
  1502 +
  1503 +
  1504 + function start() {
  1505 +
  1506 + context.save();
  1507 + context.translate(w, 0);
  1508 + context.scale(-1, 1);
  1509 + context.drawImage(img, 0, 0);
  1510 + context.restore();
  1511 +
  1512 +
  1513 + if (isMaskImage == 'N') {
  1514 +
  1515 +
  1516 + $scope.ColoredImageSRC.push(
  1517 + {
  1518 + "bodyRegionId": bodyRegionId, "SRC": src,
  1519 + "Height": h,
  1520 + "Width": w,
  1521 + "x": x,
  1522 + "y": y,
  1523 + "haveMirror": 'true'
  1524 + }
  1525 + );
  1526 +
  1527 + //-NIKI-for solving extarct issue 8286
  1528 +
  1529 + var imageCanvas = document.getElementById('imageCanvas' + bodyRegionId + '_MR');
  1530 +
  1531 + if (imageCanvas != null || imageCanvas != undefined) {
  1532 + var width = imageCanvas.width;
  1533 + var ht = imageCanvas.height;
  1534 +
  1535 + var coloredCanvasContext = imageCanvas.getContext("2d");
  1536 + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
  1537 + var coloredImageDataVar = coloredImageData;
  1538 +
  1539 + $rootScope.coloredImageMRCanvasList[parseInt(bodyRegionId)] = coloredImageDataVar;
  1540 + }
  1541 +
  1542 +
  1543 +
  1544 + //
  1545 +
  1546 + // console.log('$rootScope.isListManagerSelected= ' + $rootScope.isListManagerSelected + ' length= ' + $scope.ColoredImageSRC.length)
  1547 +
  1548 + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
  1549 +
  1550 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
  1551 + $scope.isEligibleForHighlight = true;
  1552 + }
  1553 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
  1554 + $scope.isEligibleForHighlight = true;
  1555 + }
  1556 + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
  1557 + $scope.isEligibleForHighlight = true;
  1558 + }
  1559 + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
  1560 + $scope.isEligibleForHighlight = true;
  1561 + }
  1562 + else {
  1563 + $scope.isEligibleForHighlight = false;
  1564 + }
  1565 +
  1566 + if ($scope.isEligibleForHighlight == true) {
  1567 + if ($scope.isExtract == true) {
  1568 + $rootScope.isLoading = true;
  1569 + $('#spinner').css('visibility', 'visible');
  1570 + $scope.highLightBody();
  1571 + }
  1572 + else if ($rootScope.isHighLight == true || ($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true))
  1573 + || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true)) || $rootScope.isHighlightBodyByBodySystem == true) {
  1574 +
  1575 + console.log('1. $rootScope.isHighLight= ' + $rootScope.isHighLight)
  1576 +
  1577 + $rootScope.isLoading = true;
  1578 + $('#spinner').css('visibility', 'visible');
  1579 + //$timeout(function () {
  1580 + console.log('inside start of flipped. $scope.ColoredImageSRC.length= ' + $scope.ColoredImageSRC.length)
  1581 + $rootScope.isHighLight = true;
  1582 + console.log('in FlipedImgCanvas just before highLightBody call');
  1583 + $scope.highLightBody();
  1584 + console.log('just after highLightBody call');
  1585 + //}, 500);
  1586 + }
  1587 + }
  1588 + else {
  1589 + $rootScope.isLoading = false;
  1590 + $('#spinner').css('visibility', 'hidden');
  1591 + }
  1592 + }
  1593 +
  1594 + // console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length);
  1595 + }
  1596 +
  1597 + if (FlipedImgCanvas.id.match('_mci')) {
  1598 +
  1599 + var maskImgData = context.getImageData(0, 0, w, h);
  1600 +
  1601 + $rootScope.MaskCanvasData.push(
  1602 + {
  1603 + "bodyRegionId": bodyRegionId,
  1604 + "canvasId": FlipedImgCanvas.id,
  1605 + "maskData": maskImgData,
  1606 +
  1607 + }
  1608 + );
  1609 + }
  1610 + };
  1611 +
  1612 +
  1613 + if (document.getElementById('canvasDiv') != null)
  1614 + document.getElementById('canvasDiv').appendChild(FlipedImgCanvas);
  1615 +
  1616 +
  1617 +
  1618 +
  1619 +
  1620 + }
  1621 +
  1622 + $scope.DrawImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) {
  1623 +
  1624 + $rootScope.isLoading = true;
  1625 + $('#spinner').css('visibility', 'visible');
  1626 +
  1627 + var imgCanvas = document.createElement('canvas');
  1628 +
  1629 + imgCanvas.height = h;
  1630 + imgCanvas.width = w;
  1631 + imgCanvas.setAttribute("data-IsMirrored", "N")
  1632 + imgCanvas.style.position = "absolute";
  1633 + imgCanvas.style.left = x + "px";
  1634 + imgCanvas.style.top = y + "px";
  1635 +
  1636 + if (isMaskImage == 'Y') {
  1637 + imgCanvas.style.visibility = 'hidden'
  1638 + imgCanvas.id = 'imageCanvas' + bodyRegionId + '_mci';
  1639 +
  1640 + }
  1641 + else {
  1642 + imgCanvas.id = 'imageCanvas' + bodyRegionId;
  1643 +
  1644 + if (bodyRegionId == 3) {
  1645 + //set z index of hip canavs to fix the issue caused by overlapping of arm canavs on hip canavs.
  1646 + imgCanvas.style.zIndex = "100";
  1647 + }
  1648 + if (bodyRegionId.match('modestyImg')) {
  1649 + //added class to further access this canavs to show and hide leaf as per modesty seting
  1650 + imgCanvas.className = 'modestyImg'
  1651 + imgCanvas.style.visibility = 'hidden'
  1652 + //set z index to make leaf canvas on top of hip canavs
  1653 + imgCanvas.style.zIndex = "200";
  1654 + }
  1655 + if (($rootScope.voId == 11 || $rootScope.voId == 9) && bodyRegionId == 6) {
  1656 + imgCanvas.style.zIndex = "500";
  1657 + }
  1658 +
  1659 + if ($rootScope.isExtract == true) {
  1660 + imgCanvas.style.visibility = 'visible'
  1661 + }
  1662 + else {
  1663 +
  1664 + if ($rootScope.isHighLight == true && $rootScope.isZoomed == false) {
  1665 + imgCanvas.style.visibility = 'hidden';
  1666 + }
  1667 + }
  1668 +
  1669 + }
  1670 +
  1671 + imgCanvas.addEventListener('click', function (evt) {
  1672 +
  1673 +
  1674 + if ($scope.isLayerChange == true) {
  1675 + $scope.isLayerChange = false;
  1676 + }
  1677 +
  1678 + if (evt.ctrlKey) {
  1679 + $rootScope.multiAnnotationIsON = true;
  1680 + }
  1681 + else {
  1682 + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
  1683 + $rootScope.previousHighlightList = [];
  1684 + }
  1685 + $rootScope.multiAnnotationIsON = false;
  1686 + }
  1687 +
  1688 + var annotationText;
  1689 + var context = imgCanvas.getContext("2d");
  1690 +
  1691 +
  1692 + var canvasId = context.canvas.getAttribute('id');
  1693 + var maskCanvasId;
  1694 + //for leaf canvas
  1695 + if (canvasId.match('modestyImg')) {
  1696 + maskCanvasId = canvasId;
  1697 + }
  1698 + else {
  1699 + maskCanvasId = canvasId + '_mci';
  1700 + }
  1701 + var maskCanvas = document.getElementById(maskCanvasId);
  1702 + var maskCanvasContext = maskCanvas.getContext("2d");
  1703 +
  1704 + var mousePos = $scope.getMousePos(evt);
  1705 + // alert(mousePos.x + ',' + mousePos.y);
  1706 +
  1707 + var canvasDiv = document.getElementById('canvasDiv');
  1708 + var verticalScrollPosition = canvasDiv.scrollTop;
  1709 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  1710 +
  1711 +
  1712 + //We substracted 135, as the difference between flex and html coordinates for same organ is 135
  1713 + var actulalX = mousePos.x + horizontlScrollPosition;
  1714 + var actualY = mousePos.y + verticalScrollPosition;
  1715 + var RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
  1716 +
  1717 +
  1718 + //Modesty ON
  1719 + if (maskCanvasId.match('modestyImg') && RGBColor != '000000') {
  1720 + RGBColor = DA[0].figLeafTermId;
  1721 + annotationText = $scope.GetAnnotationBasedOnActualTermNo(RGBColor);
  1722 + }
  1723 + //Modesty On but clicked somewhre else, we did modesty check because the modesty image covers whole body region so if user will click to
  1724 + //see the annotation apart from leaf then the actual click will be on modesty canvas, but for annotation er
  1725 + //
  1726 + else if (maskCanvasId.match('modestyImg') && RGBColor == '000000') {
  1727 + //if ($rootScope.voId == 11) {
  1728 + // maskCanvasId = 'imageCanvas6_mci';
  1729 + // x = $('#imageCanvas6_mci').left;
  1730 + // y = $('#imageCanvas6_mci').top;
  1731 + //}
  1732 + //else {
  1733 + bodyRegionId = maskCanvasId.slice(-1);
  1734 + maskCanvasId = 'imageCanvas' + bodyRegionId + '_mci';
  1735 + // }
  1736 + var maskCanvas = document.getElementById(maskCanvasId);
  1737 + var maskCanvasContext = maskCanvas.getContext("2d");
  1738 +
  1739 + RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
  1740 + annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
  1741 + }
  1742 + else {
  1743 + RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
  1744 + annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
  1745 +
  1746 + }
  1747 +
  1748 + $rootScope.previousHighlightList.push(RGBColor);
  1749 +
  1750 + if ($rootScope.isHighLight == true) {
  1751 + if ($scope.machedIcolorInBodyRegion != null || $scope.machedIcolorInBodyRegion != undefined) {
  1752 + if ($scope.machedIcolorInBodyRegion.length > 0) {
  1753 + if ($rootScope.multiAnnotationIsON == false) {
  1754 + for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) {
  1755 + var bodyRegionId = $scope.machedIcolorInBodyRegion[i];
  1756 +
  1757 + var grayCanvasID = 'imageCanvas' + bodyRegionId;
  1758 + var grayCanvas = document.getElementById(grayCanvasID);
  1759 +
  1760 + var grayCanvasContext = grayCanvas.getContext("2d");
  1761 + if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
  1762 + var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1];
  1763 + grayCanvasContext.putImageData(grayImageData, 0, 0);
  1764 + }
  1765 +
  1766 + // for unhighlight the mirrored body region
  1767 + if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) {
  1768 + var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
  1769 + var grayCanvasMR = document.getElementById(grayCanvasID);
  1770 +
  1771 + var grayCanvasContextMR = grayCanvasMR.getContext("2d");
  1772 +
  1773 + if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
  1774 +
  1775 + var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId];
  1776 +
  1777 + grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0);
  1778 +
  1779 + }
  1780 + }
  1781 +
  1782 + }
  1783 + }
  1784 + }
  1785 + }
  1786 +
  1787 + // $rootScope.previousHighlightList.push(RGBColor);
  1788 +
  1789 +
  1790 + if (maskCanvasId.match('modestyImg') && RGBColor != '000000') { }
  1791 + else
  1792 + {
  1793 + $scope.highLightBodyBasedOnIcolor(RGBColor);
  1794 + }
  1795 +
  1796 + }
  1797 +
  1798 + //if ($rootScope.isNormalMode == true) {
  1799 + // $rootScope.previousHighlightList.push(RGBColor);
  1800 + //}
  1801 +
  1802 + // debugger;
  1803 + //extarct clisked body part is extarct button is already enabled.
  1804 + if ($rootScope.isExtract == true) {
  1805 + $scope.enableExtract(false);
  1806 + }
  1807 +
  1808 + if ($('#speechBubbleTrns').length > 0)
  1809 + $('#speechBubbleTrns').remove();
  1810 +
  1811 + if ($rootScope.multiAnnotationIsON == true) {
  1812 +
  1813 + // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1814 + $scope.MultiLanguageAnnationArray = [];
  1815 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1816 +
  1817 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1818 + }
  1819 + else {
  1820 +
  1821 + $scope.MultiLanguageAnnationArray = [];
  1822 +
  1823 + console.log('1. annotationText: ' + annotationText);
  1824 +
  1825 + if ($('#dot').length > 0) {
  1826 + $('#dot').remove();
  1827 +
  1828 + if ($('#sppeachBubble').length > 0) {
  1829 + $('#sppeachBubble').remove();
  1830 + }
  1831 +
  1832 +
  1833 +
  1834 + // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
  1835 +
  1836 +
  1837 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1838 +
  1839 + console.log('2. annotationText: ' + annotationText + ' , length: ' + $scope.MultiLanguageAnnationArray.length);
  1840 +
  1841 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1842 +
  1843 + }
  1844 + else {
  1845 +
  1846 +
  1847 +
  1848 + $scope.MultiLanguageAnnationArray = [];
  1849 + $scope.MultiLanguageAnnationArray.push(annotationText);
  1850 +
  1851 + console.log('3. annotationText: ' + annotationText + ' , length: ' + $scope.MultiLanguageAnnationArray.length);
  1852 +
  1853 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  1854 + }
  1855 +
  1856 +
  1857 + }
  1858 + }, false);
  1859 +
  1860 + var PI = Math.PI;
  1861 + var PI2 = PI * 2;
  1862 + var cw, ch, imgW, imgH, mouseX, mouseY;
  1863 + var scaleFactor = 1.00;
  1864 +
  1865 + var context = imgCanvas.getContext('2d');
  1866 + var img = new Image();
  1867 + img.onload = start;
  1868 +
  1869 + img.src = src;
  1870 +
  1871 +
  1872 +
  1873 + function start() {
  1874 +
  1875 + context.drawImage(img, 0, 0);
  1876 +
  1877 + if (isMaskImage == 'N') {
  1878 + if (bodyRegionId == 'modestyImg3' || bodyRegionId == 'modestyImg2') {
  1879 + $scope.modestyImageInfo.push(
  1880 +
  1881 + {
  1882 + "bodyRegionId": bodyRegionId, "SRC": src,
  1883 + "Height": h,
  1884 + "Width": w,
  1885 + "x": x,
  1886 + "y": y,
  1887 + "haveMirror": 'false'
  1888 + }
  1889 +
  1890 + );
  1891 + }
  1892 + else {
  1893 +
  1894 + $scope.ColoredImageSRC.push(
  1895 + {
  1896 + "bodyRegionId": bodyRegionId, "SRC": src,
  1897 + "Height": h,
  1898 + "Width": w,
  1899 + "x": x,
  1900 + "y": y,
  1901 + "haveMirror": 'false'
  1902 + }
  1903 +
  1904 + );
  1905 +
  1906 +
  1907 + //-NIKI-for solving extarct issue 8286
  1908 +
  1909 + var imageCanvas = document.getElementById('imageCanvas' + bodyRegionId);
  1910 +
  1911 + if (imageCanvas != null || imageCanvas != undefined) {
  1912 + var width = imageCanvas.width;
  1913 + var ht = imageCanvas.height;
  1914 +
  1915 + var coloredCanvasContext = imageCanvas.getContext("2d");
  1916 + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
  1917 + var coloredImageDataVar = coloredImageData;
  1918 +
  1919 +
  1920 + $rootScope.coloredImageCanvasList[parseInt(bodyRegionId - 1)] = coloredImageDataVar;
  1921 + }
  1922 + //
  1923 +
  1924 +
  1925 + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
  1926 +
  1927 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
  1928 + $scope.isEligibleForHighlight = true;
  1929 + }
  1930 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
  1931 + $scope.isEligibleForHighlight = true;
  1932 + }
  1933 + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
  1934 + $scope.isEligibleForHighlight = true;
  1935 + }
  1936 + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
  1937 + $scope.isEligibleForHighlight = true;
  1938 + }
  1939 + else {
  1940 + $scope.isEligibleForHighlight = false;
  1941 + }
  1942 +
  1943 +
  1944 + if ($scope.isEligibleForHighlight == true) {
  1945 +
  1946 + if ($scope.isExtract == true) {
  1947 + $rootScope.isLoading = true;
  1948 + $('#spinner').css('visibility', 'visible');
  1949 + $scope.highLightBody();
  1950 + }
  1951 + else if ($rootScope.isHighLight == true || ($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true))
  1952 + || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true)) || $scope.isExtract == true || $rootScope.isHighlightBodyByBodySystem == true) {
  1953 +
  1954 + console.log('2. $rootScope.isHighLight= ' + $rootScope.isHighLight)
  1955 +
  1956 + $rootScope.isLoading = true;
  1957 + $('#spinner').css('visibility', 'visible');
  1958 +
  1959 + console.log('inside start of non flipped. $scope.ColoredImageSRC.length= ' + $scope.ColoredImageSRC.length)
  1960 + $rootScope.isHighLight = true;
  1961 +
  1962 + console.log('just before highLightBody call');
  1963 +
  1964 + $scope.highLightBody();
  1965 +
  1966 + console.log('just after highLightBody call');
  1967 +
  1968 + }
  1969 + else {
  1970 + $rootScope.isLoading = false;
  1971 + $('#spinner').css('visibility', 'hidden');
  1972 + }
  1973 + }
  1974 + else {
  1975 + $rootScope.isLoading = false;
  1976 + $('#spinner').css('visibility', 'hidden');
  1977 + }
  1978 + }
  1979 +
  1980 + console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length);
  1981 + }
  1982 + }
  1983 +
  1984 + if (imgCanvas.id.match('_mci')) {
  1985 + var maskImgData = context.getImageData(0, 0, w, h);
  1986 + $rootScope.MaskCanvasData.push(
  1987 + {
  1988 + "bodyRegionId": bodyRegionId,
  1989 + "canvasId": imgCanvas.id,
  1990 + "maskData": maskImgData,
  1991 +
  1992 + }
  1993 + );
  1994 + }
  1995 +
  1996 + };
  1997 +
  1998 + if (document.getElementById('canvasDiv') != null)
  1999 + document.getElementById('canvasDiv').appendChild(imgCanvas);
  2000 + }
  2001 +
  2002 +
  2003 +
  2004 + $scope.highLightBodyBasedOnIcolor = function (RGBColor) {
  2005 +
  2006 +
  2007 + //2. Find Actul Term No Based on Icolor.
  2008 + var ActualTermNo = $scope.getActualTermNumber(RGBColor);
  2009 +
  2010 + if (ActualTermNo != null) {
  2011 +
  2012 + //3. Find Term No List Based on ActualTermNo
  2013 + var TermList = $scope.getTermNumberList(ActualTermNo);
  2014 + if (TermList != null) {
  2015 +
  2016 + //4.
  2017 + $scope.HighlightBodyByTermList(TermList);
  2018 + }
  2019 + }
  2020 +
  2021 +
  2022 + }
  2023 +
  2024 +
  2025 + $scope.HighlightBodyOnExtract = function () {
  2026 + console.log(' insode HighlightBodyOnExtract. $rootScope.MaskCanvasData length= ' + $rootScope.MaskCanvasData.length + ', $rootScope.previousHighlightList.length= ' + $rootScope.previousHighlightList.length)
  2027 +
  2028 +
  2029 + $("#btnExtract").removeClass("btn-black");
  2030 + $("#btnExtract").addClass("btn-primary");
  2031 +
  2032 +
  2033 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  2034 + $("#btnNormalMode").removeClass("btn-primary");
  2035 + $("#btnNormalMode").addClass("btn-black");
  2036 + }
  2037 +
  2038 + if ($("#btnHighLight").hasClass("btn-primary")) {
  2039 + $("#btnHighLight").removeClass("btn-primary");
  2040 + $("#btnHighLight").addClass("btn-black");
  2041 + }
  2042 +
  2043 +
  2044 + //terminate previous running workers to create space for new workers
  2045 + $scope.layerNumber = $('#txtlayerNumber').val();
  2046 + $scope.terminateCurrentlyRunningWPs();
  2047 +
  2048 + var multiTermList = [];
  2049 + var CallBackBodyRegion = [];
  2050 + var selectedAnnotation;
  2051 +
  2052 + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0) && $rootScope.isListManagerSelected) {
  2053 +
  2054 + multiTermList = $scope.AllTerms;
  2055 + angular.forEach($rootScope.previousHighlightList, function (value, key) {
  2056 +
  2057 + var ActualTermNo = $scope.getActualTermNumber(value);
  2058 + selectedAnnotation = ActualTermNo;
  2059 + if (ActualTermNo != null) {
  2060 + var TermList = $scope.getTermNumberList(ActualTermNo);
  2061 + if (TermList != null) {
  2062 + for (var i = 0; i < TermList.length; i++) {
  2063 + multiTermList.push(TermList[i]);
  2064 + }
  2065 + }
  2066 + }
  2067 +
  2068 + // to do
  2069 + });
  2070 + }
  2071 +
  2072 + if ($rootScope.isListManagerSelected) {
  2073 +
  2074 + multiTermList = $scope.AllTerms;
  2075 + selectedAnnotation = $rootScope.actualTermNumber;
  2076 +
  2077 + }
  2078 + else if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
  2079 + angular.forEach($rootScope.previousHighlightList, function (value, key) {
  2080 +
  2081 + var ActualTermNo = $scope.getActualTermNumber(value);
  2082 + selectedAnnotation = ActualTermNo;
  2083 + if (ActualTermNo != null) {
  2084 + var TermList = $scope.getTermNumberList(ActualTermNo);
  2085 + if (TermList != null) {
  2086 + for (var i = 0; i < TermList.length; i++) {
  2087 + multiTermList.push(TermList[i]);
  2088 + }
  2089 + }
  2090 + }
  2091 +
  2092 + // to do
  2093 + });
  2094 + }
  2095 +
  2096 + //get term list to get term coordinates
  2097 + $scope.TermList = $scope.getTermNumberList(selectedAnnotation);
  2098 +
  2099 + $scope.termCoordinate = $scope.getTermCoordinate(selectedAnnotation);
  2100 +
  2101 +
  2102 +
  2103 + $timeout(function () {
  2104 +
  2105 + var loopLength = 0;
  2106 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
  2107 + loopLength = 9;
  2108 + }
  2109 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
  2110 + loopLength = 5;
  2111 + }
  2112 + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
  2113 + loopLength = 4;
  2114 + }
  2115 + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
  2116 + loopLength = 1;
  2117 + }
  2118 +
  2119 + if (loopLength !== 0) {
  2120 + for (var x = 0; x < loopLength; x++) {
  2121 + if ($rootScope.MaskCanvasData[x] != null || $rootScope.MaskCanvasData[x] != undefined) {
  2122 + var bodyRegionId = $rootScope.MaskCanvasData[x].bodyRegionId;
  2123 + var canvasId = $rootScope.MaskCanvasData[x].canvasId;
  2124 + var maskData = null;
  2125 + maskData = $rootScope.MaskCanvasData[x].maskData;
  2126 +
  2127 + var coloredImageDataVar = null;
  2128 + var grayImageDataVar = null;
  2129 +
  2130 + var white = null;
  2131 + if (canvasId.match('_MR')) {
  2132 + if ($rootScope.coloredImageMRCanvasList[bodyRegionId] != null || $rootScope.coloredImageMRCanvasList[bodyRegionId] != undefined) {
  2133 +
  2134 + coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
  2135 +
  2136 + }
  2137 +
  2138 + if ($rootScope.whiteImageMRDataList[bodyRegionId] != null || $rootScope.whiteImageMRDataList[bodyRegionId] != undefined) {
  2139 + white = $rootScope.whiteImageMRDataList[bodyRegionId];
  2140 + }
  2141 +
  2142 + }
  2143 +
  2144 + else {
  2145 +
  2146 + if ($rootScope.coloredImageCanvasList[bodyRegionId - 1] != null || $rootScope.coloredImageCanvasList[bodyRegionId - 1] != undefined) {
  2147 + coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
  2148 + }
  2149 + if ($rootScope.whiteImageDataList[bodyRegionId - 1] != null || $rootScope.whiteImageDataList[bodyRegionId - 1] != undefined) {
  2150 + white = $rootScope.whiteImageDataList[bodyRegionId - 1];
  2151 +
  2152 + }
  2153 + }
  2154 +
  2155 +
  2156 + var worker = new Worker('extract-wp.js');
  2157 +
  2158 + //push workers in array to further used the refernece to delete the workers
  2159 + $scope.runningWorkers.push({ 'workerName': worker })
  2160 +
  2161 + console.log('for BRID = ' + bodyRegionId + ', coloredImageDataVar: ' + coloredImageDataVar + ', maskData= ' + maskData + ', white= ' + white)
  2162 +
  2163 + if (coloredImageDataVar != null && maskData != null && white != null) {
  2164 + worker.postMessage({
  2165 +
  2166 + 'termList': multiTermList,
  2167 + 'maskCanvasData': maskData,
  2168 + 'coloredImageData': coloredImageDataVar,
  2169 + 'grayImageData': white,
  2170 + 'bodyRegionId': bodyRegionId,
  2171 + 'canvasId': canvasId
  2172 +
  2173 + });
  2174 + }
  2175 +
  2176 + //}
  2177 +
  2178 + worker.onmessage = function (e) {
  2179 + console.log('callback in extract for e.data.bodyRegionId: ' + e.data.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
  2180 +
  2181 +
  2182 + var updatedData = e.data.value;
  2183 +
  2184 + var bodyRegionId = e.data.bodyRegionId;
  2185 +
  2186 +
  2187 + var canvasId = (e.data.canvasId).replace('_mci', '');
  2188 +
  2189 + //for (var i = 1; i <= updatedData.length; i++) {
  2190 + var grayCanvasID = canvasId;
  2191 +
  2192 + // var grayCanvasID = 'imageCanvas' + bodyRegionId;
  2193 + var grayCanvas = document.getElementById(grayCanvasID);
  2194 + var grayCanvasContext = grayCanvas.getContext("2d");
  2195 +
  2196 +
  2197 +
  2198 + grayCanvasContext.putImageData(updatedData, 0, 0);
  2199 +
  2200 + //to resolve lateral arm black issue in highlight mode
  2201 +
  2202 + if ($rootScope.viewOrientationId == 5 && (bodyRegionId == 6 || bodyRegionId == 4)) {
  2203 +
  2204 + var canavsWidth = parseInt(grayCanvas.width);
  2205 + var canavsHeight = parseInt(grayCanvas.height);
  2206 +
  2207 + console.log('canavsWidth= ' + canavsWidth + ', canavsHeight= ' + canavsHeight)
  2208 +
  2209 + var imgData = grayCanvasContext.getImageData(0, 0, canavsWidth, canavsHeight);
  2210 + var data = imgData.data;
  2211 + var c = 0;
  2212 + for (var i = 0; i < data.length; i += 4) {
  2213 + if (data[i] == data[i + 1] && data[i + 1] == data[i + 2] && data[i + 2] === 0) {
  2214 + data[i + 3] = 0;
  2215 + }
  2216 +
  2217 + }
  2218 + grayCanvasContext.putImageData(imgData, 0, 0);
  2219 + }
  2220 +
  2221 + CallBackBodyRegion.push(bodyRegionId);
  2222 +
  2223 + $scope.doAligneCanvasWithTerm = false;
  2224 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && (CallBackBodyRegion.length == 9)) {
  2225 + $scope.doAligneCanvasWithTerm = true;
  2226 + }
  2227 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && (CallBackBodyRegion.length == 5)) {
  2228 + $scope.doAligneCanvasWithTerm = true;
  2229 + }
  2230 + else if ((($rootScope.viewOrientationId == '5')) && (CallBackBodyRegion.length == 1)) {
  2231 + $scope.doAligneCanvasWithTerm = true;
  2232 + }
  2233 + else if ((($rootScope.viewOrientationId == '6')) && (CallBackBodyRegion.length == 1)) {
  2234 + $scope.doAligneCanvasWithTerm = true;
  2235 + }
  2236 +
  2237 +
  2238 + if ($rootScope.multiAnnotationIsON == true) {
  2239 +
  2240 + if (canvasId.match('_MR'))
  2241 + $rootScope.updatedWhiteImageMRDataList[bodyRegionId] = updatedData;
  2242 + else
  2243 + $rootScope.updatedWhiteImageDataList[bodyRegionId - 1] = updatedData;
  2244 +
  2245 +
  2246 + }
  2247 + else {
  2248 +
  2249 + if (canvasId.match('_MR'))
  2250 + $rootScope.whiteImageMRDataList[bodyRegionId] = e.data.value;
  2251 + else {
  2252 + if ($rootScope.whiteImageDataList[bodyRegionId - 1] != null || $rootScope.whiteImageDataList[bodyRegionId - 1] != undefined)
  2253 + $rootScope.whiteImageDataList[bodyRegionId - 1] = e.data.value;
  2254 + }
  2255 + }
  2256 +
  2257 + //if ((CallBackBodyRegion != null || CallBackBodyRegion[i] != undefined) && (CallBackBodyRegion.length > 0)) {
  2258 + // if (CallBackBodyRegion.length == 6) {
  2259 + // $rootScope.isLoading = false;
  2260 + // $('#spinner').css('visibility', 'hidden');
  2261 + // }
  2262 + //}
  2263 +
  2264 + if ($scope.doAligneCanvasWithTerm == true) {
  2265 + $scope.aligneCanvasWithTerm()
  2266 + }
  2267 +
  2268 + // $timeout(function () { $scope.DisableProgressBar() }, 1000);
  2269 +
  2270 +
  2271 +
  2272 + };
  2273 + worker.onerror = function (e) {
  2274 + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
  2275 + };
  2276 + }
  2277 + }
  2278 + }
  2279 + }, 500)
  2280 +
  2281 + }
  2282 +
  2283 + $scope.HighlightBodyByTermList = function (TermList) {
  2284 +
  2285 + $scope.layerNumber = $('#txtlayerNumber').val();
  2286 +
  2287 + $rootScope.isLoading = true;
  2288 + $('#spinner').css('visibility', 'visible');
  2289 +
  2290 +
  2291 + if ($rootScope.isHighLight == true) {
  2292 + false;
  2293 + }
  2294 +
  2295 + console.log('HighlightBodyByTermList is called');
  2296 +
  2297 + // $scope.highlightedBR = null;
  2298 + $scope.highlightedBR = [];
  2299 +
  2300 + $scope.terminateCurrentlyRunningWPs();
  2301 +
  2302 +
  2303 +
  2304 + $timeout(function () {
  2305 + var loopLength = 0;
  2306 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
  2307 + loopLength = 9;
  2308 + }
  2309 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
  2310 + loopLength = 5;
  2311 + }
  2312 + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
  2313 + loopLength = 4;
  2314 + }
  2315 + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
  2316 + loopLength = 1;
  2317 + }
  2318 +
  2319 + for (var x = 0; x < loopLength; x++) {
  2320 + if ($rootScope.MaskCanvasData[x] != null || $rootScope.MaskCanvasData[x] != undefined) {
  2321 +
  2322 + var bodyRegionId = $rootScope.MaskCanvasData[x].bodyRegionId;
  2323 + var canvasId = $rootScope.MaskCanvasData[x].canvasId;
  2324 + var maskData = null;
  2325 + maskData = $rootScope.MaskCanvasData[x].maskData;
  2326 +
  2327 + var coloredImageDataVar = null;
  2328 + var grayImageDataVar = null;
  2329 +
  2330 + var white;
  2331 + if (canvasId.match('_MR')) {
  2332 + if ($rootScope.coloredImageMRCanvasList[bodyRegionId] != null || $rootScope.coloredImageMRCanvasList[bodyRegionId] != undefined) {
  2333 + coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
  2334 + }
  2335 +
  2336 +
  2337 + if ($rootScope.multiAnnotationIsON == true) {
  2338 + //on layer change we need the fresh data not the updated one
  2339 + if ($scope.isLayerChange == true) {
  2340 + if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
  2341 + grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
  2342 + }
  2343 + }
  2344 + else {
  2345 + if ($rootScope.updatedGrayDataList[bodyRegionId - 1] == null || $rootScope.updatedGrayDataList[bodyRegionId - 1] == undefined) {
  2346 +
  2347 + if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
  2348 + grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
  2349 + }
  2350 + }
  2351 + else {
  2352 + if ($rootScope.updatedGrayMRDataList[bodyRegionId] != null || $rootScope.updatedGrayMRDataList[bodyRegionId] != undefined) {
  2353 + grayImageDataVar = $rootScope.updatedGrayMRDataList[bodyRegionId]
  2354 + }
  2355 + }
  2356 + }
  2357 + }
  2358 + else {
  2359 + if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
  2360 + grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
  2361 + }
  2362 + }
  2363 +
  2364 +
  2365 + }
  2366 +
  2367 + else {
  2368 +
  2369 + if ($rootScope.coloredImageCanvasList[bodyRegionId - 1] != null || $rootScope.coloredImageCanvasList[bodyRegionId - 1] != undefined) {
  2370 + coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
  2371 + }
  2372 +
  2373 +
  2374 +
  2375 + if ($rootScope.multiAnnotationIsON == true) {
  2376 +
  2377 + //on layer change we need the fresh data not the updated one
  2378 + if ($scope.isLayerChange == true) {
  2379 + if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
  2380 + grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
  2381 +
  2382 + }
  2383 +
  2384 + } else {
  2385 + // this code is for the case where user first click on normal mode then extract then again highlight then we need to call highlight body in gray mode
  2386 + //and then highlight the previously selected body regions at the time of normal mode.
  2387 + if ($rootScope.updatedGrayDataList[bodyRegionId - 1] == null || $rootScope.updatedGrayDataList[bodyRegionId - 1] == undefined) {
  2388 +
  2389 + if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
  2390 + grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
  2391 + }
  2392 +
  2393 + }
  2394 + else {
  2395 + if ($rootScope.updatedGrayDataList[bodyRegionId - 1] != null || $rootScope.updatedGrayDataList[bodyRegionId - 1] != undefined) {
  2396 + // for normal case means without interdepency button case.
  2397 + grayImageDataVar = $rootScope.updatedGrayDataList[bodyRegionId - 1];
  2398 + }
  2399 + }
  2400 + }
  2401 + }
  2402 + else
  2403 + if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
  2404 + grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
  2405 + }
  2406 +
  2407 +
  2408 + }
  2409 +
  2410 + var worker = new Worker('term-number-wp.js');
  2411 +
  2412 + //push workers in array to further used the refernece to delete the workers
  2413 + $scope.runningWorkers.push({ 'workerName': worker })
  2414 +
  2415 + // console.log('for bodyRegionId = ' + bodyRegionId+ ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
  2416 + console.log('before worker call BRID: ' + bodyRegionId)
  2417 +
  2418 + if (grayImageDataVar != null && coloredImageDataVar != null && maskData != null) {
  2419 + worker.postMessage({
  2420 +
  2421 + 'termList': TermList,
  2422 + 'maskCanvasData': maskData,
  2423 + 'coloredImageData': coloredImageDataVar,
  2424 + 'grayImageData': grayImageDataVar,
  2425 + 'bodyRegionId': bodyRegionId,
  2426 + 'canvasId': canvasId
  2427 +
  2428 + });
  2429 + }
  2430 +
  2431 +
  2432 +
  2433 + worker.onmessage = function (e) {
  2434 + console.log('callback for e.data.bodyRegionId: ' + e.data.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
  2435 +
  2436 + var updatedData = e.data.value;
  2437 +
  2438 + var bodyRegionId = e.data.bodyRegionId;
  2439 + var canvasId = (e.data.canvasId).replace('_mci', '');
  2440 +
  2441 + //for (var i = 1; i <= updatedData.length; i++) {
  2442 + var grayCanvasID = canvasId;
  2443 +
  2444 + //to do
  2445 + var grayCanvas = document.getElementById(grayCanvasID);
  2446 + if (grayCanvas != null) {
  2447 + var grayCanvasContext = grayCanvas.getContext("2d");
  2448 +
  2449 + //Niki remove previous data from canvas
  2450 + var canvasHeight = grayCanvas.height + 'px';
  2451 + var canvasWidth = grayCanvas.width + 'px';
  2452 + //alert('height= ' + canvasHeight + ', width= ' + canvasWidth)
  2453 + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
  2454 +
  2455 + grayCanvasContext.putImageData(updatedData, 0, 0);
  2456 + $scope.highlightedBR.push({ 'bodyRegionId': bodyRegionId });
  2457 +
  2458 + }
  2459 +
  2460 +
  2461 +
  2462 + if (canvasId.match('_MR')) {
  2463 + $rootScope.updatedGrayMRDataList[bodyRegionId] = updatedData;
  2464 +
  2465 + //alert('HighlightBodyByTermList, is mutiAnnotation on= ' + $rootScope.multiAnnotationIsON);
  2466 +
  2467 + //$rootScope.updatedWhiteImageMRDataList[bodyRegionId] = updatedData;
  2468 + }
  2469 + else
  2470 + $rootScope.updatedGrayDataList[bodyRegionId - 1] = updatedData;
  2471 +
  2472 + //$scope.highlightedBR.push({ 'bodyRegionId': bodyRegionId });
  2473 +
  2474 + console.log('$scope.highlightedBR.length= ' + $scope.highlightedBR.length)
  2475 +
  2476 + if ($scope.highlightedBR != null || $scope.highlightedBR != undefined) {
  2477 +
  2478 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.highlightedBR.length == 9)) {
  2479 + $scope.doAligneCanvasWithTerm = true;
  2480 + }
  2481 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.highlightedBR.length == 5)) {
  2482 + $scope.doAligneCanvasWithTerm = true;
  2483 + }
  2484 + else if ((($rootScope.viewOrientationId == '5')) && ($scope.highlightedBR.length == 1)) {
  2485 + $scope.doAligneCanvasWithTerm = true;
  2486 + }
  2487 + else if ((($rootScope.viewOrientationId == '6')) && ($scope.highlightedBR.length == 1)) {
  2488 + $scope.doAligneCanvasWithTerm = true;
  2489 + }
  2490 + if ($scope.doAligneCanvasWithTerm == true) {
  2491 +
  2492 + if ($rootScope.isListManagerSelected == true)
  2493 + $scope.aligneCanvasWithTerm();
  2494 +
  2495 + else if ($rootScope.isHighlightBodyByBodySystem == true || $rootScope.isListManagerSelected == true) {
  2496 +
  2497 + $rootScope.isLoading = false;
  2498 +
  2499 + $('#spinner').css('visibility', 'hidden');
  2500 + }
  2501 + else {
  2502 + var canvasDiv = document.getElementById('canvasDiv');
  2503 + $('#canvasDiv').scrollTop($scope.imageVerticalScrollPosition);
  2504 + $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition);
  2505 +
  2506 + $rootScope.isLoading = false;
  2507 +
  2508 + $('#spinner').css('visibility', 'hidden');
  2509 + //$('#canvasDiv').scrollLeft(newX);
  2510 + //$('#canvasDiv').scrollTop(newY);
  2511 + }
  2512 +
  2513 + // $rootScope.isHighlightBodyByBodySystem = false;
  2514 +
  2515 +
  2516 + }
  2517 + }
  2518 + //
  2519 +
  2520 + };
  2521 + worker.onerror = function (e) {
  2522 + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
  2523 + };
  2524 + }
  2525 + }
  2526 + }, 100)
  2527 + }
  2528 +
  2529 +
  2530 +
  2531 + $scope.createTermListByPreviousTermsAndHighlight = function () {
  2532 +
  2533 +
  2534 + var multiTermList = [];
  2535 + angular.forEach($rootScope.previousHighlightList, function (value, key) {
  2536 + var ActualTermNo = $scope.getActualTermNumber(value);
  2537 + if (ActualTermNo != null) {
  2538 + var TermList = $scope.getTermNumberList(ActualTermNo);
  2539 + if (TermList != null) {
  2540 + for (var i = 0; i < TermList.length; i++) {
  2541 +
  2542 + multiTermList.push(TermList[i]);
  2543 + }
  2544 + }
  2545 + }
  2546 +
  2547 + });
  2548 +
  2549 + console.log('createTermListByPreviousTermsAndHighlight is called');
  2550 +
  2551 + if ((multiTermList != undefined || multiTermList != null) && multiTermList.length > 0) {
  2552 +
  2553 + $timeout(function () { $scope.HighlightBodyByTermList(multiTermList); }, 50);
  2554 + }
  2555 + }
  2556 +
  2557 +
  2558 + $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) {
  2559 + var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
  2560 +
  2561 + pixelData.data[0] = pixelData.data[0] - 9;
  2562 + pixelData.data[1] = pixelData.data[1] - 9;
  2563 + pixelData.data[2] = pixelData.data[2] - 9;
  2564 + var Red;
  2565 + var Green;
  2566 + var Blue;
  2567 + var zero = "0";
  2568 +
  2569 + if ((pixelData.data[0]).toString().length != 2) {
  2570 + Red = zero.concat((pixelData.data[0]).toString())
  2571 + }
  2572 + else {
  2573 + Red = (pixelData.data[0]).toString()
  2574 + }
  2575 + if ((pixelData.data[1]).toString().length != 2) {
  2576 + Green = zero.concat((pixelData.data[1]).toString())
  2577 + }
  2578 + else {
  2579 + Green = (pixelData.data[1]).toString()
  2580 +
  2581 + }
  2582 + if ((pixelData.data[2]).toString().length != 2) {
  2583 + Blue = zero.concat((pixelData.data[2]).toString())
  2584 + }
  2585 + else {
  2586 + Blue = (pixelData.data[2]).toString()
  2587 +
  2588 + }
  2589 + var RGBColor = (Red + Green + Blue);
  2590 + return RGBColor;
  2591 + }
  2592 +
  2593 +
  2594 + //get annotation from term number
  2595 + $scope.GetAnnotationText = function (termNumber) {
  2596 +
  2597 + var annotationText;
  2598 + //0
  2599 + var figLeafTermNo = 5868; // to do declare constant for this
  2600 +
  2601 + if (parseInt(termNumber) != parseInt(figLeafTermNo)) {
  2602 + $scope.TermNumber = termNumber;
  2603 + if ($rootScope.TermNumberData != null || $rootScope.TermNumberData != undefined) {
  2604 + $scope.matchedTermNoData = new jinqJs()
  2605 + .from($rootScope.TermNumberData.TermData.Term)
  2606 + .where('_TermNumber == ' + termNumber)
  2607 + .select();
  2608 +
  2609 + if ($scope.matchedTermNoData != null || $scope.matchedTermNoData != undefined) {
  2610 + //1.
  2611 + var actualTermNo = 0;
  2612 + for (var z = 0; z < $scope.matchedTermNoData.length; z++) {
  2613 + //send actual term no to get the term text.
  2614 + actualTermNo = $scope.matchedTermNoData[0]._ActualTermNumber;
  2615 + annotationText = $scope.GetAnnotationBasedOnActualTermNo(actualTermNo);
  2616 + $rootScope.actualTermNumber = actualTermNo;
  2617 + break;
  2618 + };
  2619 +
  2620 + //2.
  2621 +
  2622 + }
  2623 + else {
  2624 + // send term no to vocab json data to get the text
  2625 + }
  2626 + }
  2627 + }
  2628 + return annotationText;
  2629 + }
  2630 +
  2631 + $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo) {
  2632 +
  2633 + var Annotation;
  2634 + $scope.ActualTermNo = actualTermNo;
  2635 + if ($rootScope.VocabTermData != null || $rootScope.VocabTermData != undefined) {
  2636 + $scope.matchedActualTermData = new jinqJs()
  2637 + .from($rootScope.VocabTermData.VocabTerms.Term)
  2638 + .where('_ActualTermNumber == ' + actualTermNo)
  2639 + .select();
  2640 +
  2641 + if ($scope.matchedActualTermData != null || $scope.matchedActualTermData != undefined) {
  2642 + for (var z = 0; z <= $scope.matchedActualTermData.length; z++) {
  2643 + //send actual term no to get the term text.
  2644 + Annotation = $scope.matchedActualTermData[0]._TermText;
  2645 + // alert("Annotation : " + Annotation);
  2646 + break;
  2647 + };
  2648 + }
  2649 + return Annotation;
  2650 + }
  2651 + else {
  2652 + return null;
  2653 + }
  2654 + }
  2655 +
  2656 +
  2657 + //layer change function
  2658 + $scope.LayerChange = function () {
  2659 +
  2660 +
  2661 + //if listanager is visisble then close it
  2662 + // $rootScope.isListManagerSelected = false;
  2663 +
  2664 + $rootScope.CloseListManager();
  2665 +
  2666 +
  2667 +
  2668 + $scope.isLayerChange = true;
  2669 + $rootScope.isLoading = true;
  2670 + $('#spinner').css('visibility', 'visible');
  2671 +
  2672 + //1.
  2673 + $scope.terminateCurrentlyRunningWPs();
  2674 +
  2675 + var canvasDiv = document.getElementById('canvasDiv');
  2676 + $scope.imageVerticalScrollPosition = canvasDiv.scrollTop;
  2677 + $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft;
  2678 +
  2679 + // $('#daLoaderLabel').css('visibility', 'visible');
  2680 +
  2681 +
  2682 + if ($scope.isTransparencyActivated) {
  2683 +
  2684 + //crete temp canavs to store the original data which will be used to chnange the transparency
  2685 + if (document.getElementById('tempCanvas') != null) {
  2686 + $('#tempCanvas').remove();
  2687 + }
  2688 +
  2689 + if ($('#speechBubbleTrns').length > 0) {
  2690 + $('#speechBubbleTrns').remove();
  2691 + }
  2692 + var tempCanvas = document.createElement('canvas');
  2693 + tempCanvas.id = 'tempCanvas';
  2694 + $scope.tempCanvas = tempCanvas.id;
  2695 + tempCanvas.height = $scope.transparencyCanvasHeight;
  2696 + tempCanvas.width = $scope.transparencyCanvasWidth;
  2697 + tempCanvas.style.position = "absolute";
  2698 + tempCanvas.style.left = 200 + 'px';
  2699 + tempCanvas.style.backgroundColor = "transparent";
  2700 + tempCanvas.style.visibility = 'hidden';
  2701 +
  2702 + if (document.getElementById('canvasDiv') != null)
  2703 + document.getElementById('canvasDiv').appendChild(tempCanvas);
  2704 +
  2705 +
  2706 +
  2707 + var tCanvas = document.getElementById('transparencyCanvas');
  2708 +
  2709 + var tCanvasContext = tCanvas.getContext('2d');
  2710 +
  2711 + var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
  2712 +
  2713 + var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
  2714 +
  2715 +
  2716 + // var tCanvas = document.getElementById('transparencyCanvas');
  2717 + if (tCanvas != null) {
  2718 + clearTransCanvas();
  2719 + }
  2720 + var TransparencyBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
  2721 + var TransparencyEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
  2722 + var TransparencyBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
  2723 + var TransparencyBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
  2724 + var transparencyBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tCanvasHeight);
  2725 + var transparencyBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tCanvasWidth);
  2726 +
  2727 + var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
  2728 +
  2729 + $.each(BodyRegionDictionary, function (index, value) {
  2730 + //debugger;
  2731 + // alert(' $.each(BodyRegionDictionary1')
  2732 +
  2733 + var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
  2734 + var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
  2735 +
  2736 +
  2737 + // alert(' $.each(BodyRegionDictionary3. bodyRegionRight: ' + bodyRegionRight + ', bodyRegionBottom: ' + bodyRegionBottom)
  2738 + if (TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) {
  2739 + //var transNumber = parseInt(document.getElementById("txtTransparencyChange").value);
  2740 + // debugger;
  2741 + $scope.layerNumber = parseInt(txtlayerNumber.value);
  2742 +
  2743 +
  2744 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, TransparencyBoxStartX, transparencyBoxRight, TransparencyBoxStartY, transparencyBoxBottom, $scope, true, false);
  2745 + }
  2746 +
  2747 +
  2748 + })
  2749 +
  2750 + }
  2751 +
  2752 + else {
  2753 +
  2754 +
  2755 + //1. Dated:13-07-2016 Issue #4965 : The layer number should not extend beyond its level through layer text box.
  2756 + var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
  2757 + if (parseInt($('#txtlayerNumber').val()) > (dataLength - 1)) {
  2758 + $('#txtlayerNumber').val(dataLength - 1);
  2759 + $scope.currentLayerNumber = parseInt(dataLength - 1);
  2760 + $scope.layerNumber = parseInt(dataLength - 1);
  2761 + }
  2762 + else
  2763 + $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val());
  2764 +
  2765 + //$scope.isMousUp();
  2766 +
  2767 + //alert('$scope.currentLayerNumber');
  2768 +
  2769 + $rootScope.isLoading = true;
  2770 + $('#spinner').css('visibility', 'visible');
  2771 + var canDiv = document.getElementById('canvasDiv');
  2772 + var canDivChildCount = canDiv.childElementCount;
  2773 + if (canDivChildCount > 0) {
  2774 + canDiv.innerHTML = '';
  2775 + }
  2776 +
  2777 +
  2778 +
  2779 + //2.
  2780 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  2781 +
  2782 + //3.
  2783 + $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition)
  2784 + $('#canvasDiv').scrollTop($scope.imageVerticalScrollPosition)
  2785 +
  2786 +
  2787 + if ($rootScope.isHighlightBodyByBodySystem) {
  2788 + $timeout(function () { $scope.DisableProgressBar() }, 20000);
  2789 + }
  2790 + else {
  2791 + $timeout(function () { $scope.DisableProgressBar() }, 2000);
  2792 + }
  2793 + }
  2794 +
  2795 + $('#layerChangeSlider').slider("option", "value", parseInt($rootScope.totalLayers) - parseInt($scope.layerNumber));
  2796 + }
  2797 + $rootScope.PreviouslayerNumbr = 0;
  2798 + $scope.LayerChangeOnMouseUpDown = function (e) {
  2799 + //'x' button is displaying inside the input box in IE browser.
  2800 +
  2801 + if (e.currentTarget.id == "incrmntVal") {
  2802 + //Dissectible Anatomy > Inappropriate Text in Layer Input box.
  2803 + if ($("#txtlayerNumber").val() == '') {
  2804 + var layerInputVal = 0;
  2805 +
  2806 + var layerInputValInc = parseInt(layerInputVal);
  2807 + $scope.layerNumber = parseInt(layerInputValInc);
  2808 + $("#txtlayerNumber").val($scope.layerNumber);
  2809 + // $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  2810 +
  2811 + }
  2812 + else {
  2813 + var layerInputVal = $("#txtlayerNumber").val();
  2814 + if (layerInputVal != $rootScope.totalLayers) {
  2815 + var layerInputValInc = parseInt(layerInputVal) + 1;
  2816 + $scope.layerNumber = parseInt(layerInputValInc);
  2817 + $("#txtlayerNumber").val($scope.layerNumber);
  2818 + $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  2819 + }
  2820 +
  2821 + }
  2822 +
  2823 + }
  2824 + else {
  2825 +
  2826 + //Dissectible Anatomy > Inappropriate Text in Layer Input box.
  2827 + if ($("#txtlayerNumber").val() == '') {
  2828 + var layerInputVal = 0;
  2829 + var layerInputValDec = parseInt(layerInputVal);
  2830 + $scope.layerNumber = parseInt(layerInputValDec);
  2831 + $("#txtlayerNumber").val($scope.layerNumber);
  2832 + // $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  2833 +
  2834 + }
  2835 + else {
  2836 + var layerInputVal = $("#txtlayerNumber").val();
  2837 + if (layerInputVal > 0) {
  2838 + var layerInputValDec = parseInt(layerInputVal) - 1;
  2839 + $scope.layerNumber = parseInt(layerInputValDec);
  2840 + $("#txtlayerNumber").val($scope.layerNumber);
  2841 + $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  2842 + }
  2843 + }
  2844 +
  2845 + }
  2846 + $scope.LayerChange();
  2847 + $rootScope.isLoading = false;
  2848 + $('#spinner').css('visibility', 'hidden');
  2849 + }
  2850 +
  2851 +
  2852 + $scope.DisableProgressBar = function () {
  2853 +
  2854 + // alert('Disabled wait cursor is called');
  2855 +
  2856 +
  2857 + if ($rootScope.isHighLight) {
  2858 + //alert('isHighlight: ' + $scope.isHighLight);
  2859 +
  2860 + //$('#btnHighLight').removeClass('btn btn-black');
  2861 + //$('#btnHighLight').addClass('btn-primary');
  2862 +
  2863 + $("#btnHighLight").addClass("btn-primary");
  2864 + $("#btnHighLight").removeClass("btn-black");
  2865 +
  2866 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  2867 + $("#btnNormalMode").addClass("btn-black");
  2868 + }
  2869 +
  2870 + if (!$("#btnExtract").hasClass("btn-black")) {
  2871 + $("#btnExtract").addClass("btn-black");
  2872 + }
  2873 +
  2874 + if ($("#btnExtract").hasClass("btn-primary")) {
  2875 + $("#btnExtract").removeClass("btn-primary");
  2876 + }
  2877 +
  2878 +
  2879 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  2880 + $("#btnNormalMode").removeClass("btn-primary");
  2881 + }
  2882 +
  2883 + console.log('highLightBody call from DisableProgressBar')
  2884 +
  2885 + // $scope.highLightBody();
  2886 +
  2887 +
  2888 +
  2889 + }
  2890 +
  2891 + $rootScope.isLoading = false;
  2892 + $('#spinner').css('visibility', 'hidden');
  2893 +
  2894 + //alert('Disabled wait cursor is done.See val :' + $rootScope.isLoading);
  2895 + }
  2896 +
  2897 +
  2898 + $scope.changeLayer = function () {
  2899 + //console.log('changeLayer');
  2900 + // alert('slide')
  2901 + }
  2902 +
  2903 + $('layerChangeSlider').slider().on('slideStop', function (ev) {
  2904 +
  2905 + var newVal = $('.span2').data('slider').getValue();
  2906 + if (originalVal != newVal) {
  2907 +
  2908 + }
  2909 + });
  2910 +
  2911 +
  2912 + $scope.getMousePos = function (evt) {
  2913 +
  2914 + return {
  2915 + x: Math.round(evt.pageX - $('#canvasDiv').offset().left),
  2916 + y: Math.round(evt.pageY - $('#canvasDiv').offset().top)
  2917 + }
  2918 + }
  2919 +
  2920 +
  2921 +
  2922 + $scope.createDynamicSpeechBubble = function (event, x, y, isAnnotationForTBox) {
  2923 +
  2924 + //debugger;
  2925 + if (isAnnotationForTBox == true) {
  2926 + //1. In transparency box we shows two annotation at a time, so we need to decide the max length of annotation in btween two annotation because based on that
  2927 + // we decide the size of speech bubble
  2928 + $scope.longestAnnotation = $scope.MultiLanguageAnnationArray.reduce(function (firstAnnotation, seconAnnotation) { return firstAnnotation.length > seconAnnotation.length ? firstAnnotation : seconAnnotation; });
  2929 +
  2930 + //2.
  2931 + if (event.ctrlKey) {
  2932 +
  2933 + console.log('ctrl pressed');
  2934 +
  2935 + $scope.multiAnnotationIsON = true;
  2936 +
  2937 + //2.1 create unique speech bubbles
  2938 + $scope.speechBubbleCounter = $scope.speechBubbleCounter + 1;
  2939 + var id = "speechBubble" + $scope.speechBubbleCounter;
  2940 +
  2941 + //2.2 Get clicked locationa and find if it is already clicked earlier too on same location
  2942 + var pointClicked = parseInt(x) + parseInt(y);
  2943 +
  2944 + var isClickedOnSamePoint = $("#canvasDiv").find("div[id=" + pointClicked + "]").length;
  2945 +
  2946 + console.log('isClickedOnSamePoint: ' + isClickedOnSamePoint);
  2947 +
  2948 + // if user has not clciked on smae point then create speech bubble otherwise not
  2949 + if (isClickedOnSamePoint == 0) {
  2950 + console.log('not clicked on same point')
  2951 + $scope.createSpeechBubbleBasedOnAnnotationLength(pointClicked, x, y, id);
  2952 +
  2953 + $scope.speechbubbleList.push({ xaxis: x, yaxis: y, ids: id });
  2954 +
  2955 + }
  2956 +
  2957 +
  2958 + $('.appendDragg').draggable({
  2959 + drag: function (evt) {
  2960 + $(this).prev('div').css("display", "none");
  2961 + var bor_id = $(this).next('div').attr('id');
  2962 + var sub_id1 = $(this).attr('id');
  2963 + var verticalScrollPosition = canvasDiv.scrollTop;
  2964 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  2965 +
  2966 + if ($scope.speechbubbleList != null || $scope.speechbubbleList != undefined) {
  2967 + for (var m = 0; m <= $scope.speechbubbleList.length - 1; m++) {
  2968 + if ($scope.speechbubbleList[m].ids == sub_id1) {
  2969 +
  2970 + $scope.angle1($scope.speechbubbleList[m].xaxis, $scope.speechbubbleList[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id);
  2971 + break;
  2972 +
  2973 + }
  2974 + }
  2975 + }
  2976 +
  2977 + },
  2978 + });
  2979 +
  2980 +
  2981 +
  2982 + $('.dynCross').on('click', function (evt) {
  2983 + //$(this).parent().parent().parent().css('display', 'none');
  2984 + $(this).parent().parent().parent().remove();
  2985 +
  2986 + });
  2987 +
  2988 + }
  2989 +
  2990 +
  2991 + else {
  2992 + $scope.multiAnnotationIsON = false;
  2993 +
  2994 + //$(".com").css("display", "none");
  2995 + //$("#bord").css({ "width": "0px", "display": "none" });
  2996 + $(".com").remove();
  2997 + $("#bord").remove();
  2998 +
  2999 + var sppechBubbleDotHTML = '<div id="dot" style="position:absolute;height:15px;width:35px;display:none;z-index:10000;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);"></div>'
  3000 + + '<div id="sppeachBubble" style="height:auto!important;z-index:10000;margin-left:25px;border:1px solid #000;display:none;padding:5px 10px;position:absolute;color:#fff;text-align:left;font-size:12px;background-color:#19100e;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-o-border-radius:5px;-ms-border-radius:5px;font-weight:bold;">'
  3001 + + '<span style="position:absolute;right:-3px;top:-4px;color:#ffffff;cursor:pointer;">'
  3002 + + '<img class="crossDiv_temp" style="width:18px" src=' + $rootScope.path + '></span></div>'
  3003 +
  3004 + + '<div style="position:absolute;border:1px solid #000;display:none;z-index:9000;" id="bord">'
  3005 + + '</div>';
  3006 +
  3007 + //Issue #7286 :Undefined annotation should not appear
  3008 + for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
  3009 + var MultipleLanguage = $scope.MultiLanguageAnnationArray[i];
  3010 + }
  3011 +
  3012 + if (MultipleLanguage == undefined) {
  3013 + console.log("No text is found");
  3014 + } else {
  3015 + $('#canvasDiv').append(sppechBubbleDotHTML);
  3016 +
  3017 + if ($scope.MultiLanguageAnnationArray.length > 0) {
  3018 + for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
  3019 + var MultipleLanguage = $scope.MultiLanguageAnnationArray[i];
  3020 + $("#sppeachBubble").append("<p style='margin-bottom:2px;'>" + MultipleLanguage + "</p>");
  3021 + }
  3022 + }
  3023 + else {
  3024 + console.log('MultiLanguageAnnationArray.length is :' + $scope.MultiLanguageAnnationArray.length)
  3025 + }
  3026 + if ($scope.longestAnnotation != null || $scope.longestAnnotation != undefined) {
  3027 + if ($scope.longestAnnotation.length <= 10) {
  3028 +
  3029 +
  3030 + $("#sppeachBubble").css("width", "100px");
  3031 +
  3032 + }
  3033 +
  3034 + else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) {
  3035 +
  3036 +
  3037 +
  3038 + $("#sppeachBubble").css("width", "140px");
  3039 +
  3040 + }
  3041 + else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) {
  3042 +
  3043 +
  3044 + $("#sppeachBubble").css("width", "195px");
  3045 +
  3046 + }
  3047 + else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) {
  3048 +
  3049 + $("#sppeachBubble").css("width", "248px");
  3050 +
  3051 + }
  3052 + else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) {
  3053 +
  3054 +
  3055 + $("#sppeachBubble").css("width", "300px");
  3056 + }
  3057 +
  3058 + else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) {
  3059 +
  3060 + $("#sppeachBubble").css("width", "370px");
  3061 +
  3062 + }
  3063 +
  3064 + else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) {
  3065 +
  3066 +
  3067 + $("#sppeachBubble").css("width", "450px");
  3068 +
  3069 + }
  3070 +
  3071 + else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) {
  3072 +
  3073 +
  3074 + $("#sppeachBubble").css("width", "510px");
  3075 +
  3076 + }
  3077 +
  3078 + else {
  3079 +
  3080 +
  3081 + $("#sppeachBubble").css("width", ($scope.longestAnnotation.length) + "%");
  3082 +
  3083 +
  3084 + }
  3085 +
  3086 + }
  3087 + }
  3088 + var Globe = [];
  3089 + Globe.push({ currentX: x, currentY: y });
  3090 +
  3091 + document.getElementById('dot').style.display = 'block';
  3092 + document.getElementById('dot').style.left = ((Globe[0].currentX) - 10) + 'px';
  3093 + document.getElementById('dot').style.top = ((Globe[0].currentY) + 10) + 'px';
  3094 + document.getElementById('sppeachBubble').style.display = 'block';
  3095 + document.getElementById('sppeachBubble').style.left = (Globe[0].currentX) + 'px';
  3096 + document.getElementById('sppeachBubble').style.top = (Globe[0].currentY) + 'px';
  3097 +
  3098 + $('#sppeachBubble').draggable(
  3099 + {
  3100 + drag: function (evt) {
  3101 +
  3102 + //$("#dot").css("display", "none");
  3103 + $("#dot").css("visibility", "hidden");
  3104 + var verticalScrollPosition = canvasDiv.scrollTop;
  3105 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  3106 + $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
  3107 +
  3108 +
  3109 + },
  3110 + });
  3111 +
  3112 +
  3113 + $('.crossDiv_temp').on('click', function (evt) {
  3114 + //$('#sppeachBubble').css('display', 'none');
  3115 +
  3116 + //$("#bord").css("display", "none");
  3117 + //$("#dot").css("display", "none");
  3118 + $('#sppeachBubble').remove();
  3119 +
  3120 + $("#bord").remove();
  3121 + $("#dot").remove();
  3122 +
  3123 + });
  3124 +
  3125 + }
  3126 + }
  3127 +
  3128 + else {
  3129 +
  3130 + // alert("false");
  3131 + $scope.longest_annotationT1 = $scope.annotationTextArrayT1.reduce(function (a, b) { return a.length > b.length ? a : b; });
  3132 + $scope.longest_annotationT2 = $scope.annotationTextArrayT2.reduce(function (a, b) { return a.length > b.length ? a : b; });
  3133 +
  3134 + if (event.ctrlKey) {
  3135 +
  3136 + // $scope.multiAnnotationIsON = true;
  3137 +
  3138 + $scope.j = $scope.j + 1;
  3139 +
  3140 + var sub_id_annotation = "black_annotation" + $scope.j;
  3141 + // alert(sub_id_annotation);
  3142 + var pointClicked_annotation = parseInt(x) + parseInt(y);
  3143 + var Exists_annotation = $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").length;
  3144 + // alert(Exists_annotation);
  3145 + // alert(pointClicked_annotation);
  3146 + var sppechBubbleHTML_annotation = "<div id ='" + pointClicked_annotation + "' class='com_anno'><div style='z-index:10000;position:absolute;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);height:15px;width:35px;left:" + (x - 10) + "px;top:" + (y + 10) + "px;'' id='bubble" + $scope.j + "'></div><div data=" + $scope.j + " id=" + sub_id_annotation + " class='appendDragg_annotation' style='z-index:10000;margin-left:25px;border:1px solid #000;padding:5px 10px;position:absolute;color:#fff;text-align:left;font-size: 12px;background-color:#19100e;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-o-border-radius:5px;-ms-border-radius:5px;font-weight:bold;left:" + x + "px;top:" + y + "px;'><div style='z-index:7000;position:absolute;right:-3px;top:-4px;color:#ffffff;cursor:pointer;'><img id=" + $scope.j + " class='dynCross_anno' style='width:18px' src=" + $rootScope.path + "></div></div><div style='position:absolute;border:1px solid #000;display:none;z-index:9000;' id='bord_annotation" + $scope.j + "'></div></div>";
  3147 + if ($scope.longest_annotationT1.length > $scope.longest_annotationT2.length) {
  3148 + if (Exists_annotation == 0) {
  3149 + $("#canvasDiv").append(sppechBubbleHTML_annotation);
  3150 +
  3151 + for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
  3152 + var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
  3153 + // alert(MultipleLang_annotation_T1);
  3154 + // alert(sub_id_annotation);
  3155 + $("#" + sub_id_annotation).append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T1 + "</p>");
  3156 + }
  3157 +
  3158 + $("#" + sub_id_annotation).append("<p style='border-bottom:1px solid black;margin-bottom:0;'></p>");
  3159 +
  3160 + for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
  3161 + // alert(MultipleLang_annotation_T2);
  3162 + var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
  3163 + $("#" + sub_id_annotation).append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T2 + "</p>");
  3164 + }
  3165 +
  3166 +
  3167 +
  3168 + if ($scope.longest_annotationT1.length <= 10) {
  3169 +
  3170 +
  3171 + $("#" + sub_id_annotation).css("width", "100px");
  3172 +
  3173 +
  3174 + }
  3175 +
  3176 + else if ($scope.longest_annotationT1.length > 10 && $scope.longest_annotationT1.length <= 17) {
  3177 +
  3178 +
  3179 + $("#" + sub_id_annotation).css("width", "140px");
  3180 +
  3181 +
  3182 + }
  3183 +
  3184 + else if ($scope.longest_annotationT1.length > 17 && $scope.longest_annotationT1.length <= 26) {
  3185 +
  3186 +
  3187 +
  3188 + $("#" + sub_id_annotation).css("width", "195px");
  3189 +
  3190 + }
  3191 + else if ($scope.longest_annotationT1.length > 26 && $scope.longest_annotationT1.length <= 34) {
  3192 +
  3193 +
  3194 +
  3195 + $("#" + sub_id_annotation).css("width", "248px");
  3196 + }
  3197 + else if ($scope.longest_annotationT1.length > 34 && $scope.longest_annotationT1.length <= 44) {
  3198 +
  3199 +
  3200 +
  3201 + $("#" + sub_id_annotation).css("width", "300px");
  3202 + }
  3203 +
  3204 + else if ($scope.longest_annotationT1.length > 44 && $scope.longest_annotationT1.length <= 54) {
  3205 +
  3206 +
  3207 +
  3208 + $("#" + sub_id_annotation).css("width", "370px");
  3209 + }
  3210 + else if ($scope.longest_annotationT1.length > 54 && $scope.longest_annotationT1.length <= 69) {
  3211 +
  3212 +
  3213 +
  3214 + $("#" + sub_id_annotation).css("width", "450px");
  3215 + }
  3216 + else if ($scope.longest_annotationT1.length > 69 && $scope.longest_annotationT1.length <= 75) {
  3217 +
  3218 +
  3219 + $("#" + sub_id_annotation).css("width", "510px");
  3220 +
  3221 + }
  3222 + else {
  3223 +
  3224 +
  3225 + $("#" + sub_id_annotation).css("width", ($scope.longest_annotationT1.length) + "%");
  3226 + }
  3227 + }
  3228 + else {
  3229 +
  3230 + $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").css("display", "block");
  3231 +
  3232 + }
  3233 +
  3234 + }
  3235 + else {
  3236 +
  3237 + if (Exists_annotation == 0) {
  3238 +
  3239 +
  3240 +
  3241 + $("#canvasDiv").append(sppechBubbleHTML_annotation);
  3242 +
  3243 + for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
  3244 + var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
  3245 + // alert(MultipleLang_annotation_T1);
  3246 + $("#" + sub_id_annotation).append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T1 + "</p>");
  3247 + }
  3248 +
  3249 + $("#" + sub_id_annotation).append("<p style='border-bottom:1px dotted white;margin-bottom:0;'></p>");
  3250 +
  3251 + for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
  3252 + var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
  3253 + // alert(MultipleLang_annotation_T2);
  3254 + $("#" + sub_id_annotation).append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T2 + "</p>");
  3255 + }
  3256 +
  3257 + if ($scope.longest_annotationT2.length <= 10) {
  3258 +
  3259 +
  3260 + $("#" + sub_id_annotation).css("width", "100px");
  3261 +
  3262 +
  3263 + }
  3264 +
  3265 + else if ($scope.longest_annotationT2.length > 10 && $scope.longest_annotationT2.length <= 17) {
  3266 +
  3267 +
  3268 + $("#" + sub_id_annotation).css("width", "140px");
  3269 +
  3270 +
  3271 + }
  3272 +
  3273 + else if ($scope.longest_annotationT2.length > 17 && $scope.longest_annotationT2.length <= 26) {
  3274 +
  3275 +
  3276 +
  3277 + $("#" + sub_id_annotation).css("width", "195px");
  3278 +
  3279 + }
  3280 + else if ($scope.longest_annotationT2.length > 26 && $scope.longest_annotationT2.length <= 34) {
  3281 +
  3282 +
  3283 +
  3284 + $("#" + sub_id_annotation).css("width", "248px");
  3285 + }
  3286 + else if ($scope.longest_annotationT2.length > 34 && $scope.longest_annotationT2.length <= 44) {
  3287 +
  3288 +
  3289 +
  3290 + $("#" + sub_id_annotation).css("width", "300px");
  3291 + }
  3292 +
  3293 + else if ($scope.longest_annotationT2.length > 44 && $scope.longest_annotationT2.length <= 54) {
  3294 +
  3295 +
  3296 +
  3297 + $("#" + sub_id_annotation).css("width", "370px");
  3298 + }
  3299 + else if ($scope.longest_annotationT2.length > 54 && $scope.longest_annotationT2.length <= 69) {
  3300 +
  3301 +
  3302 +
  3303 + $("#" + sub_id_annotation).css("width", "450px");
  3304 + }
  3305 + else if ($scope.longest_annotationT2.length > 69 && $scope.longest_annotationT2.length <= 75) {
  3306 +
  3307 +
  3308 + $("#" + sub_id_annotation).css("width", "510px");
  3309 +
  3310 + }
  3311 + else {
  3312 +
  3313 +
  3314 + $("#" + sub_id_annotation).css("width", ($scope.longest_annotationT2.length) + "%");
  3315 + }
  3316 + }
  3317 + else {
  3318 +
  3319 + $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").css("display", "block");
  3320 +
  3321 + }
  3322 +
  3323 + }
  3324 +
  3325 + $scope.speachBubbleArrayAnnotation.push({ xaxis: x, yaxis: y, ids: sub_id_annotation });
  3326 +
  3327 + $('.appendDragg_annotation').draggable({
  3328 + drag: function (evt) {
  3329 + $(this).prev('div').css("display", "none");
  3330 + var bor_id_anno = $(this).next('div').attr('id');
  3331 + var sub_id1_anno = $(this).attr('id');
  3332 + var verticalScrollPosition = canvasDiv.scrollTop;
  3333 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  3334 +
  3335 + if ($scope.speachBubbleArrayAnnotation != null || $scope.speachBubbleArrayAnnotation != undefined) {
  3336 + for (var m = 0; m <= $scope.speachBubbleArrayAnnotation.length - 1; m++) {
  3337 + if ($scope.speachBubbleArrayAnnotation[m].ids == sub_id1_anno) {
  3338 +
  3339 + $scope.angle1($scope.speachBubbleArrayAnnotation[m].xaxis, $scope.speachBubbleArrayAnnotation[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id_anno);
  3340 + break;
  3341 +
  3342 + }
  3343 + }
  3344 + }
  3345 +
  3346 + },
  3347 + });
  3348 +
  3349 +
  3350 +
  3351 + $('.dynCross_anno').on('click', function (evt) {
  3352 + //$(this).parent().parent().parent().css('display', 'none');
  3353 + $(this).parent().parent().parent().remove();
  3354 + // $("#bord").css("display", "none");
  3355 + // $("#dot").css("display", "none");
  3356 +
  3357 +
  3358 + });
  3359 +
  3360 +
  3361 +
  3362 + }
  3363 +
  3364 + else {
  3365 +
  3366 + $scope.multiAnnotationIsON = false;
  3367 +
  3368 + $(".com_annotation").css("display", "none");
  3369 + $("#bord_annotation").css({ "width": "0px", "display": "none" });
  3370 + $('.dynCross_anno').parent().parent().parent().remove();
  3371 + var sppechBubbleDotHTML_annotation = '<div id="dot_annotation" style="position:absolute;height:15px;width:35px;display:none;z-index:10000;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);"></div>'
  3372 + + '<div id="sppeachBubble_annotation" style="height:auto!important;z-index:10000;margin-left:25px;border:1px solid #000;display:none;padding:5px 10px;position:absolute;color:#fff;text-align:left;font-size:12px;background-color:#19100e;font-weight:bold;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-o-border-radius:5px;-ms-border-radius:5px;font-weight:bold;">'
  3373 + + '<span style="position:absolute;right:-3px;top:-4px;color:#ffffff;cursor:pointer;">'
  3374 + + '<img class="crossDiv_temp_annotation" style="width:18px" src=' + $rootScope.path + '></span></div>'
  3375 +
  3376 + + '<div style="position:absolute;border:1px solid #000;display:none;z-index:9000;" id="bord_annotation">'
  3377 + + '</div>';
  3378 +
  3379 +
  3380 +
  3381 + if ($scope.longest_annotationT1.length > $scope.longest_annotationT2.length) {
  3382 +
  3383 + $("#sppeachBubble_annotation p").remove();
  3384 + $('#canvasDiv').append(sppechBubbleDotHTML_annotation);
  3385 + for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
  3386 + var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
  3387 + $("#sppeachBubble_annotation").append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T1 + "</p>");
  3388 + }
  3389 +
  3390 + $("#sppeachBubble_annotation").append("<p style='border-bottom:1px dotted white;margin-bottom:0;'></p>");
  3391 +
  3392 + for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
  3393 + var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
  3394 + $("#sppeachBubble_annotation").append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T2 + "</p>");
  3395 + }
  3396 +
  3397 + if ($scope.longest_annotationT1.length <= 10) {
  3398 +
  3399 +
  3400 + $("#sppeachBubble_annotation").css("width", "100px");
  3401 +
  3402 +
  3403 + }
  3404 +
  3405 + else if ($scope.longest_annotationT1.length > 10 && $scope.longest_annotationT1.length <= 17) {
  3406 +
  3407 +
  3408 + $("#sppeachBubble_annotation").css("width", "140px");
  3409 +
  3410 +
  3411 + }
  3412 +
  3413 + else if ($scope.longest_annotationT1.length > 17 && $scope.longest_annotationT1.length <= 26) {
  3414 +
  3415 +
  3416 +
  3417 + $("#sppeachBubble_annotation").css("width", "195px");
  3418 +
  3419 + }
  3420 + else if ($scope.longest_annotationT1.length > 26 && $scope.longest_annotationT1.length <= 34) {
  3421 +
  3422 +
  3423 +
  3424 + $("#sppeachBubble_annotation").css("width", "248px");
  3425 + }
  3426 + else if ($scope.longest_annotationT1.length > 34 && $scope.longest_annotationT1.length <= 44) {
  3427 +
  3428 +
  3429 +
  3430 + $("#sppeachBubble_annotation").css("width", "300px");
  3431 + }
  3432 +
  3433 + else if ($scope.longest_annotationT1.length > 44 && $scope.longest_annotationT1.length <= 54) {
  3434 +
  3435 +
  3436 +
  3437 + $("#sppeachBubble_annotation").css("width", "370px");
  3438 + }
  3439 + else if ($scope.longest_annotationT1.length > 54 && $scope.longest_annotationT1.length <= 69) {
  3440 +
  3441 +
  3442 +
  3443 + $("#sppeachBubble_annotation").css("width", "450px");
  3444 + }
  3445 + else if ($scope.longest_annotationT1.length > 69 && $scope.longest_annotationT1.length <= 75) {
  3446 +
  3447 +
  3448 + $("#sppeachBubble_annotation").css("width", "510px");
  3449 +
  3450 + }
  3451 + else {
  3452 +
  3453 +
  3454 + $("#sppeachBubble_annotation").css("width", ($scope.longest_annotationT1.length) + "%");
  3455 + }
  3456 + }
  3457 +
  3458 +
  3459 + else {
  3460 + $("#sppeachBubble_annotation p").remove();
  3461 + $('#canvasDiv').append(sppechBubbleDotHTML_annotation);
  3462 + for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
  3463 + var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
  3464 + $("#sppeachBubble_annotation").append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T1 + "</p>");
  3465 + }
  3466 +
  3467 + $("#sppeachBubble_annotation").append("<p style='border-bottom:1px dotted white;margin-bottom:0;'></p>");
  3468 +
  3469 + for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
  3470 + var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
  3471 + $("#sppeachBubble_annotation").append("<p style='margin-bottom:2px;'>" + MultipleLang_annotation_T2 + "</p>");
  3472 + }
  3473 +
  3474 + if ($scope.longest_annotationT2.length <= 10) {
  3475 +
  3476 +
  3477 + $("#sppeachBubble_annotation").css("width", "100px");
  3478 +
  3479 +
  3480 + }
  3481 +
  3482 + else if ($scope.longest_annotationT2.length > 10 && $scope.longest_annotationT2.length <= 17) {
  3483 +
  3484 +
  3485 + $("#sppeachBubble_annotation").css("width", "140px");
  3486 +
  3487 +
  3488 + }
  3489 +
  3490 + else if ($scope.longest_annotationT2.length > 17 && $scope.longest_annotationT2.length <= 26) {
  3491 +
  3492 +
  3493 +
  3494 + $("#sppeachBubble_annotation").css("width", "195px");
  3495 +
  3496 + }
  3497 + else if ($scope.longest_annotationT2.length > 26 && $scope.longest_annotationT2.length <= 34) {
  3498 +
  3499 +
  3500 +
  3501 + $("#sppeachBubble_annotation").css("width", "248px");
  3502 + }
  3503 + else if ($scope.longest_annotationT2.length > 34 && $scope.longest_annotationT2.length <= 44) {
  3504 +
  3505 +
  3506 +
  3507 + $("#sppeachBubble_annotation").css("width", "300px");
  3508 + }
  3509 +
  3510 + else if ($scope.longest_annotationT2.length > 44 && $scope.longest_annotationT2.length <= 54) {
  3511 +
  3512 +
  3513 +
  3514 + $("#sppeachBubble_annotation").css("width", "370px");
  3515 + }
  3516 + else if ($scope.longest_annotationT2.length > 54 && $scope.longest_annotationT2.length <= 69) {
  3517 +
  3518 +
  3519 +
  3520 + $("#sppeachBubble_annotation").css("width", "450px");
  3521 + }
  3522 + else if ($scope.longest_annotationT2.length > 69 && $scope.longest_annotationT2.length <= 75) {
  3523 +
  3524 +
  3525 + $("#sppeachBubble_annotation").css("width", "510px");
  3526 +
  3527 + }
  3528 + else {
  3529 +
  3530 +
  3531 + $("#sppeachBubble_annotation").css("width", ($scope.longest_annotationT2.length) + "%");
  3532 + }
  3533 + var Globe = [];
  3534 + Globe.push({ currentX: x, currentY: y });
  3535 +
  3536 + document.getElementById('dot_annotation').style.display = 'block';
  3537 + document.getElementById('dot_annotation').style.left = ((Globe[0].currentX) - 10) + 'px';
  3538 + document.getElementById('dot_annotation').style.top = ((Globe[0].currentY) + 10) + 'px';
  3539 + document.getElementById('sppeachBubble_annotation').style.display = 'block';
  3540 + document.getElementById('sppeachBubble_annotation').style.left = (Globe[0].currentX) + 'px';
  3541 + document.getElementById('sppeachBubble_annotation').style.top = (Globe[0].currentY) + 'px';
  3542 +
  3543 + $('#sppeachBubble_annotation').draggable(
  3544 + {
  3545 + drag: function (evt) {
  3546 +
  3547 + //$("#dot_annotation").css("display", "none");
  3548 + $("#dot_annotation").remove();
  3549 +
  3550 + var verticalScrollPosition = canvasDiv.scrollTop;
  3551 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  3552 + $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  3553 +
  3554 +
  3555 + },
  3556 + });
  3557 +
  3558 +
  3559 + $('.crossDiv_temp_annotation').on('click', function (evt) {
  3560 + //$('#sppeachBubble_annotation').css('display', 'none');
  3561 +
  3562 + //$("#bord_annotation").css("display", "none");
  3563 + //$("#dot_annotation").css("display", "none");
  3564 +
  3565 +
  3566 + $('#sppeachBubble_annotation').remove();
  3567 +
  3568 + $("#bord_annotation").remove();
  3569 + $("#dot_annotation").remove();
  3570 +
  3571 + });
  3572 + }
  3573 +
  3574 +
  3575 +
  3576 + }
  3577 +
  3578 +
  3579 + }
  3580 +
  3581 + }
  3582 +
  3583 + $scope.createSpeechBubbleBasedOnAnnotationLength = function (pointClicked, x, y, id) {
  3584 + var sppechBubbleHTML = "<div id ='" + pointClicked + "' class='com'><div style='z-index:10000;position:absolute;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);height:15px;width:35px;left:" + (x - 10) + "px;top:" + (y + 10) + "px;'' id='bubble" + $scope.speechBubbleCounter + "'></div><div data=" + $scope.speechBubbleCounter + " id=" + id + " class='appendDragg' style='z-index:10000;margin-left:25px;border:1px solid #000;padding:5px 10px;position:absolute;color:#fff;text-align:left;font-size: 12px;font-weight:bold;background-color:#19100e;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-o-border-radius:5px;-ms-border-radius:5px;font-weight:bold;left:" + x + "px;top:" + y + "px;'><div style='z-index:7000;position:absolute;right:-3px;top:-4px;color:#ffffff;cursor:pointer;'><img id=" + $scope.speechBubbleCounter + " class='dynCross' style='width:18px' src=" + $rootScope.path + "></div></div><div style='position:absolute;border:1px solid #000;display:none;z-index:9000;' id='bord" + $scope.speechBubbleCounter + "'></div></div>";
  3585 + //Issue #7286 :Undefined annotation should not appear
  3586 + for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
  3587 + var annotation = $scope.MultiLanguageAnnationArray[i];
  3588 + }
  3589 +
  3590 + if (annotation == undefined) {
  3591 + console.log("No text found");
  3592 + } else {
  3593 +
  3594 + $("#canvasDiv").append(sppechBubbleHTML);
  3595 +
  3596 + for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
  3597 + var annotation = $scope.MultiLanguageAnnationArray[i];
  3598 +
  3599 + $("#" + id).append("<p style='margin-bottom:2px;'>" + annotation + "</p>");
  3600 + }
  3601 +
  3602 + if ($scope.longestAnnotation.length <= 10) {
  3603 + $("#" + id).css("width", "100px");
  3604 + }
  3605 +
  3606 + else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) {
  3607 + $("#" + id).css("width", "140px");
  3608 + }
  3609 + else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) {
  3610 + $("#" + id).css("width", "195px");
  3611 +
  3612 + }
  3613 + else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) {
  3614 + $("#" + id).css("width", "248px");
  3615 + }
  3616 + else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) {
  3617 + $("#" + id).css("width", "300px");
  3618 + }
  3619 +
  3620 + else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) {
  3621 + $("#" + id).css("width", "370px");
  3622 + }
  3623 + else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) {
  3624 + $("#" + id).css("width", "450px");
  3625 + }
  3626 + else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) {
  3627 + $("#" + id).css("width", "510px");
  3628 +
  3629 + }
  3630 + else {
  3631 + $("#" + id).css("width", ($scope.longestAnnotation.length) + "%");
  3632 + }
  3633 + }
  3634 + }
  3635 +
  3636 + $scope.angle1 = function (cx1, cy1, ex1, ey1, id, id2) {
  3637 +
  3638 + // console.log(cx1 + " " + cy1);
  3639 + var dy = ey1 - cy1;
  3640 + var dx = ex1 - cx1;
  3641 + var theta = 0;
  3642 + if (dx < 0) {
  3643 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3644 + theta = theta + 180;
  3645 +
  3646 + }
  3647 + else if (dy < 0) {
  3648 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3649 + theta = theta + 360;
  3650 +
  3651 + }
  3652 + else {
  3653 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3654 + }
  3655 +
  3656 + var g = Math.sqrt((cx1 - ex1) * (cx1 - ex1) + (cy1 - ey1) * (cy1 - ey1));
  3657 + var e = cy1;
  3658 + var f = cx1;
  3659 +
  3660 + $('#' + id).css({ 'display': 'block', 'width': g + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
  3661 +
  3662 + }
  3663 +
  3664 + function myFunction(crossId) {
  3665 + // alert(crossId);
  3666 + $('#' + crossId).parent().parent().parent().css("display", "none");
  3667 +
  3668 + }
  3669 +
  3670 +
  3671 + $scope.angle = function (cx, cy, ex, ey, BoolValues) {
  3672 +
  3673 +
  3674 + var dy = ey - cy;
  3675 + var dx = ex - cx;
  3676 + var theta = 0;
  3677 + if (dx < 0) {
  3678 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3679 + theta = theta + 180;
  3680 +
  3681 + }
  3682 + else if (dy < 0) {
  3683 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3684 + theta = theta + 360;
  3685 +
  3686 + }
  3687 + else {
  3688 + theta = Math.atan(dy / dx) * (180 / Math.PI);
  3689 + }
  3690 +
  3691 + var d = Math.sqrt((cx - ex) * (cx - ex) + (cy - ey) * (cy - ey));
  3692 + var e = cy;
  3693 + var f = cx;
  3694 +
  3695 + if (BoolValues == true) {
  3696 + $("#bord").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
  3697 +
  3698 + }
  3699 + else {
  3700 + $("#bord_annotation").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
  3701 + }
  3702 +
  3703 +
  3704 +
  3705 + }
  3706 +
  3707 +
  3708 + $scope.createSpeechBubble = function (event, text, x, y) {
  3709 + //set z index to make annoation speech buble on top others
  3710 + $('#canvasDiv').css('cursor', 'pointer');
  3711 + $('<div id="speechBubble" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px; z-index:700"> <div class="">'
  3712 + + '<div class="Bubble">'
  3713 + + '<div class="BubbleCloseBtn"></div><div class="BubbleContent">' + text + '</div><div class="bottomLeftArrow"></div>'
  3714 + //+'<div class="bottomRightArrow"></div><div class="topLeftArrow"></div><div class="topRightArrow"></div>
  3715 + + '</div></div></div>').appendTo('#canvasDiv');
  3716 +
  3717 + $('#speechBubble').on('click', '.BubbleCloseBtn', function (evt) {
  3718 + $('#speechBubble').css('display', 'none');
  3719 + });
  3720 +
  3721 + $('#canvasDiv').attr("data-bubbleid", "speechBubble")
  3722 +
  3723 +
  3724 + };
  3725 +
  3726 +
  3727 + $scope.createTransparencyBox = function () {
  3728 +
  3729 +
  3730 + $scope.isTransparencyBtnClicked = true;
  3731 +
  3732 + //do not create TBOX if in extarct mode otherwise create
  3733 + if ($rootScope.isExtract == false) {
  3734 +
  3735 + $("#btnExtract").addClass("disabled");
  3736 +
  3737 + //if listanager is visisble then close it
  3738 + $rootScope.isListManagerSelected = false;
  3739 + $rootScope.CloseListManager();
  3740 +
  3741 +
  3742 +
  3743 + // alert('transparencyClicked' + $scope.isTransparencyActivated)
  3744 + $('#btnTranparency').addClass('tButtonActive');
  3745 + $('#btnIdentity').removeClass(' btn-primary');
  3746 + $('#btnIdentity').addClass('btn-black');
  3747 +
  3748 + var canvasDiv = document.getElementById('canvasDiv');
  3749 + $scope.verticalScrollPosition = canvasDiv.scrollTop;
  3750 + $scope.horizontlScrollPosition = canvasDiv.scrollLeft;
  3751 +
  3752 + var canvasDiv = document.getElementById('canvasDiv');
  3753 + canvasDiv.addEventListener("mousedown", mouseDownListener);
  3754 +
  3755 + canvasDiv.addEventListener("mousemove", mouseMoveListener);
  3756 +
  3757 + canvasDiv.addEventListener("mouseup", mouseUpListener)
  3758 +
  3759 + }
  3760 + else {
  3761 +
  3762 + // console.log("extract button is active");
  3763 +
  3764 + }
  3765 + }
  3766 +
  3767 + function mouseDownListener(e) {
  3768 + //Dated:18-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
  3769 + var tCanvas = document.getElementById('transparencyCanvas');
  3770 + if ($('#transparencyScale').css("visibility") == 'visible') {
  3771 + $('#transparencyScale').css('visibility', 'hidden');
  3772 + $('#transparencyCanvas').remove();
  3773 + }
  3774 + var $container = document.getElementById('canvasDiv');
  3775 + var $selection = $('<div>').addClass('rectangle');
  3776 + document.getElementById("DAView")
  3777 + $selection.css({
  3778 + 'position': 'absolute',
  3779 + //'background': 'transparent',
  3780 + 'border': '1px dotted #000'
  3781 + });
  3782 +
  3783 + var currentMousePosition = $scope.getMousePos(e);
  3784 +
  3785 + $scope.TBDrawStartX = currentMousePosition.x;
  3786 + $scope.TBDrawStartY = currentMousePosition.y;
  3787 +
  3788 +
  3789 + var actulalX = currentMousePosition.x + $scope.horizontlScrollPosition
  3790 + var actualY = currentMousePosition.y + $scope.verticalScrollPosition
  3791 +
  3792 + //alert('$scope.TransparencyBoxStartX in mouseDown: ' + $scope.TransparencyBoxStartX + ' & Y= ' + $scope.TransparencyBoxStartY);
  3793 + $scope.TransparencyBoxStartX = actulalX;
  3794 + $scope.TransparencyBoxStartY = actualY
  3795 + $scope.startX = actulalX;
  3796 + $scope.startY = actualY;
  3797 + var tBox = document.getElementById('transparencyCanvas');
  3798 +
  3799 + if (tBox == null) {
  3800 + //// canvasDiv.style.cursor = "crosshair";
  3801 + $selection.css({
  3802 + 'top': actualY,
  3803 + 'left': actulalX,
  3804 + 'width': 0,
  3805 + 'height': 0,
  3806 + 'z-index': 1000
  3807 + //'background': 'transparent',
  3808 + });
  3809 + $selection.appendTo($container);
  3810 + }
  3811 +
  3812 + document.getElementById('canvasDiv').removeEventListener("mousedown", mouseDownListener);
  3813 + //Dated:19-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
  3814 + if ($("#txtlayerNumber").val() != 0) {
  3815 + $('#layerChangeSlider').slider("option", "value", parseInt($rootScope.totalLayers) - parseInt($scope.currentLayerNumber));
  3816 + $("#txtlayerNumber").val(parseInt($scope.currentLayerNumber));
  3817 + }
  3818 + }
  3819 +
  3820 + function mouseMoveListener(e) {
  3821 +
  3822 + var currentMousePosition = $scope.getMousePos(e);
  3823 + var move_x = currentMousePosition.x + $scope.horizontlScrollPosition,
  3824 + move_y = currentMousePosition.y + $scope.verticalScrollPosition,
  3825 +
  3826 + width = move_x - $scope.TransparencyBoxStartX,
  3827 + height = move_y - $scope.TransparencyBoxStartY,
  3828 + new_x, new_y;
  3829 +
  3830 + new_x = (move_x < $scope.TransparencyBoxStartX) ? ($scope.TransparencyBoxStartX - width) : $scope.TransparencyBoxStartX;
  3831 + new_y = (move_y < $scope.TransparencyBoxStartY) ? ($scope.TransparencyBoxStartY - height) : $scope.TransparencyBoxStartY;
  3832 +
  3833 + $('.rectangle').css({
  3834 + 'width': width,
  3835 + 'height': height,
  3836 + //'background': 'transparent'
  3837 +
  3838 + });
  3839 +
  3840 +
  3841 +
  3842 + }
  3843 +
  3844 +
  3845 + function mouseUpListener(e) {
  3846 + // $selection.remove();
  3847 + // debugger;
  3848 +
  3849 + //alert('mouse up');
  3850 + console.log('MOUSE UP');
  3851 + $(".com").remove();
  3852 + $('#dot').remove();
  3853 + $('#bord').remove();
  3854 + $('#sppeachBubble').remove();
  3855 +
  3856 + $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val());
  3857 + $('.rectangle').remove();
  3858 +
  3859 + var currentMousePosition = $scope.getMousePos(e);
  3860 +
  3861 +
  3862 + var canvasDiv = document.getElementById('canvasDiv');
  3863 + var verticalScrollPosition = canvasDiv.scrollTop;
  3864 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  3865 +
  3866 + var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition
  3867 + var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition
  3868 +
  3869 +
  3870 + $scope.isTboxDrwan = true;
  3871 + $scope.TbEndX = TransparencyEndX;
  3872 + $scope.TbEndY = TransparencyBoxEndY;
  3873 + $scope.TransparencyEndX = TransparencyEndX;
  3874 + $scope.TransparencyBoxEndY = TransparencyBoxEndY;
  3875 +
  3876 + $scope.layerNumberBeforeTrans = parseInt($('#txtlayerNumber').val());
  3877 +
  3878 + //draw temp box to store the canvas data with original transparecy
  3879 + if (document.getElementById('tempCanvas') != null) {
  3880 + $('#tempCanvas').remove();
  3881 + }
  3882 + if (document.getElementById('tempCanvas') == null || document.getElementById('tempCanvas') == undefined) {
  3883 + var tempCanvas = document.createElement('canvas');
  3884 + tempCanvas.id = 'tempCanvas';
  3885 + // $scope.tempCanvas = transparencyCanvas.id;
  3886 + tempCanvas.height = TransparencyBoxEndY - $scope.startY;
  3887 + tempCanvas.width = TransparencyEndX - $scope.startX;
  3888 + tempCanvas.style.position = "absolute";
  3889 + tempCanvas.style.left = 200 + 'px';
  3890 + tempCanvas.style.top = 200 + 'px';
  3891 + tempCanvas.style.backgroundColor = "transparent";
  3892 + tempCanvas.style.visibility = 'hidden';
  3893 + tempCanvas.style.border = "black 1px solid";
  3894 + document.getElementById('canvasDiv').appendChild(tempCanvas);
  3895 + }
  3896 +
  3897 +
  3898 + $scope.isTransparencyActivated = true;
  3899 +
  3900 + var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
  3901 +
  3902 + $scope.IncludedBodyRegions = [];
  3903 + ////debugger;
  3904 + $.each(BodyRegionDictionary, function (index, value) {
  3905 + // alert(' $.each(BodyRegionDictionary1')
  3906 + var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);
  3907 + var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);
  3908 + var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);
  3909 + var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);
  3910 + // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)
  3911 + var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
  3912 + var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
  3913 +
  3914 +
  3915 +
  3916 + var transparencyCanvas = document.createElement('canvas');
  3917 + var tBox = document.getElementById('transparencyCanvas');
  3918 + if (tBox == null) {
  3919 +
  3920 + transparencyCanvas.id = 'transparencyCanvas';
  3921 + $scope.transparencyCanvasId = transparencyCanvas.id;
  3922 + transparencyCanvas.height = TransparencyBoxEndY - $scope.startY;
  3923 + transparencyCanvas.width = TransparencyEndX - $scope.startX;
  3924 + transparencyCanvas.style.position = "absolute";
  3925 + transparencyCanvas.style.left = $scope.startX + 'px' // x + "px";
  3926 + transparencyCanvas.style.top = $scope.startY + "px"//y + "px";
  3927 + transparencyCanvas.style.border = "black 1px solid";
  3928 + transparencyCanvas.style.backgroundColor = "transparent";
  3929 + transparencyCanvas.style.zIndex = 200;
  3930 + // transparencyCanvas.style.visibility = 'hidden';
  3931 + document.getElementById('canvasDiv').appendChild(transparencyCanvas);
  3932 + $scope.transparencyChangeCounter = 0;
  3933 +
  3934 + $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } });
  3935 +
  3936 + $scope.transparencyCanvasHeight = transparencyCanvas.height;
  3937 + $scope.transparencyCanvasWidth = transparencyCanvas.width;
  3938 +
  3939 + //bind click listener
  3940 + transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener);
  3941 +
  3942 + $(".ui-wrapper").css("z-index", "600");
  3943 +
  3944 + }
  3945 + if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) {
  3946 +
  3947 +
  3948 + if (($rootScope.voId == "9" || $rootScope.voId == "11")) {
  3949 + if (value.bodyRegionId == "6") {
  3950 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
  3951 + }
  3952 + else {
  3953 +
  3954 + }
  3955 + }
  3956 + else {
  3957 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
  3958 +
  3959 + }
  3960 + }
  3961 + })
  3962 +
  3963 + //for modesty
  3964 + if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
  3965 + $.each($scope.modestyImageInfo, function (index, value) {
  3966 + // alert(' $.each(BodyRegionDictionary1')
  3967 + var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);
  3968 + var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);
  3969 + var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);
  3970 + var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);
  3971 + // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)
  3972 + var bodyRegionRight = parseInt(value.x) + parseInt(value.Width);
  3973 + var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height);
  3974 +
  3975 + if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) {
  3976 +
  3977 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.x, value.y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
  3978 +
  3979 + }
  3980 + })
  3981 + }
  3982 +
  3983 +
  3984 + //
  3985 +
  3986 + // $('#transparencyScale').modal('show');
  3987 + $('#transparencyScale').css('position', 'fixed')
  3988 + $('#transparencyScale').css('top', $scope.TBDrawStartY - 10)
  3989 + $('#transparencyScale').css('left', $scope.TBDrawStartX + 130)
  3990 + $('#transparencyScale').css('visibility', 'visible')
  3991 + $('#transparencyScale').css("z-index", "100000") //Dated:16-07-2016 Issue#4962:Transparency box should be on top.
  3992 +
  3993 +
  3994 +
  3995 + document.getElementById('canvasDiv').removeEventListener("mousedown", mouseDownListener);
  3996 + document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener);
  3997 +
  3998 + document.getElementById('canvasDiv').removeEventListener("mouseup", mouseUpListener);
  3999 + // document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener);
  4000 + $('#btnTranparency').removeClass('btn-black');
  4001 +
  4002 + $('#btnTranparency').addClass('tButtonActive');
  4003 + //debugger;
  4004 + // $('#txtlayerNumber').val((parseInt($scope.currentLayerNumber)) + 1);
  4005 + //Dated:18-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
  4006 + $('#btnTranparency').removeClass('tButtonActive');
  4007 + $('#btnTranparency').addClass('btn-black');
  4008 + $('#btnIdentity').removeClass('btn-black');
  4009 + $('#btnIdentity').addClass('btn-primary');
  4010 + }
  4011 +
  4012 + $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) {
  4013 + // debugger;
  4014 +
  4015 + // else {
  4016 +
  4017 + var scope1 = angular.element(document.getElementById("DAView")).scope();
  4018 + var transparencyCanvas = document.getElementById('transparencyCanvas');
  4019 +
  4020 + TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', ''));
  4021 + TransparencyBoxStartY = parseInt((transparencyCanvas.style.top).replace('px', ''));
  4022 + TransparencyEndX = parseInt(transparencyCanvas.width) + parseInt(TransparencyBoxStartX);
  4023 + TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY);
  4024 +
  4025 +
  4026 + var XforCopyImage = 0;
  4027 + var YforCopyImage = 0;
  4028 + var WidthforCopyImage = 0;
  4029 + var HeightforCopyImage = 0;
  4030 + var XforTransImage = 0;
  4031 + var WidthforTransImage = 0;
  4032 + var HeightforTransImage = 0;
  4033 + var YforTransImage = 0;
  4034 + var PreviousBodyRegionHeight = 0;
  4035 + var PreviousBodyRegionY;
  4036 + var PreviousBodyRegionWidth;
  4037 + var PreviousBodyRegionX;
  4038 + var previousBodyRegionId;
  4039 + var transparencyTempCanvas;
  4040 +
  4041 +
  4042 +
  4043 + //X ends outside and start outside of bodyregion
  4044 + if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
  4045 + XforCopyImage = 0;
  4046 + WidthforCopyImage = Width;
  4047 + WidthforTransImage = Width;
  4048 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4049 + XforTransImage = 0;
  4050 + }
  4051 + else
  4052 + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
  4053 + // alert('1')
  4054 + }
  4055 + else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
  4056 +
  4057 + XforCopyImage = 0;
  4058 +
  4059 + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X);
  4060 +
  4061 + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X);
  4062 +
  4063 + // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage)
  4064 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4065 + XforTransImage = 0;
  4066 + }
  4067 + else
  4068 + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
  4069 +
  4070 + // alert('2')
  4071 + }
  4072 + else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
  4073 + // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX)
  4074 +
  4075 + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4076 + WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
  4077 + WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
  4078 +
  4079 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4080 +
  4081 + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4082 + }
  4083 + else
  4084 + XforTransImage = 0;
  4085 + // alert('3')
  4086 + }
  4087 + else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
  4088 + // alert('startX inside & endX inside')
  4089 + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ;
  4090 + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4091 + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4092 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4093 +
  4094 + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4095 + }
  4096 + else
  4097 + XforTransImage = 0;
  4098 + // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage)
  4099 + }
  4100 +
  4101 + //calculate Y and height for tempTranparency box from where to cut the image
  4102 +
  4103 +
  4104 + if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
  4105 +
  4106 + // alert('start Y outside and end Y outside');
  4107 +
  4108 + YforCopyImage = 0;
  4109 + HeightforCopyImage = Height;
  4110 +
  4111 + HeightforTransImage = Height;
  4112 + //alert('Y ' + Y)
  4113 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4114 + YforTransImage = 0;
  4115 + }
  4116 + else
  4117 + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4);
  4118 + // alert('5')
  4119 + }
  4120 + else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) {
  4121 +
  4122 + YforCopyImage = 0;
  4123 + HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY));
  4124 +
  4125 + HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY));
  4126 +
  4127 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4128 + YforTransImage = 0;
  4129 + }
  4130 + else
  4131 + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4);
  4132 +
  4133 + }
  4134 + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
  4135 +
  4136 + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4137 + HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
  4138 + HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
  4139 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4140 + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4141 +
  4142 + }
  4143 + else
  4144 + YforTransImage = 0;
  4145 +
  4146 + }
  4147 + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) {
  4148 +
  4149 + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4150 + HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4151 + HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4152 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4153 + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4154 +
  4155 + }
  4156 + else
  4157 + YforTransImage = 0;
  4158 + }
  4159 +
  4160 +
  4161 + //0. get current layer number
  4162 + if ($scope.isResized) {
  4163 + //do nothing
  4164 + }
  4165 + else if (isLayerChanged) {
  4166 +
  4167 +
  4168 + }
  4169 + else {
  4170 +
  4171 +
  4172 + var tranparencyLayer;
  4173 +
  4174 + var currentLayer = $scope.layerNumberBeforeTrans;
  4175 +
  4176 + if (currentLayer == $rootScope.totalLayers) {
  4177 +
  4178 + tranparencyLayer = currentLayer;
  4179 +
  4180 + }
  4181 +
  4182 + else {
  4183 +
  4184 + tranparencyLayer = currentLayer + 1;
  4185 +
  4186 + }
  4187 +
  4188 + $scope.layerNumber = tranparencyLayer;
  4189 +
  4190 + }
  4191 +
  4192 + $('#txtlayerNumber').val($scope.layerNumber);
  4193 +
  4194 + //dedebugger;
  4195 + var tranparencyImgSrc;
  4196 + var tranparencyMaskImgSrc;
  4197 + //for modesty image
  4198 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))// == "2" || bodyRegionId == "3")) {
  4199 + {
  4200 + var modestyBodyRegionData = new jinqJs()
  4201 + .from($scope.modestyImageInfo)
  4202 + .where('bodyRegionId == ' + bodyRegionId)
  4203 + .select();
  4204 + tranparencyImgSrc = modestyBodyRegionData[0].SRC;
  4205 + }
  4206 +
  4207 + //modesty end
  4208 +
  4209 + //1. get the image source
  4210 +
  4211 + else {
  4212 + tranparencyImgSrc = $scope.GetImageSource(bodyRegionId);
  4213 + tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
  4214 + }
  4215 + // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
  4216 + // debugger;
  4217 + var oldCanvas;
  4218 +
  4219 + if (IsMirror == 'Yes') {
  4220 + oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId)
  4221 + }
  4222 + else {
  4223 +
  4224 + oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)
  4225 +
  4226 + }
  4227 +
  4228 + if (oldCanvas != null) {
  4229 + document.getElementById('canvasDiv').removeChild(oldCanvas);
  4230 + }
  4231 +
  4232 + //remove tempmask canvas
  4233 + var oldtempTransCanvasMask;
  4234 + var oldtempTransCanvasMaskMR;
  4235 + if (IsMirror == 'Yes') {
  4236 + oldtempTransCanvasMaskMR = document.getElementById('transparencyTempCanvasMask_MR' + bodyRegionId + '_mci');
  4237 + oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
  4238 +
  4239 + if (oldtempTransCanvasMaskMR != null) {
  4240 + document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMaskMR);
  4241 + }
  4242 + }
  4243 + else {
  4244 + oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
  4245 +
  4246 + }
  4247 + if (oldtempTransCanvasMask != null) {
  4248 + document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask);
  4249 + }
  4250 +
  4251 + transparencyTempCanvas = document.createElement('canvas');
  4252 + var transparencyTempcanavsMask = document.createElement('canvas');
  4253 + //if mirror then draw mask image for non mirrored body region for annotation
  4254 + if (IsMirror == 'Yes') {
  4255 + transparencyTempCanvas.id = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4256 + transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_MR' + bodyRegionId + '_mci';
  4257 + }
  4258 + else {
  4259 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4260 + transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId;
  4261 + // transparencyTempCanvas.style.visibility = 'visible';
  4262 + //transparencyTempCanvas.style.zIndex = '1000'
  4263 + }
  4264 + else {
  4265 + transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId;
  4266 + transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + bodyRegionId + '_mci';
  4267 + }
  4268 +
  4269 + }
  4270 + transparencyTempCanvas.height = Height;
  4271 + transparencyTempCanvas.width = Width;
  4272 + transparencyTempCanvas.style.position = "absolute";
  4273 + transparencyTempCanvas.style.left = X + 'px' // x + "px";
  4274 + transparencyTempCanvas.style.top = Y + "px"//y + "px";
  4275 + //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4276 + // transparencyTempCanvas.style.visibility = 'visible';
  4277 + //}
  4278 + //else {
  4279 + transparencyTempCanvas.style.visibility = 'hidden';
  4280 + // }
  4281 + //transparencyTempCanvas.style.visibility = 'visible';
  4282 + // transparencyCanvas.style.zIndex = 4000;
  4283 + document.getElementById('canvasDiv').appendChild(transparencyTempCanvas);
  4284 +
  4285 + //create temp mask canvas
  4286 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { }
  4287 + else {
  4288 + transparencyTempcanavsMask.height = Height;
  4289 + transparencyTempcanavsMask.width = Width;
  4290 + transparencyTempcanavsMask.style.position = "absolute";
  4291 + transparencyTempcanavsMask.style.left = X + 'px' // x + "px";
  4292 + transparencyTempcanavsMask.style.top = Y + "px"//y + "px";
  4293 + transparencyTempcanavsMask.style.visibility = 'hidden';
  4294 + //transparencyTempCanvas.style.visibility = 'visible';
  4295 + // transparencyCanvas.style.border = "black 1px solid";
  4296 + document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
  4297 + }
  4298 +
  4299 + //for modesty canvas
  4300 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4301 +
  4302 + var modestyTransTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
  4303 + var modestyTransCanvasId = 'modestyTransCanavs_' + bodyRegionId;
  4304 + if (document.getElementById(modestyTransTempCanvasId) != null) {
  4305 + document.getElementById(modestyTransTempCanvasId).parentNode.removeChild(document.getElementById(modestyTransTempCanvasId));
  4306 + }
  4307 +
  4308 + if (document.getElementById(modestyTransTempCanvasId) == null || document.getElementById(modestyTransTempCanvasId) == undefined) {
  4309 + var tempCanvasModesty = document.createElement('canvas');
  4310 + tempCanvasModesty.id = modestyTransTempCanvasId;
  4311 + // $scope.tempCanvas = transparencyCanvas.id;
  4312 + tempCanvasModesty.height = Height;
  4313 + tempCanvasModesty.width = Width;
  4314 + tempCanvasModesty.style.position = "absolute";
  4315 + tempCanvasModesty.style.left = 10 + 'px';
  4316 + tempCanvasModesty.style.top = 10 + 'px';
  4317 + tempCanvasModesty.style.backgroundColor = "transparent";
  4318 + tempCanvasModesty.style.visibility = 'hidden';
  4319 + tempCanvasModesty.style.border = "black 1px solid";
  4320 + document.getElementById('canvasDiv').appendChild(tempCanvasModesty);
  4321 + }
  4322 + if (document.getElementById(modestyTransCanvasId) != null) {
  4323 + document.getElementById(modestyTransCanvasId).parentNode.removeChild(document.getElementById(modestyTransCanvasId));
  4324 + }
  4325 +
  4326 + if (document.getElementById(modestyTransCanvasId) == null || document.getElementById(modestyTransCanvasId) == undefined) {
  4327 + var canvasModesty = document.createElement('canvas');
  4328 + canvasModesty.id = modestyTransCanvasId;
  4329 + // $scope.tempCanvas = transparencyCanvas.id;
  4330 + canvasModesty.height = Height;
  4331 + canvasModesty.width = Width;
  4332 + canvasModesty.style.position = "absolute";
  4333 + canvasModesty.style.left = X + 'px';
  4334 + canvasModesty.style.top = Y + 'px';
  4335 + //canvasModesty.style.backgroundColor = "transparent";
  4336 + canvasModesty.style.visibility = 'visible';
  4337 + canvasModesty.style.zIndex = '2000';
  4338 + canvasModesty.addEventListener('click', OnClickModestyTransCanvas);
  4339 +
  4340 + // tempcanvasModestyCanvasModesty.style.border = "black 1px solid";
  4341 + document.getElementById('canvasDiv').appendChild(canvasModesty);
  4342 + }
  4343 + }
  4344 +
  4345 + if (tranparencyImgSrc != undefined) {
  4346 + var tempImg = new Image();
  4347 +
  4348 +
  4349 + tempImg.onload = function () {
  4350 + var tempCtx = transparencyTempCanvas.getContext('2d');
  4351 +
  4352 + if (IsMirror == 'Yes') {
  4353 + //debugger;
  4354 + tempCtx.save();
  4355 + tempCtx.translate(Width, 0);
  4356 + tempCtx.scale(-1, 1);
  4357 + tempCtx.drawImage(tempImg, 0, 0);
  4358 + }
  4359 + else {
  4360 + tempCtx.drawImage(tempImg, 0, 0);
  4361 +
  4362 + }
  4363 + // debugger;
  4364 + var tempCanvasID;
  4365 +
  4366 + if (IsMirror == 'Yes') {
  4367 + tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4368 + }
  4369 + else {
  4370 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4371 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId;
  4372 + }
  4373 + else
  4374 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
  4375 + }
  4376 +
  4377 +
  4378 + //check if transparency is activated
  4379 +
  4380 +
  4381 + var transNumber = $scope.transNumber;//txtTransparencyChange.value;
  4382 + // debugger;
  4383 + //this changes the transparency when transparency is already activated and user resizes or chage the layer
  4384 +
  4385 + var imageD = tempCtx.getImageData(0, 0, Width, Height);
  4386 +
  4387 +
  4388 + var tempCtx = document.getElementById(tempCanvasID).getContext('2d');
  4389 +
  4390 + //keep the original image on temp canavs to use it in changing transparency
  4391 +
  4392 +
  4393 +
  4394 + //if (document.getElementById(modestyTransTempCanvasId) != undefined || document.getElementById(modestyTransTempCanvasId) != null) {
  4395 + // var contxModesty = document.getElementById(modestyTransTempCanvasId).getContext('2d');
  4396 + // var tbTempCanvas = document.getElementById(tempCanvasID)
  4397 + // contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4398 +
  4399 + //}
  4400 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4401 + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
  4402 + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {
  4403 + var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d');
  4404 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4405 + contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4406 +
  4407 + }
  4408 + }
  4409 + else {
  4410 +
  4411 + if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) {
  4412 + var contx = document.getElementById('tempCanvas').getContext('2d');
  4413 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4414 + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4415 +
  4416 + }
  4417 + }
  4418 +
  4419 + // get the image data values
  4420 +
  4421 + var imageData = imageD.data;
  4422 + var length = imageData.length;
  4423 +
  4424 + //change background of image from transparent to white
  4425 +
  4426 + // set every fourth value to 50
  4427 + for (var i = 3; i < length; i += 4) {
  4428 + //NIKITA
  4429 + if ($scope.voId == "9" || $scope.voId == "11") {
  4430 +
  4431 + if (imageData[i] == 0) {
  4432 +
  4433 + }
  4434 + else {
  4435 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4436 + }
  4437 + }
  4438 + else {
  4439 + if (imageData[i] == 0) {
  4440 +
  4441 + }
  4442 + else {
  4443 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4444 + }
  4445 + }
  4446 + }
  4447 +
  4448 +
  4449 + tempCtx.putImageData(imageD, 0, 0);
  4450 +
  4451 + var ctx;
  4452 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4453 + ctx = document.getElementById(modestyTransCanvasId).getContext('2d');
  4454 + }
  4455 + else
  4456 + ctx = transparencyCanvas.getContext('2d');
  4457 +
  4458 +
  4459 + var TrtempCanvasID
  4460 + if (IsMirror == 'Yes') {
  4461 + TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4462 + }
  4463 + else {
  4464 + //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4465 + // TrtempCanvasID = 'modestyTransparencyTempCanvas_' + bodyRegionId;
  4466 + //}
  4467 + //else
  4468 + TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
  4469 + }
  4470 +
  4471 + var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d');
  4472 +
  4473 + ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage)
  4474 +
  4475 +
  4476 + XforCopyImage = 0;
  4477 + YforCopyImage = 0;
  4478 + WidthforCopyImage = 0;
  4479 + HeightforCopyImage = 0;
  4480 + XforTransImage = 0;
  4481 + WidthforTransImage = 0;
  4482 + HeightforTransImage = 0;
  4483 + YforTransImage = 0;
  4484 + PreviousBodyRegionHeight = 0;
  4485 +
  4486 + }
  4487 + tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc;
  4488 +
  4489 + }
  4490 +
  4491 +
  4492 + //mask image code
  4493 + //draw mask for annotation
  4494 + var tempMaskImg = new Image();
  4495 + var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
  4496 + tempMaskImg.src = tranparencyMaskImgSrc;//"http://localhost/AIA/" + tranparencyMaskImgSrc;
  4497 + tempMaskImg.onload = function () {
  4498 + // debugger;
  4499 + var tempmaskCtx = transparencyTempcanavsMask.getContext('2d');
  4500 +
  4501 + if (IsMirror == 'Yes') {
  4502 + //debugger;
  4503 + tempmaskCtx.save();
  4504 + tempmaskCtx.translate(Width, 0);
  4505 + tempmaskCtx.scale(-1, 1);
  4506 + tempmaskCtx.drawImage(tempMaskImg, 0, 0);
  4507 + }
  4508 + else {
  4509 + tempmaskCtx.drawImage(tempMaskImg, 0, 0);
  4510 +
  4511 + }
  4512 +
  4513 +
  4514 + }
  4515 +
  4516 +
  4517 + PreviousBodyRegionHeight = HeightforTransImage;
  4518 + PreviousBodyRegionY = YforTransImage;
  4519 + PreviousBodyRegionWidth = WidthforTransImage;
  4520 + PreviousBodyRegionX = XforTransImage;
  4521 + previousBodyRegionId = bodyRegionId;
  4522 +
  4523 + // $scope.layerNumber = parseInt($scope.layerNumber - 1);
  4524 +
  4525 + //}
  4526 +
  4527 + }
  4528 +
  4529 + $scope.changeTransparency = function () {
  4530 + //this changes the transparency when user click on transparency scale(we have already set the original
  4531 + //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated)
  4532 + // if (isTransparencyChanged == true) {
  4533 +
  4534 + // var txtTransparencyChange = document.getElementById("txtTransparencyChange");
  4535 +
  4536 + var transNumber = $scope.transNumber;
  4537 +
  4538 + var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']");
  4539 + var modestyTemCanvas = $("canvas[id*='tempCanvasModesty_']");
  4540 + if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) {
  4541 +
  4542 + for (var j = 0; j < modestyTransCanvases.length; j++) {
  4543 + var ctx = document.getElementById(modestyTransCanvases[j].id).getContext('2d');
  4544 + var imageDa = ctx.getImageData(0, 0, modestyTransCanvases[j].width, modestyTransCanvases[j].height);
  4545 + //modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]);
  4546 +
  4547 + var imageData = imageDa.data;
  4548 + var length = imageData.length;
  4549 + // set every fourth value to 50
  4550 + for (var i = 3; i < length; i += 4) {
  4551 + //NIKITA
  4552 + if ($scope.voId == "9" || $scope.voId == "11") {
  4553 +
  4554 + if (imageData[i] == 0) {
  4555 +
  4556 + }
  4557 + else {
  4558 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4559 + }
  4560 + }
  4561 + else {
  4562 + if (imageData[i] == 0) {
  4563 +
  4564 + }
  4565 + else
  4566 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4567 + }
  4568 +
  4569 + // imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4570 + }
  4571 + // after the manipulation, reset the data
  4572 + // imageDa.data = imageData;
  4573 + // and put the imagedata back to the canvas
  4574 + //ctx.putImageData(imageDa, XforTransImage, YforTransImage);
  4575 + ctx.putImageData(imageDa, 0, 0);
  4576 + }
  4577 + }
  4578 +
  4579 +
  4580 + var ctx = document.getElementById('transparencyCanvas').getContext('2d');
  4581 +
  4582 + // var imageDa = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4583 + var imageDa = ctx.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight);
  4584 +
  4585 + // get the image data values
  4586 + var imageData = imageDa.data;
  4587 + var length = imageData.length;
  4588 + // set every fourth value to 50
  4589 + for (var i = 3; i < length; i += 4) {
  4590 + //NIKITA
  4591 + if ($scope.voId == "9" || $scope.voId == "11") {
  4592 +
  4593 + if (imageData[i] == 0) {
  4594 +
  4595 + }
  4596 + else {
  4597 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4598 + }
  4599 + }
  4600 + else {
  4601 + if (imageData[i] == 0) {
  4602 +
  4603 + }
  4604 + else
  4605 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4606 + }
  4607 +
  4608 + // imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4609 + }
  4610 + // after the manipulation, reset the data
  4611 + // imageDa.data = imageData;
  4612 + // and put the imagedata back to the canvas
  4613 + //ctx.putImageData(imageDa, XforTransImage, YforTransImage);
  4614 + ctx.putImageData(imageDa, 0, 0);
  4615 +
  4616 +
  4617 + //}
  4618 + }
  4619 +
  4620 +
  4621 +
  4622 + function resizeCanvas() {
  4623 + //debugger;
  4624 + // alert('reload')
  4625 + clearTransCanvas();
  4626 + if ($('#speechBubbleTrns').length > 0) {
  4627 + $('#speechBubbleTrns').remove();
  4628 + }
  4629 + var tCanvas = document.getElementById('transparencyCanvas');
  4630 + var tCanvasContext = tCanvas.getContext('2d');
  4631 +
  4632 + var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
  4633 +
  4634 + var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
  4635 +
  4636 + var tBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
  4637 + var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
  4638 + var tBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
  4639 + var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
  4640 + var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight);
  4641 + var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth);
  4642 +
  4643 + if (tCanvas != null) {
  4644 + $('#transparencyCanvas').remove();
  4645 + }
  4646 +
  4647 +
  4648 + var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']");
  4649 + if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) {
  4650 + for (var j = 0; j < modestyTransCanvases.length; j++) {
  4651 +
  4652 + modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]);
  4653 + }
  4654 + }
  4655 +
  4656 + var modestyTempCanvases = $("canvas[id*='tempCanvasModesty_']");
  4657 + if (modestyTempCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) {
  4658 + for (var j = 0; j < modestyTempCanvases.length; j++) {
  4659 +
  4660 + modestyTempCanvases[j].parentNode.removeChild(modestyTempCanvases[j]);
  4661 + }
  4662 + }
  4663 +
  4664 + $scope.isResized = true;
  4665 +
  4666 +
  4667 + if (tCanvasHeight != $scope.transparencyCanvasHeight || tCanvasWidth != $scope.transparencyCanvasWidth) {
  4668 +
  4669 +
  4670 + var transparencyCanvas = document.createElement('canvas');
  4671 + transparencyCanvas.id = 'transparencyCanvas';
  4672 + $scope.transparencyCanvas = tCanvas.id;
  4673 + transparencyCanvas.height = tCanvasHeight;
  4674 + transparencyCanvas.width = tCanvasWidth;
  4675 + transparencyCanvas.style.position = "absolute";
  4676 + transparencyCanvas.style.left = tCanvas.style.left; // x + "px";
  4677 + transparencyCanvas.style.top = tCanvas.style.top//y + "px";
  4678 + transparencyCanvas.style.border = "black 1px solid";
  4679 + transparencyCanvas.style.zIndex = 200;
  4680 +
  4681 +
  4682 + document.getElementById('canvasDiv').appendChild(transparencyCanvas);
  4683 +
  4684 + $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } });
  4685 + $(".ui-wrapper").css("z-index", "600");
  4686 +
  4687 + //bind click listener
  4688 + transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener);
  4689 + }
  4690 + $scope.transparencyCanvasHeight = tCanvasHeight;
  4691 + $scope.transparencyCanvasWidth = tCanvasWidth;
  4692 +
  4693 + // debugger;
  4694 + //create temp cavas to retain the original anavs data for use in transparency change as
  4695 + //if u use original canvas data for transprency change then at 0 transparency all data will become transparent and if u increase transparency with this data then the canavs will be blank
  4696 + if (document.getElementById('tempCanvas') != null) {
  4697 + $('#tempCanvas').remove();
  4698 + }
  4699 + var tempCanvas = document.createElement('canvas');
  4700 + tempCanvas.id = 'tempCanvas';
  4701 + $scope.tempCanvas = tempCanvas.id;
  4702 + tempCanvas.height = $scope.transparencyCanvasHeight;
  4703 + tempCanvas.width = $scope.transparencyCanvasWidth;
  4704 + tempCanvas.style.position = "absolute";
  4705 + tempCanvas.style.left = 200 + 'px';
  4706 + tempCanvas.style.backgroundColor = "transparent";
  4707 + tempCanvas.style.visibility = 'hidden';
  4708 + // tempCanvas.style.border = "black 1px solid";
  4709 +
  4710 + document.getElementById('canvasDiv').appendChild(tempCanvas);
  4711 +
  4712 +
  4713 + var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
  4714 +
  4715 + $scope.IncludedBodyRegions = [];
  4716 + // $scope.layerNo = parseInt(document.getElementById(''))
  4717 + var counter = 0;
  4718 + $.each(BodyRegionDictionary, function (index, value) {
  4719 +
  4720 + var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
  4721 + var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
  4722 + var TBRight = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.width).replace('px', ''));
  4723 + var TBBottom = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.height).replace('px', ''));
  4724 + var TBStartX = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', ''));
  4725 + var TBStartY = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', ''));
  4726 +
  4727 +
  4728 +
  4729 +
  4730 + if (TBStartX <= bodyRegionRight && value.X <= TBRight && TBStartY <= bodyRegionBottom && value.Y <= TBBottom) {
  4731 +
  4732 +
  4733 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, false);
  4734 +
  4735 + }
  4736 +
  4737 +
  4738 + })
  4739 +
  4740 +
  4741 + //for modesty
  4742 + if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
  4743 + $.each($scope.modestyImageInfo, function (index, value) {
  4744 + // alert(' $.each(BodyRegionDictionary1')
  4745 +
  4746 +
  4747 + var bodyRegionRight = parseInt(value.x) + parseInt(value.Width);
  4748 + var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height);
  4749 + var TBRight = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.width).replace('px', ''));
  4750 + var TBBottom = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.height).replace('px', ''));
  4751 + var TBStartX = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', ''));
  4752 + var TBStartY = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', ''));
  4753 +
  4754 +
  4755 +
  4756 +
  4757 + if (TBStartX <= bodyRegionRight && value.x <= TBRight && TBStartY <= bodyRegionBottom && value.y <= TBBottom) {
  4758 +
  4759 +
  4760 + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.x, value.y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, false);
  4761 +
  4762 + }
  4763 + })
  4764 + }
  4765 +
  4766 + // });
  4767 + //$(".ui-wrapper").css("z-index", "600");
  4768 + $scope.isResized = false;
  4769 + }
  4770 +
  4771 +
  4772 + function TransparencyCanvasClickListener(evt) {
  4773 + //alert('tb clicked')
  4774 + // debugger;
  4775 + var pixelData;
  4776 + var pixelDataTrans;
  4777 + var mousePos = $scope.getMousePos(evt);
  4778 + // alert(mousePos.x + ',' + mousePos.y);
  4779 +
  4780 + var canvasDiv = document.getElementById('canvasDiv');
  4781 + var verticalScrollPosition = canvasDiv.scrollTop;
  4782 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  4783 +
  4784 +
  4785 + //We substracted 135, as the difference between flex and html coordinates for same organ is 135
  4786 + var actulalX = mousePos.x + horizontlScrollPosition;
  4787 + var actualY = mousePos.y + verticalScrollPosition //- 135; //+ tomenuBarheight + titleBarheight + searchComboheight;
  4788 + var clickedBodyRegion;
  4789 + var x;
  4790 + var y;
  4791 + var isMirror;
  4792 + var width;
  4793 + var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
  4794 + if ($rootScope.viewOrientationId == 5) {
  4795 +
  4796 + var clickedBodyRegionData = new jinqJs()
  4797 + .from(BodyRegionDictionary)
  4798 + .where('bodyRegionId == 6')
  4799 + .select();
  4800 +
  4801 +
  4802 + // clickedBodyRegion = clickedBodyRegionData[0].bodyRegionId;
  4803 + x = clickedBodyRegionData[0].X;
  4804 + y = clickedBodyRegionData[0].Y;
  4805 + width = clickedBodyRegionData[0].Width;
  4806 + var height = clickedBodyRegionData[0].Height;
  4807 + isMirror = clickedBodyRegionData[0].IsMirror;
  4808 + var bodyRegionRight = parseInt(x) + parseInt(width);
  4809 + var bodyRegionBottom = parseInt(y) + parseInt(height);
  4810 + if (actulalX <= bodyRegionRight && x <= actulalX && actualY <= bodyRegionBottom && y <= actualY) {
  4811 +
  4812 + clickedBodyRegion = clickedBodyRegionData[0].bodyRegionId;
  4813 + x = clickedBodyRegionData[0].X;
  4814 + y = clickedBodyRegionData[0].Y;
  4815 + width = clickedBodyRegionData[0].Width;
  4816 + var height = clickedBodyRegionData[0].Height;
  4817 + isMirror = clickedBodyRegionData[0].IsMirror;
  4818 + }
  4819 +
  4820 + }
  4821 + else {
  4822 + $.each(BodyRegionDictionary, function (index, value) {
  4823 +
  4824 + var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
  4825 + var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
  4826 + if (actulalX <= bodyRegionRight && value.X <= actulalX && actualY <= bodyRegionBottom && value.Y <= actualY) {
  4827 +
  4828 + clickedBodyRegion = value.bodyRegionId;
  4829 + x = value.X;
  4830 + y = value.Y;
  4831 + width = value.Width;
  4832 + isMirror = value.IsMirror;
  4833 + return false;
  4834 + }
  4835 + })
  4836 + }
  4837 +
  4838 +
  4839 + if (isMirror == "Yes") {
  4840 +
  4841 + var mirrorCanvasX = x;
  4842 + var mirrorCanvasWidth = width;
  4843 +
  4844 + var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
  4845 + var clickedCanavs = document.getElementById(clickedCanvasMaskId);
  4846 +
  4847 + var maskCanvasId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
  4848 + var maskCanvas = document.getElementById(maskCanvasId);
  4849 +
  4850 + if (maskCanvas != null) {
  4851 + x = maskCanvas.style.left;
  4852 + y = maskCanvas.style.top;
  4853 +
  4854 + var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
  4855 + var maskCanvastrans = document.getElementById(maskCanvasTransId);
  4856 + var maskCanvasContexttrans = maskCanvastrans.getContext("2d");
  4857 +
  4858 +
  4859 + getAnnotationAndCraeteSpeechBubble(mirrorCanvasX, mirrorCanvasWidth, mousePos, maskCanvasContexttrans, clickedBodyRegion, x, y, evt)
  4860 +
  4861 +
  4862 + }
  4863 +
  4864 + //if non mirrored canvas does not exist for this irror Body region then draw non mirrored image to get annotation
  4865 +
  4866 + else if (maskCanvas == null) {
  4867 + var clickedBodyRegionData = new jinqJs()
  4868 + .from(BodyRegionDictionary)
  4869 + .where('bodyRegionId == ' + clickedBodyRegion)
  4870 + .select();
  4871 + if (clickedBodyRegionData != null || clickedBodyRegionData != undefined) {
  4872 +
  4873 + var nomMirroredBodyRegion = new jinqJs()
  4874 + .from(clickedBodyRegionData)
  4875 + .where('IsMirror == No')
  4876 + .select();
  4877 +
  4878 + var transparencyTempcanavsMask = document.createElement('canvas');
  4879 + transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
  4880 + transparencyTempcanavsMask.height = nomMirroredBodyRegion[0].Height;
  4881 + transparencyTempcanavsMask.width = nomMirroredBodyRegion[0].Width;
  4882 + transparencyTempcanavsMask.style.position = "absolute";
  4883 + transparencyTempcanavsMask.style.left = nomMirroredBodyRegion[0].X + 'px' // x + "px";
  4884 + transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px";
  4885 + transparencyTempcanavsMask.style.visibility = 'hidden';
  4886 +
  4887 + document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
  4888 +
  4889 + var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion);
  4890 + var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
  4891 +
  4892 + var tempMaskImg = new Image();
  4893 + tempMaskImg.src = tranparencyMaskImgSrc;
  4894 +
  4895 + tempMaskImg.onload = function () {
  4896 + var transparencyTempcanavsMask = document.getElementById(maskCanvasId);
  4897 + var tempmaskCtx = transparencyTempcanavsMask.getContext('2d');
  4898 + tempmaskCtx.drawImage(tempMaskImg, 0, 0);
  4899 +
  4900 + //get x,y of non mirrored canvas for this body region
  4901 + x = transparencyTempcanavsMask.style.left;
  4902 + y = transparencyTempcanavsMask.style.top;
  4903 +
  4904 + getAnnotationAndCraeteSpeechBubble(mirrorCanvasX, mirrorCanvasWidth, mousePos, tempmaskCtx, clickedBodyRegion, x, y, evt)
  4905 +
  4906 + }
  4907 + }
  4908 + }
  4909 +
  4910 +
  4911 + }
  4912 + else {
  4913 +
  4914 + var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
  4915 + var maskCanvas = document.getElementById(clickedCanvasMaskId);
  4916 + var maskCanvasContext = maskCanvas.getContext("2d");
  4917 +
  4918 + //transparecncy canvas
  4919 + var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
  4920 + var maskCanvastrans = document.getElementById(maskCanvasTransId);
  4921 + var maskCanvasContexttrans = maskCanvastrans.getContext("2d");
  4922 +
  4923 + pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
  4924 +
  4925 + pixelDataTrans = maskCanvasContexttrans.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
  4926 + var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
  4927 + //var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
  4928 +
  4929 + if ($('#speechBubble').length > 0)
  4930 + $('#speechBubble').remove();
  4931 +
  4932 + if ($('#speechBubbleTrns').length > 0) {
  4933 + $('#speechBubbleTrns').remove();
  4934 +
  4935 + // $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
  4936 + $scope.annotationTextArrayT1 = [];
  4937 + $scope.annotationTextArrayT2 = [];
  4938 + $scope.annotationTextArrayT1.push(annotations.annotationT1);
  4939 + $scope.annotationTextArrayT2.push(annotations.annotationT2);
  4940 +
  4941 +
  4942 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  4943 + }
  4944 + else
  4945 + // $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
  4946 + {
  4947 +
  4948 + $scope.annotationTextArrayT1 = [];
  4949 + $scope.annotationTextArrayT2 = [];
  4950 + $scope.annotationTextArrayT1.push(annotations.annotationT1);
  4951 + $scope.annotationTextArrayT2.push(annotations.annotationT2);
  4952 +
  4953 +
  4954 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  4955 + }
  4956 +
  4957 + }
  4958 +
  4959 +
  4960 + }
  4961 +
  4962 + function OnClickModestyTransCanvas(evt) {
  4963 +
  4964 + var mousePos = $scope.getMousePos(evt);
  4965 + var canvasDiv = document.getElementById('canvasDiv');
  4966 + var verticalScrollPosition = canvasDiv.scrollTop;
  4967 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  4968 +
  4969 + var actulalX = mousePos.x + horizontlScrollPosition;
  4970 + var actualY = mousePos.y + verticalScrollPosition;
  4971 +
  4972 + var canavsX = evt.currentTarget.offsetLeft;
  4973 + var canvasY = evt.currentTarget.offsetTop;
  4974 +
  4975 + var canvasId = evt.currentTarget.id;
  4976 + var canavsContext = document.getElementById(canvasId).getContext('2d');
  4977 + var RGBColor = $scope.GetRGBColor(canavsContext, actulalX, actualY, canavsX, canvasY);
  4978 +
  4979 + var annotationText;
  4980 +
  4981 + //Modesty ON
  4982 + if (canvasId.match('modestyImg') && RGBColor != '000000') {
  4983 + RGBColor = DA[0].figLeafTermId;
  4984 + annotationText = $scope.GetAnnotationBasedOnActualTermNo(RGBColor);
  4985 + $scope.annotationTextArrayT1 = [];
  4986 + $scope.annotationTextArrayT2 = [];
  4987 + $scope.annotationTextArrayT1.push(annotationText);
  4988 + $scope.annotationTextArrayT2.push(annotationText);
  4989 + }
  4990 + //Modesty On but clicked somewhre else, we did modesty check because the modesty image covers whole body region so if user will click to
  4991 + //see the annotation apart from leaf then the actual click will be on modesty canvas, but for annotation er
  4992 + //
  4993 + else if (canvasId.match('modestyImg') && RGBColor == '000000') {
  4994 +
  4995 + var bodyRegionId = canvasId.slice(-1);
  4996 +
  4997 + var maskCanvasId = 'imageCanvas' + bodyRegionId + '_mci';
  4998 + var maskCanvas = document.getElementById(maskCanvasId);
  4999 + var maskCanvasContext = maskCanvas.getContext("2d");
  5000 + //RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, xcanavsX, canvasY);
  5001 + //annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
  5002 +
  5003 + //transparecncy canvas
  5004 + var maskCanvasTransId = 'transparencyTempCanvasMask_' + bodyRegionId + '_mci';
  5005 + var maskCanvastrans = document.getElementById(maskCanvasTransId);
  5006 + var maskCanvasContexttrans = maskCanvastrans.getContext("2d");
  5007 +
  5008 + var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - canavsX), Math.round(actualY - canvasY), 1, 1);
  5009 +
  5010 + var pixelDataTrans = maskCanvasContexttrans.getImageData(Math.round(actulalX - canavsX), Math.round(actualY - canvasY), 1, 1);
  5011 +
  5012 + var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
  5013 +
  5014 +
  5015 + // var maskCanvasId = 'imageCanvas' + bodyRegionId + '_mci';
  5016 + // var maskCanvas = document.getElementById(maskCanvasId);
  5017 + // var maskCanvasContext = maskCanvas.getContext("2d");
  5018 + // RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, xcanavsX, canvasY);
  5019 + // annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
  5020 +
  5021 +
  5022 + // createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
  5023 +
  5024 + $scope.annotationTextArrayT1 = [];
  5025 + $scope.annotationTextArrayT2 = [];
  5026 + $scope.annotationTextArrayT1.push(annotations.annotationT1);
  5027 + $scope.annotationTextArrayT2.push(annotations.annotationT2);
  5028 +
  5029 + }
  5030 +
  5031 + if ($('#speechBubble').length > 0)
  5032 + $('#speechBubble').remove();
  5033 +
  5034 +
  5035 + if ($('#speechBubbleTrns').length > 0) {
  5036 + $('#speechBubbleTrns').remove();
  5037 + }
  5038 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  5039 +
  5040 +
  5041 + }
  5042 +
  5043 + function getAnnotationAndCraeteSpeechBubble(mirrorCanvasX, mirrorCanvasWidth, mousePos, maskCanvasContexttrans, clickedBodyRegion, x, y, evt) {
  5044 + var canvasDiv = document.getElementById('canvasDiv');
  5045 + var verticalScrollPosition = canvasDiv.scrollTop;
  5046 + var horizontlScrollPosition = canvasDiv.scrollLeft;
  5047 +
  5048 + var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135);
  5049 +
  5050 + var mirrorXOnNormalImage = parseInt(maskCanvasContexttrans.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage);
  5051 +
  5052 + var actulalX = mirrorXOnNormalImage
  5053 + var actualY = mousePos.y + verticalScrollPosition
  5054 +
  5055 +
  5056 +
  5057 + var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
  5058 + var maskCanvas = document.getElementById(clickedCanvasMaskId);
  5059 + var maskCanvasContext = maskCanvas.getContext("2d");
  5060 + var imgX = Math.round(actulalX - parseInt((x).replace('px', '')));
  5061 + var imgY = Math.round(actualY - parseInt((y).replace('px', '')));
  5062 + var pixelData = maskCanvasContext.getImageData(imgX, imgY, 1, 1);
  5063 +
  5064 +
  5065 + //trans layer image data
  5066 + var pixelDataTrans = maskCanvasContexttrans.getImageData(imgX, imgY, 1, 1);
  5067 + // console.log('at the time' + pixelData.data[0])
  5068 + // debugger;
  5069 + var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
  5070 + if ($('#speechBubble').length > 0)
  5071 + $('#speechBubble').remove();
  5072 +
  5073 +
  5074 + if ($('#speechBubbleTrns').length > 0) {
  5075 + $('#speechBubbleTrns').remove();
  5076 +
  5077 + // createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
  5078 +
  5079 + $scope.annotationTextArrayT1 = [];
  5080 + $scope.annotationTextArrayT2 = [];
  5081 + $scope.annotationTextArrayT1.push(annotations.annotationT1);
  5082 + $scope.annotationTextArrayT2.push(annotations.annotationT2);
  5083 +
  5084 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  5085 + }
  5086 + else {
  5087 + $scope.annotationTextArrayT1 = [];
  5088 + $scope.annotationTextArrayT2 = [];
  5089 + $scope.annotationTextArrayT1.push(annotations.annotationT1);
  5090 + $scope.annotationTextArrayT2.push(annotations.annotationT2);
  5091 +
  5092 + $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
  5093 + }
  5094 + }
  5095 +
  5096 +
  5097 + function clearTransCanvas() {
  5098 +
  5099 + var tCanvas = document.getElementById('transparencyCanvas');
  5100 + if (tCanvas != null) {
  5101 + var tCanvasContext = tCanvas.getContext('2d');
  5102 + tCanvasContext.clearRect(0, 0, parseInt(tCanvas.style.width), parseInt(tCanvas.style.height));
  5103 + }
  5104 +
  5105 + }
  5106 +
  5107 +
  5108 + $scope.getAnnotationForTransparencyBox = function (pixelData, pixelDataTrans, scope) {
  5109 +
  5110 +
  5111 +
  5112 + pixelData.data[0] = pixelData.data[0] - 9;
  5113 + pixelData.data[1] = pixelData.data[1] - 9;
  5114 + pixelData.data[2] = pixelData.data[2] - 9;
  5115 +
  5116 + //trans pixel data
  5117 + pixelDataTrans.data[0] = pixelDataTrans.data[0] - 9;
  5118 + pixelDataTrans.data[1] = pixelDataTrans.data[1] - 9;
  5119 + pixelDataTrans.data[2] = pixelDataTrans.data[2] - 9;
  5120 +
  5121 + var Red;
  5122 + var Green;
  5123 + var Blue;
  5124 + var zero = "0";
  5125 +
  5126 + if ((pixelData.data[0]).toString().length != 2) {
  5127 + Red = zero.concat((pixelData.data[0]).toString())
  5128 + }
  5129 + else {
  5130 + Red = (pixelData.data[0]).toString()
  5131 + }
  5132 + if ((pixelData.data[1]).toString().length != 2) {
  5133 + Green = zero.concat((pixelData.data[1]).toString())
  5134 + }
  5135 + else {
  5136 + Green = (pixelData.data[1]).toString()
  5137 +
  5138 + }
  5139 + if ((pixelData.data[2]).toString().length != 2) {
  5140 + Blue = zero.concat((pixelData.data[2]).toString())
  5141 + }
  5142 + else {
  5143 + Blue = (pixelData.data[2]).toString()
  5144 +
  5145 + }
  5146 + var RGBColor = (Red + Green + Blue);
  5147 +
  5148 +
  5149 + var annotationText1 = $scope.GetAnnotationText(parseInt(RGBColor));
  5150 +
  5151 + //get annotation for trans canavs
  5152 + var RedTrans;
  5153 + var GreenTrans;
  5154 + var BlueTrans;
  5155 + var zero = "0";
  5156 +
  5157 + if ((pixelDataTrans.data[0]).toString().length != 2) {
  5158 + RedTrans = zero.concat((pixelDataTrans.data[0]).toString())
  5159 + }
  5160 + else {
  5161 + RedTrans = (pixelDataTrans.data[0]).toString()
  5162 + }
  5163 + if ((pixelDataTrans.data[1]).toString().length != 2) {
  5164 + GreenTrans = zero.concat((pixelDataTrans.data[1]).toString())
  5165 + }
  5166 + else {
  5167 + GreenTrans = (pixelDataTrans.data[1]).toString()
  5168 +
  5169 + }
  5170 + if ((pixelDataTrans.data[2]).toString().length != 2) {
  5171 + BlueTrans = zero.concat((pixelDataTrans.data[2]).toString())
  5172 + }
  5173 + else {
  5174 + BlueTrans = (pixelDataTrans.data[2]).toString()
  5175 +
  5176 + }
  5177 + var RGBColorTrans = (RedTrans + GreenTrans + BlueTrans);
  5178 +
  5179 +
  5180 + var annotationText2 = $scope.GetAnnotationText(parseInt(RGBColorTrans));
  5181 +
  5182 + return {
  5183 + annotationT1: annotationText1,
  5184 + annotationT2: annotationText2
  5185 + }
  5186 + }
  5187 +
  5188 +
  5189 + $scope.onTransparencyChange = function (ev, ui) {
  5190 + //debugger;
  5191 + // alert('t change')
  5192 + $scope.transNumber = ui.value;
  5193 +
  5194 + var tCanvas = document.getElementById('transparencyCanvas');
  5195 + var tCanvasContext = tCanvas.getContext('2d');
  5196 +
  5197 + var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
  5198 +
  5199 + var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
  5200 +
  5201 + var tBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
  5202 + var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
  5203 + var tBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
  5204 + var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
  5205 + var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight);
  5206 + var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth);
  5207 +
  5208 + //var scope = angular.element(document.getElementById("DAView")).scope();
  5209 + //scope.$apply(function () {
  5210 + var arr = [];
  5211 + $scope.transparencyChangeCounter++;
  5212 + //before changing the transparency of first canvas, hold the orignal canvas data on temp canvas
  5213 +
  5214 + //put original data on transcanvas so that it can be used to change transparency properly
  5215 + var tempCanavs = document.getElementById('tempCanvas');
  5216 + var tempCanvasContext = tempCanavs.getContext('2d');
  5217 +
  5218 + var originalTransparencyData = tempCanvasContext.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight);
  5219 + var ctx = document.getElementById('transparencyCanvas').getContext('2d');
  5220 + ctx.putImageData(originalTransparencyData, 0, 0);
  5221 +
  5222 +
  5223 + //for modesty
  5224 +
  5225 + //for modesty
  5226 + if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
  5227 + $.each($scope.modestyImageInfo, function (index, value) {
  5228 +
  5229 + var brId = value.bodyRegionId;
  5230 +
  5231 + var modestyTransTempCanvasId = 'tempCanvasModesty_' + brId;
  5232 + var modestyTransCanvasId = 'modestyTransCanavs_' + brId;
  5233 + var tempCanvasContext = document.getElementById(modestyTransTempCanvasId).getContext('2d');
  5234 + var originalTransparencyData = tempCanvasContext.getImageData(0, 0, value.Width, value.Height);
  5235 + var ctx = document.getElementById(modestyTransCanvasId).getContext('2d');
  5236 + ctx.putImageData(originalTransparencyData, 0, 0);
  5237 + })
  5238 + }
  5239 +
  5240 + $scope.changeTransparency();
  5241 +
  5242 +
  5243 + // });
  5244 + }
  5245 +
  5246 + $scope.CloseTransparencyBox = function () {
  5247 +
  5248 +
  5249 + //To enable extract button
  5250 + $scope.isTransparencyActivated = false;
  5251 + $("#btnExtract").removeClass("disabled");
  5252 +
  5253 + //$('.com_anno').css('display', 'none');
  5254 +
  5255 + //$('#sppeachBubble_annotation').css('display', 'none');
  5256 + //$('#dot_annotation').css('display', 'none');
  5257 + //$('#bord_annotation').css('display', 'none');
  5258 +
  5259 +
  5260 + $('.com_anno').remove();
  5261 +
  5262 + $('#sppeachBubble_annotation').remove();
  5263 + $('#dot_annotation').remove();
  5264 + $('#bord_annotation').remove();
  5265 +
  5266 + var tBox = document.getElementById('transparencyCanvas');
  5267 +
  5268 +
  5269 + if (tBox != null) {
  5270 + tBox.parentNode.removeChild(tBox)
  5271 + var elements = document.getElementsByClassName('ui-icon ui-icon-gripsmall-diagonal-se');
  5272 + while (elements.length > 0) {
  5273 + elements[0].parentNode.removeChild(elements[0]);
  5274 + }
  5275 + //var txtTransparencyChange = document.getElementById("txtTransparencyChange");
  5276 + //txtTransparencyChange.value = 0;
  5277 + // document.getElementById('txtLayerNumber').value = 0;
  5278 + // debugger;
  5279 +
  5280 +
  5281 + $('#layerChangeSlider').slider("option", "value", parseInt($rootScope.totalLayers) - parseInt($scope.currentLayerNumber));
  5282 + $("#txtlayerNumber").val(parseInt($scope.currentLayerNumber));
  5283 +
  5284 +
  5285 + if (document.getElementById('tempCanvas') != null) {
  5286 + $('#tempCanvas').remove();
  5287 + }
  5288 + if ($('#speechBubbleTrns').length > 0) {
  5289 + $('#speechBubbleTrns').remove();
  5290 + }
  5291 + //var scope = angular.element(document.getElementById("DAView")).scope();
  5292 + //scope.$apply(function () {
  5293 + // $scope.layerNumber = 0;
  5294 + // $scope.isTransparencyActivated = false;
  5295 + //})
  5296 +
  5297 +
  5298 + var tempCanvases = $("canvas[id*='transparencyTempCanvas']");
  5299 + for (var i = 0; i < tempCanvases.length; i++) {
  5300 + tempCanvases[i].parentNode.removeChild(tempCanvases[i]);
  5301 + }
  5302 +
  5303 + $('.ui-wrapper').remove();
  5304 +
  5305 + //$("canvas[name*='transparencyTempCanvas']").nextUntil($("canvas[name*='transparencyTempCanvas']"))
  5306 + //.remove();
  5307 + $scope.layerNumber = $scope.currentLayerNumber;
  5308 + $scope.transNumber = 50;
  5309 + $(".slider").slider({ value: 50 })
  5310 + }
  5311 +
  5312 +
  5313 + var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']");
  5314 + if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) {
  5315 + for (var j = 0; j < modestyTransCanvases.length; j++) {
  5316 +
  5317 + modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]);
  5318 + }
  5319 + }
  5320 +
  5321 + $('#transparencyScale').css('visibility', 'hidden');
  5322 +
  5323 + //$scope.isTransparencyActivated = false;
  5324 + // document.getElementById('btnTranparency').className = 't-transparency'
  5325 + $('#btnTranparency').removeClass('tButtonActive');
  5326 + $('#btnTranparency').addClass('btn-black');
  5327 + $('#btnIdentity').removeClass('btn-black');
  5328 +
  5329 + $('#btnIdentity').addClass('btn-primary');
  5330 +
  5331 + document.getElementById('btnTranparency').removeEventListener("click", $scope.createTransparencyBox);
  5332 +
  5333 + }
  5334 +
  5335 + $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) {
  5336 +
  5337 + $('#canvasDiv').css('cursor', 'pointer');
  5338 + $('<div id="speechBubbleTrns" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px;z-index:700"> <div class="">'
  5339 + + '<div class="Bubble">'
  5340 + + '<div class="BubbleCloseBtn"></div><div class="BubbleContent">' + text1 + '</div><div class="BubbleContent">' + text2 + '</div><div class="bottomLeftArrow"></div>'
  5341 + //+'<div class="bottomRightArrow"></div><div class="topLeftArrow"></div><div class="topRightArrow"></div>
  5342 + + '</div></div></div>').appendTo('#canvasDiv');
  5343 +
  5344 + $('#speechBubbleTrns').on('click', '.BubbleCloseBtn', function (e) {
  5345 + $('#speechBubbleTrns').css('display', 'none');
  5346 + });
  5347 +
  5348 + $('#canvasDiv').attr("data-bubbleid", "speechBubble")
  5349 +
  5350 +
  5351 + };
  5352 +
  5353 +
  5354 + function positionTooltip(event, x, y) {
  5355 + // alert('positionTooltip')
  5356 + x = 100,
  5357 + y = 200,
  5358 +
  5359 + $('div.speech-bubble').css({
  5360 + 'position': 'absolute', 'top': x, 'left': y, 'background-color': '#f8f8f8',
  5361 + 'border': '2px solid #c8c8c8', 'width': '150px', 'height': '50px'
  5362 + });
  5363 +
  5364 +
  5365 + $('.arrow').css({
  5366 + 'border-style': 'solid',
  5367 + 'position': 'absolute'
  5368 + });
  5369 +
  5370 + $('.bottom').css({
  5371 + 'border-color': '#c8c8c8 transparent transparent transparent',
  5372 + 'border-width': ' 8px 8px 0px 8px',
  5373 + 'bottom': -'8px'
  5374 + })
  5375 + };
  5376 +
  5377 + $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) {
  5378 +
  5379 + $('#canvasDiv').css('cursor', 'pointer');
  5380 + $('<div id="speechBubbleTrns" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px;z-index:700"> <div class="">'
  5381 + + '<div class="Bubble">'
  5382 + + '<div class="BubbleCloseBtn"></div><div class="BubbleContent">' + text1 + '</div><div class="BubbleContent">' + text2 + '</div><div class="bottomLeftArrow"></div>'
  5383 + //+'<div class="bottomRightArrow"></div><div class="topLeftArrow"></div><div class="topRightArrow"></div>
  5384 + + '</div></div></div>').appendTo('#canvasDiv');
  5385 +
  5386 + $('#speechBubbleTrns').on('click', '.BubbleCloseBtn', function (e) {
  5387 + $('#speechBubbleTrns').css('display', 'none');
  5388 + });
  5389 +
  5390 + $('#canvasDiv').attr("data-bubbleid", "speechBubble")
  5391 +
  5392 +
  5393 + };
  5394 +
  5395 +
  5396 + function positionTooltip(event, x, y) {
  5397 + // alert('positionTooltip')
  5398 + x = 100,
  5399 + y = 200,
  5400 +
  5401 + $('div.speech-bubble').css({
  5402 + 'position': 'absolute', 'top': x, 'left': y, 'background-color': '#f8f8f8',
  5403 + 'border': '2px solid #c8c8c8', 'width': '150px', 'height': '50px'
  5404 + });
  5405 +
  5406 +
  5407 + $('.arrow').css({
  5408 + 'border-style': 'solid',
  5409 + 'position': 'absolute'
  5410 + });
  5411 +
  5412 + $('.bottom').css({
  5413 + 'border-color': '#c8c8c8 transparent transparent transparent',
  5414 + 'border-width': ' 8px 8px 0px 8px',
  5415 + 'bottom': -'8px'
  5416 + })
  5417 + };
  5418 +
  5419 +
  5420 + $scope.IdentityClick = function () {
  5421 +
  5422 +
  5423 + //if listanager is visisble then close it
  5424 +
  5425 + $rootScope.isListManagerSelected = false;
  5426 + $rootScope.CloseListManager();
  5427 + // $('#btnIdentity').addClass('btn-primary');
  5428 +
  5429 + if ($scope.isTransparencyBtnClicked == true) {
  5430 +
  5431 + $scope.isTransparencyBtnClicked = false;
  5432 +
  5433 + var canvasDiv = document.getElementById('canvasDiv');
  5434 + canvasDiv.removeEventListener("mousedown", mouseDownListener);
  5435 +
  5436 + canvasDiv.removeEventListener("mousemove", mouseMoveListener);
  5437 +
  5438 + canvasDiv.removeEventListener("mouseup", mouseUpListener)
  5439 + $('#btnTranparency').removeClass('tButtonActive');
  5440 + $('#btnTranparency').addClass('btn-black');
  5441 + }
  5442 +
  5443 + }
  5444 +
  5445 + $scope.enableZoom = function () {
  5446 +
  5447 + $("#btnExtract").removeClass("disabled");
  5448 + $("#btnTranparency").removeClass("disabled");
  5449 + $rootScope.isTransparencyBoxActivated = false;
  5450 + $rootScope.isNormalMode = false;
  5451 +
  5452 +
  5453 + //if listanager is visisble then close it
  5454 +
  5455 + $rootScope.CloseListManager();
  5456 +
  5457 + $rootScope.isHighlightBodyByBodySystem = false;
  5458 +
  5459 +
  5460 + $('#sppeachBubble').css('display', 'none');
  5461 +
  5462 + $("#dot").css("display", "none");
  5463 +
  5464 + $scope.terminateCurrentlyRunningWPs();
  5465 +
  5466 + if ($scope.isTransparencyActivated) {
  5467 +
  5468 + $scope.CloseTransparencyBox();
  5469 +
  5470 + }
  5471 +
  5472 + $rootScope.isZoomed = true;
  5473 + //1.
  5474 +
  5475 + $scope.flushCanvas();
  5476 +
  5477 + if ($scope.zoomInOut == 25) {
  5478 + $scope.zoomInOut = 75;
  5479 +
  5480 + }
  5481 + else {
  5482 + $scope.zoomInOut = 25;
  5483 +
  5484 +
  5485 + }
  5486 +
  5487 + //2.
  5488 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  5489 +
  5490 + //3.
  5491 +
  5492 +
  5493 + if ($scope.zoomInOut == 25) {
  5494 + if ($('#canvasDiv') != null)
  5495 + $('#canvasDiv').scrollLeft(0)
  5496 +
  5497 + }
  5498 + else {
  5499 + if ($('#canvasDiv') != null)
  5500 + $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2)
  5501 +
  5502 +
  5503 + }
  5504 +
  5505 +
  5506 + //remove annotation speech bubble
  5507 + if ($('#dot').length > 0) {
  5508 + $('#dot').remove();
  5509 + }
  5510 +
  5511 + if ($('#sppeachBubble').length > 0) {
  5512 + $('#sppeachBubble').remove();
  5513 + }
  5514 +
  5515 + //4.
  5516 + if ($rootScope.isHighLight == true) {
  5517 +
  5518 + $timeout(function () { $scope.highLightBody() }, 50);
  5519 + }
  5520 + }
  5521 +
  5522 +
  5523 + $scope.flushCanvas = function () {
  5524 +
  5525 +
  5526 + $rootScope.isLoading = true;
  5527 + $('#spinner').css('visibility', 'visible');
  5528 +
  5529 + var endIndex = 0;
  5530 + var startIndex = 0;
  5531 + if (($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) {
  5532 + endIndex = 6;
  5533 + startIndex = 1;
  5534 + }
  5535 + else if (($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) {
  5536 + endIndex = 5;
  5537 + startIndex = 1;
  5538 + }
  5539 + else if (($rootScope.viewOrientationId == '5')) {
  5540 + endIndex = 6;
  5541 + startIndex = 2;
  5542 + }
  5543 + else if (($rootScope.viewOrientationId == '6')) {
  5544 + endIndex = 6;
  5545 + startIndex = 6;
  5546 + }
  5547 +
  5548 + for (var i = startIndex; i <= endIndex; i++) {
  5549 +
  5550 + var id;
  5551 + var maskId;
  5552 +
  5553 + id = 'imageCanvas' + i;
  5554 + maskId = 'imageCanvas' + i + '_mci';
  5555 +
  5556 + var canvas = document.getElementById(id);
  5557 + if (canvas != null || canvas != undefined)
  5558 + document.getElementById('canvasDiv').removeChild(canvas);
  5559 +
  5560 + var maskcanvas = document.getElementById(maskId);
  5561 + if (maskcanvas != null || maskcanvas != undefined)
  5562 + document.getElementById('canvasDiv').removeChild(maskcanvas);
  5563 +
  5564 + if (endIndex == 6) {
  5565 +
  5566 + if (i == 4 || i == 5 || i == 6) {
  5567 + id = 'imageCanvas' + i + '_MR';
  5568 + maskId = 'imageCanvas' + i + '_MR_mci';
  5569 +
  5570 + var canvas = document.getElementById(id);
  5571 + if (canvas != null || canvas != undefined)
  5572 + document.getElementById('canvasDiv').removeChild(canvas);
  5573 +
  5574 + var maskcanvas = document.getElementById(maskId);
  5575 + if (maskcanvas != null || maskcanvas != undefined)
  5576 + document.getElementById('canvasDiv').removeChild(maskcanvas);
  5577 + }
  5578 + }
  5579 +
  5580 + //remove modesty canavs
  5581 + var modestyCanvases = $("canvas[id*='imageCanvasmodestyImg']");
  5582 + if (modestyCanvases != null || modestyCanvases != undefined && modestyCanvases.length > 0) {
  5583 + for (var j = 0; j < modestyCanvases.length; j++) {
  5584 +
  5585 + modestyCanvases[j].parentNode.removeChild(modestyCanvases[j]);
  5586 + }
  5587 + }
  5588 + }
  5589 +
  5590 +
  5591 + }
  5592 + $scope.terminateCurrentlyRunningWPs = function () {
  5593 + if ($scope.runningWorkers != null || $scope.runningWorkers != undefined) {
  5594 + var workerCount = $scope.runningWorkers.length;
  5595 + if (workerCount > 0) {
  5596 + for (var i = workerCount - 1; i >= 0; i--) {
  5597 + var runningWorker = $scope.runningWorkers[i].workerName;
  5598 + runningWorker.terminate();
  5599 + $scope.runningWorkers.splice(i, 1);
  5600 + // workerCount--;
  5601 + }
  5602 + }
  5603 + }
  5604 + }
  5605 +
  5606 +
  5607 + $scope.enableHighlight = function () {
  5608 +
  5609 +
  5610 + // $("#btnExtract").removeClass("disabled");
  5611 + $("#btnTranparency").removeClass("disabled");
  5612 + // $rootScope.isTransparencyBoxActivated = false;
  5613 + // $rootScope.isNormalMode = false;
  5614 +
  5615 + //if listanager is visisble then close it
  5616 +
  5617 + // $rootScope.isListManagerSelected = false;
  5618 + $rootScope.CloseListManager();
  5619 +
  5620 + $rootScope.isHighlightBodyByBodySystem = false;
  5621 +
  5622 + if ($rootScope.isHighLight == true) {
  5623 +
  5624 + }
  5625 + else {
  5626 + $rootScope.isHighLight = true;
  5627 + $rootScope.isNormalMode = false;
  5628 + $rootScope.isZoomed = false;
  5629 +
  5630 + if ($rootScope.isExtract == true) {
  5631 + //1.
  5632 + $rootScope.isExtract = false;
  5633 +
  5634 + //2.
  5635 + $scope.flushCanvas();
  5636 +
  5637 + //3.
  5638 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  5639 +
  5640 +
  5641 + }
  5642 + else {
  5643 + console.log('highLightBody from enableHighlight')
  5644 + $timeout(function () { $scope.highLightBody() }, 50);
  5645 + }
  5646 +
  5647 + }
  5648 +
  5649 + // unhighlight other
  5650 +
  5651 + //$scope.Normal = "";
  5652 + //$scope.Extract = "";
  5653 + //$scope.Highlight = "LeftButtonsDefaultState";
  5654 +
  5655 + $("#btnHighLight").addClass("btn-primary");
  5656 + $("#btnHighLight").removeClass("btn-black");
  5657 +
  5658 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  5659 + $("#btnNormalMode").addClass("btn-black");
  5660 + }
  5661 +
  5662 + if (!$("#btnExtract").hasClass("btn-black")) {
  5663 + $("#btnExtract").addClass("btn-black");
  5664 + }
  5665 +
  5666 + if ($("#btnExtract").hasClass("btn-primary")) {
  5667 + $("#btnExtract").removeClass("btn-primary");
  5668 + }
  5669 +
  5670 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  5671 + $("#btnNormalMode").removeClass("btn-primary");
  5672 + }
  5673 +
  5674 + //7900
  5675 + $("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition);
  5676 + $("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition);
  5677 +
  5678 +
  5679 + }
  5680 +
  5681 + $scope.enableNormalMode = function () {
  5682 + $("#btnTranparency").removeClass("disabled");
  5683 + $rootScope.isNormalMode = false;
  5684 + console.log('enableNormalMode is called');
  5685 +
  5686 +
  5687 + // $rootScope.isHighLight = false;
  5688 +
  5689 + //to do should not call every time
  5690 + $rootScope.CloseListManager();
  5691 +
  5692 +
  5693 + $rootScope.isHighlightBodyByBodySystem = false;
  5694 +
  5695 +
  5696 + if ($rootScope.isNormalMode == true) {
  5697 +
  5698 +
  5699 +
  5700 +
  5701 +
  5702 + }
  5703 + else {
  5704 +
  5705 + //1.
  5706 + $scope.flushCanvas();
  5707 +
  5708 + //2.
  5709 + $rootScope.isNormalMode = true;
  5710 +
  5711 + //3.
  5712 + $rootScope.isHighLight = false;
  5713 +
  5714 + //4.
  5715 + $rootScope.isExtract = false;
  5716 +
  5717 + //5.
  5718 + $rootScope.isZoomed = false;
  5719 +
  5720 + //6.
  5721 + // $rootScope.isListManagerSelected = false;
  5722 + if ($rootScope.actualTermNumber != null && $rootScope.actualTermNumber != undefined && $rootScope.isListManagerSelected == true) {
  5723 + $rootScope.isListManagerSelected = false;
  5724 + $rootScope.isListManagerAlreadySelected = true;
  5725 + }
  5726 +
  5727 + //7.
  5728 +
  5729 + $scope.layerNumber = $('#txtlayerNumber').val();
  5730 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  5731 + // alert($rootScope.viewOrientationId + "gadash")
  5732 +
  5733 +
  5734 + $("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition);
  5735 + $("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition);
  5736 +
  5737 +
  5738 + }
  5739 +
  5740 + //$scope.Normal = "LeftButtonsDefaultState";
  5741 + //$scope.Extract = "";
  5742 + //$scope.Highlight = "";
  5743 + $("#btnNormalMode").addClass("btn-primary");
  5744 + $("#btnNormalMode").removeClass("btn-black");
  5745 +
  5746 + if (!$("#btnExtract").hasClass("btn-black")) {
  5747 + $("#btnExtract").addClass("btn-black");
  5748 + }
  5749 +
  5750 + if (!$("#btnHighLight").hasClass("btn-black")) {
  5751 + $("#btnHighLight").addClass("btn-black");
  5752 + }
  5753 +
  5754 + if ($("#btnExtract").hasClass("btn-primary")) {
  5755 + $("#btnExtract").removeClass("btn-primary");
  5756 + }
  5757 +
  5758 + if ($("#btnHighLight").hasClass("btn-primary")) {
  5759 + $("#btnHighLight").removeClass("btn-primary");
  5760 + }
  5761 + }
  5762 +
  5763 + // #7972 Mozilla Firefox> Incorrect navigation
  5764 + $("#canvasDiv").scroll(function (event) {
  5765 + $rootScope.CanvasDivTopPosition = $("#canvasDiv").scrollTop();
  5766 + $rootScope.CanvasDivLeftPosition = $("#canvasDiv").scrollLeft();
  5767 +
  5768 + });
  5769 +
  5770 +
  5771 +
  5772 + $scope.enableExtract = function (isCalledFromButton) {
  5773 +
  5774 + console.log('isCalledFromButton= ' + isCalledFromButton);
  5775 +
  5776 + $rootScope.isHighlightBodyByBodySystem = false;
  5777 +
  5778 +
  5779 + $rootScope.CanvasDivTopPosition = $("#canvasDiv").scrollTop();
  5780 +
  5781 + $rootScope.CanvasDivLeftPosition = $("#canvasDiv").scrollLeft();
  5782 +
  5783 +
  5784 + if ($scope.isTransparencyActivated == true) {
  5785 +
  5786 + $("#btnExtract").addClass("disabled");
  5787 +
  5788 + }
  5789 +
  5790 +
  5791 + else {
  5792 +
  5793 +
  5794 + $rootScope.CloseListManager();
  5795 + //1.
  5796 + //$rootScope.isLoading = true;
  5797 + //$('#spinner').css('visibility', 'visible');
  5798 +
  5799 + //2.
  5800 + $scope.terminateCurrentlyRunningWPs();
  5801 +
  5802 + //3.
  5803 + //if extarct is alraedy enabled and user cliked on any body part then extract that.
  5804 + if (isCalledFromButton == false) {
  5805 +
  5806 + $rootScope.isExtract = true;
  5807 + //disable transparency button
  5808 +
  5809 + $("#btnTranparency").addClass("disabled");
  5810 +
  5811 +
  5812 + if ($rootScope.isNormalMode == true) {
  5813 +
  5814 + $rootScope.isHighLight = false;
  5815 + $rootScope.isNormalMode = false;
  5816 + }
  5817 + else {
  5818 +
  5819 + $rootScope.isHighLight = false;
  5820 + }
  5821 +
  5822 + //4.
  5823 + console.log('highLightBody from enableExtract')
  5824 + $scope.highLightBody();
  5825 +
  5826 + }
  5827 + else {
  5828 +
  5829 + if ($rootScope.isExtract == true) {
  5830 +
  5831 + }
  5832 + else {
  5833 + $rootScope.isExtract = true;
  5834 + //disable transparency button
  5835 +
  5836 + $("#btnTranparency").addClass("disabled");
  5837 +
  5838 +
  5839 + if ($rootScope.isNormalMode == true) {
  5840 +
  5841 + $rootScope.isHighLight = false;
  5842 + $rootScope.isNormalMode = false;
  5843 + }
  5844 + else {
  5845 +
  5846 + $rootScope.isHighLight = false;
  5847 + }
  5848 +
  5849 + //4.
  5850 + console.log('highLightBody from enableExtract')
  5851 + $scope.highLightBody();
  5852 +
  5853 +
  5854 + }
  5855 + }
  5856 +
  5857 +
  5858 + //5. unhighlight other
  5859 + //$scope.Normal = "";
  5860 + //$scope.Extract = "LeftButtonsDefaultState";
  5861 + //$scope.Highlight = "";
  5862 +
  5863 + $("#btnExtract").addClass("btn-primary");
  5864 + $("#btnExtract").removeClass("btn-black");
  5865 +
  5866 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  5867 + $("#btnNormalMode").addClass("btn-black");
  5868 + }
  5869 +
  5870 + if (!$("#btnHighLight").hasClass("btn-black")) {
  5871 + $("#btnHighLight").addClass("btn-black");
  5872 + }
  5873 +
  5874 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  5875 + $("#btnNormalMode").removeClass("btn-primary");
  5876 + }
  5877 +
  5878 + if ($("#btnHighLight").hasClass("btn-primary")) {
  5879 + $("#btnHighLight").removeClass("btn-primary");
  5880 + }
  5881 + }
  5882 + }
  5883 +
  5884 + $scope.enableShowHideStructureBox = function () {
  5885 +
  5886 +
  5887 + //if listanager is visisble then close it
  5888 +
  5889 + $rootScope.isListManagerSelected = false;
  5890 + $rootScope.CloseListManager();
  5891 +
  5892 + $(".com").toggle();
  5893 + $('#dot').toggle();
  5894 + $('#bord').toggle();
  5895 + $('#sppeachBubble').toggle();
  5896 + $('#sppeachBubble_annotation').toggle();
  5897 +
  5898 + $("#bord_annotation").toggle();
  5899 + $("#dot_annotation").toggle();
  5900 + $(".dynCross_anno").parent().parent().parent().toggle();
  5901 +
  5902 + }
  5903 +
  5904 +
  5905 +
  5906 + $scope.highLightBody = function () {
  5907 +
  5908 +
  5909 + $scope.Normal = "";
  5910 + $scope.Extract = "";
  5911 + $scope.Highlight = "LeftButtonsDefaultState";
  5912 +
  5913 + console.log('highLightBody is called and ColoredImageSRC length: ' + $scope.ColoredImageSRC.length);
  5914 +
  5915 + $scope.terminateCurrentlyRunningWPs();
  5916 +
  5917 + //different body views have different count of bodyegions so the length of ColoredImageSRC will be different
  5918 + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
  5919 +
  5920 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
  5921 + $scope.doHighlightOrExtract = true;
  5922 + }
  5923 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
  5924 + $scope.doHighlightOrExtract = true;
  5925 + }
  5926 + else if ((($rootScope.viewOrientationId == '5')) && ($scope.ColoredImageSRC.length == 4)) {
  5927 + $scope.doHighlightOrExtract = true;
  5928 + }
  5929 + else if ((($rootScope.viewOrientationId == '6')) && ($scope.ColoredImageSRC.length == 1)) {
  5930 + $scope.doHighlightOrExtract = true;
  5931 + }
  5932 + else {
  5933 + $scope.doHighlightOrExtract = false;
  5934 + }
  5935 +
  5936 +
  5937 + if ($scope.doHighlightOrExtract == true) {
  5938 + if ($rootScope.isHighLight == true) {
  5939 +
  5940 + $scope.grayedBR = [];
  5941 +
  5942 + angular.forEach($scope.ColoredImageSRC, function (value, key) {
  5943 + console.log('$scope.ColoredImageSRC length before gray= ' + $scope.ColoredImageSRC.length)
  5944 + var id;
  5945 + if (value.haveMirror == 'true') {
  5946 + id = 'imageCanvas' + value.bodyRegionId + '_MR';
  5947 + }
  5948 + else {
  5949 + id = 'imageCanvas' + value.bodyRegionId;
  5950 + }
  5951 +
  5952 + var imageCanvas = document.getElementById(id);
  5953 +
  5954 + var width = value.Width;
  5955 + var ht = value.Height;
  5956 +
  5957 + var coloredCanvasContext = imageCanvas.getContext("2d");
  5958 + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
  5959 + var coloredImageDataVar = coloredImageData;
  5960 +
  5961 +
  5962 + //if (value.haveMirror == 'true') {
  5963 + // $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
  5964 + //}
  5965 + //else {
  5966 +
  5967 +
  5968 + // $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
  5969 +
  5970 + //}
  5971 +
  5972 +
  5973 + var context_gray = imageCanvas.getContext('2d');
  5974 +
  5975 + var dataURL = imageCanvas.toDataURL();
  5976 +
  5977 +
  5978 + var img = new Image();
  5979 +
  5980 + img.src = dataURL;
  5981 +
  5982 + img.onload = function () {
  5983 + console.log('Before BitmapData call, width: ' + Math.max(img.width) + ', height: ' + Math.max(img.height) + ' value.bodyRegionId= '
  5984 + + value.bodyRegionId)
  5985 +
  5986 + var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
  5987 + DAData.draw(img);
  5988 +
  5989 + var colorMode;
  5990 +
  5991 + if ($scope.isExtract == true) {
  5992 +
  5993 + if ((($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) || $rootScope.isListManagerSelected == true) {
  5994 +
  5995 + colorMode = $scope.applyWhiteMatrix(img, context_gray);
  5996 + }
  5997 + }
  5998 + else {
  5999 + colorMode = $scope.applyGrayMatrix(img, context_gray);
  6000 + }
  6001 +
  6002 + console.log('colorMode inside if = ' + colorMode);
  6003 +
  6004 +
  6005 + if (colorMode != undefined || colorMode != null) {
  6006 +
  6007 + $rootScope.isLoading = true;
  6008 + $('#spinner').css('visibility', 'visible');
  6009 +
  6010 +
  6011 + var zeroPoint = new Point();
  6012 +
  6013 + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
  6014 +
  6015 +
  6016 + context_gray.putImageData(DAData.data, 0, 0)
  6017 +
  6018 + //NIKI- to resolve lateral arm black issue in highlight mode
  6019 +
  6020 + if ($rootScope.viewOrientationId == 5 && (value.bodyRegionId == 6 || value.bodyRegionId == 4)) {
  6021 +
  6022 + var imgData = context_gray.getImageData(0, 0, width, ht);
  6023 + var data = imgData.data;
  6024 + var c = 0;
  6025 + for (var i = 0; i < data.length; i += 4) {
  6026 + if (data[i] == data[i + 1] && data[i + 1] == data[i + 2] && data[i + 2] === 0) {
  6027 + data[i + 3] = 0;
  6028 + }
  6029 +
  6030 + }
  6031 + context_gray.putImageData(imgData, 0, 0);
  6032 + }
  6033 +
  6034 + imageCanvas.style.visibility = 'visible';
  6035 + //push BRID into array
  6036 + $scope.grayedBR.push({ 'BRID': value.bodyRegionId });
  6037 +
  6038 + var grayImageData = context_gray.getImageData(0, 0, width, ht);
  6039 + var grayImageImageDataVar = grayImageData.data;
  6040 +
  6041 + if ($scope.isExtract == true) {
  6042 + if (value.haveMirror == 'true') {
  6043 + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  6044 + }
  6045 + else {
  6046 +
  6047 + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  6048 + }
  6049 + }
  6050 + else {
  6051 +
  6052 + if (value.haveMirror == 'true') {
  6053 + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  6054 + }
  6055 + else {
  6056 +
  6057 + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  6058 + }
  6059 + }
  6060 +
  6061 +
  6062 + if ($scope.grayedBR != null || $scope.grayedBR != undefined) {
  6063 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayedBR.length == 9)) {
  6064 + $scope.isEligibleForHighlightBodyByTermList = true;
  6065 + $scope.doHighlightOrExtract = false;
  6066 + }
  6067 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayedBR.length == 5)) {
  6068 + $scope.isEligibleForHighlightBodyByTermList = true;
  6069 + $scope.doHighlightOrExtract = false;
  6070 + }
  6071 + else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayedBR.length == 4)) {
  6072 + $scope.isEligibleForHighlightBodyByTermList = true;
  6073 + $scope.doHighlightOrExtract = false;
  6074 + }
  6075 + else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayedBR.length == 1)) {
  6076 + $scope.isEligibleForHighlightBodyByTermList = true;
  6077 + $scope.doHighlightOrExtract = false;
  6078 + }
  6079 + else {
  6080 +
  6081 + $scope.isEligibleForHighlightBodyByTermList = false;
  6082 + }
  6083 +
  6084 + if ($scope.isEligibleForHighlightBodyByTermList == true) {
  6085 + //DISABLE PROGERSS BAR FOR GENDER OR VIEW CHANGE
  6086 + // if ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) {
  6087 + //$scope.isLoading = false;
  6088 +
  6089 + //$('#spinner').css('visibility', 'hidden');
  6090 + //}
  6091 +
  6092 + if (($rootScope.isHighlightBodyByBodySystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) {
  6093 +
  6094 +
  6095 + $scope.isLoading = true;
  6096 +
  6097 + $('#spinner').css('visibility', 'visible');
  6098 + $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100);
  6099 + }
  6100 + else if (($rootScope.isListManagerSelected == true) || ($rootScope.previousHighlightList != null && $rootScope.previousHighlightList.length > 0) && ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) || $rootScope.isListManagerAlreadySelected == true) {
  6101 +
  6102 + // console.log('$scope.grayedBR.length is ' + $scope.grayedBR.length);
  6103 + $timeout(function () {
  6104 +
  6105 + $scope.isLoading = true;
  6106 + $('#spinner').css('visibility', 'visible');
  6107 +
  6108 + $scope.HighlightBodyByTermList($scope.AllTerms)
  6109 + }, 800);
  6110 +
  6111 + }
  6112 + else if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
  6113 + $scope.createTermListByPreviousTermsAndHighlight();
  6114 + }
  6115 +
  6116 + }
  6117 +
  6118 + }
  6119 +
  6120 + }
  6121 +
  6122 + // $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
  6123 +
  6124 + console.log('highlightboy. $rootScope.isExtract= ' + $rootScope.isExtract + ', $rootScope.previousHighlightList.length= ' + $rootScope.previousHighlightList.length)
  6125 + if ($rootScope.isExtract == true) {
  6126 + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
  6127 + console.log('1. $rootScope.isExtract=true and $rootScope.previousHighlightList != null')
  6128 +
  6129 + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
  6130 + }
  6131 + else if ($rootScope.isListManagerSelected == true) {
  6132 + console.log('1. $rootScope.isExtract=true and $rootScope.isListManagerSelected == true')
  6133 +
  6134 + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
  6135 +
  6136 + }
  6137 + }
  6138 + }
  6139 + })
  6140 +
  6141 + }
  6142 +
  6143 +
  6144 + else {
  6145 + // This code will execute when user will select normal Mode but this time isHighlight will be false
  6146 + console.log('highlightboy ELSE. $rootScope.isExtract= ' + $rootScope.isExtract + ', $rootScope.previousHighlightList.length= ' + $rootScope.previousHighlightList.length)
  6147 +
  6148 + angular.forEach($scope.ColoredImageSRC, function (value, key) {
  6149 + var id;
  6150 + if (value.haveMirror == 'true') {
  6151 + id = 'imageCanvas' + value.bodyRegionId + '_MR';
  6152 + }
  6153 + else {
  6154 + id = 'imageCanvas' + value.bodyRegionId;
  6155 + }
  6156 +
  6157 + var imageCanvas = document.getElementById(id);
  6158 +
  6159 + //var coloredCanvasID = 'imageCanvas' + bodyRegionId;
  6160 + //var coloredCanvas = document.getElementById(coloredCanvasID);
  6161 +
  6162 + var width = value.Width;
  6163 + var ht = value.Height;
  6164 +
  6165 + var coloredCanvasContext = imageCanvas.getContext("2d");
  6166 + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
  6167 + var coloredImageDataVar = coloredImageData;
  6168 +
  6169 +
  6170 + //if (value.haveMirror == 'true') {
  6171 + // $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
  6172 + //}
  6173 + //else {
  6174 +
  6175 + // $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
  6176 +
  6177 + //}
  6178 +
  6179 +
  6180 + var context = imageCanvas.getContext('2d');
  6181 +
  6182 +
  6183 + var dataURL = imageCanvas.toDataURL();
  6184 +
  6185 +
  6186 + var img = new Image();
  6187 +
  6188 + img.src = dataURL;
  6189 +
  6190 +
  6191 +
  6192 + img.onload = function () {
  6193 + //console.log(Math.max(img.width) + ', ' + Math.max(img.height))
  6194 +
  6195 + var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
  6196 + DAData.draw(img);
  6197 +
  6198 + var colorMode;
  6199 +
  6200 + if ($scope.isExtract == true) {
  6201 + if ((($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) || $rootScope.isListManagerSelected == true) {
  6202 +
  6203 + colorMode = $scope.applyWhiteMatrix(img, context);
  6204 + }
  6205 + }
  6206 +
  6207 + console.log('colorMode inside else = ' + colorMode);
  6208 + if (colorMode != undefined || colorMode != null) {
  6209 +
  6210 + $rootScope.isLoading = true;
  6211 + $('#spinner').css('visibility', 'visible');
  6212 +
  6213 + var zeroPoint = new Point();
  6214 +
  6215 + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
  6216 +
  6217 + context.putImageData(DAData.data, 0, 0)
  6218 +
  6219 +
  6220 + //NIKI- to resolve lateral arm black issue in mode
  6221 +
  6222 + if ($rootScope.viewOrientationId == 5 && (value.bodyRegionId == 6 || value.bodyRegionId == 4)) {
  6223 +
  6224 + var imgData = context.getImageData(0, 0, width, ht);
  6225 + var data = imgData.data;
  6226 + var c = 0;
  6227 + for (var i = 0; i < data.length; i += 4) {
  6228 + if (data[i] == data[i + 1] && data[i + 1] == data[i + 2] && data[i + 2] === 0) {
  6229 + data[i + 3] = 0;
  6230 + }
  6231 +
  6232 + }
  6233 + context.putImageData(imgData, 0, 0);
  6234 + }
  6235 +
  6236 + imageCanvas.style.visibility = 'visible'
  6237 + var grayImageData = context.getImageData(0, 0, width, ht);
  6238 + var grayImageImageDataVar = grayImageData.data;
  6239 +
  6240 + if ($scope.isExtract == true) {
  6241 + if (value.haveMirror == 'true') {
  6242 + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  6243 + }
  6244 + else {
  6245 +
  6246 + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  6247 + }
  6248 + }
  6249 + else {
  6250 +
  6251 + if (value.haveMirror == 'true') {
  6252 + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  6253 + }
  6254 + else {
  6255 +
  6256 + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  6257 + }
  6258 + }
  6259 + }
  6260 +
  6261 + // $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
  6262 + }
  6263 + })
  6264 +
  6265 + if ($rootScope.isExtract == true) {
  6266 + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
  6267 + console.log('2. $rootScope.isExtract=true and $rootScope.previousHighlightList != null, $rootScope.previousHighlightList.length= ' + $rootScope.previousHighlightList.length)
  6268 +
  6269 +
  6270 + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
  6271 +
  6272 + // to do
  6273 +
  6274 + }
  6275 + else if ($rootScope.isListManagerSelected == true) {
  6276 + console.log('2. $rootScope.isExtract=true and $rootScope.isListManagerSelected == true')
  6277 + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
  6278 +
  6279 + }
  6280 + }
  6281 +
  6282 + }
  6283 + }
  6284 + }
  6285 + }
  6286 +
  6287 +
  6288 + $scope.applyGrayMatrix = function (img, context_gray) {
  6289 + var RED = 0.3086; // luminance contrast value for red
  6290 + var GREEN = 0.694; // luminance contrast value for green
  6291 + var BLUE = 0.0820; // luminance contrast value for blue
  6292 +
  6293 + var RGB = [RED, GREEN, BLUE, 0, 0];
  6294 + var RGB2 = [RED, GREEN, BLUE, 0, 0];
  6295 + var RGB3 = [RED, GREEN, BLUE, 0, 0];
  6296 + var ALPHA = [0, 0, 0, 1, 0];
  6297 +
  6298 + var rgbPx = RGB.concat(RGB2);
  6299 + var rgbPx2 = rgbPx.concat(RGB3);
  6300 + var matrix = rgbPx2.concat(ALPHA);
  6301 +
  6302 +
  6303 + var grayScale = new ColorMatrixFilter(matrix);
  6304 +
  6305 + return grayScale;
  6306 + }
  6307 +
  6308 + $scope.applyWhiteMatrix = function (img, context_gray) {
  6309 + var RED = 255; // white color value for red
  6310 + var GREEN = 255; // white color value for green
  6311 + var BLUE = 255; // white color value for blue
  6312 +
  6313 + var RGB = [RED, GREEN, BLUE, 0, 0];
  6314 + var RGB2 = [RED, GREEN, BLUE, 0, 0];
  6315 + var RGB3 = [RED, GREEN, BLUE, 0, 0];
  6316 + var ALPHA = [0, 0, 0, 1, 0];
  6317 +
  6318 + var rgbPx = RGB.concat(RGB2);
  6319 + var rgbPx2 = rgbPx.concat(RGB3);
  6320 + var matrix = rgbPx2.concat(ALPHA);
  6321 +
  6322 +
  6323 + var grayScale = new ColorMatrixFilter(matrix);
  6324 +
  6325 + return grayScale;
  6326 + }
  6327 +
  6328 + $scope.getActualTermNumber = function (iColor) {
  6329 + $scope.actualTermNo = new jinqJs()
  6330 + .from($rootScope.TermNumberData.TermData.Term)
  6331 + .where('_TermNumber == ' + iColor)
  6332 + .select('_ActualTermNumber');
  6333 + if ($scope.actualTermNo != null || actualTermNo != undefined) {
  6334 +
  6335 + return $scope.actualTermNo[0]._ActualTermNumber;
  6336 + }
  6337 + else {
  6338 + return null;
  6339 + }
  6340 + }
  6341 +
  6342 + $scope.getTermNumberList = function (actualTermNo) {
  6343 + $scope.termList = new jinqJs()
  6344 + .from($rootScope.TermNumberData.TermData.Term)
  6345 + .where('_ActualTermNumber == ' + actualTermNo)
  6346 + .select();
  6347 + if ($scope.termList != null || $scope.termList != undefined) {
  6348 + return $scope.termList;
  6349 + }
  6350 + else {
  6351 + return null;
  6352 + }
  6353 +
  6354 + }
  6355 +
  6356 +
  6357 + $scope.OnGenderChange = function (event) {
  6358 +
  6359 + var canvasDiv = document.getElementById('canvasDiv');
  6360 + $scope.imageVerticalScrollPosition = canvasDiv.scrollTop;
  6361 + $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft;
  6362 +
  6363 + $("#btnExtract").removeClass("disabled");
  6364 + $("#btnTranparency").removeClass("disabled");
  6365 + $rootScope.isTransparencyBoxActivated = false;
  6366 + $rootScope.isNormalMode = false;
  6367 +
  6368 + //close transparecny box
  6369 + $scope.CloseTransparencyBox();
  6370 +
  6371 + //if listanager is visisble then close it
  6372 +
  6373 + // $rootScope.isListManagerSelected = false;
  6374 + $rootScope.CloseListManager();
  6375 +
  6376 + // $rootScope.isHighlightBodyByBodySystem = false;
  6377 +
  6378 +
  6379 +
  6380 + $rootScope.isGenderChnage = true;
  6381 +
  6382 +
  6383 + if ($rootScope.isExtract == true) {
  6384 + $rootScope.isExtract = false;
  6385 + $rootScope.isHighLight = true;
  6386 + $("#btnExtract").removeClass("btn-primary");
  6387 + $("#btnExtract").addClass("btn-black");
  6388 + $("#btnHighLight").removeClass("btn-black");
  6389 + $("#btnHighLight").addClass("btn-primary");
  6390 +
  6391 +
  6392 + }
  6393 +
  6394 +
  6395 + var viewname = localStorage.getItem("currentViewTitle")
  6396 + var currentBodyViewId = $scope.correspondingBodyViewIds[$rootScope.voId];
  6397 +
  6398 +
  6399 + if ((event.currentTarget.title == 'Male') && (localStorage.getItem("genderId") == 'Female')) {
  6400 +
  6401 + //1.
  6402 + localStorage.setItem("genderId", 'Male');
  6403 +
  6404 + //2 first update the currentbodyviewid in local storage
  6405 + localStorage.setItem("currentBodyViewId", currentBodyViewId);
  6406 +
  6407 + $rootScope.isLoading = true;
  6408 + $('#spinner').css('visibility', 'visible');
  6409 + //3.
  6410 +
  6411 + $scope.layerNumber = 0;
  6412 + $scope.loadSelectedBodyView(currentBodyViewId);
  6413 +
  6414 +
  6415 + //4.
  6416 + $scope.loadSelectedBodyViewNavigator(currentBodyViewId);
  6417 +
  6418 + //5. change the search terms as per the selected bodyview
  6419 + $scope.loadSearchDataForBodyView();
  6420 +
  6421 + //6.
  6422 + $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Female', 'Male');
  6423 +
  6424 + localStorage.setItem("currentViewTitle", localStorage.getItem("currentViewTitle").replace('Female', 'Male'));
  6425 +
  6426 +
  6427 + $rootScope.isLoading = true;
  6428 +
  6429 + }
  6430 +
  6431 + else if ((event.currentTarget.title == 'Female') && (localStorage.getItem("genderId") == 'Male')) {
  6432 +
  6433 + //1.
  6434 + localStorage.setItem("genderId", 'Female');
  6435 +
  6436 + //2. first update the currentbodyviewid in local storage
  6437 + localStorage.setItem("currentBodyViewId", currentBodyViewId);
  6438 +
  6439 + $rootScope.isLoading = true;
  6440 + $('#spinner').css('visibility', 'visible');
  6441 + //3.
  6442 +
  6443 + $scope.layerNumber = 0;
  6444 + $scope.loadSelectedBodyView(currentBodyViewId);
  6445 +
  6446 +
  6447 + //4.
  6448 + $scope.loadSelectedBodyViewNavigator(currentBodyViewId);
  6449 +
  6450 + //5. change the search terms as per the selected bodyview
  6451 + $scope.loadSearchDataForBodyView();
  6452 +
  6453 + //6.
  6454 + $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Male', 'Female');
  6455 +
  6456 + localStorage.setItem("currentViewTitle", localStorage.getItem("currentViewTitle").replace('Male', 'Female'));
  6457 +
  6458 +
  6459 + $rootScope.isLoading = true;
  6460 +
  6461 + }
  6462 +
  6463 + $rootScope.openViews.push(
  6464 + {
  6465 + "module": $rootScope.currentActiveModuleTitle, "bodyView": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": currentBodyViewId,
  6466 + "slug": $rootScope.currentSlug
  6467 + }
  6468 + );
  6469 +
  6470 + var target = angular.element(event.currentTarget);
  6471 + var title_male_female = target.attr('title');
  6472 +
  6473 + if (title_male_female == "Male") {
  6474 +
  6475 + $scope.male = "active";
  6476 + $scope.female = "";
  6477 + }
  6478 + else {
  6479 + $scope.male = "";
  6480 + $scope.female = "active";
  6481 + }
  6482 +
  6483 + }
  6484 +
  6485 +
  6486 + //clsoe worker process
  6487 + $scope.$on('jsPanelCloseEvent', function (event, data) {
  6488 +
  6489 +
  6490 +
  6491 + console.log('terminate worker process')
  6492 + //terminate previous running workers to create space for new workers
  6493 + $scope.terminateCurrentlyRunningWPs();
  6494 +
  6495 + $rootScope.isLoading = false;
  6496 + $('#spinner').css('visibility', 'hidden');
  6497 +
  6498 + //To fix issue of gray maintained in after closing jspanel after listmanager selection
  6499 + $rootScope.isListManagerSelected = false;
  6500 + $rootScope.isHighLight = false;
  6501 + //$rootScope.isNormalMode = false;
  6502 + $rootScope.isHighlightBodyByBodySystem = false;
  6503 + $rootScope.CloseListManager();
  6504 + })
  6505 +
  6506 + $scope.loadSelectedBodyView = function (currentBodyViewId) {
  6507 +
  6508 + //remove transaprency scale
  6509 + if ($('#transparencyScale') != null) {
  6510 +
  6511 + $('#transparencyScale').css('visibility', 'hidden');
  6512 + }
  6513 +
  6514 +
  6515 + $rootScope.voId = currentBodyViewId;
  6516 +
  6517 + var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json';
  6518 +
  6519 + DataService.getJson(layerJsonPath)
  6520 + .then(
  6521 + function (result) {
  6522 + //debugger;
  6523 +
  6524 + $rootScope.BodyLayerData = result;
  6525 +
  6526 + var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
  6527 +
  6528 + //set max for LayerNumber input
  6529 + $rootScope.totalLayers = dataLength - 1;
  6530 +
  6531 + $('#txtLayerNumber').attr('max', $rootScope.totalLayers);
  6532 + $('#layerChangeSlider').slider("option", "max", $rootScope.totalLayers);
  6533 +
  6534 + //set max for LayerNumber input
  6535 + $rootScope.totalLayers = dataLength - 1;
  6536 +
  6537 + $scope.isBodylayerdataLoaded = true;
  6538 +
  6539 + //load json for annotations
  6540 + // $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) {
  6541 + var termJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_tm_sg_' + currentBodyViewId + '.json';
  6542 + DataService.getAnotherJson(termJsonPath)
  6543 + .then(
  6544 + function (result) {
  6545 + $rootScope.TermNumberData = result;
  6546 +
  6547 + var canDiv = document.getElementById('canvasDiv');
  6548 + var canDivChildCount = canDiv.childElementCount;
  6549 + if (canDivChildCount > 0) {
  6550 + canDiv.innerHTML = '';
  6551 + }
  6552 + //if user seelcted any term and serached before gender cnage then itshould be highlighted in chnaged gender
  6553 +
  6554 + if ((($rootScope.isListManagerSelected == true) || ($rootScope.isHighLight == true && $rootScope.previousHighlightList != null && $rootScope.previousHighlightList.length > 0)) && (($rootScope.isGenderChnage == true) || $rootScope.isViewChange == true)) {
  6555 +
  6556 + $scope.setLayerNumberAndHighlightByTermList();
  6557 +
  6558 + }
  6559 +
  6560 + else {
  6561 +
  6562 + $scope.CalculateImageCordinates($rootScope.viewOrientationId);
  6563 +
  6564 + }
  6565 +
  6566 + $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
  6567 + },
  6568 + function (error) {
  6569 + // handle errors here
  6570 + console.log(' $rootScope.TermNumberData= ' + error.statusText);
  6571 + }
  6572 + )
  6573 + },
  6574 +
  6575 + function (error) {
  6576 + // handle errors here
  6577 + console.log(' $rootScope.BodyLayerData= ' + error.statusText);
  6578 + }
  6579 + );
  6580 + }
  6581 +
  6582 + $scope.OnViewChange = function (event) {
  6583 +
  6584 + var canvasDiv = document.getElementById('canvasDiv');
  6585 + $scope.imageVerticalScrollPosition = canvasDiv.scrollTop;
  6586 + $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft;
  6587 +
  6588 + $("#btnExtract").removeClass("disabled");
  6589 + $("#btnTranparency").removeClass("disabled");
  6590 + $rootScope.isTransparencyBoxActivated = false;
  6591 + $rootScope.isNormalMode = false;
  6592 +
  6593 + //close transparency box
  6594 + $scope.CloseTransparencyBox();
  6595 +
  6596 + //if listanager is visisble then close it
  6597 +
  6598 + //$rootScope.isListManagerSelected = false;
  6599 + $rootScope.CloseListManager();
  6600 +
  6601 + // $rootScope.isHighlightBodyByBodySystem = false;
  6602 +
  6603 +
  6604 +
  6605 + if ($rootScope.openViews.length > 0) {
  6606 + $rootScope.openViews.splice($rootScope.openViews.length - 1);
  6607 + }
  6608 +
  6609 + $rootScope.isViewChange = true;
  6610 +
  6611 + if ($rootScope.isExtract == true) {
  6612 + $rootScope.isExtract = false;
  6613 + $rootScope.isHighLight = true;
  6614 + $("#btnExtract").removeClass("btn-primary");
  6615 + $("#btnExtract").addClass("btn-black");
  6616 + $("#btnHighLight").removeClass("btn-black");
  6617 + $("#btnHighLight").addClass("btn-primary");
  6618 + }
  6619 +
  6620 + $scope.layerNumber = 0;
  6621 + // debugger;
  6622 + //var selectedViewId = $scope.bodyViews[event.currentTarget.attributes[1].value];
  6623 + var selectedViewId = $scope.bodyViews[event.currentTarget.title];
  6624 +
  6625 + $rootScope.viewOrientationId = selectedViewId;
  6626 + if (localStorage.getItem("genderId") == 'Male') {
  6627 + if ($rootScope.voId != selectedViewId) {
  6628 + if (selectedViewId == 5) {
  6629 + $rootScope.voId = 9;
  6630 + }
  6631 + else if (selectedViewId == 6) {
  6632 + $rootScope.voId = 10;
  6633 + }
  6634 + else
  6635 + $rootScope.voId = selectedViewId;
  6636 + $rootScope.isLoading = true;
  6637 +
  6638 + $rootScope.isLoading = true;
  6639 + $('#spinner').css('visibility', 'visible');
  6640 +
  6641 + //1. first update the currentbodyviewid in local storage
  6642 + localStorage.setItem("currentBodyViewId", $rootScope.voId);
  6643 +
  6644 + //2. Load selected body view
  6645 + $scope.loadSelectedBodyView($rootScope.voId);
  6646 +
  6647 + //3. load corresponding navigator man
  6648 + $scope.loadSelectedBodyViewNavigator($rootScope.voId);
  6649 +
  6650 + //4. change the search terms as per the selected bodyview
  6651 + $scope.loadSearchDataForBodyView();
  6652 +
  6653 + //5.Change the popup title next to search
  6654 + $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
  6655 +
  6656 + };
  6657 +
  6658 +
  6659 + //set selected view name as the title of jspanel
  6660 + // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") +" "+ event.currentTarget.attributes[1].value;
  6661 +
  6662 + }
  6663 + else {
  6664 + if (selectedViewId == 5) {
  6665 + selectedViewId = 11;
  6666 + }
  6667 + else if (selectedViewId == 6) {
  6668 + selectedViewId = 12;
  6669 + }
  6670 + else
  6671 + selectedViewId = $scope.correspondingBodyViewIds[selectedViewId];;
  6672 + if ($rootScope.voId != selectedViewId) {
  6673 + $rootScope.voId = selectedViewId;
  6674 + $rootScope.isLoading = true;
  6675 +
  6676 + $rootScope.isLoading = true;
  6677 + $('#spinner').css('visibility', 'visible');
  6678 + //1.
  6679 + $scope.loadSelectedBodyView($rootScope.voId);
  6680 +
  6681 + //2.
  6682 + $scope.loadSelectedBodyViewNavigator($rootScope.voId);
  6683 + };
  6684 +
  6685 +
  6686 + // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + $scope.bodyViews[event.currentTarget.attributes[1].value;
  6687 +
  6688 + }
  6689 + $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + event.currentTarget.title;
  6690 + localStorage.setItem("currentViewTitle", localStorage.getItem("genderId") + " " + event.currentTarget.title);
  6691 +
  6692 +
  6693 + $rootScope.openViews.push(
  6694 + {
  6695 + "module": $rootScope.currentActiveModuleTitle, "bodyView": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": $rootScope.voId,
  6696 + "slug": $rootScope.currentSlug
  6697 + }
  6698 + );
  6699 +
  6700 + var viewtarget = angular.element(event.currentTarget);
  6701 + var title_drop_view = viewtarget.attr('title');
  6702 +
  6703 + if (title_drop_view == "Anterior") {
  6704 +
  6705 + $scope.AnteriorView = "active";
  6706 + $scope.LateralView = "";
  6707 + $scope.MedialView = "";
  6708 + $scope.PosteriorView = "";
  6709 + $scope.LateralArmView = "";
  6710 + $scope.MedialArmView = "";
  6711 +
  6712 + }
  6713 + else if (title_drop_view == "Lateral") {
  6714 +
  6715 + $scope.AnteriorView = "";
  6716 + $scope.LateralView = "active";
  6717 + $scope.MedialView = "";
  6718 + $scope.PosteriorView = "";
  6719 + $scope.LateralArmView = "";
  6720 + $scope.MedialArmView = "";
  6721 + }
  6722 + else if (title_drop_view == "Medial") {
  6723 +
  6724 + $scope.AnteriorView = "";
  6725 + $scope.LateralView = "";
  6726 + $scope.MedialView = "active";
  6727 + $scope.PosteriorView = "";
  6728 + $scope.LateralArmView = "";
  6729 + $scope.MedialArmView = "";
  6730 + }
  6731 + else if (title_drop_view == "Posterior") {
  6732 +
  6733 + $scope.AnteriorView = "";
  6734 + $scope.LateralView = "";
  6735 + $scope.MedialView = "";
  6736 + $scope.PosteriorView = "active";
  6737 + $scope.LateralArmView = "";
  6738 + $scope.MedialArmView = "";
  6739 + }
  6740 + else if (title_drop_view == "Lateral Arm") {
  6741 +
  6742 + $scope.AnteriorView = "";
  6743 + $scope.LateralView = "";
  6744 + $scope.MedialView = "";
  6745 + $scope.PosteriorView = "";
  6746 + $scope.LateralArmView = "active";
  6747 + $scope.MedialArmView = "";
  6748 + }
  6749 + else if (title_drop_view == "Medial Arm") {
  6750 +
  6751 + $scope.AnteriorView = "";
  6752 + $scope.LateralView = "";
  6753 + $scope.MedialView = "";
  6754 + $scope.PosteriorView = "";
  6755 + $scope.LateralArmView = "";
  6756 + $scope.MedialArmView = "active";
  6757 + }
  6758 + }
  6759 +
  6760 + //Reload DA controller event listener after setting change
  6761 + $scope.$on('reloadDAControllerEvent', function (event, data) {
  6762 + console.log('reloadDAControllerEvent');
  6763 +
  6764 + $scope.loadDissectibleAnatomyData();
  6765 +
  6766 + })
  6767 +
  6768 + //Reload DA controller Body View after setting Change
  6769 + $scope.$on('reloadDABodyViewEvent', function (event, data) {
  6770 + //console.log('reloadDABodyViewEvent');
  6771 + $scope.layerNumber = parseInt($('#txtlayerNumber').val());
  6772 + //alert('mouseUp');
  6773 +
  6774 +
  6775 + if ($scope.layerNumber == 0) {
  6776 + $scope.loadSelectedBodyView(data.reloadDABodyViewId);
  6777 + }
  6778 + // $scope.loadSelectedBodyView(data.reloadDABodyViewId);
  6779 +
  6780 + $scope.loadSelectedBodyViewNavigator(data.reloadDABodyViewId);
  6781 +
  6782 + // $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
  6783 +
  6784 + //$rootScope.isSettingEventAlredayDispachted = false;
  6785 + //}
  6786 +
  6787 + })
  6788 +
  6789 +
  6790 +
  6791 + $scope.loadSelectedBodyViewNavigator = function (currentBodyViewId) {
  6792 +
  6793 + //$rootScope.voId = currentBodyViewId;
  6794 +
  6795 + //$scope.skinTone = $rootScope.globalSetting.ethnicity;
  6796 +
  6797 + if ($scope.NavigatorData != null || $scope.NavigatorData != undefined) {
  6798 + var navdtlOrient = new jinqJs()
  6799 + .from($scope.NavigatorData.Navigtor.ViewOrientation)
  6800 + .where("_ViewOrientationId == " + currentBodyViewId)
  6801 + .select();
  6802 +
  6803 +
  6804 + if (navdtlOrient != null || navdtlOrient != undefined) {
  6805 +
  6806 + var navOrientationdata = new jinqJs()
  6807 + .from(navdtlOrient[0].ImageInfo)
  6808 + .where("_Ethnicity == " + $rootScope.globalSetting.ethnicity)
  6809 + .select();
  6810 +
  6811 + if (navOrientationdata != null || navOrientationdata != undefined) {
  6812 +
  6813 + $scope.navigatorImage = navOrientationdata;
  6814 +
  6815 +
  6816 + var navImageModesty;
  6817 +
  6818 + angular.forEach($scope.navigatorImage, function (value, key) {
  6819 + if (value._HaveModesty === $rootScope.globalSetting.modesty) {
  6820 + navImageModesty = value._ImageName;
  6821 + }
  6822 + })
  6823 + if (typeof (navImageModesty) === "undefined" || navImageModesty === null) {
  6824 +
  6825 + navImageModesty = $scope.navigatorImage[0]._ImageName;
  6826 +
  6827 + }
  6828 +
  6829 + $scope.navimgsrc = "~/../content/images/DA/ethnicity/body-views/" + $scope.voId + '/' + $rootScope.globalSetting.ethnicity + '/navigator_images/' + navImageModesty;
  6830 + }
  6831 + }
  6832 +
  6833 + }
  6834 +
  6835 + }
  6836 +
  6837 + //Annotation tool event lsitener
  6838 +
  6839 + // $scope.drawing = drawing;
  6840 + // $scope.lastX = lastX;
  6841 + // $scope.lastY = lastY;
  6842 + // $scope.currentX;
  6843 + // $scope.currentY;
  6844 + //----Annotation Toolbar: Jcanvas---
  6845 +
  6846 + $rootScope.$on('annotationToolEvent', function (event, data) {
  6847 + $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)")
  6848 + $('#editstylebackgroundcolor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
  6849 + $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)")
  6850 + $('#outlineColor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
  6851 +
  6852 + $("#canvas").css("display", "block");
  6853 + $("#canvasPaint").css("display", "block");
  6854 + $rootScope.BindCanvasDrawingListners();
  6855 + $rootScope.FreeStylePaint();
  6856 + });
  6857 + $scope.mousePs;
  6858 + function OnPaintCanvasClick(event) {
  6859 +
  6860 +
  6861 +
  6862 + }
  6863 +
  6864 +
  6865 +
  6866 +
  6867 +
  6868 + $rootScope.FreeStylePaint = function (e) {
  6869 +
  6870 + var annotationCanvas = document.getElementById("canvas");
  6871 + // document.getElementById("canvasPaint").addEventListener("mouseup", OnPaintBrushCanvasMouseUp);
  6872 +
  6873 + annotationCanvas.addEventListener('mousedown', $scope.OnPaintCanvasMouseDown, false);
  6874 +
  6875 + annotationCanvas.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false);
  6876 + }
  6877 + $scope.OnPaintCanvasMouseDown = function (event) {
  6878 + $rootScope.isMousedownOnPaintCanvas = true;
  6879 + $scope.isStartPointDeleted = false;
  6880 + var annotationCanvas = document.getElementById("canvas");
  6881 + $scope.startPageX = parseInt(event.clientX - ($("#canvas").offset().left));
  6882 + $scope.startPageY = parseInt(event.clientY - ($("#canvas").offset().top));
  6883 +
  6884 + annotationCanvas.addEventListener('mousemove', $scope.OnPaintCanvasMouseMove, false);
  6885 +
  6886 +
  6887 +
  6888 + }
  6889 + $scope.OnPaintCanvasMouseMove = function (event) {
  6890 +
  6891 +
  6892 + $rootScope.xPage = parseInt(event.clientX - ($("#canvas").offset().left));
  6893 + $rootScope.yPage = parseInt(event.clientY - ($("#canvas").offset().top));
  6894 +
  6895 + var btneraseBrushSizeValue = $("#btnBrushSize").val();
  6896 + $rootScope.eraseshapeSize = parseInt(btneraseBrushSizeValue);
  6897 +
  6898 + if ($rootScope.isEraseToolSelected == true && $rootScope.isMousedownOnPaintCanvas == true) {
  6899 +
  6900 + var sktch = $('#canvasPaint').sketch();
  6901 + $('#canvasPaint').sketch().actions = [];
  6902 + var paintCanvas = document.getElementById("canvasPaint");
  6903 + var paintCanvasContext = paintCanvas.getContext('2d');
  6904 + if ($scope.isStartPointDeleted == false) {
  6905 +
  6906 + paintCanvasContext.clearRect($scope.startPageX, $scope.startPageY, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize);
  6907 +
  6908 + $scope.isStartPointDeleted = true;
  6909 + }
  6910 +
  6911 + paintCanvasContext.clearRect($rootScope.xPage, $rootScope.yPage, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize);
  6912 +
  6913 +
  6914 + }
  6915 + }
  6916 + $scope.OnPaintBrushCanvasMouseDown = function (event) {
  6917 + switch ($rootScope.shapeType) {
  6918 +
  6919 + case "FreeStylePaint":
  6920 +
  6921 +
  6922 +
  6923 + // $('#canvasPaint').sketch();
  6924 + // $('#canvasPaint').sketch({ defaultSize: 1 });
  6925 + // if ($("#amount-2").val() == '') {
  6926 + // //$('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
  6927 + // $('#canvasPaint').sketch();
  6928 + // }
  6929 + // else {
  6930 +
  6931 + // // var a = $("#amount-2").val();
  6932 + //// $scope.shapesize = parseInt(a);
  6933 + // // $('#canvasPaint').sketch({ defaultSize: $rootScope.shapeSize });
  6934 + // // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
  6935 +
  6936 + // }
  6937 +
  6938 +
  6939 + break;
  6940 +
  6941 + }
  6942 + }
  6943 + $scope.OnPaintBrushCanvasMouseUp = function (event) {
  6944 + $rootScope.isMousedownOnPaintCanvas = false;
  6945 + $rootScope.isEraseToolSelected = false;
  6946 +
  6947 + // var canvasElement1 = document.getElementById("canvasPaint");
  6948 + // var ctx1 = canvasElement1.getContext("2d");
  6949 +
  6950 + //switch($rootScope.shapeType)
  6951 + //{
  6952 +
  6953 + // case "FreeStylePaint":
  6954 +
  6955 +
  6956 + // if ($("#amount-2").val() == '')
  6957 + // {
  6958 + // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
  6959 + // }
  6960 + // else
  6961 + // {
  6962 +
  6963 + // var a = $("#amount-2").val();
  6964 + // $scope.shapesize = parseInt(a);
  6965 + // alert(JSON.stringify({ defaultSize: $scope.shapesize }));
  6966 + // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
  6967 +
  6968 + // }
  6969 +
  6970 +
  6971 + // break;
  6972 +
  6973 + //}
  6974 +
  6975 + }
  6976 +
  6977 +
  6978 +
  6979 +
  6980 +
  6981 + //body highlight options functinality
  6982 + $scope.LoadBodySystemData = function () {
  6983 +
  6984 + var currentBodyViewId = $rootScope.voId;
  6985 + var systemListHtml = '<ul class="dropdown-menu" aria-labelledby="dropdownMenu2"><li><a href="#" title="Current Structure">Current Structure</a></li> <li role="separator" class="divider"></li>'
  6986 + var systemList = $rootScope.CommonData.DACommonData.BodySystems.Item;
  6987 +
  6988 + angular.forEach(systemList, function (value, key) {
  6989 +
  6990 + systemListHtml = systemListHtml + '<li><a href="#" id="' + value._BodySystemId + '" title="' + value._Name + '">' + value._Name + '</a></li>'
  6991 + })
  6992 +
  6993 + systemListHtml = systemListHtml + '</ul>';
  6994 + $('#bodySystem').append(systemListHtml);
  6995 +
  6996 + var bodySystemDataPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_body_system_term_' + currentBodyViewId + '.json';
  6997 + DataService.getJson(bodySystemDataPath)
  6998 + .then(
  6999 + function (result) {
  7000 +
  7001 + $rootScope.BodySystemData = result;
  7002 +
  7003 + },
  7004 + function (error) {
  7005 + console.log(error.statusText)
  7006 + }
  7007 + )
  7008 +
  7009 + }
  7010 +
  7011 + $scope.HighlightBodyByBodySystem = function (event) {
  7012 +
  7013 + //if listanager is visisble then close it
  7014 +
  7015 + $rootScope.isListManagerSelected = false;
  7016 + $rootScope.CloseListManager();
  7017 +
  7018 +
  7019 + //NIKITA
  7020 + $rootScope.isHighlightBodyByBodySystem = true;
  7021 + $scope.systemMatchedTermList = new jinqJs()
  7022 + .from($rootScope.BodySystemData.BodySystem.BodySystemTerm)
  7023 + .where('_SystemNumber == ' + event.currentTarget.id)
  7024 + .select();
  7025 +
  7026 + if ($rootScope.isHighLight == false) {
  7027 + //color the body gray
  7028 + $rootScope.isHighLight = true
  7029 + console.log('highLightBody from HighlightBodyByBodySystem')
  7030 + $scope.highLightBody();
  7031 + }
  7032 + else {
  7033 + //This else is when user seraced anything then change the view and clicked on highlight options
  7034 + //in this case body is already highlihted(gray) so no need to
  7035 + if ($scope.grayedBR != null || $scope.grayedBR != undefined) {
  7036 + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayedBR.length == 9)) {
  7037 + $scope.isAlreadyHighlighted = true;
  7038 + }
  7039 + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayedBR.length == 5)) {
  7040 + $scope.isAlreadyHighlighted = true;
  7041 + }
  7042 + else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayedBR.length == 4)) {
  7043 + $scope.isAlreadyHighlighted = true;
  7044 + }
  7045 + else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayedBR.length == 1)) {
  7046 + $scope.isAlreadyHighlighted = true;
  7047 + }
  7048 + if (($scope.isAlreadyHighlighted == true && $rootScope.isHighlightBodyByBodySystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined && $scope.systemMatchedTermList.length > 0)) {
  7049 +
  7050 + $scope.isLoading = true;
  7051 +
  7052 + $('#spinner').css('visibility', 'visible');
  7053 + $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100);
  7054 + }
  7055 + }
  7056 + }
  7057 +
  7058 +
  7059 + //$rootScope.isLoading = true;
  7060 + $('#spinner').css('visibility', 'visible');
  7061 +
  7062 + //NIKITA
  7063 + // $rootScope.isHighlightBodyByBodySystem = true;
  7064 +
  7065 + //if (systemMatchedTermList != null || systemMatchedTermList != undefined) {
  7066 +
  7067 + // $timeout(function () { $scope.HighlightBodyByTermList(systemMatchedTermList) }, 100);
  7068 + //}
  7069 +
  7070 +
  7071 + var viewtarget_highlightbody = angular.element(event.currentTarget);
  7072 + var title_highlightbody = viewtarget_highlightbody.attr('title');
  7073 +
  7074 + if (title_highlightbody == "Cardiovascular") {
  7075 + $scope.CurrentStructure = "";
  7076 + $scope.Cardiovascular = "active";
  7077 + $scope.Digestive = "";
  7078 + $scope.Endocrine = "";
  7079 + $scope.Immune = "";
  7080 + $scope.Integumentary = "";
  7081 + $scope.Lymphatic = "";
  7082 + $scope.Muscular = "";
  7083 + $scope.Nervous = "";
  7084 + $scope.Reproductive = "";
  7085 + $scope.Respiratory = "";
  7086 + $scope.Skeletal = "";
  7087 + $scope.Urinary = "";
  7088 + }
  7089 +
  7090 + if (title_highlightbody == "Digestive") {
  7091 + $scope.CurrentStructure = "";
  7092 + $scope.Cardiovascular = "";
  7093 + $scope.Digestive = "active";
  7094 + $scope.Endocrine = "";
  7095 + $scope.Immune = "";
  7096 + $scope.Integumentary = "";
  7097 + $scope.Lymphatic = "";
  7098 + $scope.Muscular = "";
  7099 + $scope.Nervous = "";
  7100 + $scope.Reproductive = "";
  7101 + $scope.Respiratory = "";
  7102 + $scope.Skeletal = "";
  7103 + $scope.Urinary = "";
  7104 + }
  7105 +
  7106 + if (title_highlightbody == "Endocrine") {
  7107 + $scope.CurrentStructure = "";
  7108 + $scope.Cardiovascular = "";
  7109 + $scope.Digestive = "";
  7110 + $scope.Endocrine = "active";
  7111 + $scope.Immune = "";
  7112 + $scope.Integumentary = "";
  7113 + $scope.Lymphatic = "";
  7114 + $scope.Muscular = "";
  7115 + $scope.Nervous = "";
  7116 + $scope.Reproductive = "";
  7117 + $scope.Respiratory = "";
  7118 + $scope.Skeletal = "";
  7119 + $scope.Urinary = "";
  7120 + }
  7121 + if (title_highlightbody == "Immune") {
  7122 +
  7123 + $scope.CurrentStructure = "";
  7124 + $scope.Cardiovascular = "";
  7125 + $scope.Digestive = "";
  7126 + $scope.Endocrine = "";
  7127 + $scope.Immune = "active";
  7128 + $scope.Integumentary = "";
  7129 + $scope.Lymphatic = "";
  7130 + $scope.Muscular = "";
  7131 + $scope.Nervous = "";
  7132 + $scope.Reproductive = "";
  7133 + $scope.Respiratory = "";
  7134 + $scope.Skeletal = "";
  7135 + $scope.Urinary = "";
  7136 + }
  7137 + if (title_highlightbody == "Integumentary") {
  7138 + $scope.CurrentStructure = "";
  7139 + $scope.Cardiovascular = "";
  7140 + $scope.Digestive = "";
  7141 + $scope.Endocrine = "";
  7142 + $scope.Immune = "";
  7143 + $scope.Integumentary = "active";
  7144 + $scope.Lymphatic = "";
  7145 + $scope.Muscular = "";
  7146 + $scope.Nervous = "";
  7147 + $scope.Reproductive = "";
  7148 + $scope.Respiratory = "";
  7149 + $scope.Skeletal = "";
  7150 + $scope.Urinary = "";
  7151 + }
  7152 + if (title_highlightbody == "Lymphatic") {
  7153 + $scope.CurrentStructure = "";
  7154 + $scope.Cardiovascular = "";
  7155 + $scope.Digestive = "";
  7156 + $scope.Endocrine = "";
  7157 + $scope.Immune = "";
  7158 + $scope.Integumentary = "";
  7159 + $scope.Lymphatic = "active";
  7160 + $scope.Muscular = "";
  7161 + $scope.Nervous = "";
  7162 + $scope.Reproductive = "";
  7163 + $scope.Respiratory = "";
  7164 + $scope.Skeletal = "";
  7165 + $scope.Urinary = "";
  7166 + }
  7167 + if (title_highlightbody == "Muscular") {
  7168 + $scope.CurrentStructure = "";
  7169 + $scope.Cardiovascular = "";
  7170 + $scope.Digestive = "";
  7171 + $scope.Endocrine = "";
  7172 + $scope.Immune = "";
  7173 + $scope.Integumentary = "";
  7174 + $scope.Lymphatic = "";
  7175 + $scope.Muscular = "active";
  7176 + $scope.Nervous = "";
  7177 + $scope.Reproductive = "";
  7178 + $scope.Respiratory = "";
  7179 + $scope.Skeletal = "";
  7180 + $scope.Urinary = "";
  7181 + }
  7182 + if (title_highlightbody == "Nervous") {
  7183 + $scope.CurrentStructure = "";
  7184 + $scope.Cardiovascular = "";
  7185 + $scope.Digestive = "";
  7186 + $scope.Endocrine = "";
  7187 + $scope.Immune = "";
  7188 + $scope.Integumentary = "";
  7189 + $scope.Lymphatic = "";
  7190 + $scope.Muscular = "";
  7191 + $scope.Nervous = "active";
  7192 + $scope.Reproductive = "";
  7193 + $scope.Respiratory = "";
  7194 + $scope.Skeletal = "";
  7195 + $scope.Urinary = "";
  7196 + }
  7197 + if (title_highlightbody == "Reproductive") {
  7198 + $scope.CurrentStructure = "";
  7199 + $scope.Cardiovascular = "";
  7200 + $scope.Digestive = "";
  7201 + $scope.Endocrine = "";
  7202 + $scope.Immune = "";
  7203 + $scope.Integumentary = "";
  7204 + $scope.Lymphatic = "";
  7205 + $scope.Muscular = "";
  7206 + $scope.Nervous = "";
  7207 + $scope.Reproductive = "active";
  7208 + $scope.Respiratory = "";
  7209 + $scope.Skeletal = "";
  7210 + $scope.Urinary = "";
  7211 + }
  7212 + if (title_highlightbody == "Respiratory") {
  7213 + $scope.CurrentStructure = "";
  7214 + $scope.Cardiovascular = "";
  7215 + $scope.Digestive = "";
  7216 + $scope.Endocrine = "";
  7217 + $scope.Immune = "";
  7218 + $scope.Integumentary = "";
  7219 + $scope.Lymphatic = "";
  7220 + $scope.Muscular = "";
  7221 + $scope.Nervous = "";
  7222 + $scope.Reproductive = "";
  7223 + $scope.Respiratory = "active";
  7224 + $scope.Skeletal = "";
  7225 + $scope.Urinary = "";
  7226 + }
  7227 + if (title_highlightbody == "Skeletal") {
  7228 + $scope.CurrentStructure = "";
  7229 + $scope.Cardiovascular = "";
  7230 + $scope.Digestive = "";
  7231 + $scope.Endocrine = "";
  7232 + $scope.Immune = "";
  7233 + $scope.Integumentary = "";
  7234 + $scope.Lymphatic = "";
  7235 + $scope.Muscular = "";
  7236 + $scope.Nervous = "";
  7237 + $scope.Reproductive = "";
  7238 + $scope.Respiratory = "";
  7239 + $scope.Skeletal = "active";
  7240 + $scope.Urinary = "";
  7241 + }
  7242 + if (title_highlightbody == "Urinary") {
  7243 + $scope.CurrentStructure = "";
  7244 + $scope.Cardiovascular = "";
  7245 + $scope.Digestive = "";
  7246 + $scope.Endocrine = "";
  7247 + $scope.Immune = "";
  7248 + $scope.Integumentary = "";
  7249 + $scope.Lymphatic = "";
  7250 + $scope.Muscular = "";
  7251 + $scope.Nervous = "";
  7252 + $scope.Reproductive = "";
  7253 + $scope.Respiratory = "";
  7254 + $scope.Skeletal = "";
  7255 + $scope.Urinary = "active";
  7256 + }
  7257 +
  7258 + //Highlight button should be active
  7259 + $("#btnHighLight").addClass("btn-primary");
  7260 + $("#btnHighLight").removeClass("btn-black");
  7261 +
  7262 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  7263 + $("#btnNormalMode").addClass("btn-black");
  7264 + }
  7265 +
  7266 + if (!$("#btnExtract").hasClass("btn-black")) {
  7267 + $("#btnExtract").addClass("btn-black");
  7268 + }
  7269 +
  7270 + if ($("#btnExtract").hasClass("btn-primary")) {
  7271 + $("#btnExtract").removeClass("btn-primary");
  7272 + }
  7273 +
  7274 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  7275 + $("#btnNormalMode").removeClass("btn-primary");
  7276 + }
  7277 +
  7278 + }
  7279 +
  7280 + $scope.ShowSearch = function () {
  7281 +
  7282 + console.log('ShowSearch is called');
  7283 + //this check is for log only because we are writing length so need to check if its not null or undefined
  7284 + if ($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined)
  7285 + console.log('$scope.VocabTermTxt.length= ' + $scope.VocabTermTxt.length)
  7286 +
  7287 + $timeout(function () {
  7288 + if (($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined) && ($scope.VocabTermTxt.length > 0)) {
  7289 + $scope.IsSearchVisible = true;
  7290 + document.getElementById("termlistfilter").style.display = "block";
  7291 + }
  7292 + else {
  7293 + $scope.loadSearchDataForBodyView();
  7294 + if ($scope.VocabTermTxt.length > 0) {
  7295 + $scope.ShowSearch();
  7296 + }
  7297 + }
  7298 + }, 500);
  7299 +
  7300 + //$scope.IsSearchVisible = true;
  7301 +
  7302 + //document.getElementById("termlistfilter").style.display = "block";
  7303 + }
  7304 +
  7305 + $scope.HideSearch = function () {
  7306 + if ($("#backdrop").is(":hover") || $("#termlistfilter").is(":hover") || $("#typedtermname").is(":focus")) {
  7307 + $scope.IsSearchVisible = true;
  7308 + document.getElementById("termlistfilter").style.display = "block";
  7309 + }
  7310 + else {
  7311 + $scope.IsSearchVisible = false;
  7312 + document.getElementById("termlistfilter").style.display = "none";
  7313 + $scope.searchFilter = "";
  7314 + }
  7315 +
  7316 + }
  7317 +
  7318 + $scope.jumpToTerm = function (event) {
  7319 + // alert(event.currentTarget.value);
  7320 + $rootScope.searchSelectedText = $('#' + event.currentTarget.id).text();
  7321 + $('#termList option[selected="selected"]').prop("selected", false);
  7322 + $('#termList option[value="' + $rootScope.searchSelectedText + '"]').prop("selected", true);
  7323 + $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" });
  7324 + $('#termList option[value="' + $rootScope.searchSelectedText + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" });
  7325 + $rootScope.isLoading = true;
  7326 +
  7327 + $('#spinner').css('visibility', 'visible');
  7328 + //1.
  7329 + $scope.searchFilter = event.currentTarget.innerHTML;
  7330 +
  7331 + //2.
  7332 + $scope.HighlightBodyOnListManagerSelection(event.currentTarget.id);
  7333 +
  7334 + $scope.IsSearchVisible = false;
  7335 + $rootScope.isNormalMode = false;
  7336 +
  7337 + //Highlight only Highlight button
  7338 +
  7339 + $("#btnHighLight").addClass("btn-primary");
  7340 + $("#btnHighLight").removeClass("btn-black");
  7341 +
  7342 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  7343 + $("#btnNormalMode").addClass("btn-black");
  7344 + }
  7345 +
  7346 + if (!$("#btnExtract").hasClass("btn-black")) {
  7347 + $("#btnExtract").addClass("btn-black");
  7348 + }
  7349 +
  7350 + if ($("#btnExtract").hasClass("btn-primary")) {
  7351 + $("#btnExtract").removeClass("btn-primary");
  7352 + }
  7353 +
  7354 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  7355 + $("#btnNormalMode").removeClass("btn-primary");
  7356 + }
  7357 +
  7358 + }
  7359 +
  7360 + //Function to set the vertical and horizontal scroll position of CanvasDiv as per the Navigator
  7361 + $scope.ScrollCanvasDiv = function () {
  7362 +
  7363 + var x = $("#draggable").position();
  7364 + var can = $('#canvasDiv');
  7365 + var canheight = can[0].scrollHeight;
  7366 + var canwidth = can[0].scrollWidth;
  7367 +
  7368 + var scrolly = (x.top / ($('#containment-wrapper').height())) * (canheight);
  7369 +
  7370 + var scrollx = (x.left / $('#containment-wrapper').width()) * (canwidth);
  7371 +
  7372 + $("#canvasDiv").scrollTop(scrolly);
  7373 + $("#canvasDiv").scrollLeft(scrollx);
  7374 +
  7375 + if (($rootScope.isHighlightBodyByBodySystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) {
  7376 + $timeout(function () { $scope.HighlightBodyByTermList(systemMatchedTermList) }, 100);
  7377 + }
  7378 +
  7379 + }
  7380 +
  7381 + //list manager
  7382 + $scope.$on('listManagerEvent', function (event, data) {
  7383 +
  7384 +
  7385 + //if ($rootScope.MenuModuleName == "DA") {
  7386 + // if ($rootScope.disableAnnotationtoolOnListManager == true) {
  7387 + // $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').attr('disabled', 'disabled');
  7388 + // $('#slider-range-min-2').slider('disable');
  7389 + // }
  7390 + //}
  7391 + if ($rootScope.setListManagerZindex == true) {
  7392 + var canvasPaintZindex = $('#canvasPaint').css("z-index"); //x
  7393 +
  7394 + var canvasZindex = $('#canvas').css("z-index"); //y
  7395 + var listManagerZindex = $('#listManager').css("z-index"); //z
  7396 + if (canvasPaintZindex > canvasZindex) {
  7397 + //y = parseInt(canvasPaintZindex) + 1;
  7398 + //if (listManagerZindex <= canvasPaintZindex) {
  7399 + // listManagerZindex = parseInt(canvasPaintZindex) + 1;
  7400 + // $('#listManager').css("z-index", z);
  7401 + //}
  7402 + //else {
  7403 + $('#listManager').css("z-index", canvasPaintZindex);
  7404 + // }
  7405 + } else {
  7406 + //y = parseInt(y) + 1;
  7407 + $('#listManager').css("z-index", canvasZindex);
  7408 + }
  7409 +
  7410 + }
  7411 +
  7412 +
  7413 +
  7414 +
  7415 +
  7416 + if ($rootScope.islistManagerEventAlredayDispachted == true) {
  7417 +
  7418 + $('#spinner').css('visibility', 'visible');
  7419 + console.log('listManagerEvent');
  7420 + var systemList = $rootScope.CommonData.DACommonData.BodySystems.Item;
  7421 +
  7422 + $('#bodySystems').empty();
  7423 +
  7424 +
  7425 + var $all = $('<option id="0" selected="">All</option>').appendTo('#bodySystems');
  7426 + $compile($all)($scope);
  7427 +
  7428 + angular.forEach(systemList, function (value, key) {
  7429 +
  7430 + var $elem = $('<option id="' + value._BodySystemId + '" title="' + value._Name + '" >' + value._Name + '</option>').appendTo('#bodySystems');
  7431 + $compile($elem)($scope);
  7432 + })
  7433 +
  7434 +
  7435 +
  7436 + $('#viewName').empty();
  7437 + var currentView = localStorage.getItem("currentViewTitle");
  7438 + var viewNmeHtml = '<option>' + currentView + '</option>'
  7439 + $('#viewName').append(viewNmeHtml);
  7440 +
  7441 + var len = $rootScope.openModules.length;
  7442 + var openViewLen = $rootScope.openViews.length;
  7443 +
  7444 + var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId;
  7445 +
  7446 + //confirm that this is DA module which is last open
  7447 + if (currentOpenModuleId == 1) {
  7448 +
  7449 +
  7450 + $('#termList').empty();
  7451 + $scope.loadListManger();
  7452 + $rootScope.islistManagerEventAlredayDispachted = false;
  7453 + }
  7454 +
  7455 + }
  7456 +
  7457 +
  7458 +
  7459 + });
  7460 +
  7461 + $scope.loadListManger = function () {
  7462 +
  7463 +
  7464 + var vocabTermTxt = [];
  7465 +
  7466 + angular.forEach($rootScope.TermNumberData.TermData.Term, function (value1, key1) {
  7467 +
  7468 + angular.forEach($rootScope.VocabTermData.VocabTerms.Term, function (value2, key2) {
  7469 +
  7470 +
  7471 + if (value1._ActualTermNumber === value2._ActualTermNumber) {
  7472 + vocabTermTxt.push(
  7473 +
  7474 + {
  7475 +
  7476 + "_ActualTermNumber": value2._ActualTermNumber,
  7477 + "_TermText": value2._TermText,
  7478 + "_cdId": value2._cdId
  7479 +
  7480 + }
  7481 +
  7482 + );
  7483 +
  7484 + }
  7485 +
  7486 + })
  7487 +
  7488 +
  7489 +
  7490 + })
  7491 +
  7492 +
  7493 +
  7494 + $scope.VocabTermTxt = new jinqJs()
  7495 + .from(vocabTermTxt)
  7496 + .distinct('_TermText', '_ActualTermNumber')
  7497 + .orderBy([{ field: '_TermText', sort: 'asc' }])
  7498 + .select('_ActualTermNumber', '_TermText', '_cdId');
  7499 +
  7500 + if ($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined) {
  7501 +
  7502 +
  7503 + for (var j = 0; j < $scope.VocabTermTxt.length; j++) {
  7504 + var $el = $('<option title ="' + $scope.VocabTermTxt[j]._TermText + '" id=' + $scope.VocabTermTxt[j]._ActualTermNumber + '>' + $scope.VocabTermTxt[j]._TermText + '</option>').appendTo('#termList')
  7505 + $compile($el)($scope);
  7506 +
  7507 + }
  7508 +
  7509 + $rootScope.isLoading = false;
  7510 + $('#spinner').css('visibility', 'hidden');
  7511 +
  7512 + var termsTotal = '<span class="pull-left marginTop5">' + $scope.VocabTermTxt.length + ' Structures</span>';
  7513 + $("#totalTerms").empty();
  7514 + $('#totalTerms').append(termsTotal);
  7515 +
  7516 +
  7517 +
  7518 + }
  7519 + }
  7520 +
  7521 +
  7522 + $scope.HighlightBodyOnListManagerSelection = function (actualTermNumber) {
  7523 +
  7524 + console.log('inside HighlightBodyOnListManagerSelection actualTermNumber= ' + actualTermNumber)
  7525 + // Terms search in the Search list should be disable in the List Manager and Vice-Versa.
  7526 + if ($rootScope.prevId == actualTermNumber) {
  7527 +
  7528 + $rootScope.isLoading = false;
  7529 + $('#spinner').css('visibility', 'hidden');
  7530 + }
  7531 + else {
  7532 +
  7533 + $rootScope.isLoading = true;
  7534 +
  7535 + $('#spinner').css('visibility', 'visible');
  7536 +
  7537 +
  7538 + $rootScope.prevId = actualTermNumber;
  7539 + // $("#termList").find("option").attr('selected', false);
  7540 + $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" });
  7541 + $("#termList").find("option[id=" + actualTermNumber + "]").css({ "background-color": "#3399FF", "color": "#ffffff" });
  7542 + $("div#backdrop #termlistfilter li").find("a").css({ "background-color": "#ffffff", "color": "#000000" });
  7543 + $("div#backdrop #termlistfilter li").find("a[id=" + actualTermNumber + "]").css({ "background-color": "#3399FF", "color": "#ffffff" });
  7544 +
  7545 + $scope.terminateCurrentlyRunningWPs();
  7546 + //debugger
  7547 + $rootScope.isListManagerSelected = true;
  7548 + //---
  7549 + if ($rootScope.isListManagerSelected == true) {
  7550 + $("#btnHighLight").addClass("btn-primary");
  7551 + $("#btnHighLight").removeClass("btn-black");
  7552 + if (!$("#btnNormalMode").hasClass("btn-black")) {
  7553 + $("#btnNormalMode").addClass("btn-black");
  7554 + }
  7555 +
  7556 + if ($("#btnNormalMode").hasClass("btn-primary")) {
  7557 + $("#btnNormalMode").removeClass("btn-primary");
  7558 + }
  7559 + }
  7560 + //---
  7561 +
  7562 + $rootScope.isHighlightBodyByBodySystem = false;
  7563 +
  7564 + //1.
  7565 + $rootScope.actualTermNumber = actualTermNumber;//attributes[0].value;
  7566 + console.log(' $scope.actualTermNumber insde HighlightBodyOnListManagerSelection= ' + $rootScope.actualTermNumber)
  7567 +
  7568 + //2.
  7569 +
  7570 + $scope.setLayerNumberAndHighlightByTermList();
  7571 +
  7572 +
  7573 + }
  7574 +
  7575 +
  7576 + }
  7577 +
  7578 + $scope.setLayerNumberAndHighlightByTermList = function () {
  7579 + console.log(' $scope.actualTermNumber insde setLayerNumberAndHighlightByTermList= ' + $rootScope.actualTermNumber)
  7580 +
  7581 + $scope.TermList = $scope.getTermNumberList($rootScope.actualTermNumber);
  7582 +
  7583 + if (($scope.TermList != null || $scope.TermList != undefined) && $scope.TermList.length > 0) {
  7584 +
  7585 + var internalLayerNumberList = [];
  7586 + for (var i = 0; i < $scope.TermList.length; i++) {
  7587 + var layerNumber = $scope.TermList[i]._InternalLayerNumber
  7588 +
  7589 + internalLayerNumberList[i] = parseInt(layerNumber);
  7590 + }
  7591 +
  7592 + internalLayerNumberList.sort(function (a, b) { return a - b })
  7593 + var internalLayerNumber = internalLayerNumberList[0]//.replace('00', '');
  7594 +
  7595 + //3. get layer number
  7596 + if (internalLayerNumber >= DA[0].SKIN_START_INTERNAL_LAYER && internalLayerNumber <= DA[0].SKIN_END_INTERNAL_LAYER) {
  7597 +
  7598 + internalLayerNumber = DA[0].SKIN_DEFAULT_INTERNAL_LAYER;
  7599 + }
  7600 +
  7601 + var layerNumber;
  7602 + var matchedLayerNumber = new jinqJs()
  7603 + .from($rootScope.BodyLayerData.Layers.DataLayer)
  7604 + .where("_lni == " + internalLayerNumber)
  7605 + .select('_LayerNumber');
  7606 +
  7607 + if (matchedLayerNumber == null || matchedLayerNumber.length == 0) {
  7608 + layerNumber = 0;
  7609 + }
  7610 + else {
  7611 + layerNumber = matchedLayerNumber[0]._LayerNumber
  7612 + }
  7613 +
  7614 + if (layerNumber == 0) {
  7615 + layerNumber = $rootScope.totalLayers;
  7616 + }
  7617 + else {
  7618 + layerNumber = parseInt(layerNumber) - 1;
  7619 + }
  7620 +
  7621 + $scope.layerNumber = layerNumber;
  7622 +
  7623 + //4.get scroll position
  7624 + if ($rootScope.actualTermNumber != DA[0].SKIN_TERM_ID) {
  7625 +
  7626 + $scope.termCoordinate = $scope.getTermCoordinate($rootScope.actualTermNumber);
  7627 +
  7628 + }
  7629 +
  7630 + //5.
  7631 + $scope.matchdedDataOnLayer = new jinqJs()
  7632 + .from($rootScope.TermNumberData.TermData.Term)
  7633 + .where('_InternalLayerNumber == ' + internalLayerNumber)
  7634 + .select();
  7635 +
  7636 + if ($scope.matchdedDataOnLayer != null || $scope.matchdedDataOnLayer != undefined) {
  7637 +
  7638 + //6.
  7639 + var matchedDataonActualTerm = new jinqJs()
  7640 + .from($scope.matchdedDataOnLayer)
  7641 + .where('_ActualTermNumber == ' + $scope.actualTermNumber)
  7642 + .select('_TermNumber');
  7643 +
  7644 + if (matchedDataonActualTerm != null || matchedDataonActualTerm != undefined) {
  7645 +
  7646 + var termNo = matchedDataonActualTerm[0]._TermNumber.toString();
  7647 +
  7648 + //7.get termList
  7649 + $scope.fullTermlist = [];
  7650 + $scope.AllTerms = [];
  7651 +
  7652 + if (termNo != DA[0].figLeafTermId) {
  7653 +
  7654 + $scope.getChildTermList(termNo);
  7655 + // $timeout(function () { $scope.getSiblings(termNo) }, 50);
  7656 + $scope.getSiblings(termNo)
  7657 + }
  7658 +
  7659 + }
  7660 + }
  7661 + }
  7662 + $('#txtlayerNumber').val((parseInt($scope.layerNumber)));
  7663 + $('#layerChangeSlider').slider("option", "value", parseInt($rootScope.totalLayers) - parseInt($scope.layerNumber));
  7664 +
  7665 + //8.remove current layer canavses
  7666 + $scope.flushCanvas();
  7667 +
  7668 +
  7669 + //9.
  7670 + $timeout(function () {
  7671 + if (($rootScope.isGenderChnage == true && $rootScope.isHighLight == true) || ($rootScope.isViewChange == true && $rootScope.isHighLight == true)) {
  7672 +
  7673 + }
  7674 + else {
  7675 + $rootScope.isHighLight = false;
  7676 + }
  7677 + $('#sppeachBubble').css('display', 'none');
  7678 + $("#dot").css("display", "none");
  7679 + //DA > Annotation's Line should not displayed.
  7680 + $("#bord").css("display", "none");
  7681 +
  7682 + $rootScope.isLoading = true;
  7683 + $('#spinner').css('visibility', 'visible');
  7684 +
  7685 + //redraw body of respective layer
  7686 + $scope.CalculateImageCordinates($rootScope.viewOrientationId)
  7687 + }, 500);
  7688 +
  7689 + }
  7690 +
  7691 + $scope.getChildTermList = function (termNo) {
  7692 +
  7693 +
  7694 + var data = new jinqJs()
  7695 + .from($scope.matchdedDataOnLayer)
  7696 + .where("_ParentTermNumber == " + termNo)
  7697 + .select();
  7698 +
  7699 + if (data != null || data != undefined) {
  7700 +
  7701 +
  7702 + var data2 = new jinqJs()
  7703 + .from(data)
  7704 + .where("_TermNumber != " + termNo)
  7705 + .select();
  7706 +
  7707 +
  7708 + var k;
  7709 + if ((data2 != null || data2 != undefined) && (data2.length > 0)) {
  7710 + for (var i = 0; i < data2.length; i++) {
  7711 +
  7712 + var serachTerm = data2[i]._TermNumber;
  7713 + var isFound = jQuery.inArray(serachTerm, $scope.fullTermlist)
  7714 + if (isFound == -1) {
  7715 + $scope.fullTermlist.push(serachTerm);
  7716 + $scope.AllTerms.push({ '_TermNumber': serachTerm })
  7717 + $scope.getChildTermList(serachTerm);
  7718 + }
  7719 + }
  7720 + }
  7721 + }
  7722 + }
  7723 +
  7724 + $scope.getSiblings = function (termNo) {
  7725 +
  7726 + var data = new jinqJs()
  7727 + .from($scope.matchdedDataOnLayer)
  7728 + .where("_TermNumber == " + termNo)
  7729 + .select();
  7730 +
  7731 + if (data != null || data != undefined) {
  7732 +
  7733 + var termNo = data[0]._ActualTermNumber;
  7734 +
  7735 + var data2 = new jinqJs()
  7736 + .from($scope.matchdedDataOnLayer)
  7737 + .where("_ActualTermNumber == " + termNo)
  7738 + .select();
  7739 +
  7740 + if ((data2 != null || data2 != undefined) && (data2.length > 0)) {
  7741 + for (var i = 0; i < data2.length; i++) {
  7742 + $scope.fullTermlist.push(data2[i]._TermNumber);
  7743 + $scope.AllTerms.push({ '_TermNumber': data2[i]._TermNumber })
  7744 + $scope.getChildTermList(data2[i]._TermNumber);
  7745 + }
  7746 + }
  7747 + }
  7748 + }
  7749 +
  7750 + $scope.getTermCoordinate = function (actualTermNumber) {
  7751 +
  7752 + return {
  7753 + x: $scope.TermList[0]._CenterX,
  7754 + y: $scope.TermList[0]._CenterY
  7755 + }
  7756 + }
  7757 +
  7758 +
  7759 + $scope.aligneCanvasWithTerm = function () {
  7760 + console.log('aligneCanvasWithTerm')
  7761 + // debugger
  7762 +
  7763 + var newX = parseInt($scope.scaleValue($scope.termCoordinate.x, $scope.zoomInOut, DA[0].ZOOM_TERM_DATA));
  7764 + var newY = parseInt($scope.scaleValue($scope.termCoordinate.y, $scope.zoomInOut, DA[0].ZOOM_TERM_DATA));
  7765 +
  7766 + var canvasX = parseInt(document.getElementById('canvasDiv').offsetLeft);
  7767 + var canvasY = parseInt(document.getElementById('canvasDiv').offsetTop);
  7768 + var canvasHeight = $('#canvasDiv').height();
  7769 + var canvasWidth = $('#canvasDiv').width();
  7770 +
  7771 + var canvasBottom = canvasY + canvasHeight;
  7772 + var canvasRight = canvasX + canvasWidth
  7773 +
  7774 + if (newX < canvasX || newX > canvasRight || newY < canvasY || newY > canvasBottom) {
  7775 +
  7776 + newX = newX - canvasWidth / 2;
  7777 + newY = newY - canvasHeight / 2;
  7778 +
  7779 + var maxVScrollPos = $('#canvasDiv')[0].scrollHeight;
  7780 + var maxHScrollPos = $('#canvasDiv')[0].scrollWidth;
  7781 +
  7782 + if (newY < maxVScrollPos) {
  7783 + newY = newY;
  7784 + }
  7785 + else {
  7786 + newY = maxVScrollPos;
  7787 + }
  7788 +
  7789 + if (newX < maxHScrollPos) {
  7790 + newX = newX;
  7791 + }
  7792 + else {
  7793 + newX = maxHScrollPos;
  7794 + }
  7795 + //alert('newX= ' + newX + ',newY= ' + newY)
  7796 + $('#canvasDiv').scrollLeft(newX);
  7797 + $('#canvasDiv').scrollTop(newY);
  7798 + $scope.isLoading = false;
  7799 + $('#spinner').css('visibility', 'hidden');
  7800 + }
  7801 +
  7802 + $rootScope.CanvasDivTopPosition = $("#canvasDiv").scrollTop();
  7803 + $rootScope.CanvasDivLeftPosition = $("#canvasDiv").scrollLeft();
  7804 +
  7805 + }
  7806 +
  7807 +
  7808 + $scope.scaleValue = function (nValue, nNewZoom, nExistingZoom) {
  7809 +
  7810 + var iReturnValue = nValue * nNewZoom;
  7811 + return Math.round(iReturnValue / nExistingZoom);
  7812 + }
  7813 +
  7814 + $scope.refreshTermListOnSystemSelection = function (bodysystemId) {
  7815 +
  7816 + $('#termList').empty();
  7817 + // $('#termList').innerHTML = '';
  7818 +
  7819 + if (bodysystemId == 0) {
  7820 + $scope.loadListManger();
  7821 + }
  7822 + else {
  7823 + var bodySystemDataPath = '~/../content/data/json/da/body-views/' + localStorage.getItem("currentBodyViewId") + '/da_dat_body_system_term_' + localStorage.getItem("currentBodyViewId") + '.json';
  7824 + DataService.getJson(bodySystemDataPath)
  7825 + .then(
  7826 + function (result) {
  7827 +
  7828 + $rootScope.BodySystemData = result;
  7829 + var systemMatchedTermList = new jinqJs()
  7830 + .from($rootScope.BodySystemData.BodySystem.BodySystemTerm)
  7831 + .where('_SystemNumber == ' + bodysystemId)
  7832 + .select();
  7833 + if (systemMatchedTermList != null || systemMatchedTermList != undefined) {
  7834 +
  7835 + $scope.refreshTerms(systemMatchedTermList);
  7836 + }
  7837 + },
  7838 + function (error) {
  7839 + console.log(error.statusText)
  7840 + }
  7841 + )
  7842 +
  7843 + }
  7844 + }
  7845 +
  7846 + $scope.refreshTerms = function (termList) {
  7847 +
  7848 + var path = '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json'
  7849 +
  7850 + $http({ method: 'GET', url: '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json' }).success(function (data) {
  7851 +
  7852 + var VocabTermData = data;
  7853 +
  7854 + var vocabTermTxt = [];
  7855 +
  7856 + for (var i = 0; i < termList.length; i++) {
  7857 +
  7858 + var actulaTermNumber = new jinqJs()
  7859 + .from($rootScope.TermNumberData.TermData.Term)
  7860 + .where('_TermNumber == ' + termList[i]._TermNumber)
  7861 + .select('_ActualTermNumber');
  7862 +
  7863 + if (actulaTermNumber != null || actulaTermNumber != undefined) {
  7864 +
  7865 +
  7866 + angular.forEach(VocabTermData.VocabTerms.Term, function (value2, key2) {
  7867 +
  7868 +
  7869 + if (actulaTermNumber[0]._ActualTermNumber == value2._ActualTermNumber) {
  7870 + vocabTermTxt.push(
  7871 +
  7872 + {
  7873 +
  7874 + "_ActualTermNumber": value2._ActualTermNumber,
  7875 +
  7876 + "_TermText": value2._TermText,
  7877 +
  7878 + "_cdId": value2._cdId
  7879 +
  7880 + }
  7881 +
  7882 + );
  7883 +
  7884 + }
  7885 +
  7886 + })
  7887 +
  7888 + }
  7889 + }
  7890 +
  7891 + $scope.VocabTermTxt = new jinqJs()
  7892 + .from(vocabTermTxt)
  7893 + .distinct('_TermText', '_ActualTermNumber')
  7894 + .orderBy([{ field: '_TermText', sort: 'asc' }])
  7895 + .select('_ActualTermNumber', '_TermText', '_cdId');
  7896 +
  7897 + if ($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined) {
  7898 +
  7899 +
  7900 + for (var j = 0; j < $scope.VocabTermTxt.length; j++) {
  7901 + var $el = $('<option id=' + $scope.VocabTermTxt[j]._ActualTermNumber + '>' + $scope.VocabTermTxt[j]._TermText + '</option>').appendTo('#termList')
  7902 + $compile($el)($scope);
  7903 + }
  7904 +
  7905 + var termsTotal = '<span class="pull-left marginTop5">' + $scope.VocabTermTxt.length + ' Structures</span>';
  7906 + $("#totalTerms").empty();
  7907 + //$('#totalTerms').innerHTML = '';
  7908 +
  7909 + $('#totalTerms').append(termsTotal);
  7910 + $rootScope.isLoading = false;
  7911 + $('#spinner').css('visibility', 'hidden');
  7912 + }
  7913 + })
  7914 +
  7915 + .error(function (data, status, headers, config) {
  7916 + console.log(data);
  7917 +
  7918 + });
  7919 +
  7920 + }
  7921 +
  7922 + $scope.LayerChangeBasedOnKeyPressed = function (e) {
  7923 + // Dissectible Anatomy > Should not display blank page if no layer is selected.
  7924 +
  7925 +
  7926 + if (e.keyCode == 13) {
  7927 +
  7928 + if ($("#txtlayerNumber").val() == '') {
  7929 +
  7930 + $("#txtlayerNumber").val($rootScope.PreviouslayerNumbr);
  7931 + }
  7932 + else {
  7933 + $rootScope.PreviouslayerNumbr = $("#txtlayerNumber").val();
  7934 + $scope.LayerChange();
  7935 + }
  7936 +
  7937 +
  7938 + }
  7939 +
  7940 + // 'x' button is displaying inside the input box in IE browser.
  7941 + if (e.keyCode == 38) {
  7942 +
  7943 +
  7944 + var layerInputVal = $("#txtlayerNumber").val();
  7945 + if (layerInputVal != $rootScope.totalLayers) {
  7946 + var layerInputValInc = parseInt(layerInputVal) + 1;
  7947 + $scope.layerNumber = parseInt(layerInputValInc);
  7948 + $("#txtlayerNumber").val($scope.layerNumber);
  7949 + $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  7950 + }
  7951 +
  7952 +
  7953 + }
  7954 +
  7955 + // 'x' button is displaying inside the input box in IE browser.
  7956 + if (e.keyCode == 40) {
  7957 + var layerInputVal = $("#txtlayerNumber").val();
  7958 + if (layerInputVal > 0) {
  7959 + var layerInputValDec = parseInt(layerInputVal) - 1;
  7960 + $scope.layerNumber = parseInt(layerInputValDec);
  7961 + $("#txtlayerNumber").val($scope.layerNumber);
  7962 + $rootScope.PreviouslayerNumbr = $scope.layerNumber;
  7963 + }
  7964 + }
  7965 +
  7966 + }
  7967 +
  7968 +
  7969 + $scope.LayerValueChangeBasedOnKeyUp = function (e) {
  7970 +
  7971 + var keyUplayerNumber = parseInt($("#txtlayerNumber").val());
  7972 +
  7973 + if (isNaN(keyUplayerNumber)) {
  7974 +
  7975 + }
  7976 + else {
  7977 +
  7978 + if (keyUplayerNumber > $rootScope.totalLayers) {
  7979 +
  7980 + $("#txtlayerNumber").val($rootScope.totalLayers);
  7981 + $scope.layerNumber = parseInt($rootScope.totalLayers);
  7982 +
  7983 + }
  7984 + else {
  7985 +
  7986 + $("#txtlayerNumber").val(keyUplayerNumber);
  7987 + $scope.layerNumber = parseInt(keyUplayerNumber);
  7988 +
  7989 +
  7990 + }
  7991 +
  7992 + }
  7993 +
  7994 +
  7995 + }
  7996 +
  7997 +
  7998 + $rootScope.mouseMoveToolTip = function (toolTipTopPosition, toolTipLeftPosition, toolTipWidth, toolTipText) {
  7999 +
  8000 + $("#cursor-block").addClass("custom-tooltip-annotation-toolbar");
  8001 + $(".custom-tooltip-annotation-toolbar").css({ "display": "block", "top": toolTipTopPosition + "px", "width": toolTipWidth + "px", "left": toolTipLeftPosition + "px" });
  8002 + $("#cursor-block").html(toolTipText);
  8003 + }
  8004 +
  8005 + $rootScope.mouseOutToolTip = function () {
  8006 +
  8007 + $(".custom-tooltip-annotation-toolbar").css('display', 'none');
  8008 + $("#cursor-block").removeClass("custom-tooltip-annotation-toolbar");
  8009 + $("#cursor-block").html();
  8010 +
  8011 + }
  8012 +
  8013 +
  8014 +
  8015 +}]
  8016 +
  8017 +);
  8018 +
  8019 +
  8020 +function OnGenderChange(event) {
  8021 +
  8022 + console.log('gender chnaged is called outside ');
  8023 + var scope = angular.element(document.getElementById("daView")).scope();
  8024 + scope.$apply(function () {
  8025 + scope.OnGenderChange(event);
  8026 + });
  8027 +}
  8028 +
  8029 +function OnViewChange(event) {
  8030 + console.log('OnViewChange chnaged is called outside ');
  8031 + var scope = angular.element(document.getElementById("daView")).scope();
  8032 + scope.$apply(function () {
  8033 + scope.OnViewChange(event);
  8034 + });
  8035 +}
  8036 +
  8037 +function OnBodySystemSelection(event) {
  8038 + console.log('OnBodySystem chnaged is called outside ');
  8039 + var scope = angular.element(document.getElementById("daView")).scope();
  8040 + scope.$apply(function () {
  8041 + scope.HighlightBodyByBodySystem(event);
  8042 + });
  8043 +}
  8044 +
  8045 +function enableShowHideStructureBox() {
  8046 + console.log('OnBodySystem chnaged is called outside ');
  8047 + var scope = angular.element(document.getElementById("daView")).scope();
  8048 + scope.$apply(function () {
  8049 + scope.enableShowHideStructureBox();
  8050 + });
  8051 +}
  8052 +
  8053 +function OnSearch() {
  8054 + console.log('Show Search is called outside ');
  8055 + var scope = angular.element(document.getElementById("daView")).scope();
  8056 + scope.$apply(function () {
  8057 + scope.ShowSearch();
  8058 + });
  8059 +}
  8060 +function selectTerm(event) {
  8061 + console.log('selectTerm is called outside ');
  8062 + var scope = angular.element(document.getElementById("daView")).scope();
  8063 + scope.$apply(function () {
  8064 + scope.jumpToTerm(event);
  8065 + });
  8066 +}
  8067 +function HighlightBodyOnListManager(event) {
  8068 + console.log('HighlightBodyOnListManager is called outside ');
  8069 + var scope = angular.element(document.getElementById("daView")).scope();
  8070 + scope.$apply(function () {
  8071 + scope.HighlightBodyOnListManagerSelection(event);
  8072 + });
  8073 +}
  8074 +
  8075 +function refreshTermListOnSystem(bodysystemId) {
  8076 + console.log('refreshTermListOnSystem is called outside ');
  8077 + var scope = angular.element(document.getElementById("daView")).scope();
  8078 + scope.$apply(function () {
  8079 + scope.refreshTermListOnSystemSelection(bodysystemId);
  8080 + });
  8081 +}
  8082 +
  8083 +function OnEnableExtract() {
  8084 + console.log('OnEnableExtract is called outside ');
  8085 + var scope = angular.element(document.getElementById("daView")).scope();
  8086 + scope.$apply(function () {
  8087 + scope.enableExtract('true');
  8088 + });
  8089 +}
  8090 +
  8091 +function onTboxCreation() {
  8092 + console.log('OnEnableExtract is called outside ');
  8093 + var scope = angular.element(document.getElementById("daView")).scope();
  8094 + scope.$apply(function () {
  8095 + scope.createTransparencyBox('true');
  8096 + });
  8097 +}
  8098 +
  8099 +function onTboxClose() {
  8100 + console.log('onTboxClose is called outside ');
  8101 + var scope = angular.element(document.getElementById("daView")).scope();
  8102 + scope.$apply(function () {
  8103 + scope.CloseTransparencyBox();
  8104 + });
  8105 +}
  8106 +
  8107 +function OnEnableNormalMode() {
  8108 + console.log('OnEnableNormalMode is called outside ');
  8109 + var scope = angular.element(document.getElementById("daView")).scope();
  8110 + scope.$apply(function () {
  8111 + scope.enableNormalMode();
  8112 + });
  8113 +}
  8114 +
  8115 +function OnEnableHighlight() {
  8116 + console.log('OnEnableHighlight is called outside ');
  8117 + var scope = angular.element(document.getElementById("daView")).scope();
  8118 + scope.$apply(function () {
  8119 + scope.enableHighlight();
  8120 + });
  8121 +}
  8122 +
  8123 +function OnIdentityClick() {
  8124 + console.log('OnIdentityClick is called outside ');
  8125 + var scope = angular.element(document.getElementById("daView")).scope();
  8126 + scope.$apply(function () {
  8127 + scope.IdentityClick();
  8128 + });
  8129 +}
  8130 +
  8131 +function OnZoom() {
  8132 + //Dissectible Anatomy > Extract and Annotations displays apart on the page after click on Zoom-in.
  8133 + $(".com").remove();
  8134 + $("#bord").remove();
  8135 + console.log('OnZoom is called outside ');
  8136 + var scope = angular.element(document.getElementById("daView")).scope();
  8137 + scope.$apply(function () {
  8138 + scope.enableZoom();
  8139 + });
  8140 +}
  8141 +
  8142 +function onListManagerTermSelection(id) {
  8143 +
  8144 + var scope = angular.element(document.getElementById("daView")).scope();
  8145 + scope.$apply(function () {
  8146 + scope.HighlightBodyOnListManagerSelection(id);
  8147 + });
  8148 +
  8149 +}
  8150 +
253 8151  
... ...
400-SOURCECODE/AIAHTML5.Web/app/views/aa/atlas-anatomy-detail.html
1   -
2   -<div id="aaDetailPageDiv" class="bodyWrap row" ng-controller="TileViewListController">
  1 +<!--<style>
  2 + .slider label {
  3 + position: absolute;
  4 + width: 20px;
  5 + margin-left: -10px;
  6 + text-align: center;
  7 + margin-top: 20px;
  8 + }
3 9  
4   - <div class="tools pull-left" style="top:44px;">
5   - <div class="toggle-icon toggleBar toggleHeadingButton" data-toggle="tooltip" data-placement="top" title="Show/Hide Sidebar"></div>
6   - <div class="">
7   - <div class="col-sm-6" title="Hide Pins"><button class="btn btn-black btn-sm" ng-click="alert('hi')"> <img src="../../../content/images/aa/LeftMenu/hide-pin.png" alt="" title=""></button> </div>
8   - <div class="col-sm-6" title="Show Selected Pins"><button class="btn btn-black btn-sm pull-right"><img src="../../../content/images/aa/LeftMenu/draw-pin.png" alt="" title=""></button></div>
9   - <div class="col-sm-6" title="Show All Pins in System(s)"><button class="btn btn-primary btn-sm marginTop5"><img src="../../../content/images/aa/LeftMenu/all-pin.png" alt="" title=""></button></div>
10   - <div class="col-sm-6" title="Select System">
11   - <button class="btn btn-black btn-sm pull-right marginTop5 dropdown-toggle" type="button" id="dropdownMenu221" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><img src="../../../content/images/aa/LeftMenu/icon-highlight.png" alt="" title=""></button>
12   - <ul class="dropdown-menu" aria-labelledby="dropdownMenu221">
13   - <li><a href="#" title="Current Structure">All</a></li>
14   - <li role="separator" class="divider"></li>
15   - <li><a href="#" title="Cardiovascular">Cardiovascular</a></li>
16   - <li><a href="#" title="Digestive">Digestive</a></li>
17   - <li class="disabled"><a href="#" title="Endocrine">Endocrine</a></li>
18   - <li class="disabled"><a href="#" title="Immune">Immune</a></li>
19   - <li class="disabled"><a href="#" title="Integumentary">Integumentary</a></li>
20   - <li class="disabled"><a href="#" title="Lymphatic">Lymphatic</a></li>
21   - <li><a href="#" title="Muscular">Muscular</a></li>
22   - <li class="disabled"><a href="#" title="Nervous">Nervous</a></li>
23   - <li class="disabled"><a href="#" title="Reproductive">Reproductive</a></li>
24   - <li class="disabled"><a href="#" title="Respiratory">Respiratory</a></li>
25   - <li><a href="#" title="Skeletal">Skeletal</a></li>
26   - <li class="disabled"><a href="#" title="Urinary">Urinary</a></li>
27   - </ul>
  10 + /* below is not necessary, just for style */
  11 + .slider {
  12 + width: 50%;
  13 + margin: 2em auto;
  14 + }
  15 +</style>-->
  16 +<style>
  17 + /*Dated:22-07-2016 Issue#4958:In Open body view, the side buttons are getting disturbed on layer change. */
  18 + .btn-resize {
  19 + padding: 6px 11px;
  20 + border: 0px solid #000;
  21 + border-radius: 1px;
  22 + }
  23 +</style>
  24 +<style>
  25 + /*Dated:22-07-2016 Issue#4958:In Open body view, the side buttons are getting disturbed on layer change. */
  26 + .btn-resize {
  27 + padding: 6px 11px;
  28 + border: 0px solid #000;
  29 + border-radius: 1px;
  30 + }
  31 +</style>
  32 +
  33 +<style>
  34 + #draggable {
  35 + opacity: 0.2;
  36 + border: solid;
  37 + position: absolute;
  38 + }
  39 +
  40 + #wrapper {
  41 + position: relative;
  42 + width: 100%;
  43 + height: 100%;
  44 + margin: 20px auto;
  45 + }
  46 +
  47 + .tooltip-custom + .tooltip > .tooltip-inner {
  48 + background-color: #fff;
  49 + border: 1px solid #000;
  50 + color: #000;
  51 + border-radius: 0;
  52 + }
  53 +
  54 + .tooltip-custom + .tooltip > .tooltip-arrow {
  55 + display: none;
  56 + }
  57 +
  58 +
  59 + .custom-tooltip {
  60 + background-color: #333;
  61 + border: 0 none;
  62 + color: #fff !important;
  63 + left: -52px;
  64 + /*opacity: 0.9;*/
  65 + padding: 7px;
  66 + position: absolute;
  67 + text-align: center;
  68 + top: 45px;
  69 + width: 120px;
  70 + display: none;
  71 + z-index: 10000;
  72 + border: 1px solid #000;
  73 + color: #000;
  74 + border-radius: 0;
  75 + }
  76 +
  77 + .custom-tooltip1 {
  78 + background-color: #333;
  79 + border: 0 none;
  80 + color: #fff !important;
  81 + left: 52px;
  82 + /*opacity: 0.9;*/
  83 + padding: 7px;
  84 + position: absolute;
  85 + text-align: center;
  86 + top: 45px;
  87 + width: 70px;
  88 + display: none;
  89 + z-index: 10000;
  90 + border: 1px solid #000;
  91 + color: #000;
  92 + border-radius: 0;
  93 + }
  94 +
  95 + .custom-tooltip2 {
  96 + background-color: #333;
  97 + border: 0 none;
  98 + color: #fff !important;
  99 + right: 10px;
  100 + /*opacity: 0.9;*/
  101 + padding: 7px;
  102 + position: absolute;
  103 + text-align: center;
  104 + top: 45px;
  105 + width: 60px;
  106 + display: none;
  107 + z-index: 10000;
  108 + border: 1px solid #000;
  109 + color: #000;
  110 + border-radius: 0;
  111 + }
  112 +
  113 + .pad0 {
  114 + padding: 0;
  115 + }
  116 +</style>
  117 +<!--Annotation Toolbar: Jcanvas-->
  118 +<style>
  119 + .canvas-annotationStyle {
  120 + display: none;
  121 + background-color: transparent;
  122 + z-index: 12000;
  123 + position: absolute;
  124 + left: 0;
  125 + right: 0;
  126 + }
  127 +
  128 + .canvas-annotationStyle1 {
  129 + display: none;
  130 + background-color: transparent;
  131 + z-index: 12000;
  132 + position: absolute;
  133 + left: 0;
  134 + right: 0;
  135 + }
  136 +</style>
  137 +<div class=" " id="daView" ng-controller="TileViewListController">
  138 + <div class="pos-relative leftToolBar tools pull-left">
  139 + <div class="toggle-icon toggleBar toggleHeadingButton" title="Show/Hide Sidebar" style="top:20px;"></div>
  140 + <div class="" style="top:20px">
  141 + <div class="col-xs-6">
  142 + <button id="btnIdentity" onclick="OnIdentityClick()" class="btn btn-primary btn-sm tooltip-custom" data-toggle="tooltip" data-placement="bottom" title="Identify"> <img src="content/images/icon-identity.png" alt=""></button>
  143 + </div>
  144 + <div class="col-xs-6 pull-right">
  145 + <button class="btn btn-black btn-sm pull-right tooltip-custom" onclick="OnZoom()" id="btnZoom" data-toggle="tooltip" data-placement="bottom" title="Zoom-in/Zoom-out">
  146 + <img src="content/images/icon-zoom.png" alt="">
  147 + </button>
  148 +
  149 + </div>
  150 + <div class="col-xs-12">
  151 + <button id="btnTranparency" class="btn btn-black btn-sm btn-block marginTop5 tooltip-custom" onclick="onTboxCreation()" data-toggle="tooltip" data-placement="bottom" title="Transparency Box"><img src="content/images/icon-transparency.png" alt=""></button>
  152 + </div>
  153 +
  154 + <div class="col-xs-12 pad0">
  155 + <div class="col-xs-6">
  156 + <button id="btnNormalMode" class="btn btn-primary btn-sm marginTop5 tooltip-custom" onclick="OnEnableNormalMode()" data-toggle="tooltip" data-placement="bottom" title="Normal"> <img src="content/images/bulb.png" alt=""></button>
  157 + </div>
  158 + <div class="col-xs-6">
  159 + <button id="btnExtract" class="btn btn-black btn-sm pull-right marginTop5 tooltip-custom" onclick="OnEnableExtract()" data-toggle="tooltip" data-placement="bottom" title="Extract"><img src="content/images/bulb1.png" alt=""></button>
  160 + </div>
  161 + </div>
  162 + <div class="col-xs-12 pad0">
  163 + <div class="col-xs-6">
  164 + <button id="btnHighLight" class="btn btn-black btn-sm marginTop5 tooltip-custom btn-resize" onclick="OnEnableHighlight()" data-toggle="tooltip" data-placement="bottom" title="Highlight"> <img src="content/images/Highlight-bulb.png" alt=""></button>
  165 + </div>
  166 +
  167 + <div class="col-xs-6 dropdown hover-tool">
  168 + <div class="custom-tooltip">Highlight Options</div>
  169 + <button class="btn btn-black btn-sm pull-right marginTop5 dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" ng-click="LoadBodySystemData()"><img src="content/images/icon-highlight.png" alt="" title=""></button>
  170 + <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
  171 + <li ng-class="CurrentStructure"><a href="#" title="Current Structure">Current Structure</a></li>
  172 + <li role="separator" class="divider"></li>
  173 + <!--<li ng-class="Cardiovascular"><a href="#" title="Cardiovascular" id="1" ng-click="HighlightBodyByBodySystem($event)">Cardiovascular</a></li>
  174 + <li ng-class="Digestive"><a href="#" title="Digestive" id="2" ng-click="HighlightBodyByBodySystem($event)">Digestive</a></li>
  175 + <li ng-class="Endocrine"><a href="#" title="Endocrine" id="3" ng-click="HighlightBodyByBodySystem($event)">Endocrine</a></li>
  176 + <li ng-class="Immune"><a href="#" title="Immune" id="4" ng-click="HighlightBodyByBodySystem($event)">Immune</a></li>
  177 + <li ng-class="Integumentary"><a href="#" title="Integumentary" id="5" ng-click="HighlightBodyByBodySystem($event)">Integumentary</a></li>
  178 + <li ng-class="Lymphatic"><a href="#" title="Lymphatic" id="6" ng-click="HighlightBodyByBodySystem($event)">Lymphatic</a></li>
  179 + <li ng-class="Muscular"><a href="#" title="Muscular" id="7" ng-click="HighlightBodyByBodySystem($event)">Muscular</a></li>
  180 + <li ng-class="Nervous"><a href="#" title="Nervous" id="8" ng-click="HighlightBodyByBodySystem($event)">Nervous</a></li>
  181 + <li ng-class="Reproductive"><a href="#" title="Reproductive" id="9" ng-click="HighlightBodyByBodySystem($event)">Reproductive</a></li>
  182 + <li ng-class="Respiratory"><a href="#" title="Respiratory" id="10" ng-click="HighlightBodyByBodySystem($event)">Respiratory</a></li>
  183 + <li ng-class="Skeletal"><a href="#" title="Skeletal" id="11" ng-click="HighlightBodyByBodySystem($event)">Skeletal</a></li>
  184 + <li ng-class="Urinary"><a href="#" title="Urinary" id="12" ng-click="HighlightBodyByBodySystem($event)">Urinary</a></li>-->
  185 +
  186 + <li ng-class="Cardiovascular"><a href="#" title="Cardiovascular" id="1" onclick="OnBodySystemSelection(event)">Cardiovascular</a></li>
  187 + <li ng-class="Digestive"><a href="#" title="Digestive" id="2" onclick="OnBodySystemSelection(event)">Digestive</a></li>
  188 + <li ng-class="Endocrine"><a href="#" title="Endocrine" id="3" onclick="OnBodySystemSelection(event)">Endocrine</a></li>
  189 + <li ng-class="Immune"><a href="#" title="Immune" id="4" onclick="OnBodySystemSelection(event)">Immune</a></li>
  190 + <li ng-class="Integumentary"><a href="#" title="Integumentary" id="5" onclick="OnBodySystemSelection(event)">Integumentary</a></li>
  191 + <li ng-class="Lymphatic"><a href="#" title="Lymphatic" id="6" onclick="OnBodySystemSelection(event)">Lymphatic</a></li>
  192 + <li ng-class="Muscular"><a href="#" title="Muscular" id="7" onclick="OnBodySystemSelection(event)">Muscular</a></li>
  193 + <li ng-class="Nervous"><a href="#" title="Nervous" id="8" onclick="OnBodySystemSelection(event)">Nervous</a></li>
  194 + <li ng-class="Reproductive"><a href="#" title="Reproductive" id="9" onclick="OnBodySystemSelection(event)">Reproductive</a></li>
  195 + <li ng-class="Respiratory"><a href="#" title="Respiratory" id="10" onclick="OnBodySystemSelection(event)">Respiratory</a></li>
  196 + <li ng-class="Skeletal"><a href="#" title="Skeletal" id="11" onclick="OnBodySystemSelection(event)">Skeletal</a></li>
  197 + <li ng-class="Urinary"><a href="#" title="Urinary" id="12" onclick="OnBodySystemSelection(event)">Urinary</a></li>
  198 + </ul>
  199 + </div>
  200 + </div>
  201 +
  202 + <div class="col-xs-12 pad0">
  203 + <div class="col-xs-6 hover-gender-tool" ng-init="switchGender()">
  204 + <div class=" custom-tooltip1">Gender</div>
  205 + <button class="btn btn-black btn-sm marginTop5 dropdown-toggle" type="button" id="dropdownMenu4" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <i class=" fa fa-intersex font16"></i></button>
  206 + <ul class="dropdown-menu" aria-labelledby="dropdownMenu3">
  207 + <li ng-class="male">
  208 + <!--<button type="button" id="btnMale" onclick="OnGenderChange('Male')" class="btn btn-link" >Male</button>-->
  209 + <a href="#" title="Male" onclick="OnGenderChange(event)">Male</a>
  210 + </li>
  211 + <li ng-class="female">
28 212  
  213 + <!--<button type="button" id="btnFemale" onclick="OnGenderChange('Female')" class="btn btn-link">Female</button>-->
  214 + <a href="#" title="Female" onclick="OnGenderChange(event)">Female</a>
  215 +
  216 + <!--<a href="javascript:void(0)" title="Male" ng-click="OnGenderChange($event)">Male</a></li>
  217 + <li ng-class="female"><a href="javascript:void(0)" title="Female" ng-click="OnGenderChange($event)">Female</a></li>-->
  218 + </li>
  219 + </ul>
  220 + </div>
  221 +
  222 + <div class="col-xs-6 tooltip-View-custom">
  223 + <div class="custom-tooltip2">View</div>
  224 + <button class="btn btn-black btn-sm pull-right marginTop5 dropdown-toggle" type="button" id="dropdownMenu3" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><img src="content/images/view.png" alt="" title=""></button>
  225 + <ul class="dropdown-menu" aria-labelledby="dropdownMenu3">
  226 + <!--<li ng-class="AnteriorView"><a href="#" title="Anterior" ng-click="OnViewChange($event)">Anterior</a></li>
  227 + <li ng-class="LateralView"><a href="#" title="Lateral" ng-click="OnViewChange($event)">Lateral</a></li>
  228 + <li ng-class="MedialView"><a href="#" title="Medial" ng-click="OnViewChange($event)">Medial</a></li>
  229 + <li ng-class="PosteriorView"><a href="#" title="Posterior" ng-click="OnViewChange($event)">Posterior</a></li>
  230 + <li ng-class="LateralArmView"><a href="#" title="Lateral Arm" ng-click="OnViewChange($event)">Lateral Arm</a></li>
  231 + <li ng-class="MedialArmView"><a href="#" title="Medial Arm" ng-click="OnViewChange($event)">Medial Arm</a></li>-->
  232 +
  233 + <li ng-class="AnteriorView"><a href="#" title="Anterior" onclick="OnViewChange(event)">Anterior</a></li>
  234 + <li ng-class="LateralView"><a href="#" title="Lateral" onclick="OnViewChange(event)">Lateral</a></li>
  235 + <li ng-class="MedialView"><a href="#" title="Medial" onclick="OnViewChange(event)">Medial</a></li>
  236 + <li ng-class="PosteriorView"><a href="#" title="Posterior" onclick="OnViewChange(event)">Posterior</a></li>
  237 + <li ng-class="LateralArmView"><a href="#" title="Lateral Arm" onclick="OnViewChange(event)">Lateral Arm</a></li>
  238 + <li ng-class="MedialArmView"><a href="#" title="Medial Arm" onclick="OnViewChange(event)">Medial Arm</a></li>
  239 + </ul>
  240 + </div>
  241 + </div>
  242 +
  243 + <div class="col-xs-12">
  244 + <button id="btnStrutureBox" onclick="enableShowHideStructureBox()" class="btn btn-primary btn-sm marginTop5 btn-block tooltip-custom" data-toggle="tooltip" data-placement="bottom" title="Show/Hide Structure Name Boxes"> <img src="content/images/comment-box.png" alt=""></button>
29 245 </div>
30   - <div class="col-sm-12" data-toggle="tooltip" data-placement="top" title="Show/Hide Structure Name Boxes"><button class="btn btn-black btn-sm marginTop5 btn-block"> <img src="../../../content/images/aa/LeftMenu/comment-box.png" alt="" title=""></button> </div>
  246 +
31 247 </div>
32   - <div class="pips-slider" style="margin-top:125px">
33   - <h3>Zoom <i class="fa fa-search-plus"></i></h3>
34   - <div class="slider" id="vertical-slider"></div>
  248 + <div class="">
  249 +
  250 +
  251 + <!--'x' button is displaying inside the input box in IE browser.-->
  252 + <div style="width:80px;margin:10px 0 0 15px;display:inline-block;">
  253 + <div style="width: 58px; float: left;">
  254 + <input type="text" class="form-control item" id="txtlayerNumber" value="0" ng-model="layerNumber" ng-keyup="LayerValueChangeBasedOnKeyUp($event)" ng-keydown="LayerChangeBasedOnKeyPressed($event)" style="height:32px;border-radius:0;">
  255 + </div>
  256 + <div style="width: 22px; float: left;">
  257 + <div style="width: 100%; float: left; height: 16px;">
  258 + <button type="button" id="incrmntVal" ng-click="LayerChangeOnMouseUpDown($event)" class="btn btn-default" style="padding:0 5px;border-radius:0;font-size: 10px;vertical-align:top;">
  259 +
  260 + <img style="width:10px;height:10px;" src="~/../content/images/DA/angle-up.png" />
  261 + </button>
  262 + </div>
  263 + <div style="width: 100%; float: left; height: 16px;">
  264 + <button type="button" id="deccrmntVal" ng-click="LayerChangeOnMouseUpDown($event)" class="btn btn-default" style="padding:0 5px;border-radius:0;font-size: 10px;vertical-align:top;">
  265 + <img style="width:10px;height:10px;" src="~/../content/images/DA/angle-down.png" />
  266 + </button>
  267 + </div>
  268 + </div>
  269 +
  270 + </div>
  271 +
  272 +
  273 + <!--<p>
  274 + <input class="item" type="number" id="txtlayerNumber" value="0" step="1" min="0" style="width:80px; margin:10px 0 0 15px;" ng-model="layerNumber" ng-keydown="LayerChangeBasedOnKeyPressed($event)" ng-click="LayerChangeOnMouseUpDown($event)" />
  275 + </p>-->
  276 + <div id="layerChangeSlider" style="height:140px;" class="vert_slider " ng-model="layerNumber"></div>
35 277 </div>
36 278 </div>
37 279  
38 280 <div class="main2">
39 281 <div class="col-sm-12 stickey-area">
40   - <div class="breadcrumb">
  282 + <div class="breadcrumb ">
41 283 <div class="">
42 284 <div class="input-group col-sm-8 col-xs-7 col-md-10 pull-left">
43   - <input class="form-control input-sm " type="text" ng-click="alert('hi search')" placeholder="Anterior cutaneous branch of first intercostal nerve">
  285 +
  286 + <input type="text" class="form-control input-sm pull-left" id="typedtermname" ng-blur="HideSearch()" onclick="OnSearch()" ondblclick="OnSearch()" ng-model="searchFilter" ng-change="textChange(searchFilter)" placeholder="Search...">
  287 +
  288 + <div id="backdrop" ng-show="IsSearchVisible">
  289 + <div class="col-sm-12 col-xs-12 col-md-12 col-lg-12 pull-left">
  290 + <!--#Bug 6591-->
  291 + <ul id="termlistfilter" class="form-control dropdown-menu" style="height:90px;width:100%;overflow-y:scroll;position:absolute;display:none;z-index:1000;">
  292 + <li ng-repeat="item in VocabTermTxt| filter:{ _TermText: searchFilter}">
  293 + <!--<a id="{{item._ActualTermNumber}}" href="" ng-click="jumpToTerm($event)">{{item._TermText}}</a>-->
  294 + <a id="{{item._ActualTermNumber}}" href="" onclick="selectTerm(event)">{{item._TermText}}</a>
  295 + </li>
  296 + </ul>
  297 + </div>
  298 + </div>
  299 + <!--</div>-->
44 300  
45 301 </div>
46   - &nbsp;
47   - <!-- Single button -->
48 302 <div class="btn-group">
49   - <button type="button" class="btn btn-success dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
50   - <i class="fa fa-arrow-circle-right"></i>
  303 + <button type="button" style="padding:0px 0px 10px 1px !important;background-color:rgba(255,255,255,0.0); border:none;" class="btn btn-success dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  304 + <img src="~/../content/images/DA/go-to.png" style="height: 30px;width:50px">
51 305 </button>
52   - <ul class="dropdown-menu">
53   - <li><a href="#">1<sup>st</sup> &amp; 2<sup>nd</sup> Intercostal Spaces</a></li>
  306 + <ul class="dropdown-menu" style="width:100%;">
  307 + <li><a href="#">{{currentTitleFromJson}}</a></li>
54 308 <li role="separator" class="divider"></li>
55 309 <li><a href="#">All</a></li>
56 310 </ul>
57 311 </div>
58   - <div class="btn-group">
59   - <button type="button" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="navigatorMan" ng-click="alert('hi nav')">
60   - <i class="fa fa-male"></i>
  312 + <div class="btn-group open" id="da-body-nav">
  313 + <button type="button" style="padding:0px 0px 10px 1px !important;background-color:rgba(255,255,255,0.0); border:none;" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  314 + <img src="~/../content/images/DA/navigator-view.png" style="height:30px; width:50px" />
61 315 </button>
62   - <ul class="dropdown-menu" style="min-width:auto;">
63   - <li><img src="../../../content/images/aa/LeftMenu/position.jpg" class="img-responsive"></li>
64   - </ul>
65   - </div>
66 316  
  317 + <div class="dropdown-menu active" id="navigatorDiv" style="min-height:auto; min-width:auto; ">
  318 + <div id="containment-wrapper" align="center" style="min-width:auto;height:119px; ">
  319 + <img id="navimg" ng-src="{{navimgsrc}}" alt=""></img>
  320 + <div id="draggable" class="draggable ui-widget-content" ng-mouseup="ScrollCanvasDiv()" ng-style="dragdivposition">
  321 + </div>
  322 + </div>
  323 +
  324 + </div>
  325 + </div>
67 326 </div>
68 327 </div>
69 328 </div>
70   - <div class="col-sm-12">
  329 + <div class=" canavsParent col-sm-12 " id="cp">
71 330 <div class="container-fluid">
72 331 <div class="row">
  332 + <div id="canvasDiv" class="col-sm-12 img-thumbnail" align="center">
  333 + <canvas id="canvasPaint" ng-click="FreeStylePaint($event)" width="2277" height="3248" class="canvas-annotationStyle1"></canvas>
  334 + <canvas id="canvas" ng-click="BindCanvasDrawingListners($event)" width="2277" height="3248" class="canvas-annotationStyle"></canvas>
  335 + </div>
  336 + <!--<div id="canvasDiv" style=" width: 95% !important;top:0px;overflow:scroll;background-color:white;">-->
  337 + <!--<div id="daLoaderLabel">Loading....</div>-->
73 338  
74   - <div class=" col-sm-12 img-thumbnail" align="center" id="imageDiv">
75   - <img id="modItemImage" src="../../../content/images/aa/images/aa_img_3112.jpg" alt="" title="" class="img-responsive">
76   - <div class="clearfix">
77   - <!--<img id="modItemImage" ng-init="alert('hi')" alt="" title="" class="img-responsive">-->
  339 + </div>
  340 + <div class="clearfix"></div>
  341 + </div>
  342 + </div>
  343 + <div class="clearfix"></div>
  344 + </div>
  345 + <div class="clearfix"></div>
  346 + <!--to prevent transparency scale from closing on click anywhere outside set data-backdrop="static" data-keyboard="false" -->
  347 + <!--<div class="modal fade bs-example-modal-sm" tabindex="-1" aria-labelledby="mySmallModalLabel" id="transparencyScale" data-backdrop="static" data-keyboard="false">
  348 + <div class="modal-dialog modal-sm">
  349 + <div class="modal-content">
  350 + <div class="modal-header annotation-modal-header">
  351 + <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseTransparencyBox()"><span aria-hidden="true">&times;</span></button>
  352 + <h4 class="modal-title">Transparency</h4>
  353 + </div>
  354 + <div class="modal-body">
  355 + <div class="row">
  356 + <div class="col-sm-12">
  357 + <div class="padded25">
  358 + <div class="slider"></div>
  359 + </div>
  360 + </div>
  361 + </div>
  362 + </div>
  363 + </div>
  364 + </div>
  365 + </div>-->
  366 + <!--<div class="ui-widget-content" id="transparencyScale" style="width: 350px; height: 130px;visibility:hidden;display:block;float:left">
  367 + <div class="modal-dialog modal-sm">
  368 + <div class="modal-content">
  369 + <div class="modal-header annotation-modal-header">
  370 + <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseTransparencyBox()"><span aria-hidden="true">&times;</span></button>
  371 + <h4>Transparency</h4>
  372 + </div>
  373 + <div>
  374 + <div class="row">
  375 + <div class="col-sm-12">
  376 + <div class="padded25">
  377 + <div class="slider"></div>
  378 + </div>
  379 + </div>
  380 + </div>
  381 + </div>
  382 + </div>
  383 + </div>
  384 + </div>-->
  385 + <div class="ui-widget-content" id="transparencyScale" style="width: 350px; height: 150px;visibility:hidden;display:block;float:left">
  386 + <div>
  387 + <div>
  388 + <div class="modal-header annotation-modal-header">
  389 + <button id="btnTBoxClose" type="button" onclick="onTboxClose()" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  390 + <h4>Transparency</h4>
  391 + </div>
  392 + <div>
  393 + <div class="row">
  394 + <div class="col-sm-12">
  395 + <div class="padded25">
  396 + <!--<div class="slider" id="sliderScale"></div>-->
  397 + <div class="slider"></div>
  398 + </div>
78 399 </div>
79   - <!--<div class="col-sm-1 img-thumbnail pull-right" align="center"><img src="../../content/images/1000x600.jpg" alt="" title="" class="img-responsive"></div>
80   - <div class="clearfix"></div>-->
81 400 </div>
82 401 </div>
83 402 </div>
84   -
85   -
86 403 </div>
87   -
88 404 </div>
89 405 </div>
90 406  
91   - <script>
92   - $(window).load(function () {
93   - $(".stickey-area").sticky();
  407 +
  408 +<!--<script src="../../../libs/jquery/1.11.4/jquery-ui.js"></script>-->
  409 +<script src="libs/jquery/jquery_plugin/slider-pips/jquery-ui-slider-pips.js"></script>
  410 +
  411 +<script>
  412 + $(window).load(function () {
  413 + $(".stickey-area").sticky();
  414 + });</script>
  415 +<script>
  416 + $(function () {
  417 +
  418 +
  419 + var regExp = /[0-9\.\,]/;
  420 + $('#txtlayerNumber').on('keydown keyup', function (e) {
  421 + var value = String.fromCharCode(e.which) || e.key;
  422 + // Only numbers, dots and commas
  423 + if (!regExp.test(value)
  424 + && e.which != 188 // ,
  425 + && e.which != 190 // .
  426 + && e.which != 8 // backspace
  427 + && e.which != 46 // delete
  428 + && (e.which < 37 // arrow keys
  429 + || e.which > 40)
  430 + && (e.keyCode < 96 // Dissectible Anatomy > Num Lock is not working for enter the layer.
  431 + || e.keyCode > 105)) {
  432 + e.preventDefault();
  433 + return false;
  434 + }
94 435 });
95   - </script>
96   - <script>
97   - $(function () {
98   - $("#slider-range-min-2").slider({
99   - range: "min",
100   - min: 1,
101   - max: 60,
102   - value: 10,
103   - slide: function (event, ui) {
104   - $("#amount-2").val(ui.value);
105   - }
106   - });
107   - $("#amount-2").val($("#slider-vertical-2").slider("value"));
108 436  
  437 +
  438 + $("#layerChangeSlider").slider({
  439 + orientation: "vertical",
  440 + range: "max", // <--- needed...
  441 + min: 0,
  442 + // max: 100,
  443 + value: 0,
  444 + slide: function (event, ui) {
  445 + // $("#txtlayerNumber").val(100 - ui.value); // basic math operation..
  446 +
  447 + // $("#txtlayerNumber").val($("#layerChangeSlider").slider("value"));
  448 + },
  449 + stop: function (event, ui) {
  450 + var la;
  451 + var rootScope = angular.element(document.getElementById("bo")).scope();
  452 + rootScope.$apply(function () {
  453 + rootScope.isLoading = true;
  454 + })
  455 + var scope = angular.element(document.getElementById("daView")).scope();
  456 + scope.$apply(function () {
  457 + if (scope.isTransparencyActivated) {
  458 + rootScope.isLoading = false;
  459 + }
  460 + la = parseInt(scope.totalLayers) //- parseInt(scope.layerNumber);
  461 + // $('#layerChangeSlider').slider("option", "value", la - ui.value);
  462 + var slideVal = la - ui.value;
  463 + $("#txtlayerNumber").val(slideVal);
  464 + scope.layerNumber = slideVal;
  465 + scope.LayerChange();
  466 + });
  467 + },
  468 +
  469 + })
  470 + });
  471 +
  472 +</script>
  473 +<!--<script>
  474 + $(function () {
  475 + $('#layerChangeSlider').slider().on('slideStop', function () {
  476 + alert('fjkjksdbgjkgjkfgk')
  477 + })
  478 +</script>
  479 + });-->
  480 +
  481 +<script src="libs/jquery/jquery_plugin/slider-pips/jquery-ui-slider-pips.js"></script>
  482 +<script>
  483 + $(function () {
  484 + $("#transparencyScale").draggable();
  485 + $("#draggable").draggable({ containment: "#containment-wrapper", scroll: false });
  486 + });
  487 +</script>
  488 +<script>
  489 + $(function () {
  490 +
  491 + $("#dropdownMenu2").mouseover(function () {
  492 + $(".custom-tooltip").css("display", "block");
  493 + });
  494 + $("#dropdownMenu2").mouseout(function () {
  495 + $(".custom-tooltip").css("display", "none");
109 496 });
110   - </script>
111 497  
112   - <script>
113   - $(document).ready(function () {
114   - $('[data-toggle="tooltip"]').tooltip();
  498 + $("#dropdownMenu4").mouseover(function () {
  499 + $(".custom-tooltip1").css("display", "block");
  500 + });
  501 + $("#dropdownMenu4").mouseout(function () {
  502 + $(".custom-tooltip1").css("display", "none");
115 503 });
116   - </script>
117   - <script src="../../../libs/jquery/jquery_plugin/slider-pips/jquery-ui-slider-pips.js"></script>
118   - <script>
119   - $(".slider")
120   -
121   - .slider({
122   - min: 25,
123   - max: 100,
124   - value: 100,
125   - range: "min",
126   - orientation: "vertical"
127   - })
128 504  
129   - .slider("pips", {
130   - rest: "label",
131   - step: "15"
  505 + $("#dropdownMenu3").mouseover(function () {
  506 + $(".custom-tooltip2").css("display", "block");
  507 + });
  508 + $("#dropdownMenu3").mouseout(function () {
  509 + $(".custom-tooltip2").css("display", "none");
132 510 });
133   - </script>
134 511  
135   - <script>
136   - $(function () {
137   - $("#draggable").draggable();
  512 +
  513 +
  514 +
  515 + });
  516 +</script>
  517 +<script>
  518 + $(".slider")
  519 + .slider({
  520 + min: 0,
  521 + max: 100,
  522 + value: 50,
  523 + range: "min",
  524 + orientation: "horizontal",
  525 + stop: function (event, ui) {
  526 + //alert('trans changed')
  527 + var scope = angular.element(document.getElementById("daView")).scope();
  528 + scope.$apply(function () {
  529 + scope.onTransparencyChange(event, ui);
  530 + });
  531 + }
  532 + })
  533 + .slider("pips", {
  534 + rest: "label",
  535 + step: "10"
  536 + });
  537 +
  538 +</script>
  539 +<script>
  540 + $(".tooltip-custom").tooltip({
  541 + tooltipClass: 'customTooltip'
  542 + });
  543 +</script>
  544 +<script>
  545 + $(function () {
  546 + $(".modal").draggable();
  547 + });
  548 +</script>
  549 +<script>
  550 + $(function () {
  551 + "use strict";
  552 + /*** Sidebar Toggle ***/
  553 + var barPos = 0;
  554 + var bar = $('.tools');
  555 + var main = $('.main2');
  556 + $('.toggleBar').click(function () {
  557 +
  558 + bar.toggleClass('active');
  559 + main.toggleClass('active');
138 560 });
139   - </script>
  561 + });
  562 +</script>
140 563  
141 564  
... ...
400-SOURCECODE/AIAHTML5.Web/app/views/da/da-body-view.html
1 1 <div>
2 2 <div ng-include="aap/widget/MainMenu.html"></div>
3   - <div ng-init="openBodyView()" id="" class="daBodyView" ng-controller="DAController"></div>
  3 + <div ng-init="openBodyView()" id="" class="daBodyView" ng-controller="TileViewListController"></div>
4 4 <!--<div >
5 5  
6 6 </div>-->
... ...
400-SOURCECODE/AIAHTML5.Web/app/views/module-item-view.html
1 1 <div>
2 2 <div ng-include="aap/widget/MainMenu.html"></div>
3   - <div ng-init="openBodyView()" id="" class="daBodyView" ng-controller="TileViewListController"></div>
  3 + <div ng-init="openBodyView()" id="" class="daBodyView" ng-controller="DAController"></div>
4 4 <!--<div >
5 5  
6 6 </div>-->
7   -</div>
  7 +</div>
8 8 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.Web/app/views/tile-view.html
1   -<div class="bodyWrap row no-scroll">
2   - <div ng-include=" 'app/widget/MainMenu.html' " />
3   - <div class="main">
4   - <div class="col-sm-12 stickey-area clsstickydiv">
5   - <div class="breadcrumb">
6   - <div class="row center-block">
7   - <h5 class="text-center text-primary txt-white f15">Display Image By</h5>
8   - <div class="col-md-2 col-sm-4 pad-lftrgt3">
9   - <div class="form-group">
10   - <h6 class="text-center text-primary txt-white f11">Body Region</h6>
11   - <select class="form-control input-sm" ng-model="query.selectedbodyregion" ng-options="item for item in AllBodyRegion track by item">
12   - <option value="">All</option>
13   - </select>
14   - </div>
15   - </div>
16   - <div class="col-md-2 col-sm-4 pad-lftrgt3">
17   - <div class="form-group">
18   - <h6 class="text-center text-primary txt-white f11">Body System</h6>
19   - <select class="form-control input-sm" ng-model="query.selectedbodysystem" ng-options="item for item in AllBodySystem track by item">
20   - <option value="">All</option>
21   - </select>
22   - </div>
23   - </div>
24   - <div class="col-md-2 col-sm-4 pad-lftrgt3">
25   - <div class="form-group">
26   - <h6 class="text-center text-primary txt-white f11">View Orientation</h6>
27   - <select class="form-control input-sm" ng-model="query.selectedorientation" ng-options="item for item in AllOrientation track by item">
28   - <option value="">All</option>
29   - </select>
30   - </div>
31   - </div>
32   - <div class="col-md-2 col-sm-4 pad-lftrgt3">
33   - <div class="form-group">
34   - <h6 class="text-center text-primary txt-white f11">Image Type</h6>
35   - <select class="form-control input-sm" ng-model="query.selectedimagetype" ng-options="item for item in AllImageType track by item">
36   - <option value="">All</option>
37   - </select>
38   - </div>
39   - </div>
40   - <div class="col-md-2 col-sm-4 pad-lftrgt3" style="display:none">
41   - <div class="form-group">
42   - <h6 class="text-center text-primary txt-white f11">Medical Speciality</h6>
43   - <select class="form-control input-sm" ng-model="query.selectedspecialty" ng-options="item for item in CIAllSpeciality track by item">
44   - <option value="">All</option>
45   - </select>
46   - </div>
47   - </div>
48   - <div class="col-md-2 col-sm-4 pad-lftrgt3">
49   - <div class="form-group">
50   - <h6 class="text-center text-primary txt-white f11">Search</h6>
51   - <button class="btn btn-primary btn-sm" ng-click="ApplySearch(query)"><i class="fa fa-search"></i></button>&nbsp;<button class="btn btn-primary btn-sm col-md-9" ng-click="Reset(query)"><i class="fa fa-eye"></i> Show All</button>
52   - </div>
53   - </div>
54   - </div>
55   - </div>
56   - </div>
  1 +<div class="bodyWrap row ">
  2 + <div ng-include="'app/widget/MainMenu.html'" />
  3 + <div class="main" ng-init="loadForModuleById(1)">
  4 + <!--<div class="main">-->
  5 + <div class="col-sm-12" style="padding-left:25px; width:99%">
57 6  
58   - <div class="row tab-content" style="padding-left:25px; width:99%">
59   - <!--<div role="tabpanel" class="tab-pane active" id="grid-view">-->
60   - <div role="tabpanel" id="grid-view">
61   - <div ng-repeat="(key,val) in moduleLandingData.data.root.Item">
62   - <div id="{{val._Id}}" class="col-sm-3 col-md-3" title="{{val._Title}}" ng-click="openModuleItemView($event)">
63   - <div class="thumbnail">
64   - <img class="tinyImg" id="{{val._Title}}" ng-src="../content/images/aa/thumbnails/{{val._TileImageName}}" alt="" title="">
65   - <div class="caption"><p>{{val._Title}}</p></div>
66   - </div>
67   - </div>
  7 +
  8 + <!-- Nav tabs -->
  9 + <ul class="nav nav-tabs" role="tablist">
  10 + <li role="presentation" id="Male" class="active" ng-click="getDAViewList($event)"><a><i class="fa fa-mars-stroke "></i> Male</a></li>
  11 + <li role="presentation" id="Female" ng-click="getDAViewList($event)"><a><i class="fa fa-venus"></i> Female</a></li>
  12 + </ul>
  13 + <!-- Tab panes -->
  14 + <div class="tab-content">
  15 + <div role="tabpanel" class="tab-pane active">
  16 + <div class="row" id="bodyViewList">
68 17  
69 18  
70   - <!--<div ng-if="!filterstring" ng-repeat="item in selectedCIListViewData">
71   - <div id="{{item._id}}" class="col-sm-3 col-lg-2" title="{{item._Title}}" data-ng-click="openView($event)">
72   - <div class="thumbnail">
73   - <img ng-src="~ /../content/images/ci/thumbnails/{{item._ThumbnailImage}}" alt="" title="">
74   - <div class="caption">
75   - <p>{{item._Title}}</p>
76   - </div>
77   - </div>
78   - </div>
79   - </div>
80 19  
81   - <div ng-if="filterstring" ng-repeat="item in searchCIListViewData">
82   - <div id="{{item._id}}" class="col-sm-3 col-lg-2" title="{{item._Title}}" data-ng-click="openView($event)">
83   - <div class="thumbnail">
84   - <img ng-src="~ /../content/images/ci/thumbnails/{{item._ThumbnailImage}}" alt="" title="">
85   - <div class="caption">
86   - <p>{{item._Title}}</p>
87 20 </div>
88 21 </div>
89   - </div>
90   - </div>-->
91   - </div>
92   - </div>
93   - <!--<div role="tabpanel" class="tab-pane" id="list-view">-->
94   - <div role="tabpanel" ng-class="{'tab-pane active' : activeTab === 2,'tab-pane' : activeTab !==2 }" id="list-view">
95   - <!--<div class="col-sm-12 table-responsive">-->
96   - <div class="panel col-sm-12 table-responsive" style="padding-left:0px; padding-right:0; margin-left:11px; margin-bottom:0; width:99%;">
97   - <!--<table class="table table-hover table-condensed bg-white" style="padding-left:25px; width:99%">-->
98   - <table class="table table-hover table-fixed bg-white table-txt12" style="padding-left:25px; width:100%;">
99   - <thead class="clsthead">
100   - <tr class="active">
101   - <th width="15%">Title</th>
102   - <th width="15%">Region</th>
103   - <th width="15%">System</th>
104   - <th width="15%">View</th>
105   - <th width="15%">Type</th>
106   - <th width="25%">Specialty</th>
107   - </tr>
108   - </thead>
109   - <tbody ng-if="!filterstring" class="clstbody">
110   - <tr id="{{item._id}}" ng-click="showItem(item._id)" ng-dblclick="openView($event)" ng-repeat="item in selectedCIListViewData">
111   - <td width="15%">
112   - {{item._Title}}
113   - </td>
114   - <td width="15%">
115   - {{item._BodyRegion}}
116   - </td>
117   - <td width="15%">
118   - {{item._BodySystem}}
119   - </td>
120   - <td width="15%">
121   - {{item._ViewOrientation}}
122   - </td>
123   - <td width="15%">
124   - {{item._ImageType}}
125   - </td>
126   - <td width="25%" style="display:none">
127   - {{item._MedicalSpecialty}}
128   - </td>
129   - </tr>
130   - </tbody>
131   - <tbody ng-if="filterstring" class="clstbody">
132   - <tr ng-click="showItem(item._id)" ng-dblclick="openView($event)" ng-repeat="item in searchCIListViewData">
133   - <td width="15%">
134   - {{item._Title}}
135   - </td>
136   - <td width="15%">
137   - {{item._BodyRegion}}
138   - </td>
139   - <td width="15%">
140   - {{item._BodySystem}}
141   - </td>
142   - <td width="15%">
143   - {{item._ViewOrientation}}
144   - </td>
145   - <td width="15%">
146   - {{item._ImageType}}
147   - </td>
148   - <td width="25%" style="display:none">
149   - {{item._MedicalSpecialty}}
150   - </td>
151   - </tr>
152   - <tr ng-if="typeof(searchCIListViewData) == 'undefined' || searchCIListViewData == null || searchCIListViewData == ''">
153   - <td colspan="6"><strong style="color:black;">No illustration found for the selected search criteria!</strong></td>
154   - </tr>
155   - </tbody>
156   - </table>
157   - </div>
158   - <div class="col-sm-12" ng-show=" hiderow" style="padding-left:25px;padding-top:10px;">
159   - <div class="row well">
160   - <div title="{{SelectedCITitle}}" class="col-sm-3 col-lg-2 no-padding">
161   - <div class="thumbnail no-margin">
162   - <img id="{{SelectedCIId}}" src="{{SelectedCIthumbImage}}" alt="" title="{{SelectedCITitle}}" data-ng-click="openView($event)">
163   - </div>
164   - </div>
165   - <div class="col-sm-9 col-lg-9" style="padding-left:10px;">
166   - <p class="f11" ng-bind-html="SelectedCISummary"></p>
167   - <button id="{{SelectedCIId}}" type="button" class="btn btn-primary btn-sm pull-right" data-ng-click="openView($event)">Open</button>
168   - </div>
169   - </div>
170 22  
171   - </div>
172 23 </div>
173 24 </div>
174 25 </div>
  26 + </div>
175 27 </div>
  28 +
  29 +<script>
  30 + $(function () {
  31 +
  32 + $(function () {
  33 + $('[data-toggle="tooltip"]').tooltip();
  34 + })
  35 + });
  36 +</script>
  37 +<script>
  38 + (function ($) {
  39 + $(window).load(function () {
  40 + $(".sidebar").mCustomScrollbar({
  41 + autoHideScrollbar: true,
  42 + //theme:"rounded"
  43 + });
  44 + //alert("side bar DA page");
  45 + });
  46 + })(jQuery);
  47 +</script>
  48 +<script>
  49 + $(function () {
  50 + $(".modal").draggable();
  51 + });
  52 +</script>
... ...