[27713] | 1 | var SUCCESS = 1;
|
---|
| 2 | var ACCEPTED = 2;
|
---|
| 3 | var ERROR = 3;
|
---|
| 4 | var CONTINUING = 10;
|
---|
| 5 | var COMPLETED = 11;
|
---|
| 6 | var HALTED = 12;
|
---|
| 7 |
|
---|
[24930] | 8 | gs.functions = new Array();
|
---|
| 9 |
|
---|
[26396] | 10 | gs.jqGet = function(id)
|
---|
| 11 | {
|
---|
[26431] | 12 | return $("#" + id.replace(/\./g, "\\.").replace(/:/g,"\\:"));
|
---|
[26396] | 13 | }
|
---|
| 14 |
|
---|
[24930] | 15 | gs.functions.ajaxRequest = function()
|
---|
| 16 | {
|
---|
| 17 | var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
|
---|
| 18 | if(window.ActiveXObject)
|
---|
| 19 | {
|
---|
| 20 | for (var i=0; i<activexmodes.length; i++)
|
---|
| 21 | {
|
---|
| 22 | try
|
---|
| 23 | {
|
---|
| 24 | return new ActiveXObject(activexmodes[i]);
|
---|
| 25 | }
|
---|
| 26 | catch(e){}
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | else if (window.XMLHttpRequest)
|
---|
| 30 | {
|
---|
| 31 | return new XMLHttpRequest();
|
---|
| 32 | }
|
---|
| 33 | else
|
---|
| 34 | {
|
---|
| 35 | return false
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
[25364] | 39 | gs.functions.hasClass = function(elem, classVal)
|
---|
| 40 | {
|
---|
| 41 | if(!elem || !elem.getAttribute("class"))
|
---|
| 42 | {
|
---|
| 43 | return false;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | return (elem.getAttribute("class").search(classVal) != -1)
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[25142] | 49 | gs.functions.getElementsByClassName = function(cl)
|
---|
| 50 | {
|
---|
| 51 | var nodes = new Array();
|
---|
| 52 | var classRegEx = new RegExp('\\b'+cl+'\\b');
|
---|
| 53 | var allElems = document.getElementsByTagName('*');
|
---|
| 54 |
|
---|
| 55 | for (var i = 0; i < allElems.length; i++)
|
---|
| 56 | {
|
---|
| 57 | var classes = allElems[i].className;
|
---|
| 58 | if (classRegEx.test(classes))
|
---|
| 59 | {
|
---|
| 60 | nodes.push(allElems[i]);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | return nodes;
|
---|
| 64 | };
|
---|
| 65 |
|
---|
[24930] | 66 | gs.functions.makeToggle = function(buttons, divs)
|
---|
| 67 | {
|
---|
| 68 | var buttonArray = (buttons.length) ? buttons : [buttons];
|
---|
| 69 | var divArray = (divs.length) ? divs : [divs];
|
---|
| 70 |
|
---|
| 71 | for(var i = 0; i < buttonArray.length; i++)
|
---|
| 72 | {
|
---|
| 73 | buttonArray[i].onclick = function()
|
---|
| 74 | {
|
---|
| 75 | for(var j = 0; j < divArray.length; j++)
|
---|
| 76 | {
|
---|
| 77 | if(divArray[j].style.display == "none")
|
---|
| 78 | {
|
---|
| 79 | divArray[j].style.display = "block";
|
---|
| 80 | }
|
---|
| 81 | else
|
---|
| 82 | {
|
---|
| 83 | divArray[j].style.display = "none";
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | for(var j = 0; j < buttonArray.length; j++)
|
---|
| 88 | {
|
---|
| 89 | if(buttonArray[j].getAttribute("src") == gs.imageURLs.collapse)
|
---|
| 90 | {
|
---|
| 91 | buttonArray[j].setAttribute("src", gs.imageURLs.expand);
|
---|
| 92 | }
|
---|
| 93 | else if(buttonArray[j].getAttribute("src") == gs.imageURLs.expand)
|
---|
| 94 | {
|
---|
| 95 | buttonArray[j].setAttribute("src", gs.imageURLs.collapse);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | };
|
---|
| 99 | }
|
---|
[25008] | 100 | }
|
---|
| 101 |
|
---|
[27713] | 102 | gs.functions.checkForErrors = function(xml)
|
---|
| 103 | {
|
---|
| 104 | var errorElems = xml.getElementsByTagName("error");
|
---|
| 105 |
|
---|
| 106 | if(errorElems && errorElems.length > 0)
|
---|
| 107 | {
|
---|
| 108 | var errorString = gs.text.dse.error_saving_changes + ": ";
|
---|
| 109 | for(var i = 0; i < errorElems.length; i++)
|
---|
| 110 | {
|
---|
| 111 | errorString += " " + errorElems.item(i).firstChild.nodeValue;
|
---|
| 112 | }
|
---|
| 113 | alert(errorString);
|
---|
| 114 | return true;
|
---|
| 115 | }
|
---|
| 116 | return false; //No errors
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | gs.functions.validateXML = function(txt)
|
---|
| 120 | {
|
---|
| 121 | // code for IE
|
---|
| 122 | if (window.ActiveXObject)
|
---|
| 123 | {
|
---|
| 124 | var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
---|
| 125 | xmlDoc.async = "false";
|
---|
| 126 | xmlDoc.loadXML(document.all(txt).value);
|
---|
| 127 |
|
---|
| 128 | if(xmlDoc.parseError.errorCode!=0)
|
---|
| 129 | {
|
---|
| 130 | txt = dse.error_code + ": " + xmlDoc.parseError.errorCode + "\n";
|
---|
| 131 | txt = txt + dse.error_reason + ": " + xmlDoc.parseError.reason;
|
---|
| 132 | txt = txt + dse.error_line + ": " + xmlDoc.parseError.line;
|
---|
| 133 | console.log(txt);
|
---|
| 134 | return null;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | return xmlDoc;
|
---|
| 138 | }
|
---|
| 139 | // code for Mozilla, Firefox, Opera, etc.
|
---|
| 140 | else if (document.implementation.createDocument)
|
---|
| 141 | {
|
---|
| 142 | var parser = new DOMParser();
|
---|
| 143 | var xmlDoc = parser.parseFromString(txt,"text/xml");
|
---|
| 144 |
|
---|
| 145 | if (xmlDoc.getElementsByTagName("parsererror").length > 0)
|
---|
| 146 | {
|
---|
| 147 | console.log(gs.text.dse.xml_error);
|
---|
| 148 | return null;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | return xmlDoc;
|
---|
| 152 | }
|
---|
| 153 | else
|
---|
| 154 | {
|
---|
| 155 | console.log(gs.text.dse.browse_cannot_validate_xml);
|
---|
| 156 | }
|
---|
| 157 | return null;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[25008] | 160 | gs.functions.buildCollections = function(collections, finalFunction)
|
---|
| 161 | {
|
---|
| 162 | if(!collections || collections.length == 0)
|
---|
| 163 | {
|
---|
| 164 | console.log("List of collections to build is empty");
|
---|
| 165 | return;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | var counter = 0;
|
---|
| 169 | var buildFunction = function()
|
---|
| 170 | {
|
---|
| 171 | var ajax = new gs.functions.ajaxRequest();
|
---|
[27713] | 172 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=BuildCollection&s1.collection=" + collections[counter]);
|
---|
[25008] | 173 | ajax.onreadystatechange = function()
|
---|
| 174 | {
|
---|
| 175 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
| 176 | {
|
---|
| 177 | var text = ajax.responseText;
|
---|
[27713] | 178 | var xml = gs.functions.validateXML(text);
|
---|
[25008] | 179 |
|
---|
[27713] | 180 | if(!xml || gs.functions.checkForErrors(xml))
|
---|
[25008] | 181 | {
|
---|
| 182 | console.log("Could not build collection -> " + collections[counter] + ", aborting");
|
---|
| 183 | return;
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | var status = xml.getElementsByTagName("status")[0];
|
---|
| 187 | var pid = status.getAttribute("pid");
|
---|
| 188 |
|
---|
[27713] | 189 | gs.functions.startCheckLoop(pid, "BuildCollection", function()
|
---|
[25008] | 190 | {
|
---|
| 191 | var localAjax = new gs.functions.ajaxRequest();
|
---|
[27713] | 192 | localAjax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ActivateCollection&s1.collection=" + collections[counter], true);
|
---|
[25008] | 193 | localAjax.onreadystatechange = function()
|
---|
| 194 | {
|
---|
| 195 | if(localAjax.readyState == 4 && localAjax.status == 200)
|
---|
| 196 | {
|
---|
| 197 | var localText = localAjax.responseText;
|
---|
[27713] | 198 | var localXML = gs.functions.validateXML(localText);
|
---|
[25008] | 199 |
|
---|
[27713] | 200 | if(!xml || gs.functions.checkForErrors(xml))
|
---|
[25008] | 201 | {
|
---|
| 202 | console.log("Could not activate collection -> " + collections[counter] + ", aborting");
|
---|
| 203 | return;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | var localStatus = localXML.getElementsByTagName("status")[0];
|
---|
| 207 | if(localStatus)
|
---|
| 208 | {
|
---|
| 209 | var localPID = localStatus.getAttribute("pid");
|
---|
[27713] | 210 | gs.functions.startCheckLoop(localPID, "ActivateCollection", function()
|
---|
[25008] | 211 | {
|
---|
[27713] | 212 | if (++counter == collections.length)
|
---|
[25008] | 213 | {
|
---|
| 214 | //Run this function once we are done building all the collections
|
---|
| 215 | if(finalFunction){finalFunction();}
|
---|
| 216 | }
|
---|
| 217 | else
|
---|
| 218 | {
|
---|
| 219 | buildFunction();
|
---|
| 220 | }
|
---|
| 221 | });
|
---|
| 222 | }
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
| 225 | localAjax.send();
|
---|
| 226 | });
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 | ajax.send();
|
---|
| 230 | }
|
---|
| 231 | buildFunction();
|
---|
| 232 | }
|
---|
| 233 |
|
---|
[27713] | 234 | gs.functions.startCheckLoop = function(pid, serverFunction, callbackFunction)
|
---|
[25008] | 235 | {
|
---|
| 236 | var ajaxFunction = function()
|
---|
| 237 | {
|
---|
| 238 | var ajax = new gs.functions.ajaxRequest();
|
---|
[27713] | 239 | ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=s&ro=1&s=" + serverFunction + "&s1.pid=" + pid, true);
|
---|
[25008] | 240 | ajax.onreadystatechange = function()
|
---|
| 241 | {
|
---|
| 242 | if(ajax.readyState == 4 && ajax.status == 200)
|
---|
| 243 | {
|
---|
| 244 | var text = ajax.responseText;
|
---|
[27713] | 245 | var xml = gs.functions.validateXML(text);
|
---|
[25008] | 246 |
|
---|
[27713] | 247 | if(!xml || gs.functions.checkForErrors(xml))
|
---|
[25008] | 248 | {
|
---|
| 249 | console.log("Could not check status of " + serverFunction + ", there was an error in the XML, aborting");
|
---|
| 250 | return;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | var status = xml.getElementsByTagName("status")[0];
|
---|
| 254 | var code = status.getAttribute("code");
|
---|
| 255 |
|
---|
| 256 | if (code == COMPLETED || code == SUCCESS)
|
---|
| 257 | {
|
---|
| 258 | callbackFunction();
|
---|
| 259 | }
|
---|
| 260 | else if (code == HALTED || code == ERROR)
|
---|
| 261 | {
|
---|
| 262 | console.log("Could not check status of " + serverFunction + ", there was an error on the server, aborting");
|
---|
| 263 | }
|
---|
| 264 | else
|
---|
| 265 | {
|
---|
| 266 | setTimeout(ajaxFunction, 1000);
|
---|
| 267 | }
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
| 270 | ajax.send();
|
---|
| 271 | }
|
---|
| 272 | ajaxFunction();
|
---|
| 273 | }
|
---|
| 274 |
|
---|
[25364] | 275 | function inc(a, b)
|
---|
| 276 | {
|
---|
| 277 | var carry = 0;
|
---|
| 278 | var num = 0;
|
---|
| 279 | var i = 0;
|
---|
| 280 |
|
---|
| 281 | while((carry || (i < a.length) || (i < b.length)) && (i < 100))
|
---|
| 282 | {
|
---|
| 283 | num = carry;
|
---|
| 284 | if(i < a.length){num += a[i];}
|
---|
| 285 | if(i < b.length){num += b[i];}
|
---|
| 286 |
|
---|
| 287 | if(num >= 256)
|
---|
| 288 | {
|
---|
| 289 | num -= 256;
|
---|
| 290 | carry = 1;
|
---|
| 291 | }
|
---|
| 292 | else
|
---|
| 293 | {
|
---|
| 294 | carry = 0;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | a[i] = num;
|
---|
| 298 |
|
---|
| 299 | i++;
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | function ifposDec(a, b)
|
---|
| 304 | {
|
---|
| 305 | var carry = 0;
|
---|
| 306 | var num = 0;
|
---|
| 307 | var i = 0;
|
---|
| 308 |
|
---|
[25440] | 309 | if(b.length > a.length){return a;}
|
---|
[25364] | 310 | if(b.length == a.length)
|
---|
| 311 | {
|
---|
| 312 | i = a.length - 1;
|
---|
| 313 | while(i >= 0)
|
---|
| 314 | {
|
---|
[25440] | 315 | if(a[i] > b[i]){break;}
|
---|
| 316 | if(a[i] < b[i]){return a;}
|
---|
[25364] | 317 | i--;
|
---|
| 318 | }
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | i = 0;
|
---|
[25440] | 322 | var len = 0;
|
---|
| 323 | var outString = "";
|
---|
[25364] | 324 | while((i < a.length) || (i < b.length))
|
---|
| 325 | {
|
---|
| 326 | num = -carry;
|
---|
| 327 | if(i < a.length){num += a[i];}
|
---|
| 328 | if(i < b.length){num -= b[i];}
|
---|
| 329 |
|
---|
| 330 | if(num < 0)
|
---|
| 331 | {
|
---|
| 332 | num += 256;
|
---|
| 333 | carry = 1;
|
---|
| 334 | }
|
---|
| 335 | else
|
---|
| 336 | {
|
---|
| 337 | carry = 0;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | a[i] = num;
|
---|
[25440] | 341 | outString += num + ","
|
---|
[25364] | 342 | i++
|
---|
[25440] | 343 |
|
---|
| 344 | if(num != 0){len = i}
|
---|
[25364] | 345 | }
|
---|
[25440] | 346 |
|
---|
| 347 | if(len < a.length)
|
---|
| 348 | {
|
---|
| 349 | a = a.slice(0, len);
|
---|
| 350 | }
|
---|
[25364] | 351 |
|
---|
[25440] | 352 | return a;
|
---|
[25364] | 353 | }
|
---|
| 354 |
|
---|
| 355 | function convertNum(a)
|
---|
| 356 | {
|
---|
| 357 | var result = new Array();
|
---|
| 358 | var i;
|
---|
| 359 | var convert = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
---|
| 360 |
|
---|
| 361 | if(a.length == 0)
|
---|
| 362 | {
|
---|
| 363 | result.push("0");
|
---|
| 364 | return result;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | for(i = a.length - 1; i >= 0; i--)
|
---|
| 368 | {
|
---|
| 369 | result.push(convert[Math.floor(a[i]/16)]);
|
---|
| 370 | result.push(convert[Math.floor(a[i]%16)]);
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | var resultString = "";
|
---|
| 374 | for(var j = 0; j < result.length; j++)
|
---|
| 375 | {
|
---|
| 376 | resultString += result[j];
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 | return resultString;
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | gs.functions.hashString = function(str)
|
---|
| 383 | {
|
---|
| 384 | var remainder = new Array();
|
---|
| 385 | var primePow = new Array();
|
---|
| 386 | var pow =
|
---|
| 387 | [
|
---|
| 388 | 255, 255, 255,
|
---|
| 389 | 255, 255, 255,
|
---|
| 390 | 255, 255, 255,
|
---|
| 391 | 255, 255, 1
|
---|
| 392 | ];
|
---|
| 393 |
|
---|
| 394 | for(var i = 0; i < 8; i++)
|
---|
| 395 | {
|
---|
[25440] | 396 | primePow.push(pow.slice()); //The javascript way to do an array copy (yuck!)
|
---|
[25364] | 397 | inc(pow, pow);
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | for(var i = 0; i < str.length; i++)
|
---|
| 401 | {
|
---|
[25440] | 402 | var c = str.charCodeAt(i);
|
---|
[25364] | 403 |
|
---|
| 404 | if(remainder.length == 99)
|
---|
| 405 | {
|
---|
| 406 | return null;
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | for(var j = remainder.length; j > 0; j--)
|
---|
| 410 | {
|
---|
[25440] | 411 | remainder[j] = remainder[j-1];
|
---|
[25364] | 412 | }
|
---|
| 413 | remainder[0] = c;
|
---|
| 414 |
|
---|
| 415 | for(var j = 7; j >= 0; j--)
|
---|
| 416 | {
|
---|
[25440] | 417 | remainder = ifposDec(remainder, primePow[j]);
|
---|
[25364] | 418 | }
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | return convertNum(remainder);
|
---|
| 422 | }
|
---|
| 423 |
|
---|
[25008] | 424 | function callMetadataServer(callingFunction, url, responseFunction)
|
---|
| 425 | {
|
---|
[27811] | 426 | $.ajax(url)
|
---|
| 427 | .success(function(response)
|
---|
[25008] | 428 | {
|
---|
[27811] | 429 | console.log("(" + callingFunction + ") Response received from server: " + response);
|
---|
| 430 |
|
---|
| 431 | //var xml = $.parseXML(response);
|
---|
| 432 | //console.log(xml);
|
---|
| 433 |
|
---|
| 434 | if(responseFunction != null)
|
---|
[25008] | 435 | {
|
---|
[27811] | 436 | responseFunction(response);
|
---|
[25008] | 437 | }
|
---|
[27811] | 438 | })
|
---|
| 439 | .error(function()
|
---|
| 440 | {
|
---|
| 441 | console.log("(" + callingFunction + ") Failed");
|
---|
| 442 | });
|
---|
[25008] | 443 | }
|
---|
| 444 |
|
---|
| 445 | /*************************
|
---|
| 446 | * SET METADATA FUNCTIONS *
|
---|
| 447 | *************************/
|
---|
| 448 |
|
---|
[25105] | 449 | gs.functions.setImportMetadata = function(collection, site, documentID, metadataName, metadataValue, prevMetadataValue, metamode, responseFunction)
|
---|
[25008] | 450 | {
|
---|
[25105] | 451 | callMetadataServer("setImportMetadata", "cgi-bin/metadata-server.pl?a=set-import-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue + "&prevmetavalue=" + prevMetadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 452 | }
|
---|
| 453 |
|
---|
[25105] | 454 | gs.functions.setArchivesMetadata = function(collection, site, documentID, metadataName, metadataPosition, metadataValue, prevMetadataValue, metamode, responseFunction)
|
---|
[25008] | 455 | {
|
---|
| 456 | if(metadataPosition != null)
|
---|
| 457 | {
|
---|
[25105] | 458 | callMetadataServer("setArchivesMetadata", "cgi-bin/metadata-server.pl?a=set-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition + "&metavalue=" + metadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 459 | }
|
---|
[25098] | 460 | else if(prevMetadataValue != null)
|
---|
[25008] | 461 | {
|
---|
[25105] | 462 | callMetadataServer("setArchivesMetadata", "cgi-bin/metadata-server.pl?a=set-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue + "&prevmetavalue=" + prevMetadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 463 | }
|
---|
[25105] | 464 | else
|
---|
| 465 | {
|
---|
| 466 | callMetadataServer("setArchivesMetadata", "cgi-bin/metadata-server.pl?a=set-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue + "&metamode=" + metamode, responseFunction);
|
---|
| 467 | }
|
---|
[25008] | 468 | }
|
---|
| 469 |
|
---|
[25105] | 470 | gs.functions.setIndexMetadata = function(collection, site, documentID, metadataName, metadataPosition, metadataValue, prevMetadataValue, metamode, responseFunction)
|
---|
[25008] | 471 | {
|
---|
| 472 | if(metadataPosition != null)
|
---|
| 473 | {
|
---|
[25105] | 474 | callMetadataServer("setIndexMetadata", "cgi-bin/metadata-server.pl?a=set-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition + "&metavalue=" + metadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 475 | }
|
---|
[25098] | 476 | else if(prevMetadataValue != null)
|
---|
[25008] | 477 | {
|
---|
[25105] | 478 | callMetadataServer("setIndexMetadata", "cgi-bin/metadata-server.pl?a=set-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue + "&prevmetavalue=" + prevMetadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 479 | }
|
---|
| 480 | }
|
---|
| 481 |
|
---|
[25105] | 482 | gs.functions.setMetadata = function(collection, site, documentID, metadataName, metadataValue, metamode, responseFunction)
|
---|
[25008] | 483 | {
|
---|
| 484 | var nameArray = ["setImportMetadata", "setArchivesMetadata", "setIndexMetadata"];
|
---|
| 485 | var functionArray = ["set-import-metadata", "set-archives-metadata", "set-metadata"];
|
---|
| 486 |
|
---|
| 487 | for(var i = 0; i < nameArray.length; i++)
|
---|
| 488 | {
|
---|
[25105] | 489 | callMetadataServer(nameArray[i], "cgi-bin/metadata-server.pl?a=" + functionArray[i] + "&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue + "&metamode=" + metamode, responseFunction);
|
---|
[25008] | 490 | }
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | /*************************
|
---|
| 494 | * GET METADATA FUNCTIONS *
|
---|
| 495 | *************************/
|
---|
| 496 |
|
---|
| 497 | gs.functions.getImportMetadata = function(collection, site, documentID, metadataName, responseFunction)
|
---|
| 498 | {
|
---|
| 499 | var url = "cgi-bin/metadata-server.pl?a=get-import-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName;
|
---|
| 500 | callMetadataServer("getImportMetadata", url, function(responseText)
|
---|
| 501 | {
|
---|
| 502 | var metadata = new GSMetadata(collection, site, documentID, metadataName, null, responseText);
|
---|
| 503 | if(responseFunction != null)
|
---|
| 504 | {
|
---|
| 505 | responseFunction(metadata);
|
---|
| 506 | }
|
---|
| 507 | });
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | gs.functions.getArchivesMetadata = function(collection, site, documentID, metadataName, metadataPosition, responseFunction)
|
---|
| 511 | {
|
---|
| 512 | var url = "cgi-bin/metadata-server.pl?a=get-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName;
|
---|
| 513 | if(metadataPosition != null)
|
---|
| 514 | {
|
---|
| 515 | url += "&metapos=" + metadataPosition;
|
---|
| 516 | }
|
---|
| 517 |
|
---|
| 518 | callMetadataServer("getArchivesMetadata", url, function(responseText)
|
---|
| 519 | {
|
---|
| 520 | var metadata = new GSMetadata(collection, site, documentID, metadataName, metadataPosition, responseText);
|
---|
| 521 | if(responseFunction != null)
|
---|
| 522 | {
|
---|
| 523 | responseFunction(metadata);
|
---|
| 524 | }
|
---|
| 525 | });
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | gs.functions.getIndexMetadata = function(collection, site, documentID, metadataName, metadataPosition, responseFunction)
|
---|
| 529 | {
|
---|
| 530 | var url = "cgi-bin/metadata-server.pl?a=get-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName;
|
---|
| 531 | if(metadataPosition != null)
|
---|
| 532 | {
|
---|
| 533 | url += "&metapos=" + metadataPosition;
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | callMetadataServer("getIndexMetadata", url, function(responseText)
|
---|
| 537 | {
|
---|
| 538 | var metadata = new GSMetadata(collection, site, documentID, metadataName, metadataPosition, responseText);
|
---|
| 539 |
|
---|
| 540 | if(responseFunction != null)
|
---|
| 541 | {
|
---|
| 542 | responseFunction(metadata);
|
---|
| 543 | }
|
---|
| 544 | });
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | /****************************
|
---|
| 548 | * REMOVE METADATA FUNCTIONS *
|
---|
| 549 | ****************************/
|
---|
| 550 |
|
---|
| 551 | gs.functions.removeImportMetadata = function(collection, site, documentID, metadataName, metadataValue, responseFunction)
|
---|
| 552 | {
|
---|
| 553 | callMetadataServer("removeImportMetadata", "cgi-bin/metadata-server.pl?a=remove-import-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 | gs.functions.removeArchivesMetadata = function(collection, site, documentID, metadataName, metadataPosition, metadataValue, responseFunction)
|
---|
| 557 | {
|
---|
| 558 | if(metadataPosition != null)
|
---|
| 559 | {
|
---|
[25104] | 560 | callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition, responseFunction);
|
---|
[25008] | 561 | }
|
---|
| 562 | else if(metadataValue != null)
|
---|
| 563 | {
|
---|
[25104] | 564 | callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
|
---|
[25008] | 565 | }
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | gs.functions.removeIndexMetadata = function(collection, site, documentID, metadataName, metadataPosition, metadataValue, responseFunction)
|
---|
| 569 | {
|
---|
| 570 | if(metadataPosition != null)
|
---|
| 571 | {
|
---|
| 572 | callMetadataServer("removeIndexMetadata", "cgi-bin/metadata-server.pl?a=remove-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition, responseFunction);
|
---|
| 573 | }
|
---|
| 574 | else if(metadataValue != null)
|
---|
| 575 | {
|
---|
| 576 | callMetadataServer("removeIndexMetadata", "cgi-bin/metadata-server.pl?a=remove-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
| 579 |
|
---|
| 580 | gs.functions.removeMetadata = function(collection, site, documentID, metadataName, metadataValue, responseFunction)
|
---|
| 581 | {
|
---|
| 582 | var nameArray = ["removeImportMetadata", "removeArchivesMetadata", "removeIndexMetadata"];
|
---|
| 583 | var functionArray = ["remove-import-metadata", "remove-archives-metadata", "remove-metadata"];
|
---|
| 584 |
|
---|
| 585 | for(var i = 0; i < nameArray.length; i++)
|
---|
| 586 | {
|
---|
| 587 | callMetadataServer(nameArray[i], "cgi-bin/metadata-server.pl?a=" + functionArray[i] + "&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
|
---|
| 588 | }
|
---|
| 589 | }
|
---|