[31748] | 1 | /** Javascript file containing useful functions used by both documentedit_scripts.js and documentmaker_scripts.js */
|
---|
| 2 |
|
---|
| 3 |
|
---|
[25012] | 4 | //Some "constants" to match the server constants
|
---|
| 5 | var SUCCESS = 1;
|
---|
| 6 | var ACCEPTED = 2;
|
---|
| 7 | var ERROR = 3;
|
---|
| 8 | var CONTINUING = 10;
|
---|
| 9 | var COMPLETED = 11;
|
---|
| 10 | var HALTED = 12;
|
---|
| 11 |
|
---|
[31748] | 12 | var _transactions = new Array();
|
---|
| 13 | var _collectionsToBuild = new Array();
|
---|
| 14 | var _allContents = new Array();
|
---|
| 15 | var _deletedSections = new Array();
|
---|
| 16 | var _deletedMetadata = new Array();
|
---|
| 17 | var _undoOperations = new Array();
|
---|
| 18 | var _baseURL;
|
---|
| 19 | var _statusBar;
|
---|
| 20 | var _metadataSetList = new Array();
|
---|
| 21 |
|
---|
[32060] | 22 |
|
---|
| 23 | // If the user is attempting to leave the page, check if there are unsaved changes
|
---|
| 24 | // and if so, display an "Are you sure you want to leave" message.
|
---|
| 25 | // https://stackoverflow.com/questions/7080269/javascript-before-leaving-the-page
|
---|
| 26 | // Newer versions of Firefox/Chrome don't display custom message (security feature):
|
---|
| 27 | // https://stackoverflow.com/questions/22776544/why-is-jquery-onbeforeunload-not-working-in-chrome-and-firefox
|
---|
| 28 | // and http://jsfiddle.net/XZAWS/
|
---|
| 29 | // jquery bind() is deprecated: https://stackoverflow.com/questions/33654716/is-jquery-bind-deprecated
|
---|
| 30 | $(window).on("beforeunload", function(event) {
|
---|
[32440] | 31 |
|
---|
[32060] | 32 | if(gs.cgiParams.docEdit == "1") { // like document.xsl, which checks the same var upon onload
|
---|
| 33 | // shouldn't check for whether changes are saved unless on Doc Editing page (DocEdit=1)
|
---|
| 34 | // else the following pop up always ends up appearing when attempting
|
---|
| 35 | // to leave a doc view page in Doc Editing Mode (when not yet actually Doc Editing)
|
---|
| 36 | var changes = changesToUpdate();
|
---|
| 37 |
|
---|
| 38 | if(changes.length > 0) {
|
---|
[32440] | 39 | console.log("The collection hasn't yet been saved after editing. Are you sure you want to leave?");
|
---|
[32060] | 40 | return "The collection hasn't yet been saved after editing. Are you sure you want to leave?";
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | });
|
---|
| 45 |
|
---|
| 46 |
|
---|
[31126] | 47 | function encodeDelimiters(meta_value) {
|
---|
[29174] | 48 |
|
---|
[31126] | 49 | var new_value = meta_value.replace(/;/g, "%253B");
|
---|
| 50 | return new_value.replace(/&/g, "%2526");
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[25012] | 53 | function getElementsByClassName(cl, parent)
|
---|
| 54 | {
|
---|
| 55 | var elemArray = [];
|
---|
| 56 | var classRegEx = new RegExp("\\b" + cl + "\\b");
|
---|
| 57 | var elems;
|
---|
| 58 | if(parent)
|
---|
| 59 | {
|
---|
| 60 | elems = parent.getElementsByTagName("*");
|
---|
| 61 | }
|
---|
| 62 | else
|
---|
| 63 | {
|
---|
| 64 | elems = document.getElementsByTagName("*");
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | for (var i = 0; i < elems.length; i++)
|
---|
| 68 | {
|
---|
| 69 | var classeName = elems[i].className;
|
---|
| 70 | if (classRegEx.test(classeName)) elemArray.push(elems[i]);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | return elemArray;
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | function getNextSiblingOfType(elem, type)
|
---|
| 77 | {
|
---|
| 78 | if(elem == null)
|
---|
| 79 | {
|
---|
| 80 | return null;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | var current = elem.nextSibling;
|
---|
| 84 | while(current != null)
|
---|
| 85 | {
|
---|
| 86 | if(current.nodeName.toLowerCase() == type)
|
---|
| 87 | {
|
---|
| 88 | return current;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | current = current.nextSibling;
|
---|
| 92 | }
|
---|
| 93 | return null;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | function getPrevSiblingOfType(elem, type)
|
---|
| 97 | {
|
---|
| 98 | if(elem == null)
|
---|
| 99 | {
|
---|
| 100 | return null;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | var current = elem.previousSibling;
|
---|
| 104 | while(current != null)
|
---|
| 105 | {
|
---|
| 106 | if(current.nodeName.toLowerCase() == type)
|
---|
| 107 | {
|
---|
| 108 | return current;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | current = current.previousSibling;
|
---|
| 112 | }
|
---|
| 113 | return null;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | function saveTransaction(transaction)
|
---|
| 117 | {
|
---|
| 118 | console.log(transaction);
|
---|
| 119 | _transactions.push(transaction);
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | function undo()
|
---|
| 123 | {
|
---|
| 124 | if(_undoOperations.length == 0)
|
---|
| 125 | {
|
---|
| 126 | return;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | var undoOp = _undoOperations.pop();
|
---|
| 130 |
|
---|
| 131 | //Create/Duplicate undo
|
---|
| 132 | if(undoOp.op == "del")
|
---|
| 133 | {
|
---|
| 134 | if(undoOp.srcElem.childList)
|
---|
| 135 | {
|
---|
| 136 | removeFromParent(undoOp.srcElem.childList);
|
---|
| 137 | }
|
---|
| 138 | if(undoOp.srcElem.parentItem)
|
---|
| 139 | {
|
---|
| 140 | undoOp.srcElem.parentItem.menu.newSectionLink.style.display = "inline";
|
---|
| 141 | undoOp.srcElem.parentItem.childList = null;
|
---|
| 142 | }
|
---|
| 143 | removeFromParent(undoOp.srcElem);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | if(undoOp.op == "delMeta")
|
---|
| 147 | {
|
---|
| 148 | if(undoOp.srcElem.childList)
|
---|
| 149 | {
|
---|
| 150 | removeFromParent(undoOp.srcElem.childList);
|
---|
| 151 | }
|
---|
| 152 | if(undoOp.srcElem.parentItem)
|
---|
| 153 | {
|
---|
| 154 | undoOp.srcElem.parentItem.menu.newSectionLink.style.display = "inline";
|
---|
| 155 | undoOp.srcElem.parentItem.childList = null;
|
---|
| 156 | }
|
---|
| 157 | de.doc.unregisterEditSection(undoOp.srcElem);
|
---|
| 158 | removeFromParent(undoOp.srcElem);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | //Move undo (mva is move after, mvb is move before, mvi is move into)
|
---|
| 162 | else if(undoOp.op == "mva" || undoOp.op == "mvb" || undoOp.op == "mvi")
|
---|
| 163 | {
|
---|
| 164 | if(undoOp.op == "mvb")
|
---|
| 165 | {
|
---|
| 166 | undoOp.refElem.parentNode.insertBefore(undoOp.srcElem, undoOp.refElem);
|
---|
| 167 | }
|
---|
| 168 | else if(undoOp.op == "mva")
|
---|
| 169 | {
|
---|
| 170 | insertAfter(undoOp.srcElem, undoOp.refElem);
|
---|
| 171 | }
|
---|
| 172 | else
|
---|
| 173 | {
|
---|
| 174 | undoOp.refElem.removeChild(undoOp.refElem.firstChild);
|
---|
| 175 | undoOp.refElem.appendChild(undoOp.srcElem);
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | if(undoOp.srcElem.textDiv)
|
---|
| 179 | {
|
---|
| 180 | insertAfter(undoOp.srcElem.textDiv, undoOp.srcElem);
|
---|
| 181 | }
|
---|
| 182 | if(undoOp.srcElem.childList)
|
---|
| 183 | {
|
---|
| 184 | insertAfter(undoOp.srcElem.childList, undoOp.srcElem.textDiv);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | if(undoOp.srcElem.onmouseout)
|
---|
| 188 | {
|
---|
| 189 | //Uncolour the section if it coloured
|
---|
| 190 | undoOp.srcElem.onmouseout();
|
---|
| 191 | }
|
---|
| 192 | updateFromTop();
|
---|
| 193 | }
|
---|
[25104] | 194 | else if(undoOp.op == "display")
|
---|
| 195 | {
|
---|
| 196 | undoOp.srcElem.style.display = undoOp.subOp;
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | if(undoOp.removeDeletedMetadata)
|
---|
| 200 | {
|
---|
| 201 | _deletedMetadata.pop();
|
---|
| 202 | }
|
---|
[25012] | 203 |
|
---|
| 204 | if(undoOp.removeTransaction)
|
---|
| 205 | {
|
---|
| 206 | _transactions.pop();
|
---|
| 207 | }
|
---|
| 208 | }
|
---|
| 209 |
|
---|
[29226] | 210 | function enableSaveButtons(enabled) {
|
---|
| 211 | if (enabled) {
|
---|
[30780] | 212 | $("#saveButton, #quickSaveButton").html(gs.text.de.save_changes);
|
---|
[29226] | 213 | $("#saveButton, #quickSaveButton").removeAttr("disabled");
|
---|
| 214 |
|
---|
| 215 | } else {
|
---|
[30780] | 216 | $("#saveButton, #quickSaveButton").html(gs.text.de.saving + "...");
|
---|
[29226] | 217 | $("#saveButton, #quickSaveButton").attr("disabled", "disabled");
|
---|
| 218 |
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
[25012] | 221 | function addCollectionToBuild(collection)
|
---|
| 222 | {
|
---|
| 223 | for(var i = 0; i < _collectionsToBuild.length; i++)
|
---|
| 224 | {
|
---|
| 225 | if(collection == _collectionsToBuild[i])
|
---|
| 226 | {
|
---|
| 227 | return;
|
---|
| 228 | }
|
---|
| 229 | }
|
---|
| 230 | _collectionsToBuild.push(collection);
|
---|
| 231 | }
|
---|
| 232 |
|
---|
[29226] | 233 | function save() {
|
---|
| 234 | saveAndRebuild(false);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | function rebuildCurrentCollection() {
|
---|
| 238 |
|
---|
[30780] | 239 | console.log(gs.text.de.rebuilding_collection);
|
---|
[29226] | 240 | enableSaveButtons(false);
|
---|
| 241 | var collection = gs.cgiParams.c;
|
---|
| 242 |
|
---|
| 243 | var collectionsArray = new Array();
|
---|
| 244 | collectionsArray.push(collection);
|
---|
[32060] | 245 | buildCollections(collectionsArray, null, reloadUponRebuild); // passing in callback to reload the page after build, as requested by Kathy
|
---|
[29226] | 246 | }
|
---|
| 247 |
|
---|
[32060] | 248 |
|
---|
| 249 | function reloadUponRebuild() {
|
---|
| 250 | // finished rebuilding - reload the page after rebuild, but first
|
---|
| 251 | // clear transactions array of saved changes, now that we're done processing these changes during rebuild,
|
---|
| 252 | // since we don't want the "are you sure to leave page" popup which appears on _transactions array being non-empty
|
---|
| 253 | _transactions = null;
|
---|
| 254 | location.reload(true); // force reload, not from cache, https://www.w3schools.com/jsref/met_loc_reload.asp
|
---|
| 255 | }
|
---|
| 256 |
|
---|
[32471] | 257 | /************************************
|
---|
| 258 | * TEXT EDIT (CKEDITOR) SCRIPTS *
|
---|
| 259 | **************************************/
|
---|
[32060] | 260 |
|
---|
[32471] | 261 | // not using this anymore as the instanceready never seems to get called
|
---|
| 262 | function addCKEEditableState(evt,stateArray)
|
---|
| 263 | {
|
---|
| 264 | // Event->Editor->CKE DOM Inline Element that editor was for->underlying jquery element
|
---|
| 265 | element = evt.editor.element.$;
|
---|
| 266 | nodeText = element.innerHTML;
|
---|
| 267 | stateArray.push({
|
---|
| 268 | editableNode : element,
|
---|
| 269 | initHTML : nodeText
|
---|
| 270 | });
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | function addEditableState(editable,stateArray)
|
---|
| 274 | {
|
---|
| 275 |
|
---|
| 276 | if(editable.tagName == 'TEXTAREA')
|
---|
| 277 | {
|
---|
| 278 | nodeText = editable.value;
|
---|
| 279 | }
|
---|
| 280 | else
|
---|
| 281 | {
|
---|
| 282 | nodeText = editable.innerHTML;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | stateArray.push({
|
---|
| 286 | editableNode : editable,
|
---|
| 287 | initHTML : nodeText
|
---|
| 288 | });
|
---|
| 289 |
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | function getLastEditableStates()
|
---|
| 293 | {
|
---|
| 294 | editableLastStates = [];
|
---|
| 295 | $(".sectionText").each(function(){addEditableState(this,editableLastStates);});
|
---|
| 296 | $(".metaTableCellArea").each(function(){addEditableState(this,editableLastStates);});
|
---|
| 297 |
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | function changesToUpdate()
|
---|
| 301 | {
|
---|
| 302 | var resultArray = new Array();
|
---|
| 303 | getLastEditableStates();
|
---|
| 304 | for (var j in editableLastStates)
|
---|
| 305 | {
|
---|
| 306 | if (isNodeChanged(editableLastStates[j]))
|
---|
| 307 | {
|
---|
| 308 | resultArray.push(editableLastStates[j].editableNode);
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
| 311 | return resultArray;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | function isNodeChanged(StateToCheck){
|
---|
| 316 | for (var i in editableInitStates)
|
---|
| 317 | {
|
---|
| 318 | if ((StateToCheck.editableNode === editableInitStates[i].editableNode)) {
|
---|
| 319 | if ( StateToCheck.initHTML === editableInitStates[i].initHTML )
|
---|
| 320 | {
|
---|
| 321 | return false;
|
---|
| 322 | }
|
---|
| 323 | //console.log("current="+StateToCheck.initHTML);
|
---|
| 324 | //console.log("init="+editableInitStates[i].initHTML);
|
---|
| 325 | return true;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | }
|
---|
| 329 | // if get here, this must be a new node, as wasn't in init states
|
---|
| 330 | // make sure its not empty - we won't add empty nodes.
|
---|
| 331 | if (StateToCheck.initHTML == "") {
|
---|
| 332 | return false;
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | return true;
|
---|
| 336 |
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 |
|
---|
[29226] | 340 | function saveAndRebuild(rebuild)
|
---|
[25012] | 341 | {
|
---|
[29110] | 342 | //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
|
---|
| 343 | var collection;
|
---|
| 344 | if(gs.cgiParams.c && gs.cgiParams.c != "") {
|
---|
| 345 |
|
---|
| 346 | collection = gs.cgiParams.c;
|
---|
| 347 | }
|
---|
| 348 | else {
|
---|
| 349 | collection = gs.cgiParams.p_c;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
[27790] | 352 | var sendBuildRequest = function()
|
---|
[25012] | 353 | {
|
---|
[27790] | 354 | var request = "[";
|
---|
| 355 | for(var i = 0; i < _transactions.length; i++)
|
---|
[25012] | 356 | {
|
---|
[27790] | 357 | request += _transactions[i];
|
---|
| 358 | if(i != _transactions.length - 1)
|
---|
| 359 | {
|
---|
| 360 | request += ",";
|
---|
| 361 | }
|
---|
[25012] | 362 | }
|
---|
[27790] | 363 | request += "]";
|
---|
[25546] | 364 |
|
---|
[27790] | 365 | var statusID;
|
---|
| 366 | var ajax = new gs.functions.ajaxRequest();
|
---|
| 367 | ajax.open("POST", gs.xsltParams.library_name, true);
|
---|
[30381] | 368 | ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
---|
[27790] | 369 | ajax.onreadystatechange = function()
|
---|
[25012] | 370 | {
|
---|
[27790] | 371 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
[25012] | 372 | {
|
---|
[27790] | 373 | var text = ajax.responseText;
|
---|
| 374 | var xml = validateXML(text);
|
---|
[25012] | 375 |
|
---|
[27790] | 376 | var errorElems;
|
---|
| 377 | if(!xml || checkForErrors(xml))
|
---|
| 378 | {
|
---|
| 379 | alert(gs.text.dse.error_saving);
|
---|
| 380 |
|
---|
[29226] | 381 | enableSaveButtons(true);
|
---|
[27790] | 382 |
|
---|
[28168] | 383 | if(_statusBar)
|
---|
| 384 | {
|
---|
| 385 | _statusBar.removeStatus(statusID);
|
---|
| 386 | }
|
---|
[27790] | 387 | return;
|
---|
| 388 | }
|
---|
| 389 |
|
---|
[28168] | 390 | if(_statusBar)
|
---|
| 391 | {
|
---|
| 392 | _statusBar.removeStatus(statusID);
|
---|
| 393 | }
|
---|
[29226] | 394 | if (rebuild) {
|
---|
[32060] | 395 | buildCollections(_collectionsToBuild, null, reloadUponRebuild);
|
---|
[29226] | 396 | } else {
|
---|
| 397 | // reset the save button here
|
---|
[32060] | 398 | enableSaveButtons(true);
|
---|
| 399 | // saving to archives is now done, clear the transactions
|
---|
| 400 | // that were keeping track of the full text changes that have now
|
---|
| 401 | // been performed to archives (no member var keeps track of meta changes, only a local var)
|
---|
| 402 | _transactions = new Array();
|
---|
[29226] | 403 | }
|
---|
[25012] | 404 | }
|
---|
[27790] | 405 | }
|
---|
[25012] | 406 |
|
---|
[27790] | 407 | if(_collectionsToBuild.length > 0)
|
---|
| 408 | {
|
---|
[29226] | 409 | enableSaveButtons(false);
|
---|
[27790] | 410 |
|
---|
[28168] | 411 | if(_statusBar)
|
---|
| 412 | {
|
---|
| 413 | statusID = _statusBar.addStatus(gs.text.dse.modifying_archives + "...");
|
---|
| 414 | }
|
---|
[27790] | 415 | ajax.send("a=g&rt=r&s=DocumentExecuteTransaction&s1.transactions=" + request);
|
---|
[25012] | 416 | }
|
---|
[30780] | 417 | } // end sendBuildRequest definition
|
---|
[29085] | 418 |
|
---|
[29110] | 419 | var metadataChanges = new Array();
|
---|
| 420 | if (_deletedMetadata.length > 0) {
|
---|
[32132] | 421 | //addCollectionToBuild(collection);
|
---|
[29110] | 422 |
|
---|
| 423 | for(var i = 0; i < _deletedMetadata.length; i++) {
|
---|
| 424 |
|
---|
| 425 | var currentRow = _deletedMetadata[i];
|
---|
| 426 |
|
---|
| 427 | //Get document ID
|
---|
| 428 | var currentElem = currentRow;
|
---|
| 429 | while((currentElem = currentElem.parentNode).tagName != "TABLE");
|
---|
| 430 | var docID = currentElem.getAttribute("id").substring(4);
|
---|
| 431 |
|
---|
| 432 | //Get metadata name
|
---|
| 433 | var cells = currentRow.getElementsByTagName("TD");
|
---|
[32132] | 434 | var nameCell = cells[0];
|
---|
| 435 | // metadata name cell might have the multivalue indicator in it, so just want the first word
|
---|
| 436 | var name = nameCell.innerHTML.split(" ")[0];
|
---|
[29110] | 437 | var valueCell = cells[1];
|
---|
[32132] | 438 | var value = valueCell.getElementsByTagName("TEXTAREA")[0].value;
|
---|
[32078] | 439 | if (value.length) {
|
---|
| 440 | // check for non empty value, in case all they have done is add a field then deleted it.
|
---|
| 441 | metadataChanges.push({type:'delete', docID:docID, name:name, value:value});
|
---|
| 442 | addCollectionToBuild(collection);
|
---|
| 443 | }
|
---|
[29110] | 444 | removeFromParent(currentRow);
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 |
|
---|
[29861] | 448 | var changes = changesToUpdate();
|
---|
| 449 | //Clean changes
|
---|
| 450 | editableInitStates = editableLastStates;
|
---|
[29085] | 451 | for(var i = 0; i < changes.length; i++)
|
---|
| 452 | {
|
---|
| 453 | var changedElem = changes[i];
|
---|
| 454 | //Save metadata
|
---|
[29978] | 455 | if(gs.functions.hasClass(changedElem, "metaTableCellArea"))
|
---|
[29085] | 456 | {
|
---|
| 457 | //Get document ID
|
---|
| 458 | var currentElem = changedElem;
|
---|
| 459 | while((currentElem = currentElem.parentNode).tagName != "TABLE");
|
---|
| 460 | var docID = currentElem.getAttribute("id").substring(4);
|
---|
[32132] | 461 |
|
---|
[29085] | 462 | //Get metadata name
|
---|
[29978] | 463 | var row = changedElem.parentNode.parentNode;
|
---|
[29085] | 464 | var cells = row.getElementsByTagName("TD");
|
---|
[32132] | 465 | var nameCell = cells[0];
|
---|
| 466 | // metadata name cell might have the multivalue indicator in it, so just want the first word
|
---|
| 467 | var name = nameCell.innerHTML.split(" ")[0];
|
---|
[29978] | 468 | var value = changedElem.value;
|
---|
[29085] | 469 | value = value.replace(/ /g, " ");
|
---|
| 470 |
|
---|
| 471 | var orig = changedElem.originalValue;
|
---|
| 472 | if (orig) {
|
---|
| 473 | orig = orig.replace(/ /g, " ");
|
---|
| 474 | }
|
---|
[32132] | 475 | if (jQuery.inArray(name, multiValuedMetadata) != -1) {
|
---|
| 476 |
|
---|
| 477 | // split the values
|
---|
| 478 | var values_list = value.split(mvm_delimiter);
|
---|
| 479 | var orig_list;
|
---|
| 480 | var num_orig;
|
---|
| 481 | if (orig) {
|
---|
| 482 | orig_list = orig.split(mvm_delimiter);
|
---|
| 483 | num_orig = orig_list.length;
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | for(var i = 0; i < values_list.length; i++) {
|
---|
| 487 | var val = values_list[i];
|
---|
| 488 | var ori =null;
|
---|
| 489 | if (orig && i<num_orig) {
|
---|
| 490 | ori = orig_list[i];
|
---|
| 491 | }
|
---|
| 492 | metadataChanges.push({collection:collection, docID:docID, name:name, value:val, orig:ori});
|
---|
| 493 | }
|
---|
| 494 | } else {
|
---|
[29085] | 495 | metadataChanges.push({collection:collection, docID:docID, name:name, value:value, orig:orig});
|
---|
[32132] | 496 | }
|
---|
[29978] | 497 | changedElem.originalValue = changedElem.value;
|
---|
[29085] | 498 | addCollectionToBuild(collection);
|
---|
| 499 | }
|
---|
| 500 | //Save content
|
---|
| 501 | else if(gs.functions.hasClass(changedElem, "renderedText"))
|
---|
| 502 | {
|
---|
| 503 | var section = changedElem.parentDiv.parentItem;
|
---|
[30309] | 504 | saveTransaction('{"operation":"setText", "text":"' + CKEDITOR.instances[changedElem.getAttribute("id")].getData().replace(/%/g, "%25").replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + section.collection + '", "oid":"' + section.nodeID + '"}'); //'
|
---|
[29085] | 505 | addCollectionToBuild(section.collection);
|
---|
| 506 | }
|
---|
| 507 | else if(gs.functions.hasClass(changedElem, "sectionText"))
|
---|
| 508 | {
|
---|
| 509 | var id = changedElem.getAttribute("id");
|
---|
| 510 | var sectionID = id.substring(4);
|
---|
[30309] | 511 | saveTransaction('{"operation":"setText", "text":"' + CKEDITOR.instances[changedElem.getAttribute("id")].getData().replace(/%/g, "%25").replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + gs.cgiParams.c + '", "oid":"' + sectionID + '"}'); //'
|
---|
[29085] | 512 | addCollectionToBuild(gs.cgiParams.c);
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
[29110] | 515 |
|
---|
[29085] | 516 |
|
---|
[29110] | 517 | var processChangesLoop = function(index)
|
---|
[25096] | 518 | {
|
---|
[29085] | 519 |
|
---|
[27790] | 520 | var change = metadataChanges[index];
|
---|
| 521 |
|
---|
| 522 | var callbackFunction;
|
---|
| 523 | if(index + 1 == metadataChanges.length)
|
---|
| 524 | {
|
---|
| 525 | callbackFunction = sendBuildRequest;
|
---|
| 526 | }
|
---|
| 527 | else
|
---|
| 528 | {
|
---|
[29110] | 529 | callbackFunction = function(){processChangesLoop(index + 1)};
|
---|
[27790] | 530 | }
|
---|
[29110] | 531 | if (change.type == "delete") {
|
---|
[31126] | 532 | gs.functions.removeArchivesMetadata(collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), function(){callbackFunction();});
|
---|
[29110] | 533 | } else {
|
---|
| 534 | if(change.orig)
|
---|
| 535 | {
|
---|
[31126] | 536 | gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), encodeDelimiters(change.orig), "override", function(){callbackFunction();});
|
---|
[29110] | 537 | }
|
---|
| 538 | else
|
---|
| 539 | {
|
---|
[31126] | 540 | gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), null, "accumulate", function(){callbackFunction();});
|
---|
[29110] | 541 | }
|
---|
[27790] | 542 | }
|
---|
[25096] | 543 | }
|
---|
[29225] | 544 | if (metadataChanges.length>0) {
|
---|
| 545 | // this will process each change one by one, and then send the build request
|
---|
| 546 | processChangesLoop(0);
|
---|
| 547 | }
|
---|
| 548 | else if(_collectionsToBuild.length > 0) {
|
---|
| 549 | // if there are no metadata changes, but some other changes eg text have happened, then we need to send the build request.
|
---|
| 550 | sendBuildRequest();
|
---|
| 551 | }
|
---|
| 552 |
|
---|
| 553 | /* need to clear the changes from the page so that we don't process them again next time */
|
---|
| 554 | while (_deletedMetadata.length>0) {
|
---|
| 555 | _deletedMetadata.pop();
|
---|
| 556 | }
|
---|
[29110] | 557 |
|
---|
[25012] | 558 | }
|
---|
| 559 |
|
---|
[29110] | 560 |
|
---|
[25546] | 561 | function buildCollections(collections, documents, callback)
|
---|
[25012] | 562 | {
|
---|
| 563 | if(!collections || collections.length == 0)
|
---|
| 564 | {
|
---|
[25296] | 565 | console.log(gs.text.dse.empty_collection_list);
|
---|
[29226] | 566 | enableSaveButtons(true);
|
---|
[25012] | 567 | return;
|
---|
| 568 | }
|
---|
[25546] | 569 |
|
---|
| 570 | var docs = "";
|
---|
| 571 | var buildOperation = "";
|
---|
| 572 | if(documents)
|
---|
| 573 | {
|
---|
| 574 | buildOperation = "ImportCollection";
|
---|
| 575 | docs += "&s1.documents=";
|
---|
| 576 | for(var i = 0; i < documents.length; i++)
|
---|
| 577 | {
|
---|
| 578 | docs += documents[i];
|
---|
| 579 | if(i < documents.length - 1)
|
---|
| 580 | {
|
---|
| 581 | docs += ",";
|
---|
| 582 | }
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | else
|
---|
| 586 | {
|
---|
| 587 | buildOperation = "BuildAndActivateCollection";
|
---|
| 588 | }
|
---|
[25012] | 589 |
|
---|
| 590 | var counter = 0;
|
---|
| 591 | var statusID = 0;
|
---|
| 592 | var buildFunction = function()
|
---|
| 593 | {
|
---|
| 594 | var ajax = new gs.functions.ajaxRequest();
|
---|
[30780] | 595 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=" + buildOperation + "&s1.incremental=true&s1.collection=" + collections[counter] + docs);
|
---|
[25012] | 596 | ajax.onreadystatechange = function()
|
---|
| 597 | {
|
---|
| 598 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
| 599 | {
|
---|
| 600 | var text = ajax.responseText;
|
---|
| 601 | var xml = validateXML(text);
|
---|
| 602 |
|
---|
| 603 | if(!xml || checkForErrors(xml))
|
---|
| 604 | {
|
---|
[25296] | 605 | alert(gs.text.dse.could_not_build_p1 + " " + collections[counter] + gs.text.dse.could_not_build_p2);
|
---|
[25012] | 606 |
|
---|
[28168] | 607 | if(_statusBar)
|
---|
| 608 | {
|
---|
| 609 | _statusBar.removeStatus(statusID);
|
---|
| 610 | }
|
---|
[29226] | 611 | enableSaveButtons(true);
|
---|
[25012] | 612 |
|
---|
| 613 | return;
|
---|
| 614 | }
|
---|
| 615 |
|
---|
| 616 | var status = xml.getElementsByTagName("status")[0];
|
---|
| 617 | var pid = status.getAttribute("pid");
|
---|
| 618 |
|
---|
[25546] | 619 | startCheckLoop(pid, buildOperation, statusID, function()
|
---|
[25012] | 620 | {
|
---|
[25546] | 621 | /*
|
---|
[25012] | 622 | var localAjax = new gs.functions.ajaxRequest();
|
---|
[28168] | 623 | localAjax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ActivateCollection&s1.collection=" + collections[counter], true);
|
---|
[25012] | 624 | localAjax.onreadystatechange = function()
|
---|
| 625 | {
|
---|
| 626 | if(localAjax.readyState == 4 && localAjax.status == 200)
|
---|
| 627 | {
|
---|
| 628 | var localText = localAjax.responseText;
|
---|
| 629 | var localXML = validateXML(localText);
|
---|
| 630 |
|
---|
| 631 | if(!xml || checkForErrors(xml))
|
---|
| 632 | {
|
---|
[25296] | 633 | alert(gs.text.dse.could_not_activate_p1 + " " + collections[counter] + gs.text.dse.could_not_activate_p2);
|
---|
[25012] | 634 |
|
---|
[28168] | 635 | if(_statusBar)
|
---|
| 636 | {
|
---|
| 637 | _statusBar.removeStatus(statusID);
|
---|
| 638 | }
|
---|
[29226] | 639 | enableSaveButtons(true);
|
---|
[25012] | 640 |
|
---|
| 641 | return;
|
---|
| 642 | }
|
---|
| 643 |
|
---|
| 644 | var localStatus = localXML.getElementsByTagName("status")[0];
|
---|
| 645 | if(localStatus)
|
---|
| 646 | {
|
---|
| 647 | var localPID = localStatus.getAttribute("pid");
|
---|
| 648 | startCheckLoop(localPID, "ActivateCollection", statusID, function()
|
---|
| 649 | {
|
---|
[25546] | 650 | */
|
---|
[25012] | 651 | if(counter == collections.length - 1)
|
---|
| 652 | {
|
---|
| 653 | removeCollectionsFromBuildList(collections);
|
---|
[25546] | 654 | if(callback)
|
---|
| 655 | {
|
---|
| 656 | callback();
|
---|
| 657 | }
|
---|
[25012] | 658 | }
|
---|
| 659 | else
|
---|
| 660 | {
|
---|
| 661 | counter++;
|
---|
| 662 | buildFunction();
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | _transactions = new Array();
|
---|
| 666 |
|
---|
[28168] | 667 | if(_statusBar)
|
---|
| 668 | {
|
---|
| 669 | _statusBar.removeStatus(statusID);
|
---|
| 670 | }
|
---|
[29226] | 671 | enableSaveButtons(true);
|
---|
[25546] | 672 | /*
|
---|
[25012] | 673 | });
|
---|
| 674 | }
|
---|
| 675 | }
|
---|
| 676 | }
|
---|
[28168] | 677 | if(_statusBar)
|
---|
| 678 | {
|
---|
| 679 | _statusBar.changeStatus(statusID, gs.text.dse.activating + " " + collections[counter] + "...");
|
---|
| 680 | }
|
---|
[25012] | 681 | localAjax.send();
|
---|
[25546] | 682 | */
|
---|
[25012] | 683 | });
|
---|
| 684 | }
|
---|
| 685 | }
|
---|
[28168] | 686 | if(_statusBar)
|
---|
| 687 | {
|
---|
| 688 | statusID = _statusBar.addStatus(gs.text.dse.building + " " + collections[counter] + "...");
|
---|
| 689 | }
|
---|
[25012] | 690 | ajax.send();
|
---|
| 691 | }
|
---|
| 692 | buildFunction();
|
---|
| 693 | }
|
---|
| 694 |
|
---|
| 695 | function startCheckLoop(pid, serverFunction, statusID, callbackFunction)
|
---|
| 696 | {
|
---|
| 697 | var ajaxFunction = function()
|
---|
| 698 | {
|
---|
| 699 | var ajax = new gs.functions.ajaxRequest();
|
---|
[28168] | 700 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=s&ro=1&s=" + serverFunction + "&s1.pid=" + pid, true);
|
---|
[25012] | 701 | ajax.onreadystatechange = function()
|
---|
| 702 | {
|
---|
| 703 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
| 704 | {
|
---|
| 705 | var text = ajax.responseText;
|
---|
| 706 | var xml = validateXML(text);
|
---|
| 707 |
|
---|
| 708 | if(!xml || checkForErrors(xml))
|
---|
| 709 | {
|
---|
[25296] | 710 | alert(gs.text.dse.could_not_check_status_p1 + " " + serverFunction + gs.text.dse.could_not_check_status_p2a);
|
---|
[25012] | 711 |
|
---|
[28168] | 712 | if(_statusBar)
|
---|
| 713 | {
|
---|
| 714 | _statusBar.removeStatus(statusID);
|
---|
| 715 | }
|
---|
[29226] | 716 | enableSaveButtons(true);
|
---|
[25012] | 717 |
|
---|
| 718 | return;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | var status = xml.getElementsByTagName("status")[0];
|
---|
| 722 | var code = status.getAttribute("code");
|
---|
| 723 |
|
---|
| 724 | if (code == COMPLETED || code == SUCCESS)
|
---|
| 725 | {
|
---|
| 726 | callbackFunction();
|
---|
| 727 | }
|
---|
| 728 | else if (code == HALTED || code == ERROR)
|
---|
| 729 | {
|
---|
[25296] | 730 | alert(gs.text.dse.could_not_check_status_p1 + " " + serverFunction + gs.text.dse.could_not_check_status_p2b);
|
---|
[25012] | 731 |
|
---|
[28168] | 732 | if(_statusBar)
|
---|
| 733 | {
|
---|
| 734 | _statusBar.removeStatus(statusID);
|
---|
| 735 | }
|
---|
[29226] | 736 | enableSaveButtons(true);
|
---|
[25012] | 737 | }
|
---|
| 738 | else
|
---|
| 739 | {
|
---|
| 740 | setTimeout(ajaxFunction, 1000);
|
---|
| 741 | }
|
---|
| 742 | }
|
---|
| 743 | }
|
---|
| 744 | ajax.send();
|
---|
| 745 | }
|
---|
| 746 | ajaxFunction();
|
---|
| 747 | }
|
---|
| 748 |
|
---|
| 749 | function removeCollectionsFromBuildList(collections)
|
---|
| 750 | {
|
---|
| 751 | var tempArray = new Array();
|
---|
| 752 | for(var i = 0; i < _collectionsToBuild.length; i++)
|
---|
| 753 | {
|
---|
| 754 | var found = false;
|
---|
| 755 | for(var j = 0; j < collections.length; j++)
|
---|
| 756 | {
|
---|
| 757 | if(collections[j] == _collectionsToBuild[i])
|
---|
| 758 | {
|
---|
| 759 | found = true;
|
---|
| 760 | break;
|
---|
| 761 | }
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | if(!found)
|
---|
| 765 | {
|
---|
| 766 | tempArray.push(_collectionsToBuild[i]);
|
---|
| 767 | }
|
---|
| 768 | }
|
---|
| 769 | _collectionsToBuild = tempArray;
|
---|
| 770 | }
|
---|
| 771 |
|
---|
| 772 | function checkForErrors(xml)
|
---|
| 773 | {
|
---|
| 774 | var errorElems = xml.getElementsByTagName("error");
|
---|
| 775 |
|
---|
| 776 | if(errorElems && errorElems.length > 0)
|
---|
| 777 | {
|
---|
[25296] | 778 | var errorString = gs.text.dse.error_saving_changes + ": ";
|
---|
[25012] | 779 | for(var i = 0; i < errorElems.length; i++)
|
---|
| 780 | {
|
---|
| 781 | errorString += " " + errorElems.item(i).firstChild.nodeValue;
|
---|
| 782 | }
|
---|
| 783 | alert(errorString);
|
---|
| 784 | return true;
|
---|
| 785 | }
|
---|
| 786 | return false; //No errors
|
---|
| 787 | }
|
---|
| 788 |
|
---|
| 789 | function validateXML(txt)
|
---|
| 790 | {
|
---|
| 791 | // code for IE
|
---|
| 792 | if (window.ActiveXObject)
|
---|
| 793 | {
|
---|
| 794 | var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
---|
| 795 | xmlDoc.async = "false";
|
---|
| 796 | xmlDoc.loadXML(document.all(txt).value);
|
---|
| 797 |
|
---|
| 798 | if(xmlDoc.parseError.errorCode!=0)
|
---|
| 799 | {
|
---|
[25296] | 800 | txt = dse.error_code + ": " + xmlDoc.parseError.errorCode + "\n";
|
---|
| 801 | txt = txt + dse.error_reason + ": " + xmlDoc.parseError.reason;
|
---|
| 802 | txt = txt + dse.error_line + ": " + xmlDoc.parseError.line;
|
---|
[25012] | 803 | console.log(txt);
|
---|
| 804 | return null;
|
---|
| 805 | }
|
---|
| 806 |
|
---|
| 807 | return xmlDoc;
|
---|
| 808 | }
|
---|
| 809 | // code for Mozilla, Firefox, Opera, etc.
|
---|
| 810 | else if (document.implementation.createDocument)
|
---|
| 811 | {
|
---|
| 812 | var parser = new DOMParser();
|
---|
| 813 | var xmlDoc = parser.parseFromString(txt,"text/xml");
|
---|
| 814 |
|
---|
| 815 | if (xmlDoc.getElementsByTagName("parsererror").length > 0)
|
---|
| 816 | {
|
---|
[25296] | 817 | console.log(gs.text.dse.xml_error);
|
---|
[25012] | 818 | return null;
|
---|
| 819 | }
|
---|
| 820 |
|
---|
| 821 | return xmlDoc;
|
---|
| 822 | }
|
---|
| 823 | else
|
---|
| 824 | {
|
---|
[25296] | 825 | console.log(gs.text.dse.browse_cannot_validate_xml);
|
---|
[25012] | 826 | }
|
---|
| 827 | return null;
|
---|
| 828 | }
|
---|
| 829 |
|
---|
[25096] | 830 | function onVisibleMetadataSetChange()
|
---|
| 831 | {
|
---|
| 832 | var metadataList = document.getElementById("metadataSetList");
|
---|
| 833 | var index = metadataList.selectedIndex;
|
---|
| 834 | var options = metadataList.getElementsByTagName("OPTION");
|
---|
| 835 | var selectedOption = options[index];
|
---|
| 836 |
|
---|
[29214] | 837 | var selectedSet = selectedOption.value;
|
---|
[25096] | 838 | changeVisibleMetadata(selectedSet);
|
---|
| 839 | }
|
---|
| 840 |
|
---|
| 841 | function changeVisibleMetadata(metadataSetName)
|
---|
| 842 | {
|
---|
[29499] | 843 | var metaSetList = metadataSetName.split(",");
|
---|
[25096] | 844 | var tables = document.getElementsByTagName("TABLE");
|
---|
| 845 | for(var i = 0; i < tables.length; i++)
|
---|
| 846 | {
|
---|
| 847 | var id = tables[i].getAttribute("id");
|
---|
| 848 | if(id && id.search(/^meta/) != -1)
|
---|
| 849 | {
|
---|
| 850 | var rows = tables[i].getElementsByTagName("TR");
|
---|
| 851 | for(var j = 0; j < rows.length; j++)
|
---|
| 852 | {
|
---|
| 853 | if(metadataSetName == "All")
|
---|
| 854 | {
|
---|
| 855 | rows[j].style.display = "table-row";
|
---|
| 856 | }
|
---|
| 857 | else
|
---|
| 858 | {
|
---|
[32132] | 859 | var cells = rows[j].getElementsByTagName("TD");
|
---|
| 860 | // metadata name cell might have the multivalue indicator in it, so just want the first word
|
---|
| 861 | var cellName = cells[0].innerHTML.split(" ")[0];
|
---|
[25096] | 862 |
|
---|
| 863 | if(cellName.indexOf(".") == -1)
|
---|
| 864 | {
|
---|
| 865 | rows[j].style.display = "none";
|
---|
| 866 | }
|
---|
| 867 | else
|
---|
| 868 | {
|
---|
| 869 | var setName = cellName.substring(0, cellName.lastIndexOf("."));
|
---|
[29499] | 870 | if (metaSetList.indexOf(setName)!= -1)
|
---|
[25096] | 871 | {
|
---|
| 872 | rows[j].style.display = "table-row";
|
---|
| 873 | }
|
---|
| 874 | else
|
---|
| 875 | {
|
---|
| 876 | rows[j].style.display = "none";
|
---|
| 877 | }
|
---|
| 878 | }
|
---|
| 879 | }
|
---|
| 880 | }
|
---|
| 881 | }
|
---|
| 882 | }
|
---|
| 883 | }
|
---|
| 884 |
|
---|
| 885 | function asyncRegisterEditSection(cell)
|
---|
| 886 | {
|
---|
| 887 | //This registering can cause a sizeable delay so we'll thread it (effectively) so the browser is not paused
|
---|
[29978] | 888 | cell.originalValue = cell.value;
|
---|
[29861] | 889 | setTimeout(function(){addEditableState(cell, editableInitStates)}, 0);
|
---|
[25096] | 890 | }
|
---|
| 891 |
|
---|
[29214] | 892 | function addOptionToList(list, optionvalue, optiontext, selected) {
|
---|
[29174] | 893 | var newOption = $("<option>");
|
---|
[29214] | 894 | if (optiontext) {
|
---|
| 895 | newOption.html(optiontext);
|
---|
| 896 | newOption.attr("value", optionvalue);
|
---|
| 897 | } else {
|
---|
| 898 | newOption.html(optionvalue);
|
---|
| 899 | }
|
---|
[29174] | 900 | if (selected) {
|
---|
| 901 | newOption.attr("selected", true);
|
---|
| 902 | }
|
---|
| 903 | list.append(newOption);
|
---|
| 904 | }
|
---|
| 905 |
|
---|
[29214] | 906 | /* returns either an input or a select element. Data based on
|
---|
| 907 | availableMetadataElements var. */
|
---|
| 908 | function createMetadataElementSelector() {
|
---|
| 909 | var metaNameField;
|
---|
| 910 | if (new_metadata_field_input_type == "fixedlist") {
|
---|
| 911 | metaNameField = $("<select>", {"class": "ui-state-default"});
|
---|
| 912 | for(var i=0; i<availableMetadataElements.length; i++) {
|
---|
| 913 | addOptionToList(metaNameField, availableMetadataElements[i]);
|
---|
| 914 | }
|
---|
| 915 | return metaNameField;
|
---|
| 916 | }
|
---|
| 917 | metaNameField = $("<input>", {"type": "text","style":"margin: 5px; border: 1px solid #000;"});
|
---|
| 918 | if (new_metadata_field_input_type == "autocomplete") {
|
---|
| 919 | metaNameField.autocomplete({
|
---|
| 920 | minLength: 0,
|
---|
| 921 | source: availableMetadataElements
|
---|
| 922 | });
|
---|
[30780] | 923 | metaNameField.attr("title", gs.text.de.enter_meta_dropdwon); //"Enter a metadata name, or use the down arrow to select one, then click 'Add New Metadata'");
|
---|
[29214] | 924 | } else {
|
---|
[30780] | 925 | metaNameField.attr("title", gs.text.de.enter_meta_name); //"Enter a metadata name, then click 'Add New Metadata'");
|
---|
[29214] | 926 | }
|
---|
| 927 |
|
---|
| 928 | return metaNameField;
|
---|
| 929 | }
|
---|
| 930 |
|
---|
| 931 |
|
---|
| 932 |
|
---|
[25012] | 933 | function addFunctionalityToTable(table)
|
---|
| 934 | {
|
---|
[26397] | 935 | table.find("tr").each(function()
|
---|
[25012] | 936 | {
|
---|
[26397] | 937 | var cells = $(this).find("td");
|
---|
| 938 | var metadataName = $(cells[0]).html();
|
---|
[32132] | 939 |
|
---|
[29214] | 940 | if(dynamic_metadata_set_list == true && metadataName.indexOf(".") != -1)
|
---|
[25096] | 941 | {
|
---|
| 942 | var metadataSetName = metadataName.substring(0, metadataName.lastIndexOf("."));
|
---|
[25012] | 943 |
|
---|
[25096] | 944 | var found = false;
|
---|
| 945 | for(var j = 0; j < _metadataSetList.length; j++)
|
---|
| 946 | {
|
---|
| 947 | if(metadataSetName == _metadataSetList[j])
|
---|
| 948 | {
|
---|
| 949 | found = true;
|
---|
| 950 | break;
|
---|
| 951 | }
|
---|
| 952 | }
|
---|
| 953 |
|
---|
| 954 | if(!found)
|
---|
| 955 | {
|
---|
| 956 | _metadataSetList.push(metadataSetName);
|
---|
[29214] | 957 | addOptionToList( $("#metadataSetList"), metadataSetName);
|
---|
[25096] | 958 | }
|
---|
| 959 | }
|
---|
| 960 |
|
---|
[29978] | 961 | asyncRegisterEditSection(cells[1].getElementsByTagName("textarea")[0]);
|
---|
[32132] | 962 | addRemoveLinkToRow(this);
|
---|
| 963 |
|
---|
| 964 | // add multivalued indicator if needed
|
---|
| 965 | if (jQuery.inArray(metadataName, multiValuedMetadata) != -1) {
|
---|
| 966 | //if (multiValuedMetadata.includes(metadataName)){
|
---|
| 967 | $(cells[0]).html(metadataName + " <span title='"+gs.text.de.multi_valued_tooltip + "' style='float:right;'>"+mvm_delimiter+"</span>"); //Multi-valued metadata. Separate values with semi-colon ;
|
---|
| 968 | }
|
---|
| 969 |
|
---|
[26397] | 970 | });
|
---|
[25096] | 971 |
|
---|
[31052] | 972 | // set up autocomplete values
|
---|
| 973 | var value_cells = $(".metaTableCellArea");
|
---|
| 974 | for (var k=0; k<autocompleteMetadata.length; k++) {
|
---|
| 975 | var source_name = autocompleteMetadata[k].replace(/[\.-]/g, "");
|
---|
| 976 | var source_obj = window[source_name+"_values"];
|
---|
| 977 | if (source_obj) {
|
---|
| 978 | value_cells.filter("."+source_name).autocomplete({
|
---|
| 979 | minLength: 0,
|
---|
| 980 | source: source_obj
|
---|
| 981 | });
|
---|
| 982 | }
|
---|
| 983 | }
|
---|
[32132] | 984 |
|
---|
| 985 | // add metadata field selector
|
---|
[31052] | 986 | var metaNameField = createMetadataElementSelector();
|
---|
[26397] | 987 | table.after(metaNameField);
|
---|
[25143] | 988 | table.metaNameField = metaNameField;
|
---|
[25012] | 989 |
|
---|
[31909] | 990 | /* add the buttons */
|
---|
| 991 | // check enable_add_all_button - only valid for fixedlist and autocomplete
|
---|
| 992 | if (enable_add_all_metadata_button == true) {
|
---|
| 993 | if (new_metadata_field_input_type != "fixedlist" && new_metadata_field_input_type != "autocomplete") {
|
---|
| 994 | enable_add_all_metadata_button = false;
|
---|
| 995 | }
|
---|
| 996 | }
|
---|
| 997 |
|
---|
| 998 | // add single metadata button
|
---|
| 999 | var addRowButton = $("<button>",{"class": "ui-state-default ui-corner-all", "style": "margin: 5px;"});
|
---|
| 1000 |
|
---|
[30780] | 1001 | addRowButton.html(gs.text.de.add_new_metadata);
|
---|
[26397] | 1002 | addRowButton.click(function()
|
---|
[25012] | 1003 | {
|
---|
[29214] | 1004 | var name = metaNameField.val();
|
---|
[25012] | 1005 | if(!name || name == "")
|
---|
| 1006 | {
|
---|
[30780] | 1007 | console.log(gs.text.de.no_meta_name_given);
|
---|
[25012] | 1008 | return;
|
---|
| 1009 | }
|
---|
[31909] | 1010 | addNewMetadataRow(table, name);
|
---|
[30382] | 1011 |
|
---|
[25012] | 1012 |
|
---|
[26397] | 1013 | });
|
---|
[31909] | 1014 | table.addRowButton = addRowButton;
|
---|
| 1015 | metaNameField.after(addRowButton);
|
---|
[29214] | 1016 |
|
---|
[31909] | 1017 | // add all metadata button
|
---|
| 1018 | if (enable_add_all_metadata_button == true) {
|
---|
| 1019 | var addAllButton = $("<button>",{"class": "ui-state-default ui-corner-all", "style": "margin: 5px;"});
|
---|
| 1020 | addAllButton.html(gs.text.de.add_all_metadata);
|
---|
| 1021 | addAllButton.click(function()
|
---|
| 1022 | {
|
---|
| 1023 | for(var i=0; i<availableMetadataElements.length; i++) {
|
---|
| 1024 |
|
---|
| 1025 | addNewMetadataRow(table, availableMetadataElements[i])
|
---|
| 1026 | }
|
---|
| 1027 |
|
---|
| 1028 | });
|
---|
| 1029 | table.addAllButton = addAllButton;
|
---|
| 1030 | addRowButton.after(addAllButton);
|
---|
| 1031 |
|
---|
| 1032 | }
|
---|
| 1033 |
|
---|
[25012] | 1034 | }
|
---|
| 1035 |
|
---|
[31909] | 1036 | function addNewMetadataRow(table, name) {
|
---|
| 1037 |
|
---|
| 1038 | var clean_name = name.replace(/[\.-]/g, "");
|
---|
| 1039 | var newRow = $("<tr>", {"style": "display: table-row;"});
|
---|
[32134] | 1040 | var nameCell;
|
---|
| 1041 | if (jQuery.inArray(name, multiValuedMetadata) != -1) {
|
---|
| 1042 | nameCell = $("<td>" + name + " <span title='"+gs.text.de.multi_valued_tooltip + "' style='float:right;'>"+mvm_delimiter+"</span></td>");
|
---|
| 1043 | } else {
|
---|
| 1044 | nameCell = $("<td>" + name + "</td>");
|
---|
| 1045 | }
|
---|
[31909] | 1046 | nameCell.attr("class", "metaTableCellName");
|
---|
| 1047 | var valueCell = $("<td>", {"class": "metaTableCell"});
|
---|
| 1048 | var textValue = $("<textarea>", {"class": "metaTableCellArea "+ clean_name});
|
---|
| 1049 |
|
---|
| 1050 | if (jQuery.inArray(name, autocompleteMetadata) != -1) {
|
---|
| 1051 | var source_obje = window[clean_name +"_values"];
|
---|
| 1052 | if (source_obje) {
|
---|
| 1053 | textValue.autocomplete({
|
---|
| 1054 | minLength: 0,
|
---|
| 1055 | source: source_obje
|
---|
| 1056 | });
|
---|
| 1057 | }
|
---|
| 1058 | }
|
---|
| 1059 | valueCell.append(textValue);
|
---|
| 1060 | newRow.append(nameCell);
|
---|
| 1061 | newRow.append(valueCell);
|
---|
| 1062 | addRemoveLinkToRow(newRow.get(0));
|
---|
| 1063 | table.append(newRow);
|
---|
| 1064 |
|
---|
| 1065 | var undo = new Array();
|
---|
| 1066 | undo.op = "delMeta";
|
---|
| 1067 | undo.srcElem = newRow;
|
---|
| 1068 | undo.removeTransaction = false;
|
---|
| 1069 | _undoOperations.push(undo);
|
---|
| 1070 | if ( hierarchyStorage && hierarchyStorage[name])
|
---|
| 1071 | {
|
---|
| 1072 | setHierarchyEventsWrappers(name);
|
---|
| 1073 | }
|
---|
| 1074 | }
|
---|
| 1075 |
|
---|
[25012] | 1076 | function addRemoveLinkToRow(row)
|
---|
| 1077 | {
|
---|
[26397] | 1078 | var newCell = $("<td>");
|
---|
[30815] | 1079 | var removeLink = $("<a>"+gs.text.de.remove+"</a>", {"href": "javascript:;"});
|
---|
[26397] | 1080 | removeLink.click(function()
|
---|
[25012] | 1081 | {
|
---|
| 1082 | var undo = new Array();
|
---|
| 1083 | undo.srcElem = row;
|
---|
[25104] | 1084 | undo.op = "display";
|
---|
| 1085 | undo.subOp = "table-row";
|
---|
| 1086 | undo.removeDeletedMetadata = true;
|
---|
[25012] | 1087 | _undoOperations.push(undo);
|
---|
[25104] | 1088 | _deletedMetadata.push(row);
|
---|
[29085] | 1089 | //row.css("display", "none");
|
---|
| 1090 | $(row).hide();
|
---|
[26397] | 1091 | });
|
---|
| 1092 | newCell.append(removeLink);
|
---|
[29214] | 1093 | newCell.attr({"class": "metaTableCellRemove", "style": "font-size:0.6em; padding-left: 3px; padding-right: 3px;"});
|
---|
[26397] | 1094 | $(row).append(newCell);
|
---|
[25012] | 1095 | }
|
---|
| 1096 |
|
---|
[29174] | 1097 | /* This is for 'edit structure' menu bar */
|
---|
[25012] | 1098 | function createTopMenuBar()
|
---|
| 1099 | {
|
---|
| 1100 | //Create the top menu bar
|
---|
| 1101 | var headerTable = document.createElement("TABLE");
|
---|
| 1102 | var tableBody = document.createElement("TBODY");
|
---|
| 1103 | var row = document.createElement("TR");
|
---|
| 1104 | var newDocCell = document.createElement("TD");
|
---|
| 1105 | var newSecCell = document.createElement("TD");
|
---|
| 1106 | var saveCell = document.createElement("TD");
|
---|
| 1107 | var undoCell = document.createElement("TD");
|
---|
[25096] | 1108 | var metadataListCell = document.createElement("TD");
|
---|
| 1109 |
|
---|
| 1110 | var metadataListLabel = document.createElement("SPAN");
|
---|
[30815] | 1111 | metadataListLabel.innerHTML = gs.text.de.visible_metadata;
|
---|
[25096] | 1112 | var metadataList = document.createElement("SELECT");
|
---|
| 1113 | metadataList.setAttribute("id", "metadataSetList");
|
---|
| 1114 | metadataList.onchange = onVisibleMetadataSetChange;
|
---|
| 1115 | var allMetadataOption = document.createElement("OPTION");
|
---|
| 1116 | metadataList.appendChild(allMetadataOption);
|
---|
[30815] | 1117 | allMetadataOption.innerHTML = gs.text.de.all_metadata;
|
---|
[25096] | 1118 | metadataListCell.appendChild(metadataListLabel);
|
---|
| 1119 | metadataListCell.appendChild(metadataList);
|
---|
| 1120 |
|
---|
| 1121 | metadataListCell.setAttribute("class", "headerTableTD");
|
---|
[25012] | 1122 | newDocCell.setAttribute("class", "headerTableTD");
|
---|
| 1123 | newSecCell.setAttribute("class", "headerTableTD");
|
---|
| 1124 | undoCell.setAttribute("class", "headerTableTD");
|
---|
| 1125 | saveCell.setAttribute("class", "headerTableTD");
|
---|
| 1126 |
|
---|
| 1127 | headerTable.appendChild(tableBody);
|
---|
| 1128 | tableBody.appendChild(row);
|
---|
| 1129 | row.appendChild(saveCell);
|
---|
| 1130 | row.appendChild(undoCell);
|
---|
| 1131 | row.appendChild(newDocCell);
|
---|
| 1132 | row.appendChild(newSecCell);
|
---|
[25096] | 1133 | row.appendChild(metadataListCell);
|
---|
[25012] | 1134 |
|
---|
| 1135 | //The "Save changes" button
|
---|
| 1136 | var saveButton = document.createElement("BUTTON");
|
---|
[30780] | 1137 | saveButton.innerHTML = gs.text.de.save_changes;
|
---|
[29226] | 1138 | saveButton.setAttribute("onclick", "saveAndRebuild();");
|
---|
[25012] | 1139 | saveButton.setAttribute("id", "saveButton");
|
---|
| 1140 | saveCell.appendChild(saveButton);
|
---|
| 1141 |
|
---|
| 1142 | //The "Undo" button
|
---|
| 1143 | var undoButton = document.createElement("BUTTON");
|
---|
[30815] | 1144 | undoButton.innerHTML = gs.text.dse.undo;
|
---|
[25012] | 1145 | undoButton.setAttribute("onclick", "undo();");
|
---|
| 1146 | undoCell.appendChild(undoButton);
|
---|
| 1147 |
|
---|
| 1148 | //The "Create new document" button
|
---|
| 1149 | var newDocButton = document.createElement("BUTTON");
|
---|
[25296] | 1150 | newDocButton.innerHTML = gs.text.dse.create_new_document;
|
---|
[25012] | 1151 | newDocButton.setAttribute("onclick", "createNewDocumentArea();");
|
---|
[25546] | 1152 | newDocButton.setAttribute("id", "createNewDocumentButton");
|
---|
[25012] | 1153 | newDocCell.appendChild(newDocButton);
|
---|
| 1154 |
|
---|
| 1155 | //The "Insert new section" LI
|
---|
| 1156 | var newSecLI = createDraggableNewSection(newSecCell);
|
---|
| 1157 |
|
---|
| 1158 | return headerTable;
|
---|
| 1159 | }
|
---|
| 1160 |
|
---|
| 1161 | function getMetadataFromNode(node, name)
|
---|
| 1162 | {
|
---|
| 1163 | var currentNode = node.firstChild;
|
---|
| 1164 | while(currentNode != null)
|
---|
| 1165 | {
|
---|
| 1166 | if(currentNode.nodeName == "metadataList")
|
---|
| 1167 | {
|
---|
| 1168 | currentNode = currentNode.firstChild;
|
---|
| 1169 | break;
|
---|
| 1170 | }
|
---|
| 1171 |
|
---|
| 1172 | currentNode = currentNode.nextSibling;
|
---|
| 1173 | }
|
---|
| 1174 |
|
---|
| 1175 | while(currentNode != null)
|
---|
| 1176 | {
|
---|
| 1177 | if(currentNode.nodeName == "metadata" && currentNode.getAttribute("name") == name)
|
---|
| 1178 | {
|
---|
| 1179 | return currentNode.firstChild.nodeValue;
|
---|
| 1180 | }
|
---|
| 1181 |
|
---|
| 1182 | currentNode = currentNode.nextSibling;
|
---|
| 1183 | }
|
---|
[25296] | 1184 | return "";
|
---|
[25012] | 1185 | }
|
---|
| 1186 |
|
---|
| 1187 | function storeMetadata(node, listItem)
|
---|
| 1188 | {
|
---|
| 1189 | listItem.metadata = new Array();
|
---|
| 1190 |
|
---|
| 1191 | var currentNode = node.firstChild;
|
---|
| 1192 | while(currentNode != null)
|
---|
| 1193 | {
|
---|
| 1194 | if(currentNode.nodeName == "metadataList")
|
---|
| 1195 | {
|
---|
| 1196 | currentNode = currentNode.firstChild;
|
---|
| 1197 | break;
|
---|
| 1198 | }
|
---|
| 1199 |
|
---|
| 1200 | currentNode = currentNode.nextSibling;
|
---|
| 1201 | }
|
---|
| 1202 |
|
---|
| 1203 | while(currentNode != null)
|
---|
| 1204 | {
|
---|
| 1205 | if(currentNode.nodeName == "metadata")
|
---|
| 1206 | {
|
---|
| 1207 | listItem.metadata[currentNode.getAttribute("name")] = currentNode.firstChild.nodeValue;
|
---|
| 1208 | }
|
---|
| 1209 |
|
---|
| 1210 | currentNode = currentNode.nextSibling;
|
---|
| 1211 | }
|
---|
| 1212 | }
|
---|
| 1213 |
|
---|
| 1214 | function getNodeContent(node)
|
---|
| 1215 | {
|
---|
| 1216 | var currentNode = node.firstChild;
|
---|
| 1217 | while(currentNode != null)
|
---|
| 1218 | {
|
---|
| 1219 | if(currentNode.nodeName == "nodeContent")
|
---|
| 1220 | {
|
---|
| 1221 | return currentNode.firstChild;
|
---|
| 1222 | }
|
---|
| 1223 |
|
---|
| 1224 | currentNode = currentNode.nextSibling;
|
---|
| 1225 | }
|
---|
| 1226 | return null;
|
---|
| 1227 | }
|
---|
| 1228 |
|
---|
| 1229 | function containsDocumentNode(node)
|
---|
| 1230 | {
|
---|
| 1231 | var currentNode = node.firstChild;
|
---|
| 1232 | while(currentNode != null)
|
---|
| 1233 | {
|
---|
| 1234 | if(currentNode.nodeName == "documentNode")
|
---|
| 1235 | {
|
---|
| 1236 | return true;
|
---|
| 1237 | }
|
---|
| 1238 |
|
---|
| 1239 | currentNode = currentNode.nextSibling;
|
---|
| 1240 | }
|
---|
| 1241 | return false;
|
---|
| 1242 | }
|
---|
| 1243 |
|
---|
| 1244 | function isExpanded(textDiv)
|
---|
| 1245 | {
|
---|
[30168] | 1246 | if(typeof textDiv.style == "undefined" || typeof textDiv.style.display == "undefined" || textDiv.style.display == "block")
|
---|
[25012] | 1247 | {
|
---|
| 1248 | return true;
|
---|
| 1249 | }
|
---|
| 1250 | return false;
|
---|
| 1251 | }
|
---|
| 1252 |
|
---|
| 1253 | function toggleTextDiv(section)
|
---|
| 1254 | {
|
---|
| 1255 | var textDiv = section.textDiv;
|
---|
| 1256 | if(textDiv)
|
---|
| 1257 | {
|
---|
| 1258 | if(isExpanded(textDiv))
|
---|
| 1259 | {
|
---|
| 1260 | textDiv.style.display = "none";
|
---|
[25296] | 1261 | section.menu.editTextLink.innerHTML = gs.text.dse.edit;
|
---|
[25012] | 1262 | }
|
---|
| 1263 | else
|
---|
| 1264 | {
|
---|
| 1265 | textDiv.style.display = "block";
|
---|
[25296] | 1266 | section.menu.editTextLink.innerHTML = gs.text.dse.hide;
|
---|
[25012] | 1267 | }
|
---|
| 1268 | }
|
---|
| 1269 | }
|
---|
| 1270 |
|
---|
| 1271 | function updateFromTop()
|
---|
| 1272 | {
|
---|
| 1273 | updateRecursive(document.getElementById("dbDiv"), null, null, 0);
|
---|
| 1274 | }
|
---|
| 1275 |
|
---|
| 1276 | function insertAfter(elem, refElem)
|
---|
| 1277 | {
|
---|
| 1278 | if(refElem.nextSibling)
|
---|
| 1279 | {
|
---|
| 1280 | refElem.parentNode.insertBefore(elem, refElem.nextSibling);
|
---|
| 1281 | }
|
---|
| 1282 | else
|
---|
| 1283 | {
|
---|
| 1284 | refElem.parentNode.appendChild(elem);
|
---|
| 1285 | }
|
---|
| 1286 | }
|
---|
| 1287 |
|
---|
| 1288 | function removeFromParent(elem)
|
---|
| 1289 | {
|
---|
| 1290 | elem.parentNode.removeChild(elem);
|
---|
| 1291 | }
|
---|
| 1292 |
|
---|
| 1293 | function createSectionTitle(text)
|
---|
| 1294 | {
|
---|
| 1295 | var textSpan = document.createElement("SPAN");
|
---|
| 1296 | if(text)
|
---|
| 1297 | {
|
---|
| 1298 | textSpan.appendChild(document.createTextNode(" " + text + " "));
|
---|
| 1299 | }
|
---|
| 1300 | else
|
---|
| 1301 | {
|
---|
[25296] | 1302 | textSpan.appendChild(document.createTextNode(" [" + gs.text.dse.untitled_section + "] "));
|
---|
[25012] | 1303 | }
|
---|
| 1304 | return textSpan;
|
---|
| 1305 | }
|
---|
| 1306 |
|
---|
| 1307 | function setMouseOverAndOutFunctions(section)
|
---|
| 1308 | {
|
---|
| 1309 | //Colour the list item and display the menu on mouse over
|
---|
| 1310 | section.onmouseover = function(e)
|
---|
| 1311 | {
|
---|
| 1312 | if(this.menu){this.menu.style.display = "inline";}
|
---|
| 1313 | this.style.background = "rgb(255, 200, 0)";
|
---|
| 1314 | };
|
---|
| 1315 | //Uncolour the list item and hide the menu on mouse out
|
---|
| 1316 | section.onmouseout = function(e)
|
---|
| 1317 | {
|
---|
| 1318 | if(this.menu){this.menu.style.display = "none";}
|
---|
| 1319 | this.style.background = "none";
|
---|
| 1320 | };
|
---|
| 1321 | }
|
---|
| 1322 |
|
---|
| 1323 | function createDraggableNewSection(parent)
|
---|
| 1324 | {
|
---|
| 1325 | var newSecLI = document.createElement("LI");
|
---|
| 1326 | var newSpan = document.createElement("SPAN");
|
---|
[25296] | 1327 | newSpan.innerHTML = gs.text.dse.insert_new_section + " ";
|
---|
[25012] | 1328 |
|
---|
| 1329 | newSecLI.sectionTitle = newSpan;
|
---|
| 1330 | newSecLI.appendChild(newSpan);
|
---|
| 1331 | newSecLI.setAttribute("class", "dragItem newSection");
|
---|
| 1332 | newSecLI.newSection = true;
|
---|
| 1333 | newSecLI.parent = parent;
|
---|
| 1334 | newSecLI.index = -1;
|
---|
| 1335 | new YAHOO.example.DDList(newSecLI);
|
---|
| 1336 | parent.appendChild(newSecLI);
|
---|
| 1337 | }
|
---|
| 1338 |
|
---|
| 1339 | function closeAllOpenContents()
|
---|
| 1340 | {
|
---|
| 1341 | for(var i = 0; i < _allContents.length; i++)
|
---|
| 1342 | {
|
---|
| 1343 | if(isExpanded(_allContents[i].textDiv))
|
---|
| 1344 | {
|
---|
| 1345 | toggleTextDiv(_allContents[i]);
|
---|
| 1346 | }
|
---|
| 1347 | }
|
---|
| 1348 | DDM.refreshCache();
|
---|
| 1349 | }
|
---|
| 1350 |
|
---|
| 1351 | //Status Bar class (initialised with new StatusBar(elem);)
|
---|
| 1352 | function StatusBar(mainElem)
|
---|
| 1353 | {
|
---|
| 1354 | var _statusMap = new Array();
|
---|
| 1355 | var _statusIDCounter = 0;
|
---|
| 1356 | var _mainElem = mainElem;
|
---|
| 1357 | var _activeMessages = 0;
|
---|
| 1358 |
|
---|
| 1359 | _mainElem.style.display = "none";
|
---|
| 1360 |
|
---|
| 1361 | this.addStatus = function(newStatus)
|
---|
| 1362 | {
|
---|
| 1363 | _mainElem.style.display = "block";
|
---|
| 1364 | var newStatusDiv = document.createElement("DIV");
|
---|
| 1365 | var newStatusSpan = document.createElement("SPAN");
|
---|
| 1366 |
|
---|
| 1367 | var workingImage = document.createElement("IMG");
|
---|
| 1368 | workingImage.setAttribute("src", gs.imageURLs.loading);
|
---|
| 1369 | workingImage.setAttribute("height", "16px");
|
---|
| 1370 | workingImage.setAttribute("width", "16px");
|
---|
| 1371 | newStatusDiv.appendChild(workingImage);
|
---|
| 1372 |
|
---|
| 1373 | newStatusDiv.appendChild(newStatusSpan);
|
---|
| 1374 | newStatusSpan.innerHTML = " " + newStatus;
|
---|
| 1375 | newStatusDiv.setAttribute("class", "statusMessage");
|
---|
| 1376 | newStatusDiv.span = newStatusSpan;
|
---|
| 1377 |
|
---|
| 1378 | _mainElem.appendChild(newStatusDiv);
|
---|
| 1379 | _statusMap["status" + _statusIDCounter] = newStatusDiv;
|
---|
| 1380 | _activeMessages++;
|
---|
| 1381 | return _statusIDCounter++;
|
---|
| 1382 | }
|
---|
| 1383 |
|
---|
| 1384 | this.changeStatus = function(id, newStatus)
|
---|
| 1385 | {
|
---|
| 1386 | if(_statusMap["status" + id])
|
---|
| 1387 | {
|
---|
| 1388 | _statusMap["status" + id].span.innerHTML = " " + newStatus;
|
---|
| 1389 | }
|
---|
| 1390 | }
|
---|
| 1391 |
|
---|
| 1392 | this.removeStatus = function(id)
|
---|
| 1393 | {
|
---|
| 1394 | if(_statusMap["status" + id])
|
---|
| 1395 | {
|
---|
| 1396 | removeFromParent(_statusMap["status" + id]);
|
---|
| 1397 |
|
---|
| 1398 | if(--_activeMessages == 0)
|
---|
| 1399 | {
|
---|
| 1400 | _mainElem.style.display = "none";
|
---|
| 1401 | }
|
---|
| 1402 | }
|
---|
| 1403 | }
|
---|
[28209] | 1404 |
|
---|
| 1405 | this.clear = function()
|
---|
| 1406 | {
|
---|
| 1407 | for(var p in _statusMap)
|
---|
| 1408 | {
|
---|
| 1409 | if(_statusMap.hasOwnProperty(p))
|
---|
| 1410 | {
|
---|
| 1411 | if(_statusMap[p] && _statusMap[p].parentNode)
|
---|
| 1412 | {
|
---|
| 1413 | removeFromParent(_statusMap[p]);
|
---|
| 1414 | }
|
---|
| 1415 |
|
---|
| 1416 | if(--_activeMessages == 0)
|
---|
| 1417 | {
|
---|
| 1418 | _mainElem.style.display = "none";
|
---|
| 1419 | }
|
---|
| 1420 | }
|
---|
| 1421 | }
|
---|
| 1422 | }
|
---|
[25012] | 1423 | }
|
---|
| 1424 |
|
---|
| 1425 | /*
|
---|
| 1426 | function toggleEdit(e)
|
---|
| 1427 | {
|
---|
| 1428 | var mousePos = de.events.getXYInWindowFromEvent(e);
|
---|
| 1429 | var cDesc = de.cursor.getCursorDescAtXY(mousePos.x, mousePos.y, de.events.getEventTarget(e));
|
---|
| 1430 | de.cursor.setCursor(cDesc);
|
---|
| 1431 | }
|
---|
[29861] | 1432 | */
|
---|