DAController.js
3.67 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
'use strict';
AIA.controller("DAController", ["$scope", "$compile", "$http", "$log", "$location", "$timeout","DA",
function ($scope, $compile,$http, $log, $location, $timeout,DA ) {
$scope.genderId = "";
$scope.BodyViewData = null;
$scope.selectedGenderBodyViewData = null;
$scope.imagePath = "";
//get the DA body view list based on selected gender
$scope.getDAViewList = function ($event) {
$("#bodyViewList").empty();
//for default load
if ($event == null) {
$scope.genderId = "Male";
}
else {
$scope.genderId = $event.currentTarget.id;
}
$scope.selectedGenderBodyViewData = new jinqJs()
.from($scope.BodyViewData.BodyViews.view)
.where('_gender == ' + $scope.genderId)
.select();
angular.forEach($scope.selectedGenderBodyViewData, function (value, key) {
var userEthnicity = DA[0].ethnicity;
var userModestysettings = DA[0].modesty;
var userSelectedSkintone = 'W';
$scope.userModestySetting = 'Y'
var thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity + userModestysettings)) + '.jpg';
$scope.imagePath = "http://localhost/AIA/content/images/DA/BodyViews/" + value._id + '/skintone/' + userEthnicity + '/' + thumbnailImage;
$scope.isImageExists = $scope.checkImgExistance($scope.imagePath);
//debugger
if ($scope.isImageExists == false) {
$scope.imagePath = ($scope.imagePath).replace($scope.userModestySetting, "");
}
//debugger
var $el = $('<div id=' + value._id + ' class="col-sm-3 col-lg-2" data-ng-click="openView($event)"><div class="thumbnail" >'
+ '<img class= "daImg" id="' + value._title + '" src="' + $scope.imagePath + '" alt="" title="" >'
+ '<div class="caption"><p>' + value._title + '</p></div></a></div></div>').appendTo('#bodyViewList');
$compile($el)($scope);
});
};
$scope.checkImgExistance = function (imagePath) {
var result = "";
$.ajax({
url: imagePath,
success: function (data) {
result = true;
},
error: function (data) {
result = false;
},
})
debugger
return result;
}
$scope.openView = function ($event) {
alert('clicked: ' + $event.currentTarget.id)
}
//load json data for body view
$scope.loadBodyViewData = function () {
$http({ method: 'GET', url: 'http://localhost/AIA/content/data/json/da_dat_contentlist.json' }).success(function (data) {
$scope.BodyViewData = data;
//load default body view list for male
$scope.getDAViewList();
})
.error(function (data, status, headers, config) {
console.log(data);
});
}
angular.element(document).ready(function () {
})
}]
);