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