1 // vim: noet:sw=4:ts=4:
2 var xmlDeclaration = /^<\?xml version[^>]+?>/;
4 var serializer = new XMLSerializer();
5 var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
6 var gw = new Namespace("http://opensrf.org/-/namespaces/gateway/v1");
7 var xulns = new Namespace("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
8 default xml namespace = marcns;
10 var tooltip_hash = {};
17 function mangle_005() {
19 var y = now.getUTCFullYear();
21 var m = now.getUTCMonth() + 1;
22 if (m < 10) m = '0' + m;
24 var d = now.getUTCDate();
25 if (d < 10) d = '0' + d;
27 var H = now.getUTCHours();
28 if (H < 10) H = '0' + H;
30 var M = now.getUTCMinutes();
31 if (M < 10) M = '0' + M;
33 var S = now.getUTCSeconds();
34 if (S < 10) S = '0' + S;
37 var stamp = '' + y + m + d + H + M + S + '.0';
38 createControlField('005',stamp);
42 function createControlField (tag,data) {
43 // first, remove the old field, if any;
44 for (var i in xml_record.controlfield.(@tag == tag)) delete xml_record.controlfield.(@tag == tag)[i];
46 var cf = <controlfield tag="" xmlns="http://www.loc.gov/MARC21/slim">{ data }</controlfield>;
49 // then, find the right position and insert it
51 var cfields = xml_record.controlfield;
52 var base = Number(tag.substring(2));
53 for (var i in cfields) {
54 var t = Number(cfields[i].@tag.toString().substring(2));
56 xml_record.insertChildBefore( cfields[i], cf );
62 if (!done) xml_record.insertChildBefore( xml_record.datafield[0], cf );
67 function xml_escape_unicode ( str ) {
70 function (r,s) { return "&#x" + s.charCodeAt(0).toString(16) + ";"; }
76 // Fake xulG for standalone...
81 window.xulG.record = {};
82 window.xulG.save = {};
84 window.xulG.save.label = 'Save Record';
85 window.xulG.save.func = function (r) { alert(r); }
88 var _rid = cgi.param('record');
90 window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
95 document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
96 document.getElementById('save-button').setAttribute('oncommand',
98 'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' +
99 'window.xulG.save.func( xml_string ); ' +
100 'loadRecord(xml_record);'
103 if (window.xulG.record.url) {
104 var req = new XMLHttpRequest();
105 req.open('GET',window.xulG.record.url,false);
107 window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
110 xml_record = new XML( window.xulG.record.marc );
111 if (xml_record..record[0]) xml_record = xml_record..record[0];
113 // Get the tooltip xml all async like
114 req = new XMLHttpRequest();
116 // Set a default locale in case preferences fail us
117 var locale = "en-US";
119 // Try to get the locale from our preferences - not working
120 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
122 var Cc = Components.classes;
123 var Ci = Components.interfaces;
125 Cc["@mozilla.org/preferences-service;1"].
126 getService(Ci.nsIPrefService).getBranch("general.useragent").
127 getCharPref("locale");
131 // Get the locale-specific tooltips
132 // TODO: We should send a HEAD request to check for the existence of the desired file
133 // then fall back to the default locale if preferred locale is not necessary
134 req.open('GET','/xul/server/locale/' + locale + '/marcedit-tooltips.xml',true);
136 req.onreadystatechange = function () {
137 if (req.readyState == 4) {
138 bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
144 loadRecord(xml_record);
146 alert('FIXME, MARC Editor, my_init: ' + E);
151 function createComplexHTMLElement (e, attrs, objects, text) {
152 var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
155 for (var i in attrs) l.setAttribute(i,attrs[i]);
159 for ( var i in objects ) l.appendChild( objects[i] );
163 l.appendChild( document.createTextNode(text) )
169 function createComplexXULElement (e, attrs, objects) {
170 var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
173 for (var i in attrs) {
174 if (typeof attrs[i] == 'function') {
175 l.addEventListener( i, attrs[i], true );
177 l.setAttribute(i,attrs[i]);
183 for ( var i in objects ) l.appendChild( objects[i] );
189 function createDescription (attrs) {
190 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
193 function createTooltip (attrs) {
194 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
197 function createLabel (attrs) {
198 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
201 function createVbox (attrs) {
202 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
205 function createHbox (attrs) {
206 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
209 function createRow (attrs) {
210 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
213 function createTextbox (attrs) {
214 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
217 function createMenu (attrs) {
218 return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
221 function createMenuPopup (attrs) {
222 return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
225 function createPopup (attrs) {
226 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
229 function createMenuitem (attrs) {
230 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
233 function createCheckbox (attrs) {
234 return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
237 function createMARCTextbox (element,attrs) {
239 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
240 box.onkeypress = function (event) {
243 while(node = node.parent()) {
247 var row = event.target;
248 while (row.tagName != 'row') row = row.parentNode;
250 if (element.nodeKind() == 'attribute') element[0]=box.value;
251 else element.setChildren( box.value );
253 if (element.localName() != 'controlfield') {
254 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
256 var index_sf, target, move_data;
257 if (element.localName() == 'subfield') {
259 target = event.target.parentNode;
261 var start = event.target.selectionStart;
262 var end = event.target.selectionEnd - event.target.selectionStart ?
263 event.target.selectionEnd :
264 event.target.value.length;
266 move_data = event.target.value.substring(start,end);
267 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
268 event.target.setAttribute('size', event.target.value.length + 2);
270 element.setChildren( event.target.value );
272 } else if (element.localName() == 'code') {
273 index_sf = element.parent();
274 target = event.target.parentNode;
275 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
276 index_sf = element.parent().children()[element.parent().children().length() - 1];
277 target = event.target.parentNode.lastChild.lastChild;
280 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
282 index_sf.parent().insertChildAfter( index_sf, sf );
284 var new_sf = marcSubfield(sf);
286 if (target === target.parentNode.lastChild) {
287 target.parentNode.appendChild( new_sf );
289 target.parentNode.insertBefore( new_sf, target.nextSibling );
292 new_sf.firstChild.nextSibling.focus();
294 event.preventDefault();
297 } else if (event.keyCode == 13 || event.keyCode == 77) {
298 if (event.ctrlKey) { // ctrl+enter
301 if (element.localName() == 'subfield') index = element.parent();
302 if (element.localName() == 'code') index = element.parent().parent();
303 if (element.localName() == 'tag') index = element.parent();
304 if (element.localName() == 'ind1') index = element.parent();
305 if (element.localName() == 'ind2') index = element.parent();
307 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
309 if (event.shiftKey) { // ctrl+shift+enter
310 index.parent().insertChildBefore( index, df );
312 index.parent().insertChildAfter( index, df );
315 var new_df = marcDatafield(df);
317 if (row.parentNode.lastChild === row) {
318 row.parentNode.appendChild( new_df );
320 if (event.shiftKey) { // ctrl+shift+enter
321 row.parentNode.insertBefore( new_df, row );
323 row.parentNode.insertBefore( new_df, row.nextSibling );
327 new_df.firstChild.focus();
329 event.preventDefault();
332 } else if (event.shiftKey) {
333 if (row.previousSibling.className.match('marcDatafieldRow'))
334 row.previousSibling.firstChild.focus();
336 row.nextSibling.firstChild.focus();
339 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
342 if (element.localName() == 'subfield') index = element.parent();
343 if (element.localName() == 'code') index = element.parent().parent();
344 if (element.localName() == 'tag') index = element.parent();
345 if (element.localName() == 'ind1') index = element.parent();
346 if (element.localName() == 'ind2') index = element.parent();
348 for (var i in index.parent().children()) {
349 if (index === index.parent().children()[i]) {
350 delete index.parent().children()[i];
355 row.previousSibling.firstChild.focus();
356 row.parentNode.removeChild(row);
358 event.preventDefault();
361 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
364 if (element.localName() == 'subfield') index = element;
365 if (element.localName() == 'code') index = element.parent();
368 for (var i in index.parent().children()) {
369 if (index === index.parent().children()[i]) {
370 delete index.parent().children()[i];
375 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
376 event.target.parentNode.previousSibling.lastChild.focus();
378 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
381 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
383 event.preventDefault();
386 } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
387 createControlField('006','');
388 loadRecord(xml_record);
389 } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
390 createControlField('007','');
391 loadRecord(xml_record);
392 } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
393 createControlField('008','');
394 loadRecord(xml_record);
400 box.addEventListener(
403 if (element.nodeKind() == 'attribute') element[0]=box.value;
404 else element.setChildren( box.value );
410 box.addEventListener(
413 if (element.nodeKind() == 'attribute') element[0]=box.value;
414 else element.setChildren( box.value );
420 box.addEventListener(
423 if (element.nodeKind() == 'attribute') element[0]=box.value;
424 else element.setChildren( box.value );
430 box.addEventListener(
433 if (element.localName() == 'controlfield')
434 eval('fillFixedFields(xml_record);');
443 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
444 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
445 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
446 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
447 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
448 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
449 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
450 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
456 SCO : {start : 33, len : 1, def : ' ' },
457 REC : {start : 33, len : 1, def : 'n' },
460 SCO : {start : 16, len : 1, def : ' ' },
461 REC : {start : 16, len : 1, def : 'n' },
466 VIS : {start : 33, len : 1, def : ' ' },
469 VIS : {start : 16, len : 1, def : ' ' },
474 VIS : {start : 18, len : 3, def : ' ' },
477 VIS : {start : 1, len : 3, def : ' ' },
482 VIS : {start : 34, len : 1, def : 'n' },
485 VIS : {start : 17, len : 1, def : 'n' },
490 SER : {start : 21, len : 1, def : ' ' },
493 SER : {start : 4, len : 1, def : ' ' },
498 BKS : {start : 39, len : 1, def : 'd' },
499 SER : {start : 39, len : 1, def : 'd' },
500 VIS : {start : 39, len : 1, def : 'd' },
501 MIX : {start : 39, len : 1, def : 'd' },
502 MAP : {start : 39, len : 1, def : 'd' },
503 SCO : {start : 39, len : 1, def : 'd' },
504 REC : {start : 39, len : 1, def : 'd' },
505 COM : {start : 39, len : 1, def : 'd' },
510 MAP : {start : 33, len : 2, def : ' ' },
513 MAP : {start : 16, len : 2, def : ' ' },
518 MAP : {start : 18, len : 4, def : ' ' },
521 MAP : {start : 1, len : 4, def : ' ' },
526 SER : {start : 19, len : 1, def : ' ' },
529 SER : {start : 2, len : 1, def : ' ' },
534 MAP : {start : 22, len : 2, def : ' ' },
537 MAP : {start : 5, len : 2, def : ' ' },
542 SCO : {start : 21, len : 1, def : ' ' },
543 REC : {start : 21, len : 1, def : 'n' },
546 SCO : {start : 4, len : 1, def : ' ' },
547 REC : {start : 4, len : 1, def : 'n' },
552 SER : {start : 22, len : 1, def : ' ' },
555 SER : {start : 5, len : 1, def : ' ' },
560 SCO : {start : 30, len : 2, def : ' ' },
561 REC : {start : 30, len : 2, def : ' ' },
564 SCO : {start : 13, len : 2, def : ' ' },
565 REC : {start : 13, len : 2, def : ' ' },
570 SER : {start : 18, len : 1, def : ' ' },
573 SER : {start : 1, len : 1, def : ' ' },
578 SCO : {start : 20, len : 1, def : ' ' },
579 REC : {start : 20, len : 1, def : 'n' },
582 SCO : {start : 3, len : 1, def : ' ' },
583 REC : {start : 3, len : 1, def : 'n' },
588 COM : {start : 26, len : 1, def : 'u' },
591 COM : {start : 9, len : 1, def : 'u' },
596 SER : {start : 24, len : 1, def : ' ' },
599 SER : {start : 7, len : 1, def : ' ' },
604 SCO : {start : 24, len : 6, def : ' ' },
605 REC : {start : 24, len : 6, def : ' ' },
608 SCO : {start : 7, len : 6, def : ' ' },
609 REC : {start : 7, len : 6, def : ' ' },
614 SCO : {start : 18, len : 2, def : ' ' },
615 REC : {start : 18, len : 2, def : ' ' },
618 SCO : {start : 1, len : 2, def : ' ' },
619 REC : {start : 1, len : 2, def : ' ' },
624 MAP : {start : 25, len : 1, def : ' ' },
627 MAP : {start : 8, len : 1, def : ' ' },
632 BKS : {start : 15, len : 3, def : ' ' },
633 SER : {start : 15, len : 3, def : ' ' },
634 VIS : {start : 15, len : 3, def : ' ' },
635 MIX : {start : 15, len : 3, def : ' ' },
636 MAP : {start : 15, len : 3, def : ' ' },
637 SCO : {start : 15, len : 3, def : ' ' },
638 REC : {start : 15, len : 3, def : ' ' },
639 COM : {start : 15, len : 3, def : ' ' },
644 BKS : {start : 35, len : 3, def : ' ' },
645 SER : {start : 35, len : 3, def : ' ' },
646 VIS : {start : 35, len : 3, def : ' ' },
647 MIX : {start : 35, len : 3, def : ' ' },
648 MAP : {start : 35, len : 3, def : ' ' },
649 SCO : {start : 35, len : 3, def : ' ' },
650 REC : {start : 35, len : 3, def : ' ' },
651 COM : {start : 35, len : 3, def : ' ' },
656 BKS : {start : 38, len : 1, def : ' ' },
657 SER : {start : 38, len : 1, def : ' ' },
658 VIS : {start : 38, len : 1, def : ' ' },
659 MIX : {start : 38, len : 1, def : ' ' },
660 MAP : {start : 38, len : 1, def : ' ' },
661 SCO : {start : 38, len : 1, def : ' ' },
662 REC : {start : 38, len : 1, def : ' ' },
663 COM : {start : 38, len : 1, def : ' ' },
668 BKS : {start : 6, len : 1, def : ' ' },
669 SER : {start : 6, len : 1, def : 'c' },
670 VIS : {start : 6, len : 1, def : ' ' },
671 MIX : {start : 6, len : 1, def : ' ' },
672 MAP : {start : 6, len : 1, def : ' ' },
673 SCO : {start : 6, len : 1, def : ' ' },
674 REC : {start : 6, len : 1, def : ' ' },
675 COM : {start : 6, len : 1, def : ' ' },
680 BKS : {start : 6, len : 1, def : 'a' },
681 SER : {start : 6, len : 1, def : 'a' },
682 VIS : {start : 6, len : 1, def : 'g' },
683 MIX : {start : 6, len : 1, def : 'p' },
684 MAP : {start : 6, len : 1, def : 'e' },
685 SCO : {start : 6, len : 1, def : 'c' },
686 REC : {start : 6, len : 1, def : 'i' },
687 COM : {start : 6, len : 1, def : 'm' },
692 BKS : {start : 8, len : 1, def : ' ' },
693 SER : {start : 8, len : 1, def : ' ' },
694 VIS : {start : 8, len : 1, def : ' ' },
695 MIX : {start : 8, len : 1, def : ' ' },
696 MAP : {start : 8, len : 1, def : ' ' },
697 SCO : {start : 8, len : 1, def : ' ' },
698 REC : {start : 8, len : 1, def : ' ' },
699 COM : {start : 8, len : 1, def : ' ' },
704 BKS : {start : 7, len : 1, def : 'm' },
705 SER : {start : 7, len : 1, def : 's' },
706 VIS : {start : 7, len : 1, def : 'm' },
707 MIX : {start : 7, len : 1, def : 'c' },
708 MAP : {start : 7, len : 1, def : 'm' },
709 SCO : {start : 7, len : 1, def : 'm' },
710 REC : {start : 7, len : 1, def : 'm' },
711 COM : {start : 7, len : 1, def : 'm' },
716 BKS : {start : 18, len : 1, def : ' ' },
717 SER : {start : 18, len : 1, def : ' ' },
718 VIS : {start : 18, len : 1, def : ' ' },
719 MIX : {start : 18, len : 1, def : ' ' },
720 MAP : {start : 18, len : 1, def : ' ' },
721 SCO : {start : 18, len : 1, def : ' ' },
722 REC : {start : 18, len : 1, def : ' ' },
723 COM : {start : 18, len : 1, def : ' ' },
728 BKS : {start : 17, len : 1, def : ' ' },
729 SER : {start : 17, len : 1, def : ' ' },
730 VIS : {start : 17, len : 1, def : ' ' },
731 MIX : {start : 17, len : 1, def : ' ' },
732 MAP : {start : 17, len : 1, def : ' ' },
733 SCO : {start : 17, len : 1, def : ' ' },
734 REC : {start : 17, len : 1, def : ' ' },
735 COM : {start : 17, len : 1, def : ' ' },
740 BKS : {start : 31, len : 1, def : '0' },
741 MAP : {start : 31, len : 1, def : '0' },
744 BKS : {start : 14, len : 1, def : '0' },
745 MAP : {start : 14, len : 1, def : '0' },
750 BKS : {start : 7, len : 4, def : ' ' },
751 SER : {start : 7, len : 4, def : ' ' },
752 VIS : {start : 7, len : 4, def : ' ' },
753 MIX : {start : 7, len : 4, def : ' ' },
754 MAP : {start : 7, len : 4, def : ' ' },
755 SCO : {start : 7, len : 4, def : ' ' },
756 REC : {start : 7, len : 4, def : ' ' },
757 COM : {start : 7, len : 4, def : ' ' },
762 BKS : {start : 11, len : 4, def : ' ' },
763 SER : {start : 11, len : 4, def : '9' },
764 VIS : {start : 11, len : 4, def : ' ' },
765 MIX : {start : 11, len : 4, def : ' ' },
766 MAP : {start : 11, len : 4, def : ' ' },
767 SCO : {start : 11, len : 4, def : ' ' },
768 REC : {start : 11, len : 4, def : ' ' },
769 COM : {start : 11, len : 4, def : ' ' },
774 BKS : {start : 33, len : 1, def : '0' },
777 BKS : {start : 16, len : 1, def : '0' },
782 BKS : {start : 34, len : 1, def : ' ' },
785 BKS : {start : 17, len : 1, def : ' ' },
790 BKS : {start : 18, len : 4, def : ' ' },
793 BKS : {start : 1, len : 4, def : ' ' },
798 BKS : {start : 30, len : 1, def : '0' },
801 BKS : {start : 13, len : 1, def : '0' },
806 BKS : {start : 29, len : 1, def : '0' },
807 SER : {start : 29, len : 1, def : '0' },
810 BKS : {start : 12, len : 1, def : '0' },
811 SER : {start : 12, len : 1, def : '0' },
816 BKS : {start : 24, len : 4, def : ' ' },
817 SER : {start : 25, len : 3, def : ' ' },
820 BKS : {start : 7, len : 4, def : ' ' },
821 SER : {start : 8, len : 3, def : ' ' },
826 BKS : {start : 28, len : 1, def : ' ' },
827 SER : {start : 28, len : 1, def : ' ' },
828 VIS : {start : 28, len : 1, def : ' ' },
829 MAP : {start : 28, len : 1, def : ' ' },
830 COM : {start : 28, len : 1, def : ' ' },
833 BKS : {start : 11, len : 1, def : ' ' },
834 SER : {start : 11, len : 1, def : ' ' },
835 VIS : {start : 11, len : 1, def : ' ' },
836 MAP : {start : 11, len : 1, def : ' ' },
837 COM : {start : 11, len : 1, def : ' ' },
842 BKS : {start : 22, len : 1, def : ' ' },
843 SER : {start : 22, len : 1, def : ' ' },
844 VIS : {start : 22, len : 1, def : ' ' },
845 SCO : {start : 22, len : 1, def : ' ' },
846 REC : {start : 22, len : 1, def : ' ' },
847 COM : {start : 22, len : 1, def : ' ' },
850 BKS : {start : 5, len : 1, def : ' ' },
851 SER : {start : 5, len : 1, def : ' ' },
852 VIS : {start : 5, len : 1, def : ' ' },
853 SCO : {start : 5, len : 1, def : ' ' },
854 REC : {start : 5, len : 1, def : ' ' },
855 COM : {start : 5, len : 1, def : ' ' },
860 BKS : {start : 23, len : 1, def : ' ' },
861 SER : {start : 23, len : 1, def : ' ' },
862 VIS : {start : 29, len : 1, def : ' ' },
863 MIX : {start : 23, len : 1, def : ' ' },
864 MAP : {start : 29, len : 1, def : ' ' },
865 SCO : {start : 23, len : 1, def : ' ' },
866 REC : {start : 23, len : 1, def : ' ' },
869 BKS : {start : 6, len : 1, def : ' ' },
870 SER : {start : 6, len : 1, def : ' ' },
871 VIS : {start : 12, len : 1, def : ' ' },
872 MIX : {start : 6, len : 1, def : ' ' },
873 MAP : {start : 12, len : 1, def : ' ' },
874 SCO : {start : 6, len : 1, def : ' ' },
875 REC : {start : 6, len : 1, def : ' ' },
880 SER : {start : 34, len : 1, def : '0' },
883 SER : {start : 17, len : 1, def : '0' },
888 SER : {start : 33, len : 1, def : ' ' },
891 SER : {start : 16, len : 1, def : ' ' },
896 function recordType (rec) {
898 var _l = rec.leader.toString();
900 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
901 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
903 for (var t in rec_type) {
904 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
905 document.getElementById('recordTypeLabel').value = t;
911 alert('FIXME, MARC Editor, recordType: ' + E);
915 function toggleFFE () {
916 var grid = document.getElementById('leaderGrid');
925 function changeFFEditor (type) {
926 var grid = document.getElementById('leaderGrid');
927 grid.setAttribute('type',type);
930 function fillFixedFields (rec) {
932 var grid = document.getElementById('leaderGrid');
934 var rtype = _record_type;
936 var _l = rec.leader.toString();
937 var _6 = rec.controlfield.(@tag=='006').toString();
938 var _7 = rec.controlfield.(@tag=='007').toString();
939 var _8 = rec.controlfield.(@tag=='008').toString();
942 var pre_list = grid.getElementsByTagName('label');
943 for (var i in pre_list) {
944 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
945 list.push( pre_list[i] );
949 for (var i in list) {
950 var name = list[i].getAttribute('name');
956 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
957 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
959 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
960 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
962 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
963 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
965 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
966 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
971 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
972 d = ff_pos[name].ldr[rtype].def;
976 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
977 d = ff_pos[name]._8[rtype].def;
981 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
982 d = ff_pos[name]._6[rtype].def;
986 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
987 d = ff_pos[name]._7[rtype].def;
992 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
998 list[i].nextSibling.value = value;
1003 alert('FIXME, MARC Editor, fillFixedFields: ' + E);
1007 function updateFixedFields (element) {
1008 var grid = document.getElementById('leaderGrid');
1009 var recGrid = document.getElementById('recGrid');
1011 var rtype = _record_type;
1012 var new_value = element.value;
1015 ldr : _record.leader,
1016 _6 : _record.controlfield.(@tag=='006'),
1017 _7 : _record.controlfield.(@tag=='007'),
1018 _8 : _record.controlfield.(@tag=='008'),
1021 var name = element.getAttribute('name');
1022 for (var i in ff_pos[name]) {
1024 if (!ff_pos[name][i][rtype]) continue;
1025 if (!parts[i]) continue;
1027 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
1028 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
1030 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
1031 new_value += ff_pos[name][i][rtype].def;
1034 parts[i].setChildren( before + new_value + after );
1035 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
1041 function marcLeader (leader) {
1042 var row = createRow(
1043 { class : 'marcLeaderRow',
1048 tooltiptext : "MARC Leader" } ),
1051 class : 'marcInd1' } ),
1054 class : 'marcInd2' } ),
1056 { value : leader.text(),
1057 class : 'marcLeader' } )
1063 function marcControlfield (field) {
1064 tagname = field.@tag.toString().substr(2);
1066 if (tagname == '6' || tagname == '7' || tagname == '8') {
1068 { class : 'marcControlfieldRow',
1069 tag : '_' + tagname },
1071 { value : field.@tag,
1073 context : 'tags_popup',
1074 onmouseover : 'getTooltip(this, "tag");',
1075 tooltipid : 'tag' + field.@tag } ),
1077 { value : field.@ind1,
1079 onmouseover : 'getTooltip(this, "ind1");',
1080 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1082 { value : field.@ind2,
1084 onmouseover : 'getTooltip(this, "ind2");',
1085 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1088 { value : field.text(),
1089 class : 'plain marcEditableControlfield',
1090 name : 'CONTROL' + tagname,
1091 oncontext : 'return false();',
1097 { class : 'marcControlfieldRow',
1098 tag : '_' + tagname },
1100 { value : field.@tag,
1102 onmouseover : 'getTooltip(this, "tag");',
1103 tooltipid : 'tag' + field.@tag } ),
1105 { value : field.@ind1,
1107 onmouseover : 'getTooltip(this, "ind1");',
1108 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1110 { value : field.@ind2,
1112 onmouseover : 'getTooltip(this, "ind2");',
1113 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1115 { value : field.text(),
1116 class : 'marcControlfield' } )
1123 function stackSubfields(checkbox) {
1124 var list = document.getElementsByAttribute('name','sf_box');
1127 if (checkbox.checked) o = 'horizontal';
1129 for (var i = 0; i < list.length; i++) {
1130 if (list[i]) list[i].setAttribute('orient',o);
1134 function marcDatafield (field) {
1135 var row = createRow(
1136 { class : 'marcDatafieldRow' },
1139 { value : field.@tag,
1140 class : 'plain marcTag',
1142 context : 'tags_popup',
1143 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
1146 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
1149 { value : field.@ind1,
1150 class : 'plain marcInd1',
1152 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1155 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
1156 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
1159 { value : field.@ind2,
1160 class : 'plain marcInd2',
1162 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
1165 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
1166 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
1167 createHbox({ name : 'sf_box' })
1170 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
1171 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
1172 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
1174 var sf_box = row.lastChild;
1175 if (document.getElementById('stackSubfields').checked)
1176 sf_box.setAttribute('orient','vertical');
1178 sf_box.addEventListener(
1181 if (sf_box === e.target) {
1182 sf_box.lastChild.lastChild.focus();
1183 } else if (e.target.parentNode === sf_box) {
1184 e.target.lastChild.focus();
1191 for (var i in field.subfield) {
1192 var sf = field.subfield[i];
1197 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
1198 current_focus = sf_box.lastChild.childNodes[1];
1204 function marcSubfield (sf) {
1206 { class : 'marcSubfieldBox' },
1209 class : 'plain marcSubfieldDelimiter',
1210 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
1211 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
1212 //onclick : 'this.nextSibling.focus();',
1213 onfocus : 'this.nextSibling.focus();',
1218 class : 'plain marcSubfieldCode',
1219 name : 'marcSubfieldCode',
1220 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
1221 oncontextmenu : 'getContextMenu(this, "subfield");',
1222 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1227 { value : sf.text(),
1228 name : sf.parent().@tag + ':' + sf.@code,
1229 class : 'plain marcSubfield',
1230 onmouseover : 'getTooltip(this, "subfield");',
1231 contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
1232 size : new String(sf.text()).length + 2,
1233 oninput : "this.setAttribute('size', this.value.length + 2);",
1238 function loadRecord(rec) {
1241 var grid_rows = document.getElementById('recGrid').lastChild;
1243 while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
1245 grid_rows.appendChild( marcLeader( rec.leader ) );
1247 for (var i in rec.controlfield) {
1248 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
1251 for (var i in rec.datafield) {
1252 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
1255 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
1256 changeFFEditor(recordType(rec));
1257 fillFixedFields(rec);
1259 alert('FIXME, MARC Editor, loadRecord: ' + E);
1263 var context_menus = createComplexXULElement('popupset');
1264 document.documentElement.appendChild( context_menus );
1266 var tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
1267 context_menus.appendChild( tag_menu );
1269 tag_menu.appendChild(
1271 { label : 'Add Row',
1273 'var e = document.createEvent("KeyEvents");' +
1274 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
1275 'current_focus.inputField.dispatchEvent(e);',
1280 tag_menu.appendChild(
1282 { label : 'Remove Row',
1284 'var e = document.createEvent("KeyEvents");' +
1285 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
1286 'current_focus.inputField.dispatchEvent(e);',
1291 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
1293 tag_menu.appendChild(
1295 { label : 'Add/Replace 006',
1297 'var e = document.createEvent("KeyEvents");' +
1298 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
1299 'current_focus.inputField.dispatchEvent(e);',
1304 tag_menu.appendChild(
1306 { label : 'Add/Replace 007',
1308 'var e = document.createEvent("KeyEvents");' +
1309 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
1310 'current_focus.inputField.dispatchEvent(e);',
1315 tag_menu.appendChild(
1317 { label : 'Add/Replace 008',
1319 'var e = document.createEvent("KeyEvents");' +
1320 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
1321 'current_focus.inputField.dispatchEvent(e);',
1326 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
1330 function genToolTips () {
1331 for (var i in bib_data.field) {
1332 var f = bib_data.field[i];
1334 tag_menu.appendChild(
1338 'current_focus.value = "' + f.@tag + '";' +
1339 'var e = document.createEvent("MutationEvents");' +
1340 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1341 'current_focus.inputField.dispatchEvent(e);',
1342 disabled : f.@tag < '010' ? "true" : "false",
1343 tooltiptext : f.description }
1347 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
1348 context_menus.appendChild( i1_popup );
1350 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
1351 context_menus.appendChild( i2_popup );
1353 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
1354 context_menus.appendChild( sf_popup );
1356 tooltip_hash['tag' + f.@tag] = f.description;
1357 for (var j in f.indicator) {
1358 var ind = f.indicator[j];
1359 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
1361 if (ind.@position == 1) {
1362 i1_popup.appendChild(
1364 { label : ind.@value,
1366 'current_focus.value = "' + ind.@value + '";' +
1367 'var e = document.createEvent("MutationEvents");' +
1368 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1369 'current_focus.inputField.dispatchEvent(e);',
1370 tooltiptext : ind.description }
1375 if (ind.@position == 2) {
1376 i2_popup.appendChild(
1378 { label : ind.@value,
1380 'current_focus.value = "' + ind.@value + '";' +
1381 'var e = document.createEvent("MutationEvents");' +
1382 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1383 'current_focus.inputField.dispatchEvent(e);',
1384 tooltiptext : ind.description }
1390 for (var j in f.subfield) {
1391 var sf = f.subfield[j];
1392 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
1394 sf_popup.appendChild(
1398 'current_focus.value = "' + sf.@code + '";' +
1399 'var e = document.createEvent("MutationEvents");' +
1400 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1401 'current_focus.inputField.dispatchEvent(e);',
1402 tooltiptext : sf.description,
1410 var p = createComplexXULElement('popupset');
1411 document.documentElement.appendChild( p );
1413 function getTooltip (target, type) {
1416 if (type == 'subfield')
1417 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
1420 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
1423 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
1426 tt = 'tag' + target.parentNode.firstChild.value;
1428 if (!document.getElementById( tt )) {
1433 orient : 'vertical',
1434 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
1435 class : 'tooltip' },
1436 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
1441 target.tooltip = tt;
1445 function getContextMenu (target, type) {
1448 if (type == 'subfield')
1449 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
1452 tt = 't' + target.parentNode.firstChild.value + 'i1';
1455 tt = 't' + target.parentNode.firstChild.value + 'i2';
1457 target.setAttribute('context', tt);
1461 var authority_tag_map = {
1462 100 : ['[100,400,500,700]',100],
1463 400 : ['[100,400,500,700]',100],
1464 700 : ['[100,400,500,700]',100],
1465 800 : ['[100,400,500,700]',100],
1466 110 : ['[110,410,510,710]',110],
1467 410 : ['[110,410,510,710]',110],
1468 710 : ['[110,410,510,710]',110],
1469 810 : ['[110,410,510,710]',110],
1470 111 : ['[111,411,511,711]',111],
1471 411 : ['[111,411,511,711]',111],
1472 711 : ['[111,411,511,711]',111],
1473 811 : ['[111,411,511,711]',111],
1474 240 : ['[130,430,530,730]',130],
1475 440 : ['[130,430,530,730]',130],
1476 130 : ['[130,430,530,730]',130],
1477 730 : ['[130,430,530,730]',130],
1478 830 : ['[130,430,530,730]',130],
1479 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
1480 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
1481 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
1482 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155],
1485 function getAuthorityContextMenu (target, sf) {
1486 var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
1488 var old = document.getElementById( menu_id );
1489 if (old) old.parentNode.removeChild(old);
1491 var sf_popup = createPopup({ id : menu_id, flex : 1 });
1492 context_menus.appendChild( sf_popup );
1494 if (!authority_tag_map[sf.parent().@tag]) {
1495 sf_popup.appendChild(createLabel( { value : "Not a controlled subfield" } ) );
1496 target.setAttribute('context', menu_id);
1500 var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
1502 var res = new XML( auth_data.responseText );
1506 var recs = res.gw::payload.gw::array.gw::string;
1507 for (var i in recs) {
1509 var xml = new XML(x.toString());
1510 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1512 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1515 for (var i in main) {
1516 if (main_text) main_text += ' / ';
1517 main_text += main[i];
1520 rec_list.push( [ main_text, xml ] );
1523 for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
1525 var main_text = rec_list[i][0];
1526 var xml = rec_list[i][1];
1527 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1529 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1531 var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
1532 grid.setAttribute('name','-none-');
1533 grid.setAttribute('style','overflow:scroll');
1536 var submenu = createMenu( { label : main_text } );
1538 var popup = createMenuPopup({ flex : "1" });
1539 submenu.appendChild(popup);
1541 var fields = xml.datafield;
1542 for (var j in fields) {
1544 var row = createRow(
1546 createLabel( { value : fields[j].@tag } ),
1547 createLabel( { value : fields[j].@ind1 } ),
1548 createLabel( { value : fields[j].@ind2 } )
1551 var sf_box = createHbox();
1553 var subfields = fields[j].subfield;
1554 for (var k in subfields) {
1557 { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
1558 subfield : subfields[k].@code,
1559 tag : subfields[k].parent().@tag,
1560 value : subfields[k]
1564 row.appendChild(sf_box);
1567 grid.lastChild.appendChild(row);
1570 grid.hidden = false;
1571 popup.appendChild( grid );
1575 { label : 'Apply Selected',
1576 command : function (event) {
1577 applyAuthority(event.target.previousSibling, target, sf);
1584 sf_popup.appendChild( submenu );
1587 if (sf_popup.childNodes.length == 0)
1588 sf_popup.appendChild(createLabel( { value : "No matching authority records found" } ) );
1590 target.setAttribute('context', menu_id);
1594 function applyAuthority ( target, ui_sf, e4x_sf ) {
1596 var new_vals = target.getElementsByAttribute('checked','true');
1597 var field = e4x_sf.parent();
1599 for (var i = 0; i < new_vals.length; i++) {
1601 var sf_list = field.subfield;
1602 for (var j in sf_list) {
1604 if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
1605 sf_list[j] = new_vals[i].getAttribute('value');
1606 new_vals[i].setAttribute('subfield','');
1612 for (var i = 0; i < new_vals.length; i++) {
1613 if (!new_vals[i].getAttribute('subfield')) continue;
1615 var val = new_vals[i].getAttribute('value');
1617 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
1618 sf.@code = new_vals[i].getAttribute('subfield');
1620 field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
1623 var row = marcDatafield( field );
1626 while (node.nodeName != 'row') {
1627 node = node.parentNode;
1630 node.parentNode.replaceChild( row, node );
1636 'a' : { 100 : 'a' },
1637 'd' : { 100 : 'd' },
1640 'a' : { 110 : 'a' },
1641 'd' : { 110 : 'd' },
1644 'a' : { 111 : 'a' },
1645 'd' : { 111 : 'd' },
1648 'a' : { 130 : 'a' },
1649 'd' : { 130 : 'd' },
1652 'a' : { 130 : 'a' },
1653 'd' : { 130 : 'd' },
1656 'a' : { 100 : 'a' },
1657 'd' : { 100 : 'd' },
1660 'a' : { 110 : 'a' },
1661 'd' : { 110 : 'd' },
1664 'a' : { 111 : 'a' },
1665 'd' : { 111 : 'd' },
1668 'a' : { 130 : 'a' },
1669 'n' : { 130 : 'n' },
1670 'p' : { 130 : 'p' },
1673 'a' : { 100 : 'a' },
1674 'd' : { 100 : 'd' },
1677 'a' : { 110 : 'a' },
1678 'd' : { 110 : 'd' },
1681 'a' : { 111 : 'a' },
1682 'd' : { 111 : 'd' },
1685 'a' : { 130 : 'a' },
1686 'd' : { 130 : 'd' },
1689 'a' : { 100 : 'a' },
1690 'd' : { 100 : 'd' },
1693 'a' : { 110 : 'a' },
1694 'd' : { 110 : 'd' },
1697 'a' : { 111 : 'a' },
1698 'd' : { 111 : 'd' },
1701 'a' : { 130 : 'a' },
1702 'd' : { 130 : 'd' },
1705 'a' : { 100 : 'a' },
1706 'd' : { 100 : 'd' },
1707 't' : { 100 : 't' },
1734 'a' : { 110 : 'a' },
1735 'd' : { 110 : 'd' },
1736 't' : { 110 : 't' },
1763 'a' : { 111 : 'a' },
1764 'd' : { 111 : 'd' },
1765 't' : { 111 : 't' },
1792 'a' : { 130 : 'a' },
1793 'd' : { 130 : 'd' },
1796 'a' : { 150 : 'a' },
1797 'b' : { 150 : 'b' },
1824 'a' : { 151 : 'a' },
1851 'a' : { 155 : 'a' },
1879 function validateAuthority (button) {
1880 var grid = document.getElementById('recGrid');
1881 var label = button.getAttribute('label');
1884 var rows = grid.lastChild.childNodes;
1885 for (var i = 0; i < rows.length; i++) {
1887 var tag = row.firstChild;
1889 if (!control_map[tag.value]) continue
1891 var ind1 = tag.nextSibling;
1892 var ind2 = ind1.nextSibling;
1893 var subfields = ind2.nextSibling.childNodes;
1895 for (var j = 0; j < subfields.length; j++) {
1896 var sf = subfields[j];
1898 if (!control_map[tag.value][sf.childNodes[1].value]) continue;
1900 button.setAttribute('label', label + ' - ' + tag.value + sf.childNodes[1].value);
1903 for (var k in control_map[tag.value][sf.childNodes[1].value]) {
1904 var x = searchAuthority(sf.childNodes[2].value, k, control_map[tag.value][sf.childNodes[1].value][k], 1);
1905 var res = new XML( x.responseText );
1907 if (res.gw::payload.gw::array.gw::string.length()) {
1914 sf.childNodes[2].inputField.style.color = 'red';
1916 sf.childNodes[2].inputField.style.color = 'black';
1921 button.setAttribute('label', label);
1927 function searchAuthority (term, tag, sf, limit) {
1928 var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
1929 url += '¶m="term"¶m="' + term + '"';
1930 url += '¶m="limit"¶m=' + limit;
1931 url += '¶m="tag"¶m=' + tag;
1932 url += '¶m="subfield"¶m="' + sf + '"';
1935 var req = new XMLHttpRequest();
1936 req.open('GET',url,false);