1 | //Some "constants" to match the server constants
|
---|
2 | var SUCCESS = 1;
|
---|
3 | var ACCEPTED = 2;
|
---|
4 | var ERROR = 3;
|
---|
5 | var CONTINUING = 10;
|
---|
6 | var COMPLETED = 11;
|
---|
7 | var HALTED = 12;
|
---|
8 |
|
---|
9 |
|
---|
10 | function getElementsByClassName(cl, parent)
|
---|
11 | {
|
---|
12 | var elemArray = [];
|
---|
13 | var classRegEx = new RegExp("\\b" + cl + "\\b");
|
---|
14 | var elems;
|
---|
15 | if(parent)
|
---|
16 | {
|
---|
17 | elems = parent.getElementsByTagName("*");
|
---|
18 | }
|
---|
19 | else
|
---|
20 | {
|
---|
21 | elems = document.getElementsByTagName("*");
|
---|
22 | }
|
---|
23 |
|
---|
24 | for (var i = 0; i < elems.length; i++)
|
---|
25 | {
|
---|
26 | var classeName = elems[i].className;
|
---|
27 | if (classRegEx.test(classeName)) elemArray.push(elems[i]);
|
---|
28 | }
|
---|
29 |
|
---|
30 | return elemArray;
|
---|
31 | };
|
---|
32 |
|
---|
33 | function getNextSiblingOfType(elem, type)
|
---|
34 | {
|
---|
35 | if(elem == null)
|
---|
36 | {
|
---|
37 | return null;
|
---|
38 | }
|
---|
39 |
|
---|
40 | var current = elem.nextSibling;
|
---|
41 | while(current != null)
|
---|
42 | {
|
---|
43 | if(current.nodeName.toLowerCase() == type)
|
---|
44 | {
|
---|
45 | return current;
|
---|
46 | }
|
---|
47 |
|
---|
48 | current = current.nextSibling;
|
---|
49 | }
|
---|
50 | return null;
|
---|
51 | }
|
---|
52 |
|
---|
53 | function getPrevSiblingOfType(elem, type)
|
---|
54 | {
|
---|
55 | if(elem == null)
|
---|
56 | {
|
---|
57 | return null;
|
---|
58 | }
|
---|
59 |
|
---|
60 | var current = elem.previousSibling;
|
---|
61 | while(current != null)
|
---|
62 | {
|
---|
63 | if(current.nodeName.toLowerCase() == type)
|
---|
64 | {
|
---|
65 | return current;
|
---|
66 | }
|
---|
67 |
|
---|
68 | current = current.previousSibling;
|
---|
69 | }
|
---|
70 | return null;
|
---|
71 | }
|
---|
72 |
|
---|
73 | function saveTransaction(transaction)
|
---|
74 | {
|
---|
75 | console.log(transaction);
|
---|
76 | _transactions.push(transaction);
|
---|
77 | }
|
---|
78 |
|
---|
79 | function undo()
|
---|
80 | {
|
---|
81 | if(_undoOperations.length == 0)
|
---|
82 | {
|
---|
83 | return;
|
---|
84 | }
|
---|
85 |
|
---|
86 | var undoOp = _undoOperations.pop();
|
---|
87 |
|
---|
88 | //Create/Duplicate undo
|
---|
89 | if(undoOp.op == "del")
|
---|
90 | {
|
---|
91 | if(undoOp.srcElem.childList)
|
---|
92 | {
|
---|
93 | removeFromParent(undoOp.srcElem.childList);
|
---|
94 | }
|
---|
95 | if(undoOp.srcElem.parentItem)
|
---|
96 | {
|
---|
97 | undoOp.srcElem.parentItem.menu.newSectionLink.style.display = "inline";
|
---|
98 | undoOp.srcElem.parentItem.childList = null;
|
---|
99 | }
|
---|
100 | removeFromParent(undoOp.srcElem);
|
---|
101 | }
|
---|
102 |
|
---|
103 | if(undoOp.op == "delMeta")
|
---|
104 | {
|
---|
105 | if(undoOp.srcElem.childList)
|
---|
106 | {
|
---|
107 | removeFromParent(undoOp.srcElem.childList);
|
---|
108 | }
|
---|
109 | if(undoOp.srcElem.parentItem)
|
---|
110 | {
|
---|
111 | undoOp.srcElem.parentItem.menu.newSectionLink.style.display = "inline";
|
---|
112 | undoOp.srcElem.parentItem.childList = null;
|
---|
113 | }
|
---|
114 | de.doc.unregisterEditSection(undoOp.srcElem);
|
---|
115 | removeFromParent(undoOp.srcElem);
|
---|
116 | }
|
---|
117 |
|
---|
118 | //Move undo (mva is move after, mvb is move before, mvi is move into)
|
---|
119 | else if(undoOp.op == "mva" || undoOp.op == "mvb" || undoOp.op == "mvi")
|
---|
120 | {
|
---|
121 | if(undoOp.op == "mvb")
|
---|
122 | {
|
---|
123 | undoOp.refElem.parentNode.insertBefore(undoOp.srcElem, undoOp.refElem);
|
---|
124 | }
|
---|
125 | else if(undoOp.op == "mva")
|
---|
126 | {
|
---|
127 | insertAfter(undoOp.srcElem, undoOp.refElem);
|
---|
128 | }
|
---|
129 | else
|
---|
130 | {
|
---|
131 | undoOp.refElem.removeChild(undoOp.refElem.firstChild);
|
---|
132 | undoOp.refElem.appendChild(undoOp.srcElem);
|
---|
133 | }
|
---|
134 |
|
---|
135 | if(undoOp.srcElem.textDiv)
|
---|
136 | {
|
---|
137 | insertAfter(undoOp.srcElem.textDiv, undoOp.srcElem);
|
---|
138 | }
|
---|
139 | if(undoOp.srcElem.childList)
|
---|
140 | {
|
---|
141 | insertAfter(undoOp.srcElem.childList, undoOp.srcElem.textDiv);
|
---|
142 | }
|
---|
143 |
|
---|
144 | if(undoOp.srcElem.onmouseout)
|
---|
145 | {
|
---|
146 | //Uncolour the section if it coloured
|
---|
147 | undoOp.srcElem.onmouseout();
|
---|
148 | }
|
---|
149 | updateFromTop();
|
---|
150 | }
|
---|
151 | else if(undoOp.op == "display")
|
---|
152 | {
|
---|
153 | undoOp.srcElem.style.display = undoOp.subOp;
|
---|
154 | }
|
---|
155 |
|
---|
156 | if(undoOp.removeDeletedMetadata)
|
---|
157 | {
|
---|
158 | _deletedMetadata.pop();
|
---|
159 | }
|
---|
160 |
|
---|
161 | if(undoOp.removeTransaction)
|
---|
162 | {
|
---|
163 | _transactions.pop();
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | function addCollectionToBuild(collection)
|
---|
168 | {
|
---|
169 | for(var i = 0; i < _collectionsToBuild.length; i++)
|
---|
170 | {
|
---|
171 | if(collection == _collectionsToBuild[i])
|
---|
172 | {
|
---|
173 | return;
|
---|
174 | }
|
---|
175 | }
|
---|
176 | _collectionsToBuild.push(collection);
|
---|
177 | }
|
---|
178 |
|
---|
179 | function save()
|
---|
180 | {
|
---|
181 | //This works in most cases but will not work when taking a doc from one collection to another, will need to be fixed at some point
|
---|
182 | var collection;
|
---|
183 | if(gs.cgiParams.c && gs.cgiParams.c != "") {
|
---|
184 |
|
---|
185 | collection = gs.cgiParams.c;
|
---|
186 | }
|
---|
187 | else {
|
---|
188 | collection = gs.cgiParams.p_c;
|
---|
189 | }
|
---|
190 |
|
---|
191 | var sendBuildRequest = function()
|
---|
192 | {
|
---|
193 | var request = "[";
|
---|
194 | for(var i = 0; i < _transactions.length; i++)
|
---|
195 | {
|
---|
196 | request += _transactions[i];
|
---|
197 | if(i != _transactions.length - 1)
|
---|
198 | {
|
---|
199 | request += ",";
|
---|
200 | }
|
---|
201 | }
|
---|
202 | request += "]";
|
---|
203 |
|
---|
204 | var statusID;
|
---|
205 | var ajax = new gs.functions.ajaxRequest();
|
---|
206 | ajax.open("POST", gs.xsltParams.library_name, true);
|
---|
207 | ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
---|
208 | ajax.onreadystatechange = function()
|
---|
209 | {
|
---|
210 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
211 | {
|
---|
212 | var text = ajax.responseText;
|
---|
213 | var xml = validateXML(text);
|
---|
214 |
|
---|
215 | var errorElems;
|
---|
216 | if(!xml || checkForErrors(xml))
|
---|
217 | {
|
---|
218 | alert(gs.text.dse.error_saving);
|
---|
219 |
|
---|
220 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
221 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
222 |
|
---|
223 | if(_statusBar)
|
---|
224 | {
|
---|
225 | _statusBar.removeStatus(statusID);
|
---|
226 | }
|
---|
227 | return;
|
---|
228 | }
|
---|
229 |
|
---|
230 | if(_statusBar)
|
---|
231 | {
|
---|
232 | _statusBar.removeStatus(statusID);
|
---|
233 | }
|
---|
234 | buildCollections(_collectionsToBuild);
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | if(_collectionsToBuild.length > 0)
|
---|
239 | {
|
---|
240 | $("#saveButton, #quickSaveButton").html(gs.text.dse.saving + "...");
|
---|
241 | $("#saveButton, #quickSaveButton").attr("disabled", "disabled");
|
---|
242 |
|
---|
243 | if(_statusBar)
|
---|
244 | {
|
---|
245 | statusID = _statusBar.addStatus(gs.text.dse.modifying_archives + "...");
|
---|
246 | }
|
---|
247 | ajax.send("a=g&rt=r&s=DocumentExecuteTransaction&s1.transactions=" + request);
|
---|
248 | }
|
---|
249 | }
|
---|
250 |
|
---|
251 | var metadataChanges = new Array();
|
---|
252 | if (_deletedMetadata.length > 0) {
|
---|
253 | addCollectionToBuild(collection);
|
---|
254 |
|
---|
255 | for(var i = 0; i < _deletedMetadata.length; i++) {
|
---|
256 |
|
---|
257 | var currentRow = _deletedMetadata[i];
|
---|
258 |
|
---|
259 | //Get document ID
|
---|
260 | var currentElem = currentRow;
|
---|
261 | while((currentElem = currentElem.parentNode).tagName != "TABLE");
|
---|
262 | var docID = currentElem.getAttribute("id").substring(4);
|
---|
263 |
|
---|
264 | //Get metadata name
|
---|
265 | var cells = currentRow.getElementsByTagName("TD");
|
---|
266 | var nameCell = cells[0];
|
---|
267 | var name = nameCell.innerHTML;
|
---|
268 | var valueCell = cells[1];
|
---|
269 | var value = valueCell.innerHTML;
|
---|
270 | metadataChanges.push({type:'delete', docID:docID, name:name, value:value});
|
---|
271 | removeFromParent(currentRow);
|
---|
272 | }
|
---|
273 | }
|
---|
274 |
|
---|
275 | var changes = de.Changes.getChangedEditableSections();
|
---|
276 | for(var i = 0; i < changes.length; i++)
|
---|
277 | {
|
---|
278 | var changedElem = changes[i];
|
---|
279 |
|
---|
280 | //Save metadata
|
---|
281 | if(gs.functions.hasClass(changedElem, "metaTableCell"))
|
---|
282 | {
|
---|
283 | //Get document ID
|
---|
284 | var currentElem = changedElem;
|
---|
285 | while((currentElem = currentElem.parentNode).tagName != "TABLE");
|
---|
286 | var docID = currentElem.getAttribute("id").substring(4);
|
---|
287 |
|
---|
288 | //Get metadata name
|
---|
289 | var row = changedElem.parentNode;
|
---|
290 | var cells = row.getElementsByTagName("TD");
|
---|
291 | var nameCell = cells[0];
|
---|
292 | var name = nameCell.innerHTML;
|
---|
293 | var value = changedElem.innerHTML;
|
---|
294 | value = value.replace(/ /g, " ");
|
---|
295 |
|
---|
296 | var orig = changedElem.originalValue;
|
---|
297 | if (orig) {
|
---|
298 | orig = orig.replace(/ /g, " ");
|
---|
299 | }
|
---|
300 | metadataChanges.push({collection:collection, docID:docID, name:name, value:value, orig:orig});
|
---|
301 | changedElem.originalValue = changedElem.innerHTML;
|
---|
302 | addCollectionToBuild(collection);
|
---|
303 | }
|
---|
304 | //Save content
|
---|
305 | else if(gs.functions.hasClass(changedElem, "renderedText"))
|
---|
306 | {
|
---|
307 | var section = changedElem.parentDiv.parentItem;
|
---|
308 | saveTransaction('{"operation":"setText", "text":"' + changedElem.innerHTML.replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + section.collection + '", "oid":"' + section.nodeID + '"}'); //'
|
---|
309 | addCollectionToBuild(section.collection);
|
---|
310 | }
|
---|
311 | else if(gs.functions.hasClass(changedElem, "sectionText"))
|
---|
312 | {
|
---|
313 | var id = changedElem.getAttribute("id");
|
---|
314 | var sectionID = id.substring(4);
|
---|
315 | saveTransaction('{"operation":"setText", "text":"' + changedElem.innerHTML.replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + gs.cgiParams.c + '", "oid":"' + sectionID + '"}'); //'
|
---|
316 | addCollectionToBuild(gs.cgiParams.c);
|
---|
317 | }
|
---|
318 | }
|
---|
319 |
|
---|
320 |
|
---|
321 | var processChangesLoop = function(index)
|
---|
322 | {
|
---|
323 |
|
---|
324 | var change = metadataChanges[index];
|
---|
325 |
|
---|
326 | var callbackFunction;
|
---|
327 | if(index + 1 == metadataChanges.length)
|
---|
328 | {
|
---|
329 | callbackFunction = sendBuildRequest;
|
---|
330 | }
|
---|
331 | else
|
---|
332 | {
|
---|
333 | callbackFunction = function(){processChangesLoop(index + 1)};
|
---|
334 | }
|
---|
335 | if (change.type == "delete") {
|
---|
336 | gs.functions.removeArchivesMetadata(collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, function(){callbackFunction();});
|
---|
337 | } else {
|
---|
338 | if(change.orig)
|
---|
339 | {
|
---|
340 | gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, change.orig, "override", function(){callbackFunction();});
|
---|
341 | }
|
---|
342 | else
|
---|
343 | {
|
---|
344 | gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, null, "accumulate", function(){callbackFunction();});
|
---|
345 | }
|
---|
346 | }
|
---|
347 | }
|
---|
348 | if (metadataChanges.length>0) {
|
---|
349 | // this will process each change one by one, and then send the build request
|
---|
350 | processChangesLoop(0);
|
---|
351 | }
|
---|
352 | else if(_collectionsToBuild.length > 0) {
|
---|
353 | // if there are no metadata changes, but some other changes eg text have happened, then we need to send the build request.
|
---|
354 | sendBuildRequest();
|
---|
355 | }
|
---|
356 |
|
---|
357 | /* need to clear the changes from the page so that we don't process them again next time */
|
---|
358 | de.Changes.clear();
|
---|
359 | while (_deletedMetadata.length>0) {
|
---|
360 | _deletedMetadata.pop();
|
---|
361 | }
|
---|
362 |
|
---|
363 | }
|
---|
364 |
|
---|
365 |
|
---|
366 | function buildCollections(collections, documents, callback)
|
---|
367 | {
|
---|
368 | if(!collections || collections.length == 0)
|
---|
369 | {
|
---|
370 | console.log(gs.text.dse.empty_collection_list);
|
---|
371 | $("#saveButton, #quickSaveButton").html(gs.text.save_changes);
|
---|
372 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
373 | return;
|
---|
374 | }
|
---|
375 |
|
---|
376 | var docs = "";
|
---|
377 | var buildOperation = "";
|
---|
378 | if(documents)
|
---|
379 | {
|
---|
380 | buildOperation = "ImportCollection";
|
---|
381 | docs += "&s1.documents=";
|
---|
382 | for(var i = 0; i < documents.length; i++)
|
---|
383 | {
|
---|
384 | docs += documents[i];
|
---|
385 | if(i < documents.length - 1)
|
---|
386 | {
|
---|
387 | docs += ",";
|
---|
388 | }
|
---|
389 | }
|
---|
390 | }
|
---|
391 | else
|
---|
392 | {
|
---|
393 | buildOperation = "BuildAndActivateCollection";
|
---|
394 | }
|
---|
395 |
|
---|
396 | var counter = 0;
|
---|
397 | var statusID = 0;
|
---|
398 | var buildFunction = function()
|
---|
399 | {
|
---|
400 | var ajax = new gs.functions.ajaxRequest();
|
---|
401 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=" + buildOperation + "&s1.collection=" + collections[counter] + docs);
|
---|
402 | ajax.onreadystatechange = function()
|
---|
403 | {
|
---|
404 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
405 | {
|
---|
406 | var text = ajax.responseText;
|
---|
407 | var xml = validateXML(text);
|
---|
408 |
|
---|
409 | if(!xml || checkForErrors(xml))
|
---|
410 | {
|
---|
411 | alert(gs.text.dse.could_not_build_p1 + " " + collections[counter] + gs.text.dse.could_not_build_p2);
|
---|
412 |
|
---|
413 | if(_statusBar)
|
---|
414 | {
|
---|
415 | _statusBar.removeStatus(statusID);
|
---|
416 | }
|
---|
417 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
418 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
419 |
|
---|
420 | return;
|
---|
421 | }
|
---|
422 |
|
---|
423 | var status = xml.getElementsByTagName("status")[0];
|
---|
424 | var pid = status.getAttribute("pid");
|
---|
425 |
|
---|
426 | startCheckLoop(pid, buildOperation, statusID, function()
|
---|
427 | {
|
---|
428 | /*
|
---|
429 | var localAjax = new gs.functions.ajaxRequest();
|
---|
430 | localAjax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ActivateCollection&s1.collection=" + collections[counter], true);
|
---|
431 | localAjax.onreadystatechange = function()
|
---|
432 | {
|
---|
433 | if(localAjax.readyState == 4 && localAjax.status == 200)
|
---|
434 | {
|
---|
435 | var localText = localAjax.responseText;
|
---|
436 | var localXML = validateXML(localText);
|
---|
437 |
|
---|
438 | if(!xml || checkForErrors(xml))
|
---|
439 | {
|
---|
440 | alert(gs.text.dse.could_not_activate_p1 + " " + collections[counter] + gs.text.dse.could_not_activate_p2);
|
---|
441 |
|
---|
442 | if(_statusBar)
|
---|
443 | {
|
---|
444 | _statusBar.removeStatus(statusID);
|
---|
445 | }
|
---|
446 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
447 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
448 |
|
---|
449 | return;
|
---|
450 | }
|
---|
451 |
|
---|
452 | var localStatus = localXML.getElementsByTagName("status")[0];
|
---|
453 | if(localStatus)
|
---|
454 | {
|
---|
455 | var localPID = localStatus.getAttribute("pid");
|
---|
456 | startCheckLoop(localPID, "ActivateCollection", statusID, function()
|
---|
457 | {
|
---|
458 | */
|
---|
459 | if(counter == collections.length - 1)
|
---|
460 | {
|
---|
461 | removeCollectionsFromBuildList(collections);
|
---|
462 | if(callback)
|
---|
463 | {
|
---|
464 | callback();
|
---|
465 | }
|
---|
466 | }
|
---|
467 | else
|
---|
468 | {
|
---|
469 | counter++;
|
---|
470 | buildFunction();
|
---|
471 | }
|
---|
472 |
|
---|
473 | _transactions = new Array();
|
---|
474 |
|
---|
475 | if(_statusBar)
|
---|
476 | {
|
---|
477 | _statusBar.removeStatus(statusID);
|
---|
478 | }
|
---|
479 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
480 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
481 | /*
|
---|
482 | });
|
---|
483 | }
|
---|
484 | }
|
---|
485 | }
|
---|
486 | if(_statusBar)
|
---|
487 | {
|
---|
488 | _statusBar.changeStatus(statusID, gs.text.dse.activating + " " + collections[counter] + "...");
|
---|
489 | }
|
---|
490 | localAjax.send();
|
---|
491 | */
|
---|
492 | });
|
---|
493 | }
|
---|
494 | }
|
---|
495 | if(_statusBar)
|
---|
496 | {
|
---|
497 | statusID = _statusBar.addStatus(gs.text.dse.building + " " + collections[counter] + "...");
|
---|
498 | }
|
---|
499 | ajax.send();
|
---|
500 | }
|
---|
501 | buildFunction();
|
---|
502 | }
|
---|
503 |
|
---|
504 | function startCheckLoop(pid, serverFunction, statusID, callbackFunction)
|
---|
505 | {
|
---|
506 | var ajaxFunction = function()
|
---|
507 | {
|
---|
508 | var ajax = new gs.functions.ajaxRequest();
|
---|
509 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=s&ro=1&s=" + serverFunction + "&s1.pid=" + pid, true);
|
---|
510 | ajax.onreadystatechange = function()
|
---|
511 | {
|
---|
512 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
513 | {
|
---|
514 | var text = ajax.responseText;
|
---|
515 | var xml = validateXML(text);
|
---|
516 |
|
---|
517 | if(!xml || checkForErrors(xml))
|
---|
518 | {
|
---|
519 | alert(gs.text.dse.could_not_check_status_p1 + " " + serverFunction + gs.text.dse.could_not_check_status_p2a);
|
---|
520 |
|
---|
521 | if(_statusBar)
|
---|
522 | {
|
---|
523 | _statusBar.removeStatus(statusID);
|
---|
524 | }
|
---|
525 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
526 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
527 |
|
---|
528 | return;
|
---|
529 | }
|
---|
530 |
|
---|
531 | var status = xml.getElementsByTagName("status")[0];
|
---|
532 | var code = status.getAttribute("code");
|
---|
533 |
|
---|
534 | if (code == COMPLETED || code == SUCCESS)
|
---|
535 | {
|
---|
536 | callbackFunction();
|
---|
537 | }
|
---|
538 | else if (code == HALTED || code == ERROR)
|
---|
539 | {
|
---|
540 | alert(gs.text.dse.could_not_check_status_p1 + " " + serverFunction + gs.text.dse.could_not_check_status_p2b);
|
---|
541 |
|
---|
542 | if(_statusBar)
|
---|
543 | {
|
---|
544 | _statusBar.removeStatus(statusID);
|
---|
545 | }
|
---|
546 | $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
|
---|
547 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
548 | }
|
---|
549 | else
|
---|
550 | {
|
---|
551 | setTimeout(ajaxFunction, 1000);
|
---|
552 | }
|
---|
553 | }
|
---|
554 | }
|
---|
555 | ajax.send();
|
---|
556 | }
|
---|
557 | ajaxFunction();
|
---|
558 | }
|
---|
559 |
|
---|
560 | function removeCollectionsFromBuildList(collections)
|
---|
561 | {
|
---|
562 | var tempArray = new Array();
|
---|
563 | for(var i = 0; i < _collectionsToBuild.length; i++)
|
---|
564 | {
|
---|
565 | var found = false;
|
---|
566 | for(var j = 0; j < collections.length; j++)
|
---|
567 | {
|
---|
568 | if(collections[j] == _collectionsToBuild[i])
|
---|
569 | {
|
---|
570 | found = true;
|
---|
571 | break;
|
---|
572 | }
|
---|
573 | }
|
---|
574 |
|
---|
575 | if(!found)
|
---|
576 | {
|
---|
577 | tempArray.push(_collectionsToBuild[i]);
|
---|
578 | }
|
---|
579 | }
|
---|
580 | _collectionsToBuild = tempArray;
|
---|
581 | }
|
---|
582 |
|
---|
583 | function checkForErrors(xml)
|
---|
584 | {
|
---|
585 | var errorElems = xml.getElementsByTagName("error");
|
---|
586 |
|
---|
587 | if(errorElems && errorElems.length > 0)
|
---|
588 | {
|
---|
589 | var errorString = gs.text.dse.error_saving_changes + ": ";
|
---|
590 | for(var i = 0; i < errorElems.length; i++)
|
---|
591 | {
|
---|
592 | errorString += " " + errorElems.item(i).firstChild.nodeValue;
|
---|
593 | }
|
---|
594 | alert(errorString);
|
---|
595 | return true;
|
---|
596 | }
|
---|
597 | return false; //No errors
|
---|
598 | }
|
---|
599 |
|
---|
600 | function validateXML(txt)
|
---|
601 | {
|
---|
602 | // code for IE
|
---|
603 | if (window.ActiveXObject)
|
---|
604 | {
|
---|
605 | var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
---|
606 | xmlDoc.async = "false";
|
---|
607 | xmlDoc.loadXML(document.all(txt).value);
|
---|
608 |
|
---|
609 | if(xmlDoc.parseError.errorCode!=0)
|
---|
610 | {
|
---|
611 | txt = dse.error_code + ": " + xmlDoc.parseError.errorCode + "\n";
|
---|
612 | txt = txt + dse.error_reason + ": " + xmlDoc.parseError.reason;
|
---|
613 | txt = txt + dse.error_line + ": " + xmlDoc.parseError.line;
|
---|
614 | console.log(txt);
|
---|
615 | return null;
|
---|
616 | }
|
---|
617 |
|
---|
618 | return xmlDoc;
|
---|
619 | }
|
---|
620 | // code for Mozilla, Firefox, Opera, etc.
|
---|
621 | else if (document.implementation.createDocument)
|
---|
622 | {
|
---|
623 | var parser = new DOMParser();
|
---|
624 | var xmlDoc = parser.parseFromString(txt,"text/xml");
|
---|
625 |
|
---|
626 | if (xmlDoc.getElementsByTagName("parsererror").length > 0)
|
---|
627 | {
|
---|
628 | console.log(gs.text.dse.xml_error);
|
---|
629 | return null;
|
---|
630 | }
|
---|
631 |
|
---|
632 | return xmlDoc;
|
---|
633 | }
|
---|
634 | else
|
---|
635 | {
|
---|
636 | console.log(gs.text.dse.browse_cannot_validate_xml);
|
---|
637 | }
|
---|
638 | return null;
|
---|
639 | }
|
---|
640 |
|
---|
641 | function onVisibleMetadataSetChange()
|
---|
642 | {
|
---|
643 | var metadataList = document.getElementById("metadataSetList");
|
---|
644 | var index = metadataList.selectedIndex;
|
---|
645 | var options = metadataList.getElementsByTagName("OPTION");
|
---|
646 | var selectedOption = options[index];
|
---|
647 |
|
---|
648 | var selectedSet = selectedOption.value;
|
---|
649 | changeVisibleMetadata(selectedSet);
|
---|
650 | }
|
---|
651 |
|
---|
652 | function changeVisibleMetadata(metadataSetName)
|
---|
653 | {
|
---|
654 | var tables = document.getElementsByTagName("TABLE");
|
---|
655 | for(var i = 0; i < tables.length; i++)
|
---|
656 | {
|
---|
657 | var id = tables[i].getAttribute("id");
|
---|
658 | if(id && id.search(/^meta/) != -1)
|
---|
659 | {
|
---|
660 | var rows = tables[i].getElementsByTagName("TR");
|
---|
661 | for(var j = 0; j < rows.length; j++)
|
---|
662 | {
|
---|
663 | if(metadataSetName == "All")
|
---|
664 | {
|
---|
665 | rows[j].style.display = "table-row";
|
---|
666 | }
|
---|
667 | else
|
---|
668 | {
|
---|
669 | var cells = rows[j].getElementsByTagName("TD");
|
---|
670 | var cellName = cells[0].innerHTML;
|
---|
671 |
|
---|
672 | if(cellName.indexOf(".") == -1)
|
---|
673 | {
|
---|
674 | rows[j].style.display = "none";
|
---|
675 | }
|
---|
676 | else
|
---|
677 | {
|
---|
678 | var setName = cellName.substring(0, cellName.lastIndexOf("."));
|
---|
679 | if(setName == metadataSetName)
|
---|
680 | {
|
---|
681 | rows[j].style.display = "table-row";
|
---|
682 | }
|
---|
683 | else
|
---|
684 | {
|
---|
685 | rows[j].style.display = "none";
|
---|
686 | }
|
---|
687 | }
|
---|
688 | }
|
---|
689 | }
|
---|
690 | }
|
---|
691 | }
|
---|
692 | }
|
---|
693 |
|
---|
694 | function asyncRegisterEditSection(cell)
|
---|
695 | {
|
---|
696 | //This registering can cause a sizeable delay so we'll thread it (effectively) so the browser is not paused
|
---|
697 | cell.originalValue = cell.innerHTML;
|
---|
698 | setTimeout(function(){de.doc.registerEditSection(cell)}, 0);
|
---|
699 | }
|
---|
700 |
|
---|
701 | function addOptionToList(list, optionvalue, optiontext, selected) {
|
---|
702 | var newOption = $("<option>");
|
---|
703 | if (optiontext) {
|
---|
704 | newOption.html(optiontext);
|
---|
705 | newOption.attr("value", optionvalue);
|
---|
706 | } else {
|
---|
707 | newOption.html(optionvalue);
|
---|
708 | }
|
---|
709 | if (selected) {
|
---|
710 | newOption.attr("selected", true);
|
---|
711 | }
|
---|
712 | list.append(newOption);
|
---|
713 | }
|
---|
714 |
|
---|
715 | /* returns either an input or a select element. Data based on
|
---|
716 | availableMetadataElements var. */
|
---|
717 | function createMetadataElementSelector() {
|
---|
718 | var metaNameField;
|
---|
719 | if (new_metadata_field_input_type == "fixedlist") {
|
---|
720 | metaNameField = $("<select>", {"class": "ui-state-default"});
|
---|
721 | for(var i=0; i<availableMetadataElements.length; i++) {
|
---|
722 | addOptionToList(metaNameField, availableMetadataElements[i]);
|
---|
723 | }
|
---|
724 | return metaNameField;
|
---|
725 | }
|
---|
726 | metaNameField = $("<input>", {"type": "text","style":"margin: 5px; border: 1px solid #000;"});
|
---|
727 | if (new_metadata_field_input_type == "autocomplete") {
|
---|
728 | metaNameField.autocomplete({
|
---|
729 | minLength: 0,
|
---|
730 | source: availableMetadataElements
|
---|
731 | });
|
---|
732 | metaNameField.attr("title", "Enter a metadata name, or use the down arrow to select one, then click 'Add New Metadata'");
|
---|
733 | } else {
|
---|
734 | metaNameField.attr("title", "Enter a metadata name, then click 'Add New Metadata'");
|
---|
735 | }
|
---|
736 |
|
---|
737 | return metaNameField;
|
---|
738 | }
|
---|
739 |
|
---|
740 |
|
---|
741 |
|
---|
742 | function addFunctionalityToTable(table)
|
---|
743 | {
|
---|
744 | table.find("tr").each(function()
|
---|
745 | {
|
---|
746 | var cells = $(this).find("td");
|
---|
747 | var metadataName = $(cells[0]).html();
|
---|
748 |
|
---|
749 | if(dynamic_metadata_set_list == true && metadataName.indexOf(".") != -1)
|
---|
750 | {
|
---|
751 | var metadataSetName = metadataName.substring(0, metadataName.lastIndexOf("."));
|
---|
752 |
|
---|
753 | var found = false;
|
---|
754 | for(var j = 0; j < _metadataSetList.length; j++)
|
---|
755 | {
|
---|
756 | if(metadataSetName == _metadataSetList[j])
|
---|
757 | {
|
---|
758 | found = true;
|
---|
759 | break;
|
---|
760 | }
|
---|
761 | }
|
---|
762 |
|
---|
763 | if(!found)
|
---|
764 | {
|
---|
765 | _metadataSetList.push(metadataSetName);
|
---|
766 | addOptionToList( $("#metadataSetList"), metadataSetName);
|
---|
767 | }
|
---|
768 | }
|
---|
769 |
|
---|
770 | asyncRegisterEditSection(cells[1]);
|
---|
771 | addRemoveLinkToRow(this);
|
---|
772 | });
|
---|
773 |
|
---|
774 | var metaNameField = createMetadataElementSelector();
|
---|
775 | table.after(metaNameField);
|
---|
776 | table.metaNameField = metaNameField;
|
---|
777 |
|
---|
778 | var addRowButton = $("<button>",{"class": "ui-state-default ui-corner-all", "style": "margin: 5px;"});
|
---|
779 | addRowButton.html(gs.text.dse.add_new_metadata);
|
---|
780 | addRowButton.click(function()
|
---|
781 | {
|
---|
782 | var name = metaNameField.val();
|
---|
783 | if(!name || name == "")
|
---|
784 | {
|
---|
785 | console.log(gs.text.dse.no_value_given);
|
---|
786 | return;
|
---|
787 | }
|
---|
788 |
|
---|
789 | var newRow = $("<tr>");
|
---|
790 | var nameCell = $("<td>" + name + "</td>");
|
---|
791 | nameCell.attr("class", "metaTableCellName");
|
---|
792 | var valueCell = $("<td>", {"class": "metaTableCell"});
|
---|
793 |
|
---|
794 | newRow.append(nameCell);
|
---|
795 | newRow.append(valueCell);
|
---|
796 | addRemoveLinkToRow(newRow);
|
---|
797 | table.append(newRow);
|
---|
798 |
|
---|
799 | var undo = new Array();
|
---|
800 | undo.op = "delMeta";
|
---|
801 | undo.srcElem = newRow;
|
---|
802 | undo.removeTransaction = false;
|
---|
803 | _undoOperations.push(undo);
|
---|
804 |
|
---|
805 | //Threading this function here probably isn't necessary like the other times it is called
|
---|
806 | de.doc.registerEditSection(valueCell[0]);
|
---|
807 | });
|
---|
808 | table.addRowButton = addRowButton;
|
---|
809 | metaNameField.after(addRowButton);
|
---|
810 |
|
---|
811 | }
|
---|
812 |
|
---|
813 | function addRemoveLinkToRow(row)
|
---|
814 | {
|
---|
815 | var newCell = $("<td>");
|
---|
816 | var removeLink = $("<a>remove</a>", {"href": "javascript:;"});
|
---|
817 | removeLink.click(function()
|
---|
818 | {
|
---|
819 | var undo = new Array();
|
---|
820 | undo.srcElem = row;
|
---|
821 | undo.op = "display";
|
---|
822 | undo.subOp = "table-row";
|
---|
823 | undo.removeDeletedMetadata = true;
|
---|
824 | _undoOperations.push(undo);
|
---|
825 | _deletedMetadata.push(row);
|
---|
826 | //row.css("display", "none");
|
---|
827 | $(row).hide();
|
---|
828 | });
|
---|
829 | newCell.append(removeLink);
|
---|
830 | newCell.attr({"class": "metaTableCellRemove", "style": "font-size:0.6em; padding-left: 3px; padding-right: 3px;"});
|
---|
831 | $(row).append(newCell);
|
---|
832 | }
|
---|
833 |
|
---|
834 | /* This is for 'edit structure' menu bar */
|
---|
835 | function createTopMenuBar()
|
---|
836 | {
|
---|
837 | //Create the top menu bar
|
---|
838 | var headerTable = document.createElement("TABLE");
|
---|
839 | var tableBody = document.createElement("TBODY");
|
---|
840 | var row = document.createElement("TR");
|
---|
841 | var newDocCell = document.createElement("TD");
|
---|
842 | var newSecCell = document.createElement("TD");
|
---|
843 | var saveCell = document.createElement("TD");
|
---|
844 | var undoCell = document.createElement("TD");
|
---|
845 | var metadataListCell = document.createElement("TD");
|
---|
846 |
|
---|
847 | var metadataListLabel = document.createElement("SPAN");
|
---|
848 | metadataListLabel.innerHTML = "Visible metadata: ";
|
---|
849 | var metadataList = document.createElement("SELECT");
|
---|
850 | metadataList.setAttribute("id", "metadataSetList");
|
---|
851 | metadataList.onchange = onVisibleMetadataSetChange;
|
---|
852 | var allMetadataOption = document.createElement("OPTION");
|
---|
853 | metadataList.appendChild(allMetadataOption);
|
---|
854 | allMetadataOption.innerHTML = "All";
|
---|
855 | metadataListCell.appendChild(metadataListLabel);
|
---|
856 | metadataListCell.appendChild(metadataList);
|
---|
857 |
|
---|
858 | metadataListCell.setAttribute("class", "headerTableTD");
|
---|
859 | newDocCell.setAttribute("class", "headerTableTD");
|
---|
860 | newSecCell.setAttribute("class", "headerTableTD");
|
---|
861 | undoCell.setAttribute("class", "headerTableTD");
|
---|
862 | saveCell.setAttribute("class", "headerTableTD");
|
---|
863 |
|
---|
864 | headerTable.appendChild(tableBody);
|
---|
865 | tableBody.appendChild(row);
|
---|
866 | row.appendChild(saveCell);
|
---|
867 | row.appendChild(undoCell);
|
---|
868 | row.appendChild(newDocCell);
|
---|
869 | row.appendChild(newSecCell);
|
---|
870 | row.appendChild(metadataListCell);
|
---|
871 |
|
---|
872 | //The "Save changes" button
|
---|
873 | var saveButton = document.createElement("BUTTON");
|
---|
874 | saveButton.innerHTML = gs.text.dse.save_changes;
|
---|
875 | saveButton.setAttribute("onclick", "save();");
|
---|
876 | saveButton.setAttribute("id", "saveButton");
|
---|
877 | saveCell.appendChild(saveButton);
|
---|
878 |
|
---|
879 | //The "Undo" button
|
---|
880 | var undoButton = document.createElement("BUTTON");
|
---|
881 | undoButton.innerHTML = "Undo";
|
---|
882 | undoButton.setAttribute("onclick", "undo();");
|
---|
883 | undoCell.appendChild(undoButton);
|
---|
884 |
|
---|
885 | //The "Create new document" button
|
---|
886 | var newDocButton = document.createElement("BUTTON");
|
---|
887 | newDocButton.innerHTML = gs.text.dse.create_new_document;
|
---|
888 | newDocButton.setAttribute("onclick", "createNewDocumentArea();");
|
---|
889 | newDocButton.setAttribute("id", "createNewDocumentButton");
|
---|
890 | newDocCell.appendChild(newDocButton);
|
---|
891 |
|
---|
892 | //The "Insert new section" LI
|
---|
893 | var newSecLI = createDraggableNewSection(newSecCell);
|
---|
894 |
|
---|
895 | return headerTable;
|
---|
896 | }
|
---|
897 |
|
---|
898 | function getMetadataFromNode(node, name)
|
---|
899 | {
|
---|
900 | var currentNode = node.firstChild;
|
---|
901 | while(currentNode != null)
|
---|
902 | {
|
---|
903 | if(currentNode.nodeName == "metadataList")
|
---|
904 | {
|
---|
905 | currentNode = currentNode.firstChild;
|
---|
906 | break;
|
---|
907 | }
|
---|
908 |
|
---|
909 | currentNode = currentNode.nextSibling;
|
---|
910 | }
|
---|
911 |
|
---|
912 | while(currentNode != null)
|
---|
913 | {
|
---|
914 | if(currentNode.nodeName == "metadata" && currentNode.getAttribute("name") == name)
|
---|
915 | {
|
---|
916 | return currentNode.firstChild.nodeValue;
|
---|
917 | }
|
---|
918 |
|
---|
919 | currentNode = currentNode.nextSibling;
|
---|
920 | }
|
---|
921 | return "";
|
---|
922 | }
|
---|
923 |
|
---|
924 | function storeMetadata(node, listItem)
|
---|
925 | {
|
---|
926 | listItem.metadata = new Array();
|
---|
927 |
|
---|
928 | var currentNode = node.firstChild;
|
---|
929 | while(currentNode != null)
|
---|
930 | {
|
---|
931 | if(currentNode.nodeName == "metadataList")
|
---|
932 | {
|
---|
933 | currentNode = currentNode.firstChild;
|
---|
934 | break;
|
---|
935 | }
|
---|
936 |
|
---|
937 | currentNode = currentNode.nextSibling;
|
---|
938 | }
|
---|
939 |
|
---|
940 | while(currentNode != null)
|
---|
941 | {
|
---|
942 | if(currentNode.nodeName == "metadata")
|
---|
943 | {
|
---|
944 | listItem.metadata[currentNode.getAttribute("name")] = currentNode.firstChild.nodeValue;
|
---|
945 | }
|
---|
946 |
|
---|
947 | currentNode = currentNode.nextSibling;
|
---|
948 | }
|
---|
949 | }
|
---|
950 |
|
---|
951 | function getNodeContent(node)
|
---|
952 | {
|
---|
953 | var currentNode = node.firstChild;
|
---|
954 | while(currentNode != null)
|
---|
955 | {
|
---|
956 | if(currentNode.nodeName == "nodeContent")
|
---|
957 | {
|
---|
958 | return currentNode.firstChild;
|
---|
959 | }
|
---|
960 |
|
---|
961 | currentNode = currentNode.nextSibling;
|
---|
962 | }
|
---|
963 | return null;
|
---|
964 | }
|
---|
965 |
|
---|
966 | function containsDocumentNode(node)
|
---|
967 | {
|
---|
968 | var currentNode = node.firstChild;
|
---|
969 | while(currentNode != null)
|
---|
970 | {
|
---|
971 | if(currentNode.nodeName == "documentNode")
|
---|
972 | {
|
---|
973 | return true;
|
---|
974 | }
|
---|
975 |
|
---|
976 | currentNode = currentNode.nextSibling;
|
---|
977 | }
|
---|
978 | return false;
|
---|
979 | }
|
---|
980 |
|
---|
981 | function isExpanded(textDiv)
|
---|
982 | {
|
---|
983 | if(!textDiv.style.display || textDiv.style.display == "block")
|
---|
984 | {
|
---|
985 | return true;
|
---|
986 | }
|
---|
987 | return false;
|
---|
988 | }
|
---|
989 |
|
---|
990 | function toggleTextDiv(section)
|
---|
991 | {
|
---|
992 | var textDiv = section.textDiv;
|
---|
993 | if(textDiv)
|
---|
994 | {
|
---|
995 | if(isExpanded(textDiv))
|
---|
996 | {
|
---|
997 | textDiv.style.display = "none";
|
---|
998 | section.menu.editTextLink.innerHTML = gs.text.dse.edit;
|
---|
999 | }
|
---|
1000 | else
|
---|
1001 | {
|
---|
1002 | textDiv.style.display = "block";
|
---|
1003 | section.menu.editTextLink.innerHTML = gs.text.dse.hide;
|
---|
1004 | }
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | function updateFromTop()
|
---|
1009 | {
|
---|
1010 | updateRecursive(document.getElementById("dbDiv"), null, null, 0);
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | function insertAfter(elem, refElem)
|
---|
1014 | {
|
---|
1015 | if(refElem.nextSibling)
|
---|
1016 | {
|
---|
1017 | refElem.parentNode.insertBefore(elem, refElem.nextSibling);
|
---|
1018 | }
|
---|
1019 | else
|
---|
1020 | {
|
---|
1021 | refElem.parentNode.appendChild(elem);
|
---|
1022 | }
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | function removeFromParent(elem)
|
---|
1026 | {
|
---|
1027 | elem.parentNode.removeChild(elem);
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | function createSectionTitle(text)
|
---|
1031 | {
|
---|
1032 | var textSpan = document.createElement("SPAN");
|
---|
1033 | if(text)
|
---|
1034 | {
|
---|
1035 | textSpan.appendChild(document.createTextNode(" " + text + " "));
|
---|
1036 | }
|
---|
1037 | else
|
---|
1038 | {
|
---|
1039 | textSpan.appendChild(document.createTextNode(" [" + gs.text.dse.untitled_section + "] "));
|
---|
1040 | }
|
---|
1041 | return textSpan;
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | function setMouseOverAndOutFunctions(section)
|
---|
1045 | {
|
---|
1046 | //Colour the list item and display the menu on mouse over
|
---|
1047 | section.onmouseover = function(e)
|
---|
1048 | {
|
---|
1049 | if(this.menu){this.menu.style.display = "inline";}
|
---|
1050 | this.style.background = "rgb(255, 200, 0)";
|
---|
1051 | };
|
---|
1052 | //Uncolour the list item and hide the menu on mouse out
|
---|
1053 | section.onmouseout = function(e)
|
---|
1054 | {
|
---|
1055 | if(this.menu){this.menu.style.display = "none";}
|
---|
1056 | this.style.background = "none";
|
---|
1057 | };
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | function createDraggableNewSection(parent)
|
---|
1061 | {
|
---|
1062 | var newSecLI = document.createElement("LI");
|
---|
1063 | var newSpan = document.createElement("SPAN");
|
---|
1064 | newSpan.innerHTML = gs.text.dse.insert_new_section + " ";
|
---|
1065 |
|
---|
1066 | newSecLI.sectionTitle = newSpan;
|
---|
1067 | newSecLI.appendChild(newSpan);
|
---|
1068 | newSecLI.setAttribute("class", "dragItem newSection");
|
---|
1069 | newSecLI.newSection = true;
|
---|
1070 | newSecLI.parent = parent;
|
---|
1071 | newSecLI.index = -1;
|
---|
1072 | new YAHOO.example.DDList(newSecLI);
|
---|
1073 | parent.appendChild(newSecLI);
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | function closeAllOpenContents()
|
---|
1077 | {
|
---|
1078 | for(var i = 0; i < _allContents.length; i++)
|
---|
1079 | {
|
---|
1080 | if(isExpanded(_allContents[i].textDiv))
|
---|
1081 | {
|
---|
1082 | toggleTextDiv(_allContents[i]);
|
---|
1083 | }
|
---|
1084 | }
|
---|
1085 | DDM.refreshCache();
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | //Status Bar class (initialised with new StatusBar(elem);)
|
---|
1089 | function StatusBar(mainElem)
|
---|
1090 | {
|
---|
1091 | var _statusMap = new Array();
|
---|
1092 | var _statusIDCounter = 0;
|
---|
1093 | var _mainElem = mainElem;
|
---|
1094 | var _activeMessages = 0;
|
---|
1095 |
|
---|
1096 | _mainElem.style.display = "none";
|
---|
1097 |
|
---|
1098 | this.addStatus = function(newStatus)
|
---|
1099 | {
|
---|
1100 | _mainElem.style.display = "block";
|
---|
1101 | var newStatusDiv = document.createElement("DIV");
|
---|
1102 | var newStatusSpan = document.createElement("SPAN");
|
---|
1103 |
|
---|
1104 | var workingImage = document.createElement("IMG");
|
---|
1105 | workingImage.setAttribute("src", gs.imageURLs.loading);
|
---|
1106 | workingImage.setAttribute("height", "16px");
|
---|
1107 | workingImage.setAttribute("width", "16px");
|
---|
1108 | newStatusDiv.appendChild(workingImage);
|
---|
1109 |
|
---|
1110 | newStatusDiv.appendChild(newStatusSpan);
|
---|
1111 | newStatusSpan.innerHTML = " " + newStatus;
|
---|
1112 | newStatusDiv.setAttribute("class", "statusMessage");
|
---|
1113 | newStatusDiv.span = newStatusSpan;
|
---|
1114 |
|
---|
1115 | _mainElem.appendChild(newStatusDiv);
|
---|
1116 | _statusMap["status" + _statusIDCounter] = newStatusDiv;
|
---|
1117 | _activeMessages++;
|
---|
1118 | return _statusIDCounter++;
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | this.changeStatus = function(id, newStatus)
|
---|
1122 | {
|
---|
1123 | if(_statusMap["status" + id])
|
---|
1124 | {
|
---|
1125 | _statusMap["status" + id].span.innerHTML = " " + newStatus;
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 |
|
---|
1129 | this.removeStatus = function(id)
|
---|
1130 | {
|
---|
1131 | if(_statusMap["status" + id])
|
---|
1132 | {
|
---|
1133 | removeFromParent(_statusMap["status" + id]);
|
---|
1134 |
|
---|
1135 | if(--_activeMessages == 0)
|
---|
1136 | {
|
---|
1137 | _mainElem.style.display = "none";
|
---|
1138 | }
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | this.clear = function()
|
---|
1143 | {
|
---|
1144 | for(var p in _statusMap)
|
---|
1145 | {
|
---|
1146 | if(_statusMap.hasOwnProperty(p))
|
---|
1147 | {
|
---|
1148 | if(_statusMap[p] && _statusMap[p].parentNode)
|
---|
1149 | {
|
---|
1150 | removeFromParent(_statusMap[p]);
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | if(--_activeMessages == 0)
|
---|
1154 | {
|
---|
1155 | _mainElem.style.display = "none";
|
---|
1156 | }
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 | }
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | /*
|
---|
1163 | function toggleEdit(e)
|
---|
1164 | {
|
---|
1165 | var mousePos = de.events.getXYInWindowFromEvent(e);
|
---|
1166 | var cDesc = de.cursor.getCursorDescAtXY(mousePos.x, mousePos.y, de.events.getEventTarget(e));
|
---|
1167 | de.cursor.setCursor(cDesc);
|
---|
1168 | }
|
---|
1169 | */ |
---|