-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.html
376 lines (320 loc) · 10.7 KB
/
test.html
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<html>
<head>
<meta charset="utf-8">
<title>OParl test</title>
<script src="lib/oparl-src.js"></script>
</head>
<body>
<script>
//-----------------------------------------------------------------------
function log(text) {
var div = document.createElement('div');
div.style.cssText = 'color:#555;padding:0 .5em;';
div.innerHTML = text || '<br>';
document.body.appendChild(div);
}
//-----------------------------------------------------------------------
function error(text) {
var div = document.createElement('div');
div.style.cssText = 'color:#f55;padding:.2em .5em;';
div.innerHTML = text;
document.body.appendChild(div);
}
//-----------------------------------------------------------------------
function testAgendaItem(data) {
'use strict';
log();
log('Agenda: ' + data.number + '. ' + data.name);
log('Result: ' + data.result);
log('Text: ' + data.resolutionText);
log('Start time: ' + (isNaN(data.start) ? '---' : data.start.toJSON().slice(11, 16)));
log('End time: ' + (isNaN(data.end) ? '---' : data.end.toJSON().slice(11, 16)));
}
//-----------------------------------------------------------------------
function testLocation(data, callback) {
'use strict';
log();
log('Location: ' + data.description);
log('Address: ' + data.streetAddress);
log('Room: ' + data.room);
log('Locality: ' + data.locality + ' - ' + data.subLocality);
log('ZIP: ' + data.postalCode);
callback();
}
//-----------------------------------------------------------------------
function testMembership(data, callback) {
'use strict';
log();
log('Membership as: ' + data.role);
log('Voting right: ' + (data.votingRight ? 'yes' : 'no'));
log('Start date: ' + (isNaN(data.startDate) ? '---' : data.startDate.toJSON().slice(0, 10)));
log('End date: ' + (isNaN(data.endDate) ? '---' : data.endDate.toJSON().slice(0, 10)));
callback();
}
//-----------------------------------------------------------------------
function testParticipant(data, callback) {
'use strict';
log();
log('Participant name: ' + data.name);
log('Participant name: ' + data.formOfAddress + ' ' + data.affix + ' ' + data.givenName + ' ' + data.familyName);
log('Gender: ' + data.gender);
log('Phone: ' + (data.phone.length === 0 ? '---' : data.phone[0]));
log('Email: ' + (data.email.length === 0 ? '---' : data.email[0]));
log('Status: ' + (data.status.length === 0 ? '---' : data.status[0]));
log('Some text about the people: ' + data.life);
log('Source: ' + data.lifeSource);
data.membershipList.get(function (err, dataMembershipList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Membership count: ' + dataMembershipList.length);
if (dataMembershipList.length > 0) {
dataMembershipList[0].get(function (err, dataMembership) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testMembership(dataMembership, function () {
data.locationObject.get(function (err, dataLocation) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testLocation(dataLocation, callback);
}
});
});
}
});
}
}
});
}
//-----------------------------------------------------------------------
function testMeeting(data) {
'use strict';
log();
log('Meeting name: ' + data.name);
log('Date: ' + (isNaN(data.start) ? '---' : data.start.toJSON().slice(0, 10)));
log('Start time: ' + (isNaN(data.start) ? '---' : data.start.toJSON().slice(11, 16)));
log('End time: ' + (isNaN(data.end) ? '---' : data.end.toJSON().slice(11, 16)));
data.organizationList.get(function (err, dataOrganizationList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Organization count: ' + dataOrganizationList.length);
data.participantList.get(function (err, dataParticipantList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Participant count: ' + dataParticipantList.length);
data.auxiliaryFileList.get(function (err, dataAuxiliaryFileList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Auxiliary file count: ' + dataAuxiliaryFileList.length);
data.agendaItemList.get(function (err, dataAgendaItemList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Agenda item count: ' + dataAgendaItemList.length);
if (dataParticipantList.length > 0) {
dataParticipantList[0].get(function (err, dataParticipant) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testParticipant(dataParticipant, function () {
if (dataAgendaItemList.length > 0) {
dataAgendaItemList[0].get(function (err, dataAgendaItem) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testAgendaItem(dataAgendaItem);
}
});
}
});
}
});
}
}
});
}
});
}
});
}
});
}
//-----------------------------------------------------------------------
function testOrganization(data) {
'use strict';
log();
log('Organization name: ' + data.name);
log('Organization type: ' + data.organizationType);
log('Classification: ' + data.classification);
log('Start date: ' + (isNaN(data.startDate) ? '---' : data.startDate.toJSON().slice(0, 10)));
log('End date: ' + (isNaN(data.endDate) ? '---' : data.endDate.toJSON().slice(0, 10)));
data.membershipList.get(function (err, dataMembership) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Membership count: ' + dataMembership.length);
data.meetingList.get(function (err, dataMeetingList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Meeting count: ' + dataMeetingList.length);
if (dataMeetingList.length > 0) {
dataMeetingList[0].get(function (err, dataMeeting) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testMeeting(dataMeeting);
}
});
}
}
});
}
});
}
//-----------------------------------------------------------------------
function testLegislative(data, callback) {
'use strict';
log();
log('Legislative term name: ' + data.name);
data.bodyObject.get(function (err, dataBody) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
if (dataBody === null) {
log('Body name: ---');
} else {
log('Body name: ' + dataBody.name);
}
log('Start date: ' + (isNaN(data.startDate) ? '---' : data.startDate.toJSON().slice(0, 10)));
log('End date: ' + (isNaN(data.endDate) ? '---' : data.endDate.toJSON().slice(0, 10)));
callback();
}
});
}
//-----------------------------------------------------------------------
function testBody(data) {
log();
log('Body name: ' + data.name);
log('Body license: ' + data.license);
log('Body modified: ' + isNaN(data.modified) ? '' : data.modified.toJSON().substr(0, 10));
data.systemObject.get(function (err, dataSystem) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('System name: ' + dataSystem.name);
data.organizationList.get(function (err, dataOrganizationList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Organization count: ' + dataOrganizationList.length);
data.personList.get(function (err, dataPersonList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Person count: ' + dataPersonList.length);
data.meetingList.get(function (err, dataMeetingList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Meeting count: ' + dataMeetingList.length);
data.paperList.get(function (err, dataPaperList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Paper count: ' + dataPaperList.length);
data.legislativeTermList.get(function (err, dataLegislativeTermList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Legislative count: ' + dataLegislativeTermList.length);
if (dataLegislativeTermList.length > 0) {
dataLegislativeTermList[0].get(function (err, dataLegislativeTerm) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testLegislative(dataLegislativeTerm, function () {
if (dataOrganizationList.length > 0) {
dataOrganizationList[0].get(function (err, dataOrganization) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testOrganization(dataOrganization);
}
});
}
});
}
});
} else {
var orga = 6;
if (dataOrganizationList.length > orga) {
dataOrganizationList[orga].get(function (err, dataOrganization) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testOrganization(dataOrganization);
}
});
}
}
}
});
}
});
}
});
}
});
}
});
}
});
}
//-----------------------------------------------------------------------
function testSystem(data) {
log();
log('System name: ' + data.name);
log('System license: ' + data.license);
data.bodyList.get(function (err, dataBodyList) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
log('Body count: ' + dataBodyList.length);
if (dataBodyList.length > 0) {
dataBodyList[0].get(function (err, object) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testBody(object);
}
});
}
}
});
}
//-----------------------------------------------------------------------
function start() {
OParl.open('https://www.lwl-pch.sitzung-online.de/oi/oparl/1.0/system.asp', function (err, data) {
// OParl.open('https://dev.oparl.org/api/v1/system/', function (err, data) {
if (err !== null) {
error('Something went wrong: ' + err);
} else {
testSystem(data);
}
});
}
//-----------------------------------------------------------------------
document.onreadystatechange = function () {
if (document.readyState == "complete") {
start();
}
}
</script>
</body>
</html>