ModuleService.js
5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var ATLAS_ANATOMY = 'Atlas Anatomy';
var CLINICAL_ILLUSTRATION = 'Clinical Illustrations';
var CLINICAL_ANIMATION = 'Clinical Animations';
var OpenedModuleItemList = [];
var ModDetail = [];
//module.service( 'Book', [ '$rootScope', function( $rootScope ) {
AIA.service('ModuleService', ['$rootScope', function ($rootScope, DataService) {
return {
SaveOpenedModules: function (moduleDetails) {
ModDetail = moduleDetails;
OpenedModuleItemList.push("imageId: " + moduleDetails[0]);
OpenedModuleItemList.push("moduleId:" + moduleDetails[1]);
OpenedModuleItemList.push("moduleName: " + moduleDetails[2]);
//var moduleId = moduleDetails.moduleId;
//OpenedModuleList.push(moduleId);
//OpenedModuleList.tileViewId = moduleDetails.TileViewId;
//OpenedModuleList.tileImageName = moduleDetails.imageName;
//OpenedModuleList.tileImageSRC = moduleDetails.imagePath;
//moduleData.push($scope.moduleId);
//moduleData.push(value._Id);
//moduleData.push(value._ImageId);
//moduleData.push(value._Title);
//moduleData.push(value._ImageName);
//moduleData.push(value._BodySystem);
//moduleData.push(value._BodyRegion);
//moduleData.push(value._ViewOrientation);
//moduleData.push(value._ImageType);
//moduleData.push(value._TileImageName);
console.log('called service');
this.renderModuleItemById();
},
renderModuleItemById: function () {
var jsonFileForOpenModule;
if (ModDetail[2] == ATLAS_ANATOMY) {
this.loadPinData();
}
else if (ModDetail[2] == CLINICAL_ANIMATION) {
}
else if (ModDetail[3] == CLINICAL_ILLUSTRATION) {
}
},
loadPinData: function () {
var pinJsonFile = "/content/data/json/aa/aa_pin_data/aa_dat_pindata_" + ModDetail[0] + ".json";
alert('pinJsonFile: ' + pinJsonFile);
var promise = DataService.getJson(pinJsonFile);
promise.then(
function (result) {
var AtlasAnatomyPinData = result;
var data = new jinqJs()
.from(AtlasAnatomyPinData.root.Item)
//.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
})
},
loadModuleDataBasedOnModuleName: function (moduleName) {
alert('loadModuleDataBasedOnModuleName is called');
var jsonPath;
if (moduleName == ATLAS_ANATOMY) {
jsonPath = '~/../content/data/json/aa/aa_dat_contentlist.json';
}
else if (moduleName == CLINICAL_ANIMATION) {
//to do, in next phase of project
jsonPath = '~/../content/data/json/ca/ca_dat_contentlist.json';
}
else if (moduleName == CLINICAL_ILLUSTRATION) {
//to do, in next phase of project
jsonPath = '~/../content/data/json/ci/ci_dat_contentlist.json';
}
var promise = DataService.getJson(jsonPath)
.then(
function (result) {
var AtlasAnatomyData = result;
var data = new jinqJs()
.from(AtlasAnatomyData.root.Item)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
angular.forEach(data, function (value, key) {
// $rootScope.moduleData = [];
//$scope.moduleData.push({ "id": value._Id, "imageID": value._ImageId, "TileName": value._TileImageName, "DivImageTitle": value._Title });
// $scope.moduleData.push(value._ImageId);
// $scope.moduleData.push(value._TileImageName);
var ImageName = value._TileImageName;
var imagePath = "~/../content/images/aa/thumbnails/" + value._TileImageName;
//$scope.TileViewId = value._Id;
$rootScope.tileHTML = $('<div id="' + value._Id + '" class="col-sm-3 col-md-3" title = "' + value._Title + '" data-ng-click="openModuleItem()">'
+ '<div class="thumbnail" >'
+ '<img class="tinyImg" id="' + value._Title + '"ng-src="' + imagePath + '" alt="" title="" >'
+ '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>');//.appendTo('#grid-view');
debugger;
})
//if ($rootScope.tileHTML != undefined) {
// alert('come before broadcast')
// $rootScope.$broadcast('SendTileDataEvent', true);
//}
},
function (error) {
// handle errors here
console.log(' $rootScope.TermNumberData= ' + error.statusText);
}
)
}
}
}]);