-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·261 lines (239 loc) · 7.18 KB
/
app.js
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// Code goes here
// Code goes here
var app = angular.module('iawaApp', ['ngMaterial', 'ngRoute']);
var searchFilter = function(item, q) {
for(var k in item) {
if(k==="documents")
continue;
v = item[k];
if(v.toLowerCase().includes(q.toLowerCase()))
return true;
}
return false;
}
var getDataTitled = function(arr, title) {
for(var i=0; i<arr.length; i++) {
var item = arr[i];
if(item.title==title)
return item
}
}
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'home.html',
controller: 'mainController'
})
.when('/collections', {
templateUrl: 'collections.html',
controller: 'mainController'
})
.when('/collections/item/:param1', {
templateUrl: 'collection-item.html',
controller: 'mainController'
})
.when('/collections/item/document/:param1', {
templateUrl: 'document.html',
controller: 'mainController'
})
.when('/bookmarks', {
templateUrl: 'bookmarks.html',
controller: 'mainController'
})
.when('/about', {
templateUrl: 'about.html',
controller: 'mainController'
})
.when('/help', {
templateUrl: 'help.html',
controller: 'mainController'
})
.when('/signin', {
templateUrl: 'sign-in.html',
controller: 'mainController'
})
.when('/contact', {
templateUrl: 'contact.html',
controller: 'mainController'
})
});
app.controller('mainController', ['$scope', '$filter', '$location', '$routeParams', function($scope, $filter, $location, $routeParams) {
$scope.searchTerm = "";
$scope.data_raw = [
{"title": "The Berta Rahm Architectural Collection",
"year": "1998",
"architect": "Berta Rahm",
"description": "Architect of Switzerland. Educated at l'Ecole Polytechnique Federale de Zurich (Diploma in architecture, 1934). Inspired by her uncle",
"documents": [
{
"title": "title",
"img": "",
"description": "asdfsadfasdfsadfsadfsafd",
"cite": "asdfasdfafsfsdfasdf",
"type": "asdfas"
}
]
},
{"title": "Sigrid L. Rupp Architectural Collection",
"year": "1997",
"architect": "Sigrid L. Rupp",
"description": "Rupp's collection encompasses over twenty years of her firm, SLR/Architects, and includes",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
},
{"title": "Liane Zimbler Architectural Collection",
"year": "1988",
"architect": "Liane Zimbler",
"description": "Liane Zimbler was born in Czechoslovakia in 1892. She studied Art and Architecture at the State Art School in Austria",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
},
{"title": "The L. Jane Hastings Architectural Papers",
"year": "1951",
"architect": "L. Jane Hastings",
"description": "L. Jane Hastings was born and raised in Seattle, Washington. She received a Bachelor of Architecture from the University of Washington in 1952",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
}
];
$scope.viewType = "list";
$scope.changeView = function(viewType) {
$scope.viewType = viewType;
}
$scope.checkViewType = function(viewType){
return viewType === $scope.viewType;
}
var title=$routeParams.param1;
if(title)
$scope.currCollection = getDataTitled($scope.data_raw, title);
else
$scope.currCollection = getDataTitled($scope.data_raw, "Liane Zimbler Architectural Collection");
$scope.openCollection = function(title) {
$location.path("/collections/item/"+title)
}
$scope.gotosignin = function() {
$location.path("/signin");
}
$scope.gotoBookmarks = function() {
$location.path("/bookmarks")
}
$scope.openDocument = function(title) {
$location.path("/collections/item/document/"+title)
}
$scope.searchQuery = function() {
$scope.data = $scope.data_raw.filter(x=>searchFilter(x, $scope.searchTerm));
console.log($scope.searchTerm);
}
$scope.data = JSON.parse(JSON.stringify($scope.data_raw));
$scope.showSearchbar = false;
$scope.filterChange = function(changeObj, type) {
var showFilter = function(arr, value, type) {
var valid = arr.filter(x=>x['isChecked']);
if(valid.length === 0){
valid = arr.filter(x=>true);
}
valid = valid.map(x=>x[type]);
return valid.includes(value);
}
if(type==="year") {
$scope.data = $scope.data_raw.filter(x=>showFilter($scope.years, x['year'], 'year'));
$scope.apply();
}
else if(type==="architect") {
$scope.data = $scope.data_raw.filter(x=>showFilter($scope.architects, x['architect'], 'architect'));
$scope.apply();
}
}
var yearFilterObj = function(year) {
return {"year": year, "isChecked": false}
}
var architectFilterObj = function(name) {
return {"architect": name, "isChecked": false}
}
$scope.years = $scope.data.map(x=>new yearFilterObj(x["year"]));
$scope.architects = $scope.data.map(x=>new architectFilterObj(x["architect"]));
$scope.sortResults = function(sortBy) {
$scope.data = $filter('orderBy')($scope.data, sortBy, false)
}
}]);
app.controller('collectionController', ['$scope', '$routeParams', function($scope, $routeParams) {
$scope.data_raw = [
{"title": "The Berta Rahm Architectural Collection",
"year": "1998",
"architect": "Berta Rahm",
"description": "Architect of Switzerland. Educated at l'Ecole Polytechnique Federale de Zurich (Diploma in architecture, 1934). Inspired by her uncle",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
},
{"title": "Sigrid L. Rupp Architectural Collection",
"year": "1997",
"architect": "Sigrid L. Rupp",
"description": "Rupp's collection encompasses over twenty years of her firm, SLR/Architects, and includes",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
},
{"title": "Liane Zimbler Architectural Collection",
"year": "1988",
"architect": "Liane Zimbler",
"description": "Liane Zimbler was born in Czechoslovakia in 1892. She studied Art and Architecture at the State Art School in Austria",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
},
{"title": "The L. Jane Hastings Architectural Papers",
"year": "1951",
"architect": "L. Jane Hastings",
"description": "L. Jane Hastings was born and raised in Seattle, Washington. She received a Bachelor of Architecture from the University of Washington in 1952",
"documents": [
{
"title": "",
"img": "",
"description": "",
"cite": "",
"type": ""
}
]
}
];
}]);