'use strict'; AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService", function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService) { $scope.genderId = ""; $scope.BodyViewData; $scope.selectedGenderBodyViewData; $scope.imagePath = ""; $rootScope.BodyRegionData; $rootScope.BodyRegionCordinatesData; $scope.isTransparencyActivated = false; $rootScope.BodyLayerData; $rootScope.VocabTermData; //for modesty image layers $scope.lowerlayerNumberForModesty; $scope.HigherlayerNumberForModesty; $scope.layerInfoForModesty; $scope.VocabTermTxt; $scope.CommonData $rootScope.TermNumberData; $rootScope.BodySystemData $scope.bodyViewId = 0; $rootScope.bgartData; $scope.drawnBodyRegions; //view specific constants $rootScope.voId; $scope.layerNumber; $scope.daCounter = 1; $scope.bagartDetails; $scope.transNumber = 50; //for transarency scale $scope.TBDrawStartX; $scope.TBDrawStartY; $scope.isTBDrawnOnBodyRegion; $rootScope.path = "~/../content/images/speeachBubbleClose.png"; $rootScope.isHighLight = false; $rootScope.coloredImageCanvasList = []; $rootScope.coloredImageMRCanvasList = []; $rootScope.ColoredCanvasData = []; $rootScope.grayImageDataList = []; $rootScope.grayImageMRDataList = []; $rootScope.updatedGrayDataList = []; $rootScope.updatedGrayMRDataList = []; $scope.isEligibleForHighlight = false; $scope.doHighlightOrExtract = false; $scope.isClickedOnBodyForHighlight; $scope.isEligibleForHighlightBodyByTermList = false; // $scope.AnteriorView = "active"; $scope.zoomInOut = 75; $scope.speechBubbleCounter = 0; $scope.j = 0; $scope.speechbubbleList = []; $scope.speachBubbleArrayAnnotation = []; $rootScope.multiAnnotationIsON = false; $scope.previousGrayImageDataVar; $scope.previousGrayCanvas; $rootScope.updatedImageDataList = []; $rootScope.updatedImageMRDataList = []; $scope.previousSelectedTermList = []; $scope.runningWorkers = []; $scope.runningSearchWorkers = []; $scope.runningBodyViewWorkers = []; // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false. $scope.machedIcolorInBodyRegion = []; $rootScope.MaskCanvasData = []; //extract $rootScope.isExtract = false; $rootScope.UIWrapperZIndex = 12000; $rootScope.whiteImageDataList = []; $rootScope.whiteImageMRDataList = []; $rootScope.previousHighlightList = []; $rootScope.isViewChange = false; $rootScope.isGenderChnage = false; // to do it is setting but not using. need to check $rootScope.updatedWhiteImageDataList = []; $rootScope.updatedWhiteImageMRDataList = []; //normal mode $rootScope.isNormalMode = true; $rootScope.isZoomed = false; //navigator man functionality $scope.navigatorImage; $rootScope.NavigatorData; $scope.navimgsrc; $scope.dragdivleft = 0; $scope.dragdivtop = 0; $scope.IsSearchVisible = false; $scope.shapesize = 1; $scope.dragdivposition = { "left": $scope.dragdivleft, "top": $scope.dragdivtop }; //array for bodyviewid correspoing to male female(used for gender change) $scope.correspondingBodyViewIds = { '1': '5', '2': '6', '3': '7', '4': '8', '9': '11', '10': '12', '5': '1', '6': '2', '7': '3', '8': '4', '11': '9', '12': '10', } $scope.bodyViews = { 'Anterior': '1', 'Lateral': '2', 'Medial': '3', 'Posterior': '4', 'Lateral Arm': '5', 'Medial Arm': '6' } $scope.isBodylayerdataLoaded = false; $scope.isBodyRegionDataLoaded = false; //currentTitleFromJson shows the current BodyView Title $scope.currentTitleFromJson; $scope.showme = false; $scope.IsVisible = function () { $scope.scroll(); } $scope.scroll = function () { // $window.scrollTo(0, 0); $("html,body").scrollTop(0); //alert("scroll"); } $scope.switchGender = function () { var retrievedObject = localStorage.getItem('currentViewTitle'); if (retrievedObject == "Male Anterior") { $scope.male = "active"; $scope.female = ""; } else if (retrievedObject == "Female Anterior") { $scope.male = ""; $scope.female = "active"; } } //get the DA body view list based on selected gender //get the DA body view list based on selected gender $scope.getDAViewList = function ($event) { if ($('#MainImage') != null) { $('#MainImage').remove(); } // $rootScope.currentActiveModuleTitle = Modules[0].Name; $("#bodyViewList").empty(); //for default load if ($event == null || $event == undefined) { //if ((localStorage.getItem("genderId") != "")||(localStorage.getItem("genderId")!="null")) { // $scope.genderId = localStorage.getItem("genderId"); //} var selectedGender = localStorage.getItem("genderId"); if ((selectedGender == null)) { $scope.genderId = "Male"; } else $scope.genderId = localStorage.getItem("genderId"); } else { $scope.genderId = $event.currentTarget.id; } localStorage.setItem("genderId", $scope.genderId); var selectedGender = localStorage.getItem("genderId"); if (selectedGender != null) { if (selectedGender == "Male") { $('#Male').addClass('active'); $('#Female').removeClass("active"); } else { $('#Female').addClass('active'); $('#Male').removeClass("active"); } } $scope.selectedGenderBodyViewData = new jinqJs() .from($scope.BodyViewData.BodyViews.view) .where('_gender == ' + $scope.genderId) .select(); if ($scope.selectedGenderBodyViewData != null || $scope.selectedGenderBodyViewData != undefined) { angular.forEach($scope.selectedGenderBodyViewData, function (value, key) { var userEthnicity; var userModestysettings; var curentEthnicity = localStorage.getItem("globalEthnicity"); if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) { userEthnicity = curentEthnicity; } else { userEthnicity = $rootScope.globalSetting.ethnicity; } var curentmodesty = localStorage.getItem("globalModesty"); if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) { userModestysettings = curentmodesty; } else { userModestysettings = $rootScope.globalSetting.modesty; } //var userSelectedSkintone = 'W'; //$scope.userModestySetting = 'Y' var thumbnailImage; if ((value._id == 1) || (value._id == 3) || (value._id == 5) || (value._id == 6) || (value._id == 7) || (value._id == 11)) thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity + userModestysettings)) + '.jpg'; else { thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity)) + '.jpg'; } $scope.imagePath = "~/../content/images/DA/" + $scope.zoomInOut + "/body-views/" + value._id + '/skintone/' + userEthnicity + '/' + thumbnailImage; var $el = $('
' + '' + '

