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 = {};
21 function $(id) { return document.getElementById(id); }
23 function mangle_005() {
25 var y = now.getUTCFullYear();
27 var m = now.getUTCMonth() + 1;
28 if (m < 10) m = '0' + m;
30 var d = now.getUTCDate();
31 if (d < 10) d = '0' + d;
33 var H = now.getUTCHours();
34 if (H < 10) H = '0' + H;
36 var M = now.getUTCMinutes();
37 if (M < 10) M = '0' + M;
39 var S = now.getUTCSeconds();
40 if (S < 10) S = '0' + S;
43 var stamp = '' + y + m + d + H + M + S + '.0';
44 createControlField('005',stamp);
48 function createControlField (tag,data) {
49 // first, remove the old field, if any;
50 for (var i in xml_record.controlfield.(@tag == tag)) delete xml_record.controlfield.(@tag == tag)[i];
52 var cf = <controlfield tag="" xmlns="http://www.loc.gov/MARC21/slim">{ data }</controlfield>;
55 // then, find the right position and insert it
57 var cfields = xml_record.controlfield;
58 var base = Number(tag.substring(2));
59 for (var i in cfields) {
60 var t = Number(cfields[i].@tag.toString().substring(2));
62 xml_record.insertChildBefore( cfields[i], cf );
68 if (!done) xml_record.insertChildBefore( xml_record.datafield[0], cf );
73 function xml_escape_unicode ( str ) {
76 function (r,s) { return "&#x" + s.charCodeAt(0).toString(16) + ";"; }
82 // Fake xulG for standalone...
87 window.xulG.record = {};
88 window.xulG.save = {};
90 window.xulG.save.label = $('catStrings').getString('staff.cat.marcedit.save.label');
91 window.xulG.save.func = function (r) { alert(r); }
94 var _rid = cgi.param('record');
96 window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
101 document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
102 document.getElementById('save-button').setAttribute('oncommand',
104 'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' +
105 'window.xulG.save.func( xml_string ); ' +
106 'loadRecord(xml_record);'
109 if (window.xulG.record.url) {
110 var req = new XMLHttpRequest();
111 req.open('POST',window.xulG.record.url,false);
113 window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
116 xml_record = new XML( window.xulG.record.marc );
117 if (xml_record..record[0]) xml_record = xml_record..record[0];
119 // Get the tooltip xml all async like
120 req = new XMLHttpRequest();
122 // Set a default locale in case preferences fail us
123 var locale = "en-US";
125 // Try to get the locale from our preferences
126 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
128 const Cc = Components.classes;
129 const Ci = Components.interfaces;
130 locale = Cc["@mozilla.org/preferences-service;1"].
131 getService(Ci.nsIPrefBranch).
132 getCharPref("general.useragent.locale");
136 // Get the locale-specific tooltips
137 // TODO: We should send a HEAD request to check for the existence of the desired file
138 // then fall back to the default locale if preferred locale is not necessary
139 req.open('GET','/xul/server/locale/' + locale + '/marcedit-tooltips.xml',true);
141 context_menus = createComplexXULElement('popupset');
142 document.documentElement.appendChild( context_menus );
144 tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
145 context_menus.appendChild( tag_menu );
147 tag_menu.appendChild(
149 { label : $('catStrings').getString('staff.cat.marcedit.add_row.label'),
151 'var e = document.createEvent("KeyEvents");' +
152 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
153 'current_focus.inputField.dispatchEvent(e);'
158 tag_menu.appendChild(
160 { label : $('catStrings').getString('staff.cat.marcedit.insert_row.label'),
162 'var e = document.createEvent("KeyEvents");' +
163 'e.initKeyEvent("keypress",1,1,null,1,0,1,0,13,0);' +
164 'current_focus.inputField.dispatchEvent(e);'
169 tag_menu.appendChild(
171 { label : $('catStrings').getString('staff.cat.marcedit.remove_row.label'),
173 'var e = document.createEvent("KeyEvents");' +
174 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
175 'current_focus.inputField.dispatchEvent(e);'
180 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
182 tag_menu.appendChild(
184 { label : $('catStrings').getString('staff.cat.marcedit.replace_006.label'),
186 'var e = document.createEvent("KeyEvents");' +
187 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
188 'current_focus.inputField.dispatchEvent(e);'
193 tag_menu.appendChild(
195 { label : $('catStrings').getString('staff.cat.marcedit.replace_007.label'),
197 'var e = document.createEvent("KeyEvents");' +
198 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
199 'current_focus.inputField.dispatchEvent(e);'
204 tag_menu.appendChild(
206 { label : $('catStrings').getString('staff.cat.marcedit.replace_008.label'),
208 'var e = document.createEvent("KeyEvents");' +
209 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
210 'current_focus.inputField.dispatchEvent(e);'
215 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
217 p = createComplexXULElement('popupset');
218 document.documentElement.appendChild( p );
220 req.onreadystatechange = function () {
221 if (req.readyState == 4) {
222 bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
228 loadRecord(xml_record);
232 alert('FIXME, MARC Editor, my_init: ' + E);
237 function createComplexHTMLElement (e, attrs, objects, text) {
238 var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
241 for (var i in attrs) l.setAttribute(i,attrs[i]);
245 for ( var i in objects ) l.appendChild( objects[i] );
249 l.appendChild( document.createTextNode(text) )
255 function createComplexXULElement (e, attrs, objects) {
256 var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
259 for (var i in attrs) {
260 if (typeof attrs[i] == 'function') {
261 l.addEventListener( i, attrs[i], true );
263 l.setAttribute(i,attrs[i]);
269 for ( var i in objects ) l.appendChild( objects[i] );
275 function createDescription (attrs) {
276 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
279 function createTooltip (attrs) {
280 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
283 function createLabel (attrs) {
284 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
287 function createVbox (attrs) {
288 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
291 function createHbox (attrs) {
292 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
295 function createRow (attrs) {
296 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
299 function createTextbox (attrs) {
300 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
303 function createMenu (attrs) {
304 return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
307 function createMenuPopup (attrs) {
308 return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
311 function createPopup (attrs) {
312 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
315 function createMenuitem (attrs) {
316 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
319 function createCheckbox (attrs) {
320 return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
323 function createMARCTextbox (element,attrs) {
325 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
326 box.onkeypress = function (event) {
329 while(node = node.parent()) {
333 var row = event.target;
334 while (row.tagName != 'row') row = row.parentNode;
336 if (element.nodeKind() == 'attribute') element[0]=box.value;
337 else element.setChildren( box.value );
339 if (element.localName() != 'controlfield') {
340 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
342 var index_sf, target, move_data;
343 if (element.localName() == 'subfield') {
345 target = event.target.parentNode;
347 var start = event.target.selectionStart;
348 var end = event.target.selectionEnd - event.target.selectionStart ?
349 event.target.selectionEnd :
350 event.target.value.length;
352 move_data = event.target.value.substring(start,end);
353 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
354 event.target.setAttribute('size', event.target.value.length + 2);
356 element.setChildren( event.target.value );
358 } else if (element.localName() == 'code') {
359 index_sf = element.parent();
360 target = event.target.parentNode;
361 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
362 index_sf = element.parent().children()[element.parent().children().length() - 1];
363 target = event.target.parentNode.lastChild.lastChild;
366 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
368 index_sf.parent().insertChildAfter( index_sf, sf );
370 var new_sf = marcSubfield(sf);
372 if (target === target.parentNode.lastChild) {
373 target.parentNode.appendChild( new_sf );
375 target.parentNode.insertBefore( new_sf, target.nextSibling );
378 new_sf.firstChild.nextSibling.focus();
380 event.preventDefault();
383 } else if (event.keyCode == 13 || event.keyCode == 77) {
384 if (event.ctrlKey) { // ctrl+enter
387 if (element.localName() == 'subfield') index = element.parent();
388 if (element.localName() == 'code') index = element.parent().parent();
389 if (element.localName() == 'tag') index = element.parent();
390 if (element.localName() == 'ind1') index = element.parent();
391 if (element.localName() == 'ind2') index = element.parent();
393 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
395 if (event.shiftKey) { // ctrl+shift+enter
396 index.parent().insertChildBefore( index, df );
398 index.parent().insertChildAfter( index, df );
401 var new_df = marcDatafield(df);
403 if (row.parentNode.lastChild === row) {
404 row.parentNode.appendChild( new_df );
406 if (event.shiftKey) { // ctrl+shift+enter
407 row.parentNode.insertBefore( new_df, row );
409 row.parentNode.insertBefore( new_df, row.nextSibling );
413 new_df.firstChild.focus();
415 event.preventDefault();
418 } else if (event.shiftKey) {
419 if (row.previousSibling.className.match('marcDatafieldRow'))
420 row.previousSibling.firstChild.focus();
422 row.nextSibling.firstChild.focus();
425 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
428 if (element.localName() == 'subfield') index = element.parent();
429 if (element.localName() == 'code') index = element.parent().parent();
430 if (element.localName() == 'tag') index = element.parent();
431 if (element.localName() == 'ind1') index = element.parent();
432 if (element.localName() == 'ind2') index = element.parent();
434 for (var i in index.parent().children()) {
435 if (index === index.parent().children()[i]) {
436 delete index.parent().children()[i];
441 row.previousSibling.firstChild.focus();
442 row.parentNode.removeChild(row);
444 event.preventDefault();
447 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
450 if (element.localName() == 'subfield') index = element;
451 if (element.localName() == 'code') index = element.parent();
454 for (var i in index.parent().children()) {
455 if (index === index.parent().children()[i]) {
456 delete index.parent().children()[i];
461 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
462 event.target.parentNode.previousSibling.lastChild.focus();
464 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
467 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
469 event.preventDefault();
472 } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
473 createControlField('006','');
474 loadRecord(xml_record);
475 } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
476 createControlField('007','');
477 loadRecord(xml_record);
478 } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
479 createControlField('008','');
480 loadRecord(xml_record);
486 box.addEventListener(
489 if (element.nodeKind() == 'attribute') element[0]=box.value;
490 else element.setChildren( box.value );
496 box.addEventListener(
499 if (element.nodeKind() == 'attribute') element[0]=box.value;
500 else element.setChildren( box.value );
506 box.addEventListener(
509 if (element.nodeKind() == 'attribute') element[0]=box.value;
510 else element.setChildren( box.value );
516 box.addEventListener(
519 if (element.localName() == 'controlfield')
520 eval('fillFixedFields(xml_record);');
529 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
530 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
531 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
532 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
533 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
534 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
535 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
536 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
542 SCO : {start : 33, len : 1, def : ' ' },
543 REC : {start : 33, len : 1, def : 'n' }
546 SCO : {start : 16, len : 1, def : ' ' },
547 REC : {start : 16, len : 1, def : 'n' }
552 VIS : {start : 33, len : 1, def : ' ' }
555 VIS : {start : 16, len : 1, def : ' ' }
560 VIS : {start : 18, len : 3, def : ' ' }
563 VIS : {start : 1, len : 3, def : ' ' }
568 VIS : {start : 34, len : 1, def : 'n' }
571 VIS : {start : 17, len : 1, def : 'n' }
576 SER : {start : 21, len : 1, def : ' ' }
579 SER : {start : 4, len : 1, def : ' ' }
584 BKS : {start : 39, len : 1, def : 'd' },
585 SER : {start : 39, len : 1, def : 'd' },
586 VIS : {start : 39, len : 1, def : 'd' },
587 MIX : {start : 39, len : 1, def : 'd' },
588 MAP : {start : 39, len : 1, def : 'd' },
589 SCO : {start : 39, len : 1, def : 'd' },
590 REC : {start : 39, len : 1, def : 'd' },
591 COM : {start : 39, len : 1, def : 'd' }
596 MAP : {start : 33, len : 2, def : ' ' }
599 MAP : {start : 16, len : 2, def : ' ' }
604 MAP : {start : 18, len : 4, def : ' ' }
607 MAP : {start : 1, len : 4, def : ' ' }
612 SER : {start : 19, len : 1, def : ' ' }
615 SER : {start : 2, len : 1, def : ' ' }
620 MAP : {start : 22, len : 2, def : ' ' }
623 MAP : {start : 5, len : 2, def : ' ' }
628 SCO : {start : 21, len : 1, def : ' ' },
629 REC : {start : 21, len : 1, def : 'n' }
632 SCO : {start : 4, len : 1, def : ' ' },
633 REC : {start : 4, len : 1, def : 'n' }
638 SER : {start : 22, len : 1, def : ' ' }
641 SER : {start : 5, len : 1, def : ' ' }
646 SCO : {start : 30, len : 2, def : ' ' },
647 REC : {start : 30, len : 2, def : ' ' }
650 SCO : {start : 13, len : 2, def : ' ' },
651 REC : {start : 13, len : 2, def : ' ' }
656 SER : {start : 18, len : 1, def : ' ' }
659 SER : {start : 1, len : 1, def : ' ' }
664 SCO : {start : 20, len : 1, def : ' ' },
665 REC : {start : 20, len : 1, def : 'n' }
668 SCO : {start : 3, len : 1, def : ' ' },
669 REC : {start : 3, len : 1, def : 'n' }
674 COM : {start : 26, len : 1, def : 'u' }
677 COM : {start : 9, len : 1, def : 'u' }
682 SER : {start : 24, len : 1, def : ' ' }
685 SER : {start : 7, len : 1, def : ' ' }
690 SCO : {start : 24, len : 6, def : ' ' },
691 REC : {start : 24, len : 6, def : ' ' }
694 SCO : {start : 7, len : 6, def : ' ' },
695 REC : {start : 7, len : 6, def : ' ' }
700 SCO : {start : 18, len : 2, def : ' ' },
701 REC : {start : 18, len : 2, def : ' ' }
704 SCO : {start : 1, len : 2, def : ' ' },
705 REC : {start : 1, len : 2, def : ' ' }
710 MAP : {start : 25, len : 1, def : ' ' }
713 MAP : {start : 8, len : 1, def : ' ' }
718 BKS : {start : 15, len : 3, def : ' ' },
719 SER : {start : 15, len : 3, def : ' ' },
720 VIS : {start : 15, len : 3, def : ' ' },
721 MIX : {start : 15, len : 3, def : ' ' },
722 MAP : {start : 15, len : 3, def : ' ' },
723 SCO : {start : 15, len : 3, def : ' ' },
724 REC : {start : 15, len : 3, def : ' ' },
725 COM : {start : 15, len : 3, def : ' ' }
730 BKS : {start : 35, len : 3, def : ' ' },
731 SER : {start : 35, len : 3, def : ' ' },
732 VIS : {start : 35, len : 3, def : ' ' },
733 MIX : {start : 35, len : 3, def : ' ' },
734 MAP : {start : 35, len : 3, def : ' ' },
735 SCO : {start : 35, len : 3, def : ' ' },
736 REC : {start : 35, len : 3, def : ' ' },
737 COM : {start : 35, len : 3, def : ' ' }
742 BKS : {start : 38, len : 1, def : ' ' },
743 SER : {start : 38, len : 1, def : ' ' },
744 VIS : {start : 38, len : 1, def : ' ' },
745 MIX : {start : 38, len : 1, def : ' ' },
746 MAP : {start : 38, len : 1, def : ' ' },
747 SCO : {start : 38, len : 1, def : ' ' },
748 REC : {start : 38, len : 1, def : ' ' },
749 COM : {start : 38, len : 1, def : ' ' }
754 BKS : {start : 6, len : 1, def : ' ' },
755 SER : {start : 6, len : 1, def : 'c' },
756 VIS : {start : 6, len : 1, def : ' ' },
757 MIX : {start : 6, len : 1, def : ' ' },
758 MAP : {start : 6, len : 1, def : ' ' },
759 SCO : {start : 6, len : 1, def : ' ' },
760 REC : {start : 6, len : 1, def : ' ' },
761 COM : {start : 6, len : 1, def : ' ' }
766 BKS : {start : 6, len : 1, def : 'a' },
767 SER : {start : 6, len : 1, def : 'a' },
768 VIS : {start : 6, len : 1, def : 'g' },
769 MIX : {start : 6, len : 1, def : 'p' },
770 MAP : {start : 6, len : 1, def : 'e' },
771 SCO : {start : 6, len : 1, def : 'c' },
772 REC : {start : 6, len : 1, def : 'i' },
773 COM : {start : 6, len : 1, def : 'm' }
778 BKS : {start : 8, len : 1, def : ' ' },
779 SER : {start : 8, len : 1, def : ' ' },
780 VIS : {start : 8, len : 1, def : ' ' },
781 MIX : {start : 8, len : 1, def : ' ' },
782 MAP : {start : 8, len : 1, def : ' ' },
783 SCO : {start : 8, len : 1, def : ' ' },
784 REC : {start : 8, len : 1, def : ' ' },
785 COM : {start : 8, len : 1, def : ' ' }
790 BKS : {start : 7, len : 1, def : 'm' },
791 SER : {start : 7, len : 1, def : 's' },
792 VIS : {start : 7, len : 1, def : 'm' },
793 MIX : {start : 7, len : 1, def : 'c' },
794 MAP : {start : 7, len : 1, def : 'm' },
795 SCO : {start : 7, len : 1, def : 'm' },
796 REC : {start : 7, len : 1, def : 'm' },
797 COM : {start : 7, len : 1, def : 'm' }
802 BKS : {start : 18, len : 1, def : ' ' },
803 SER : {start : 18, len : 1, def : ' ' },
804 VIS : {start : 18, len : 1, def : ' ' },
805 MIX : {start : 18, len : 1, def : ' ' },
806 MAP : {start : 18, len : 1, def : ' ' },
807 SCO : {start : 18, len : 1, def : ' ' },
808 REC : {start : 18, len : 1, def : ' ' },
809 COM : {start : 18, len : 1, def : ' ' }
814 BKS : {start : 17, len : 1, def : ' ' },
815 SER : {start : 17, len : 1, def : ' ' },
816 VIS : {start : 17, len : 1, def : ' ' },
817 MIX : {start : 17, len : 1, def : ' ' },
818 MAP : {start : 17, len : 1, def : ' ' },
819 SCO : {start : 17, len : 1, def : ' ' },
820 REC : {start : 17, len : 1, def : ' ' },
821 COM : {start : 17, len : 1, def : ' ' }
826 BKS : {start : 31, len : 1, def : '0' },
827 MAP : {start : 31, len : 1, def : '0' }
830 BKS : {start : 14, len : 1, def : '0' },
831 MAP : {start : 14, len : 1, def : '0' }
836 BKS : {start : 7, len : 4, def : ' ' },
837 SER : {start : 7, len : 4, def : ' ' },
838 VIS : {start : 7, len : 4, def : ' ' },
839 MIX : {start : 7, len : 4, def : ' ' },
840 MAP : {start : 7, len : 4, def : ' ' },
841 SCO : {start : 7, len : 4, def : ' ' },
842 REC : {start : 7, len : 4, def : ' ' },
843 COM : {start : 7, len : 4, def : ' ' }
848 BKS : {start : 11, len : 4, def : ' ' },
849 SER : {start : 11, len : 4, def : '9' },
850 VIS : {start : 11, len : 4, def : ' ' },
851 MIX : {start : 11, len : 4, def : ' ' },
852 MAP : {start : 11, len : 4, def : ' ' },
853 SCO : {start : 11, len : 4, def : ' ' },
854 REC : {start : 11, len : 4, def : ' ' },
855 COM : {start : 11, len : 4, def : ' ' }
860 BKS : {start : 33, len : 1, def : '0' }
863 BKS : {start : 16, len : 1, def : '0' }
868 BKS : {start : 34, len : 1, def : ' ' }
871 BKS : {start : 17, len : 1, def : ' ' }
876 BKS : {start : 18, len : 4, def : ' ' }
879 BKS : {start : 1, len : 4, def : ' ' }
884 BKS : {start : 30, len : 1, def : '0' }
887 BKS : {start : 13, len : 1, def : '0' }
892 BKS : {start : 29, len : 1, def : '0' },
893 SER : {start : 29, len : 1, def : '0' }
896 BKS : {start : 12, len : 1, def : '0' },
897 SER : {start : 12, len : 1, def : '0' }
902 BKS : {start : 24, len : 4, def : ' ' },
903 SER : {start : 25, len : 3, def : ' ' }
906 BKS : {start : 7, len : 4, def : ' ' },
907 SER : {start : 8, len : 3, def : ' ' }
912 BKS : {start : 28, len : 1, def : ' ' },
913 SER : {start : 28, len : 1, def : ' ' },
914 VIS : {start : 28, len : 1, def : ' ' },
915 MAP : {start : 28, len : 1, def : ' ' },
916 COM : {start : 28, len : 1, def : ' ' }
919 BKS : {start : 11, len : 1, def : ' ' },
920 SER : {start : 11, len : 1, def : ' ' },
921 VIS : {start : 11, len : 1, def : ' ' },
922 MAP : {start : 11, len : 1, def : ' ' },
923 COM : {start : 11, len : 1, def : ' ' }
928 BKS : {start : 22, len : 1, def : ' ' },
929 SER : {start : 22, len : 1, def : ' ' },
930 VIS : {start : 22, len : 1, def : ' ' },
931 SCO : {start : 22, len : 1, def : ' ' },
932 REC : {start : 22, len : 1, def : ' ' },
933 COM : {start : 22, len : 1, def : ' ' }
936 BKS : {start : 5, len : 1, def : ' ' },
937 SER : {start : 5, len : 1, def : ' ' },
938 VIS : {start : 5, len : 1, def : ' ' },
939 SCO : {start : 5, len : 1, def : ' ' },
940 REC : {start : 5, len : 1, def : ' ' },
941 COM : {start : 5, len : 1, def : ' ' }
946 BKS : {start : 23, len : 1, def : ' ' },
947 SER : {start : 23, len : 1, def : ' ' },
948 VIS : {start : 29, len : 1, def : ' ' },
949 MIX : {start : 23, len : 1, def : ' ' },
950 MAP : {start : 29, len : 1, def : ' ' },
951 SCO : {start : 23, len : 1, def : ' ' },
952 REC : {start : 23, len : 1, def : ' ' }
955 BKS : {start : 6, len : 1, def : ' ' },
956 SER : {start : 6, len : 1, def : ' ' },
957 VIS : {start : 12, len : 1, def : ' ' },
958 MIX : {start : 6, len : 1, def : ' ' },
959 MAP : {start : 12, len : 1, def : ' ' },
960 SCO : {start : 6, len : 1, def : ' ' },
961 REC : {start : 6, len : 1, def : ' ' }
966 SER : {start : 34, len : 1, def : '0' }
969 SER : {start : 17, len : 1, def : '0' }
974 SER : {start : 33, len : 1, def : ' ' }
977 SER : {start : 16, len : 1, def : ' ' }
982 function recordType (rec) {
984 var _l = rec.leader.toString();
986 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
987 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
989 for (var t in rec_type) {
990 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
991 document.getElementById('recordTypeLabel').value = t;
997 alert('FIXME, MARC Editor, recordType: ' + E);
1001 function toggleFFE () {
1002 var grid = document.getElementById('leaderGrid');
1004 grid.hidden = false;
1011 function changeFFEditor (type) {
1012 var grid = document.getElementById('leaderGrid');
1013 grid.setAttribute('type',type);
1016 function fillFixedFields (rec) {
1018 var grid = document.getElementById('leaderGrid');
1020 var rtype = _record_type;
1022 var _l = rec.leader.toString();
1023 var _6 = rec.controlfield.(@tag=='006').toString();
1024 var _7 = rec.controlfield.(@tag=='007').toString();
1025 var _8 = rec.controlfield.(@tag=='008').toString();
1028 var pre_list = grid.getElementsByTagName('label');
1029 for (var i in pre_list) {
1030 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
1031 list.push( pre_list[i] );
1035 for (var i in list) {
1036 var name = list[i].getAttribute('name');
1042 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
1043 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
1045 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
1046 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
1048 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
1049 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
1051 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
1052 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
1057 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
1058 d = ff_pos[name].ldr[rtype].def;
1062 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
1063 d = ff_pos[name]._8[rtype].def;
1067 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
1068 d = ff_pos[name]._6[rtype].def;
1072 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
1073 d = ff_pos[name]._7[rtype].def;
1078 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
1084 list[i].nextSibling.value = value;
1089 alert('FIXME, MARC Editor, fillFixedFields: ' + E);
1093 function updateFixedFields (element) {
1094 var grid = document.getElementById('leaderGrid');
1095 var recGrid = document.getElementById('recGrid');
1097 var rtype = _record_type;
1098 var new_value = element.value;
1101 ldr : _record.leader,
1102 _6 : _record.controlfield.(@tag=='006'),
1103 _7 : _record.controlfield.(@tag=='007'),
1104 _8 : _record.controlfield.(@tag=='008')
1107 var name = element.getAttribute('name');
1108 for (var i in ff_pos[name]) {
1110 if (!ff_pos[name][i][rtype]) continue;
1111 if (!parts[i]) continue;
1113 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
1114 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
1116 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
1117 new_value += ff_pos[name][i][rtype].def;
1120 parts[i].setChildren( before + new_value + after );
1121 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
1127 function marcLeader (leader) {
1128 var row = createRow(
1129 { class : 'marcLeaderRow',
1134 tooltiptext : $('catStrings').getString('staff.cat.marcedit.marcTag.LDR.label') } ),
1137 class : 'marcInd1' } ),
1140 class : 'marcInd2' } ),
1142 { value : leader.text(),
1143 class : 'marcLeader' } )
1149 function marcControlfield (field) {
1150 tagname = field.@tag.toString().substr(2);
1152 if (tagname == '6' || tagname == '7' || tagname == '8') {
1154 { class : 'marcControlfieldRow',
1155 tag : '_' + tagname },
1157 { value : field.@tag,
1159 context : 'tags_popup',
1160 onmouseover : 'getTooltip(this, "tag");',
1161 tooltipid : 'tag' + field.@tag } ),
1163 { value : field.@ind1,
1165 onmouseover : 'getTooltip(this, "ind1");',
1166 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1168 { value : field.@ind2,
1170 onmouseover : 'getTooltip(this, "ind2");',
1171 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1174 { value : field.text(),
1175 class : 'plain marcEditableControlfield',
1176 name : 'CONTROL' + tagname,
1177 oncontext : 'return false();',
1183 { class : 'marcControlfieldRow',
1184 tag : '_' + tagname },
1186 { value : field.@tag,
1188 onmouseover : 'getTooltip(this, "tag");',
1189 tooltipid : 'tag' + field.@tag } ),
1191 { value : field.@ind1,
1193 onmouseover : 'getTooltip(this, "ind1");',
1194 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1196 { value : field.@ind2,
1198 onmouseover : 'getTooltip(this, "ind2");',
1199 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1201 { value : field.text(),
1202 class : 'marcControlfield' } )
1209 function stackSubfields(checkbox) {
1210 var list = document.getElementsByAttribute('name','sf_box');
1213 if (checkbox.checked) o = 'horizontal';
1215 for (var i = 0; i < list.length; i++) {
1216 if (list[i]) list[i].setAttribute('orient',o);
1220 function marcDatafield (field) {
1221 var row = createRow(
1222 { class : 'marcDatafieldRow' },
1225 { value : field.@tag,
1226 class : 'plain marcTag',
1228 context : 'tags_popup',
1229 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
1232 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
1235 { value : field.@ind1,
1236 class : 'plain marcInd1',
1238 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1241 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
1242 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
1245 { value : field.@ind2,
1246 class : 'plain marcInd2',
1248 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
1251 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
1252 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
1253 createHbox({ name : 'sf_box' })
1256 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
1257 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
1258 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
1260 var sf_box = row.lastChild;
1261 if (document.getElementById('stackSubfields').checked)
1262 sf_box.setAttribute('orient','vertical');
1264 sf_box.addEventListener(
1267 if (sf_box === e.target) {
1268 sf_box.lastChild.lastChild.focus();
1269 } else if (e.target.parentNode === sf_box) {
1270 e.target.lastChild.focus();
1277 for (var i in field.subfield) {
1278 var sf = field.subfield[i];
1283 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
1284 current_focus = sf_box.lastChild.childNodes[1];
1290 function marcSubfield (sf) {
1292 { class : 'marcSubfieldBox' },
1295 class : 'plain marcSubfieldDelimiter',
1296 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
1297 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
1298 //onclick : 'this.nextSibling.focus();',
1299 onfocus : 'this.nextSibling.focus();',
1304 class : 'plain marcSubfieldCode',
1305 name : 'marcSubfieldCode',
1306 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
1307 oncontextmenu : 'getContextMenu(this, "subfield");',
1308 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1313 { value : sf.text(),
1314 name : sf.parent().@tag + ':' + sf.@code,
1315 class : 'plain marcSubfield',
1316 onmouseover : 'getTooltip(this, "subfield");',
1317 contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
1318 size : new String(sf.text()).length + 2,
1319 oninput : "this.setAttribute('size', this.value.length + 2);"
1324 function loadRecord(rec) {
1327 var grid_rows = document.getElementById('recGrid').lastChild;
1329 while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
1331 grid_rows.appendChild( marcLeader( rec.leader ) );
1333 for (var i in rec.controlfield) {
1334 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
1337 for (var i in rec.datafield) {
1338 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
1341 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
1342 changeFFEditor(recordType(rec));
1343 fillFixedFields(rec);
1345 alert('FIXME, MARC Editor, loadRecord: ' + E);
1350 function genToolTips () {
1351 for (var i in bib_data.field) {
1352 var f = bib_data.field[i];
1354 tag_menu.appendChild(
1358 'current_focus.value = "' + f.@tag + '";' +
1359 'var e = document.createEvent("MutationEvents");' +
1360 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1361 'current_focus.inputField.dispatchEvent(e);',
1362 disabled : f.@tag < '010' ? "true" : "false",
1363 tooltiptext : f.description }
1367 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
1368 context_menus.appendChild( i1_popup );
1370 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
1371 context_menus.appendChild( i2_popup );
1373 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
1374 context_menus.appendChild( sf_popup );
1376 tooltip_hash['tag' + f.@tag] = f.description;
1377 for (var j in f.indicator) {
1378 var ind = f.indicator[j];
1379 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
1381 if (ind.@position == 1) {
1382 i1_popup.appendChild(
1384 { label : ind.@value,
1386 'current_focus.value = "' + ind.@value + '";' +
1387 'var e = document.createEvent("MutationEvents");' +
1388 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1389 'current_focus.inputField.dispatchEvent(e);',
1390 tooltiptext : ind.description }
1395 if (ind.@position == 2) {
1396 i2_popup.appendChild(
1398 { label : ind.@value,
1400 'current_focus.value = "' + ind.@value + '";' +
1401 'var e = document.createEvent("MutationEvents");' +
1402 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1403 'current_focus.inputField.dispatchEvent(e);',
1404 tooltiptext : ind.description }
1410 for (var j in f.subfield) {
1411 var sf = f.subfield[j];
1412 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
1414 sf_popup.appendChild(
1418 'current_focus.value = "' + sf.@code + '";' +
1419 'var e = document.createEvent("MutationEvents");' +
1420 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1421 'current_focus.inputField.dispatchEvent(e);',
1422 tooltiptext : sf.description
1430 function getTooltip (target, type) {
1433 if (type == 'subfield')
1434 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
1437 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
1440 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
1443 tt = 'tag' + target.parentNode.firstChild.value;
1445 if (!document.getElementById( tt )) {
1450 orient : 'vertical',
1451 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
1452 class : 'tooltip' },
1453 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
1458 target.tooltip = tt;
1462 function getContextMenu (target, type) {
1465 if (type == 'subfield')
1466 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
1469 tt = 't' + target.parentNode.firstChild.value + 'i1';
1472 tt = 't' + target.parentNode.firstChild.value + 'i2';
1474 target.setAttribute('context', tt);
1478 var authority_tag_map = {
1479 100 : ['[100,400,500,700]',100],
1480 400 : ['[100,400,500,700]',100],
1481 700 : ['[100,400,500,700]',100],
1482 800 : ['[100,400,500,700]',100],
1483 110 : ['[110,410,510,710]',110],
1484 410 : ['[110,410,510,710]',110],
1485 710 : ['[110,410,510,710]',110],
1486 810 : ['[110,410,510,710]',110],
1487 111 : ['[111,411,511,711]',111],
1488 411 : ['[111,411,511,711]',111],
1489 711 : ['[111,411,511,711]',111],
1490 811 : ['[111,411,511,711]',111],
1491 240 : ['[130,430,530,730]',130],
1492 440 : ['[130,430,530,730]',130],
1493 130 : ['[130,430,530,730]',130],
1494 730 : ['[130,430,530,730]',130],
1495 830 : ['[130,430,530,730]',130],
1496 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
1497 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
1498 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
1499 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155]
1502 function getAuthorityContextMenu (target, sf) {
1503 var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
1505 var old = document.getElementById( menu_id );
1506 if (old) old.parentNode.removeChild(old);
1508 var sf_popup = createPopup({ id : menu_id, flex : 1 });
1509 context_menus.appendChild( sf_popup );
1511 if (!authority_tag_map[sf.parent().@tag]) {
1512 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
1513 target.setAttribute('context', menu_id);
1517 var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
1519 var res = new XML( auth_data.responseText );
1523 var recs = res.gw::payload.gw::array.gw::string;
1524 for (var i in recs) {
1526 var xml = new XML(x.toString());
1527 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1529 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1532 for (var i in main) {
1533 if (main_text) main_text += ' / ';
1534 main_text += main[i];
1537 rec_list.push( [ main_text, xml ] );
1540 for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
1542 var main_text = rec_list[i][0];
1543 var xml = rec_list[i][1];
1544 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1546 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1548 var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
1549 grid.setAttribute('name','-none-');
1550 grid.setAttribute('style','overflow:scroll');
1553 var submenu = createMenu( { label : main_text } );
1555 var popup = createMenuPopup({ flex : "1" });
1556 submenu.appendChild(popup);
1558 var fields = xml.datafield;
1559 for (var j in fields) {
1561 var row = createRow(
1563 createLabel( { value : fields[j].@tag } ),
1564 createLabel( { value : fields[j].@ind1 } ),
1565 createLabel( { value : fields[j].@ind2 } )
1568 var sf_box = createHbox();
1570 var subfields = fields[j].subfield;
1571 for (var k in subfields) {
1574 { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
1575 subfield : subfields[k].@code,
1576 tag : subfields[k].parent().@tag,
1577 value : subfields[k]
1581 row.appendChild(sf_box);
1584 grid.lastChild.appendChild(row);
1587 grid.hidden = false;
1588 popup.appendChild( grid );
1592 { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'),
1593 command : function (event) {
1594 applyAuthority(event.target.previousSibling, target, sf);
1601 sf_popup.appendChild( submenu );
1604 if (sf_popup.childNodes.length == 0)
1605 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.no_authority_match.label') } ) );
1607 target.setAttribute('context', menu_id);
1611 function applyAuthority ( target, ui_sf, e4x_sf ) {
1613 var new_vals = target.getElementsByAttribute('checked','true');
1614 var field = e4x_sf.parent();
1616 for (var i = 0; i < new_vals.length; i++) {
1618 var sf_list = field.subfield;
1619 for (var j in sf_list) {
1621 if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
1622 sf_list[j] = new_vals[i].getAttribute('value');
1623 new_vals[i].setAttribute('subfield','');
1629 for (var i = 0; i < new_vals.length; i++) {
1630 if (!new_vals[i].getAttribute('subfield')) continue;
1632 var val = new_vals[i].getAttribute('value');
1634 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
1635 sf.@code = new_vals[i].getAttribute('subfield');
1637 field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
1640 var row = marcDatafield( field );
1643 while (node.nodeName != 'row') {
1644 node = node.parentNode;
1647 node.parentNode.replaceChild( row, node );
1653 'a' : { 100 : 'a' },
1657 'a' : { 110 : 'a' },
1661 'a' : { 111 : 'a' },
1665 'a' : { 130 : 'a' },
1669 'a' : { 130 : 'a' },
1673 'a' : { 100 : 'a' },
1677 'a' : { 110 : 'a' },
1681 'a' : { 111 : 'a' },
1685 'a' : { 130 : 'a' },
1686 'n' : { 130 : 'n' },
1690 'a' : { 100 : 'a' },
1694 'a' : { 110 : 'a' },
1698 'a' : { 111 : 'a' },
1702 'a' : { 130 : 'a' },
1706 'a' : { 100 : 'a' },
1710 'a' : { 110 : 'a' },
1714 'a' : { 111 : 'a' },
1718 'a' : { 130 : 'a' },
1722 'a' : { 100 : 'a' },
1723 'd' : { 100 : 'd' },
1724 't' : { 100 : 't' },
1751 'a' : { 110 : 'a' },
1752 'd' : { 110 : 'd' },
1753 't' : { 110 : 't' },
1780 'a' : { 111 : 'a' },
1781 'd' : { 111 : 'd' },
1782 't' : { 111 : 't' },
1809 'a' : { 130 : 'a' },
1813 'a' : { 150 : 'a' },
1814 'b' : { 150 : 'b' },
1841 'a' : { 151 : 'a' },
1868 'a' : { 155 : 'a' },
1896 function validateAuthority (button) {
1897 var grid = document.getElementById('recGrid');
1898 var label = button.getAttribute('label');
1901 var rows = grid.lastChild.childNodes;
1902 for (var i = 0; i < rows.length; i++) {
1904 var tag = row.firstChild;
1906 if (!control_map[tag.value]) continue
1907 button.setAttribute('label', label + ' - ' + tag.value);
1909 var ind1 = tag.nextSibling;
1910 var ind2 = ind1.nextSibling;
1911 var subfields = ind2.nextSibling.childNodes;
1915 for (var j = 0; j < subfields.length; j++) {
1916 var sf = subfields[j];
1917 var sf_code = sf.childNodes[1].value;
1918 var sf_value = sf.childNodes[2].value;
1920 if (!control_map[tag.value][sf_code]) continue;
1923 for (var a_tag in control_map[tag.value][sf_code]) {
1924 if (!tags[a_tag]) tags[a_tag] = [];
1925 tags[a_tag].push({ term : sf_value, subfield : sf_code });
1930 for (var val_tag in tags) {
1931 var auth_data = validateBibField( [val_tag], tags[val_tag]);
1932 var res = new XML( auth_data.responseText );
1933 found = parseInt(res.gw::payload.gw::string.toString());
1937 // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
1938 for (var j = 0; j < subfields.length; j++) {
1939 var sf = subfields[j];
1941 sf.childNodes[2].inputField.style.color = 'red';
1943 sf.childNodes[2].inputField.style.color = 'black';
1948 button.setAttribute('label', label);
1954 function validateBibField (tags, searches) {
1955 var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.validate.tag";
1956 url += '¶m="tags"¶m=' + js2JSON(tags);
1957 url += '¶m="searches"¶m=' + js2JSON(searches);
1960 var req = new XMLHttpRequest();
1961 req.open('GET',url,false);
1967 function searchAuthority (term, tag, sf, limit) {
1968 var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
1969 url += '¶m="term"¶m="' + term + '"';
1970 url += '¶m="limit"¶m=' + limit;
1971 url += '¶m="tag"¶m=' + tag;
1972 url += '¶m="subfield"¶m="' + sf + '"';
1975 var req = new XMLHttpRequest();
1976 req.open('GET',url,false);