[go: up one dir, main page]

Menu

[r10]: / libs / madcollector.js  Maximize  Restore  History

Download this file

345 lines (333 with data), 11.3 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
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
function checkAll(nomForm,nomItem)
{
var objFormulaire = document.forms[nomForm];
if(!objFormulaire)
return;
var objCheckBoxes = objFormulaire.elements[nomItem];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = true;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = true;
}
function uncheckAll(nomForm,nomItem)
{
var objFormulaire = document.forms[nomForm];
if(!objFormulaire)
return;
var objCheckBoxes = objFormulaire.elements[nomItem];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = false;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = false;
}
function mad_include_arc(id, url, option) {
var element = document.getElementById(id);
if (!element) {
return;
}
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&select=' + option.value, false);
req.send(null);
element.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('arc');
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
element.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
objOptionVide.text = items[i].getElementsByTagName('label')[0].childNodes[0].data;
}
if(items.length==0) element.style.display='none';
else element.style.display='inline';
}
}
function mad_include_artist(id, url, option) {
var element = document.getElementById(id);
if (!element) {
return;
}
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&lastname=' + option.value, false);
req.send(null);
element.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('artist');
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
element.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("lastname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("firstname").length>0)
nom += ', '+items[i].getElementsByTagName("firstname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("middlename").length>0)
nom += ' '+items[i].getElementsByTagName("middlename")[0].childNodes[0].data;
objOptionVide.text = nom;
}
if(items.length==0) element.style.display='none';
else element.style.display='inline';
}
}
function check_name(tagcheck,valuecheck,input_name,submit_name,url,resultdiv) {
var nameinput = document.getElementById(input_name);
var bouton = document.getElementById(submit_name);
var element = document.getElementById(resultdiv);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&action='+ escape(nameinput.value) , false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName(tagcheck);
if(message!=null)
{
paragVide = document.createElement("p");
textParag = document.createTextNode(message);
paragVide.appendChild(textParag);
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
objOptionVide.text = items[i].getElementsByTagName(valuecheck)[0].childNodes[0].data;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function check_artist_name(first_name,middle_name,last_name,artist_data_submit,check_artist) {
var firstinput = document.getElementById(first_name);
var middleinput = document.getElementById(middle_name);
var lastinput = document.getElementById(last_name);
var bouton = document.getElementById(artist_data_submit);
var element = document.getElementById(check_artist);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=artist&format=xml' + '&firstname='+ escape(firstinput.value) + '&middlename='+ escape(middleinput.value) + '&lastname='+ escape(lastinput.value) , false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName("artist");
if(message!=null)
{
paragVide = document.createElement("p");
textParag = document.createTextNode(message);
paragVide.appendChild(textParag);
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("lastname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("firstname").length>0)
nom += ', '+items[i].getElementsByTagName("firstname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("middlename").length>0)
nom += ' '+items[i].getElementsByTagName("middlename")[0].childNodes[0].data;
objOptionVide.text = nom;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function check_series_name(refname) {
var nameinput = document.getElementById(refname);
var publisher = nameinput.form.elements["new_publisher"];
var volume = nameinput.form.elements["new_volume"];
var edition = nameinput.form.elements["new_firstedition"];
var edition_value='';
for (var i=0; i<edition.length;i++)
if (edition[i].checked)
edition_value = edition[i].value;
var bouton = nameinput.form.elements["add_series"];
var element = document.getElementById("check_series");
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=series&id_publisher=' + publisher.value + '&format=xml&action='+ escape(nameinput.value) + '&volume=' + escape(volume.value) + '&edition=' + escape(edition_value), false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName("series");
if(message!=null)
{
paragVide = document.createElement("p");
textParag = document.createTextNode(message);
paragVide.appendChild(textParag);
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("seriesname")[0].childNodes[0].data + ' vol.' + items[i].getAttribute('volume');
if(items[i].getAttribute('year')!=null) nom += ' (' + items[i].getAttribute('year') + ')';
objOptionVide.text = nom;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function story_vote(id_series,issue,id_story, option) {
var element = document.getElementById("story_vote_"+id_story);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=vote&id_series=' + id_series + '&issue=' + issue + '&id_story=' + id_story + '&vote=' + option + '&action=story', false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var status = myDoc.getElementsByTagName("vote")[0].getAttribute('status');
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
if(message!=null)
{
paragVide = document.createElement("p");
textParag = document.createTextNode(message);
paragVide.appendChild(textParag);
element.appendChild(paragVide);
element.setAttribute("class","voted");
}
}
}
function loadXMLData(content)
{
// code for IE
if (window.ActiveXObject)
{
var doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(content);
}
// code for Mozilla, Firefox, Opera, etc.
else
{
var parser=new DOMParser();
var doc=parser.parseFromString(content,"text/xml");
}
return doc.documentElement;
}
function create_XMLHTTP()
{
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
}
else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
return req;
}