' + value._title + '

').appendTo('#bodyViewList'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); }); } }; $scope.openView = function ($event) { $rootScope.disableAnnotationTB = false; $rootScope.MenuModuleName = "DA"; //alert($rootScope.MenuModuleName); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $rootScope.currentBodyViewId = $event.currentTarget.id; $rootScope.ViewTitle = $event.currentTarget.textContent; localStorage.setItem("currentViewTitleFromJson", $event.currentTarget.textContent); localStorage.setItem("currentViewTitle", $event.currentTarget.textContent); localStorage.setItem("currentBodyViewId", $event.currentTarget.id); var u = $location.url(); $location.url('/da-body-view'); var view_list = angular.element($event.currentTarget); var view_list_male_female = view_list.attr('title'); if (($event.currentTarget.textContent == "Female Anterior" || $event.currentTarget.textContent == "Male Anterior")) { $rootScope.AnteriorView = "active"; $rootScope.LateralView = ""; $rootScope.MedialView = ""; $rootScope.PosteriorView = ""; $rootScope.LateralArmView = ""; $rootScope.MedialArmView = ""; } if (($event.currentTarget.textContent == "Female Lateral" || $event.currentTarget.textContent == "Male Lateral")) { $rootScope.AnteriorView = ""; $rootScope.LateralView = "active"; $rootScope.MedialView = ""; $rootScope.PosteriorView = ""; $rootScope.LateralArmView = ""; $rootScope.MedialArmView = ""; } if (($event.currentTarget.textContent == "Female Medial" || $event.currentTarget.textContent == "Male Medial")) { $rootScope.AnteriorView = ""; $rootScope.LateralView = ""; $rootScope.MedialView = "active"; $rootScope.PosteriorView = ""; $rootScope.LateralArmView = ""; $rootScope.MedialArmView = ""; } if (($event.currentTarget.textContent == "Female Posterior" || $event.currentTarget.textContent == "Male Posterior")) { $rootScope.AnteriorView = ""; $rootScope.LateralView = ""; $rootScope.MedialView = ""; $rootScope.PosteriorView = "active"; $rootScope.LateralArmView = ""; $rootScope.MedialArmView = ""; } if (($event.currentTarget.textContent == "Female Lateral Arm" || $event.currentTarget.textContent == "Male Lateral Arm")) { $rootScope.AnteriorView = ""; $rootScope.LateralView = ""; $rootScope.MedialView = ""; $rootScope.PosteriorView = ""; $rootScope.LateralArmView = "active"; $rootScope.MedialArmView = ""; } if (($event.currentTarget.textContent == "Female Medial Arm" || $event.currentTarget.textContent == "Male Medial Arm")) { $rootScope.AnteriorView = ""; $rootScope.LateralView = ""; $rootScope.MedialView = ""; $rootScope.PosteriorView = ""; $rootScope.LateralArmView = ""; $rootScope.MedialArmView = "active"; } //$rootScope.Normal = "LeftButtonsDefaultState"; if (view_list_male_female == "Male") { $rootScope.male = "active"; $rootScope.female = ""; } else { $rootScope.male = ""; $rootScope.female = "active"; } } //load json data for body view $scope.loadDissectibleAnatomyData = function () { //get current path var currentURL = $location.path(); var selectedModuleName = ''; angular.forEach( $rootScope.userModules, function (value, key) { if (value.slug === currentURL.replace('/','')) { selectedModuleName = value.name; $rootScope.currentActiveModuleTitle = selectedModuleName; } }) $rootScope.ClearIframe(); //load common data var commondataJsonPath = '~/../content/data/json/da/da_dat_common.json'; DataService.getAnotherJson(commondataJsonPath) .then( function (result) { $rootScope.CommonData = result; $http({ method: 'GET', url: '~/../content/data/json/da/da_dat_contentlist.json' }).success(function (data) { $scope.BodyViewData = data; $scope.getDAViewList(); }) .error(function (data, status, headers, config) { console.log(data); }); }, function (error) { console.log(error.statusText) } ) //load body-views data // $('#daLoaderLabel').css('visibility', 'hidden') $rootScope.isLoading = false; //push the details of open module in array $rootScope.openModules $rootScope.openModules.push({ "ModuleId": 1 }); } //da-body-views functions $scope.openBodyView = function () { //0. we will initially append container to load body //check if localstorage has any settings var curentEthnicity = localStorage.getItem("globalEthnicity"); if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) { $rootScope.globalSetting.ethnicity = curentEthnicity; } var curentmodesty = localStorage.getItem("globalModesty"); if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) { $rootScope.globalSetting.modesty = curentmodesty } //0.1 var currentBodyViewId = localStorage.getItem("currentBodyViewId"); $scope.loadSearchDataForBodyView(); console.log('currentBodyViewId pickjed from localStorage: ' + currentBodyViewId); var openViews; if ($rootScope.openViews != null || $rootScope.openViews != undefined) { if ($rootScope.openViews.length > 0) { openViews = new jinqJs() .from($rootScope.openViews) .where("BodyViewId == " + currentBodyViewId) .select(); } } // 0.2 getting corresponding body view title //var counter = 1; var tittle = localStorage.getItem("currentViewTitleFromJson"); localStorage.setItem("currentViewTitle", tittle); //WILL BE USED WHEN MULTI VIEWOPEN FUNCTIONALITY IS IMPELMNETD //if (openViews != null && openViews != undefined) { // angular.forEach(openViews, function (value, key) { // if (value.bodyView == tittle) { // tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; // $rootScope.currentActiveViewTitle = tittle; // localStorage.setItem("currentViewTitle", tittle); // } // }); //} //else { // localStorage.setItem("currentViewTitle", tittle); //} //0.3 $.jsPanel({ id: 'daImagePanel', selector: '.daBodyView', theme: 'success', currentController: 'DAController', parentSlug: 'da-view-list', ajax: { url: 'app/views/da/da-view.html' }, title: localStorage.getItem("currentViewTitle"), position: { top: 70, left: 1, }, size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, }); console.log('jsPanel loaded daImagePanel exist= ' + document.getElementById('daImagePanel')) //0.1 $rootScope.currentSlug = 'da-body-view'; //0.2 $rootScope.openViews.push( { "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, "slug": $rootScope.currentSlug } ); //0.3 var daBodyviewElement = angular.element(document.getElementById("daBodyview")); $timeout(function () { $compile(daBodyviewElement.contents())($scope); console.log('html is compiled' + document.getElementById('daView')) if (document.getElementById('daView') != null) { //0.4 added some stylesheets $('#daBodyview').css("height", $(window).outerHeight()); $('#daBodyview').css("width", $(window).outerWidth()); //1. load navigator man first console.log('before LoadBodyViewNavigatorImage call') $scope.LoadBodyViewNavigatorImage(); //$scope.loadSearchDataForBodyView(); $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle"); $scope.layerNumber = 0; //2. console.log('currentBodyViewId just before sending: ' + currentBodyViewId); $scope.loadBodyViewData(currentBodyViewId); //2. load bodyRegion data $rootScope.isLoading = true; $rootScope.voId = localStorage.getItem("currentBodyViewId"); $('#daBodyview').css("height", $(window).outerHeight()); $('#daBodyview').css("width", $(window).outerWidth()); } }, 250); } angular.element(document).ready(function (e) { $("#layerChangeSlider").slider({ orientation: "vertical", range: "max", // <--- needed... min: 0, // max: 100, value: 0, slide: function (event, ui) { // $("#txtlayerNumber").val(100 - ui.value); // basic math operation.. // $("#txtlayerNumber").val($("#layerChangeSlider").slider("value")); }, stop: function (event, ui) { var la; var rootScope = angular.element(document.getElementById("bo")).scope(); rootScope.$apply(function () { rootScope.isLoading = true; }) var scope = angular.element(document.getElementById("daView")).scope(); scope.$apply(function () { if (scope.isTransparencyActivated) { rootScope.isLoading = false; } la = parseInt(scope.totalLayers) //- parseInt(scope.layerNumber); // $('#layerChangeSlider').slider("option", "value", la - ui.value); var slideVal = la - ui.value; $("#txtlayerNumber").val(slideVal); scope.layerNumber = slideVal; scope.LayerChange(); $("#annotationpaintbrushsize").removeClass("activebtncolor"); $("#annotationpainteraser").removeClass("activebtncolor"); }); }, }); $("#daImagePanel").resize(function () { $("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition); $("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition); }); $(document).on("mouseover", "#termList option", function (e) { $('#termList option[selected="selected"]').attr("selected", false); $(this).attr("selected", true); }); $(document).keypress(function (e) { if ($('#termList option[selected="selected"]').attr("id") == "undefined") { return false; } else { var originator = e.keyCode || e.which; // alert($('#termList option[selected="selected"]').attr("id")); if ($('#termList option[selected="selected"]').attr("id")) { if (e.keyCode == 13) { onListManagerTermSelection($('#termList option[selected="selected"]').attr("id")); } } } }); }) $scope.loadSearchDataForBodyView = function () { console.log('loadSearchDataForBodyView'); var currentBodyViewId = localStorage.getItem("currentBodyViewId"); var searchWorker = new Worker('search-wp.js'); //push workers in array to further used the refernece to delete the workers $scope.runningSearchWorkers.push({ 'workerName': searchWorker }) //console.log('for bodyRegionId = ' + bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")) searchWorker.postMessage({ 'currentBodyViewId': currentBodyViewId, }) searchWorker.onmessage = function (e) { //console.log('callback searchWorker , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); $rootScope.TermNumberData = e.data.TermNumberData, $rootScope.VocabTermData = e.data.VocabTermData, $scope.vocabTermTxt = e.data.vocabTermTxt $scope.VocabTermTxt = new jinqJs() .from($scope.vocabTermTxt) .distinct('_TermText', '_ActualTermNumber') .orderBy([{ field: '_TermText', sort: 'asc' }]) .select('_ActualTermNumber', '_TermText', '_cdId'); console.log('JlinqActivity , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); if ($scope.runningSearchWorkers != null || $scope.runningSearchWorkers != undefined) { var workerCount = $scope.runningSearchWorkers.length; if (workerCount > 0) { for (var i = workerCount - 1; i >= 0; i--) { var runningWorker = $scope.runningSearchWorkers[i].workerName; runningWorker.terminate(); $scope.runningSearchWorkers.splice(i, 1); // workerCount--; } } } } //call watch on '$scope.VocabTermTxt and compile
  • and append to