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('GET',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.remove_row.label'),
162 'var e = document.createEvent("KeyEvents");' +
163 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
164 'current_focus.inputField.dispatchEvent(e);'
169 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
171 tag_menu.appendChild(
173 { label : $('catStrings').getString('staff.cat.marcedit.replace_006.label'),
175 'var e = document.createEvent("KeyEvents");' +
176 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
177 'current_focus.inputField.dispatchEvent(e);'
182 tag_menu.appendChild(
184 { label : $('catStrings').getString('staff.cat.marcedit.replace_007.label'),
186 'var e = document.createEvent("KeyEvents");' +
187 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
188 'current_focus.inputField.dispatchEvent(e);'
193 tag_menu.appendChild(
195 { label : $('catStrings').getString('staff.cat.marcedit.replace_008.label'),
197 'var e = document.createEvent("KeyEvents");' +
198 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
199 'current_focus.inputField.dispatchEvent(e);'
204 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
206 p = createComplexXULElement('popupset');
207 document.documentElement.appendChild( p );
209 req.onreadystatechange = function () {
210 if (req.readyState == 4) {
211 bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
217 loadRecord(xml_record);
221 alert('FIXME, MARC Editor, my_init: ' + E);
226 function createComplexHTMLElement (e, attrs, objects, text) {
227 var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
230 for (var i in attrs) l.setAttribute(i,attrs[i]);
234 for ( var i in objects ) l.appendChild( objects[i] );
238 l.appendChild( document.createTextNode(text) )
244 function createComplexXULElement (e, attrs, objects) {
245 var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
248 for (var i in attrs) {
249 if (typeof attrs[i] == 'function') {
250 l.addEventListener( i, attrs[i], true );
252 l.setAttribute(i,attrs[i]);
258 for ( var i in objects ) l.appendChild( objects[i] );
264 function createDescription (attrs) {
265 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
268 function createTooltip (attrs) {
269 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
272 function createLabel (attrs) {
273 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
276 function createVbox (attrs) {
277 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
280 function createHbox (attrs) {
281 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
284 function createRow (attrs) {
285 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
288 function createTextbox (attrs) {
289 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
292 function createMenu (attrs) {
293 return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
296 function createMenuPopup (attrs) {
297 return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
300 function createPopup (attrs) {
301 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
304 function createMenuitem (attrs) {
305 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
308 function createCheckbox (attrs) {
309 return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
312 function createMARCTextbox (element,attrs) {
314 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
315 box.onkeypress = function (event) {
318 while(node = node.parent()) {
322 var row = event.target;
323 while (row.tagName != 'row') row = row.parentNode;
325 if (element.nodeKind() == 'attribute') element[0]=box.value;
326 else element.setChildren( box.value );
328 if (element.localName() != 'controlfield') {
329 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
331 var index_sf, target, move_data;
332 if (element.localName() == 'subfield') {
334 target = event.target.parentNode;
336 var start = event.target.selectionStart;
337 var end = event.target.selectionEnd - event.target.selectionStart ?
338 event.target.selectionEnd :
339 event.target.value.length;
341 move_data = event.target.value.substring(start,end);
342 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
343 event.target.setAttribute('size', event.target.value.length + 2);
345 element.setChildren( event.target.value );
347 } else if (element.localName() == 'code') {
348 index_sf = element.parent();
349 target = event.target.parentNode;
350 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
351 index_sf = element.parent().children()[element.parent().children().length() - 1];
352 target = event.target.parentNode.lastChild.lastChild;
355 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
357 index_sf.parent().insertChildAfter( index_sf, sf );
359 var new_sf = marcSubfield(sf);
361 if (target === target.parentNode.lastChild) {
362 target.parentNode.appendChild( new_sf );
364 target.parentNode.insertBefore( new_sf, target.nextSibling );
367 new_sf.firstChild.nextSibling.focus();
369 event.preventDefault();
372 } else if (event.keyCode == 13 || event.keyCode == 77) {
373 if (event.ctrlKey) { // ctrl+enter
376 if (element.localName() == 'subfield') index = element.parent();
377 if (element.localName() == 'code') index = element.parent().parent();
378 if (element.localName() == 'tag') index = element.parent();
379 if (element.localName() == 'ind1') index = element.parent();
380 if (element.localName() == 'ind2') index = element.parent();
382 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
384 if (event.shiftKey) { // ctrl+shift+enter
385 index.parent().insertChildBefore( index, df );
387 index.parent().insertChildAfter( index, df );
390 var new_df = marcDatafield(df);
392 if (row.parentNode.lastChild === row) {
393 row.parentNode.appendChild( new_df );
395 if (event.shiftKey) { // ctrl+shift+enter
396 row.parentNode.insertBefore( new_df, row );
398 row.parentNode.insertBefore( new_df, row.nextSibling );
402 new_df.firstChild.focus();
404 event.preventDefault();
407 } else if (event.shiftKey) {
408 if (row.previousSibling.className.match('marcDatafieldRow'))
409 row.previousSibling.firstChild.focus();
411 row.nextSibling.firstChild.focus();
414 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
417 if (element.localName() == 'subfield') index = element.parent();
418 if (element.localName() == 'code') index = element.parent().parent();
419 if (element.localName() == 'tag') index = element.parent();
420 if (element.localName() == 'ind1') index = element.parent();
421 if (element.localName() == 'ind2') index = element.parent();
423 for (var i in index.parent().children()) {
424 if (index === index.parent().children()[i]) {
425 delete index.parent().children()[i];
430 row.previousSibling.firstChild.focus();
431 row.parentNode.removeChild(row);
433 event.preventDefault();
436 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
439 if (element.localName() == 'subfield') index = element;
440 if (element.localName() == 'code') index = element.parent();
443 for (var i in index.parent().children()) {
444 if (index === index.parent().children()[i]) {
445 delete index.parent().children()[i];
450 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
451 event.target.parentNode.previousSibling.lastChild.focus();
453 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
456 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
458 event.preventDefault();
461 } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
462 createControlField('006','');
463 loadRecord(xml_record);
464 } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
465 createControlField('007','');
466 loadRecord(xml_record);
467 } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
468 createControlField('008','');
469 loadRecord(xml_record);
475 box.addEventListener(
478 if (element.nodeKind() == 'attribute') element[0]=box.value;
479 else element.setChildren( box.value );
485 box.addEventListener(
488 if (element.nodeKind() == 'attribute') element[0]=box.value;
489 else element.setChildren( box.value );
495 box.addEventListener(
498 if (element.nodeKind() == 'attribute') element[0]=box.value;
499 else element.setChildren( box.value );
505 box.addEventListener(
508 if (element.localName() == 'controlfield')
509 eval('fillFixedFields(xml_record);');
518 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
519 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
520 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
521 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
522 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
523 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
524 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
525 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
531 SCO : {start : 33, len : 1, def : ' ' },
532 REC : {start : 33, len : 1, def : 'n' }
535 SCO : {start : 16, len : 1, def : ' ' },
536 REC : {start : 16, len : 1, def : 'n' }
541 VIS : {start : 33, len : 1, def : ' ' }
544 VIS : {start : 16, len : 1, def : ' ' }
549 VIS : {start : 18, len : 3, def : ' ' }
552 VIS : {start : 1, len : 3, def : ' ' }
557 VIS : {start : 34, len : 1, def : 'n' }
560 VIS : {start : 17, len : 1, def : 'n' }
565 SER : {start : 21, len : 1, def : ' ' }
568 SER : {start : 4, len : 1, def : ' ' }
573 BKS : {start : 39, len : 1, def : 'd' },
574 SER : {start : 39, len : 1, def : 'd' },
575 VIS : {start : 39, len : 1, def : 'd' },
576 MIX : {start : 39, len : 1, def : 'd' },
577 MAP : {start : 39, len : 1, def : 'd' },
578 SCO : {start : 39, len : 1, def : 'd' },
579 REC : {start : 39, len : 1, def : 'd' },
580 COM : {start : 39, len : 1, def : 'd' }
585 MAP : {start : 33, len : 2, def : ' ' }
588 MAP : {start : 16, len : 2, def : ' ' }
593 MAP : {start : 18, len : 4, def : ' ' }
596 MAP : {start : 1, len : 4, def : ' ' }
601 SER : {start : 19, len : 1, def : ' ' }
604 SER : {start : 2, len : 1, def : ' ' }
609 MAP : {start : 22, len : 2, def : ' ' }
612 MAP : {start : 5, len : 2, def : ' ' }
617 SCO : {start : 21, len : 1, def : ' ' },
618 REC : {start : 21, len : 1, def : 'n' }
621 SCO : {start : 4, len : 1, def : ' ' },
622 REC : {start : 4, len : 1, def : 'n' }
627 SER : {start : 22, len : 1, def : ' ' }
630 SER : {start : 5, len : 1, def : ' ' }
635 SCO : {start : 30, len : 2, def : ' ' },
636 REC : {start : 30, len : 2, def : ' ' }
639 SCO : {start : 13, len : 2, def : ' ' },
640 REC : {start : 13, len : 2, def : ' ' }
645 SER : {start : 18, len : 1, def : ' ' }
648 SER : {start : 1, len : 1, def : ' ' }
653 SCO : {start : 20, len : 1, def : ' ' },
654 REC : {start : 20, len : 1, def : 'n' }
657 SCO : {start : 3, len : 1, def : ' ' },
658 REC : {start : 3, len : 1, def : 'n' }
663 COM : {start : 26, len : 1, def : 'u' }
666 COM : {start : 9, len : 1, def : 'u' }
671 SER : {start : 24, len : 1, def : ' ' }
674 SER : {start : 7, len : 1, def : ' ' }
679 SCO : {start : 24, len : 6, def : ' ' },
680 REC : {start : 24, len : 6, def : ' ' }
683 SCO : {start : 7, len : 6, def : ' ' },
684 REC : {start : 7, len : 6, def : ' ' }
689 SCO : {start : 18, len : 2, def : ' ' },
690 REC : {start : 18, len : 2, def : ' ' }
693 SCO : {start : 1, len : 2, def : ' ' },
694 REC : {start : 1, len : 2, def : ' ' }
699 MAP : {start : 25, len : 1, def : ' ' }
702 MAP : {start : 8, len : 1, def : ' ' }
707 BKS : {start : 15, len : 3, def : ' ' },
708 SER : {start : 15, len : 3, def : ' ' },
709 VIS : {start : 15, len : 3, def : ' ' },
710 MIX : {start : 15, len : 3, def : ' ' },
711 MAP : {start : 15, len : 3, def : ' ' },
712 SCO : {start : 15, len : 3, def : ' ' },
713 REC : {start : 15, len : 3, def : ' ' },
714 COM : {start : 15, len : 3, def : ' ' }
719 BKS : {start : 35, len : 3, def : ' ' },
720 SER : {start : 35, len : 3, def : ' ' },
721 VIS : {start : 35, len : 3, def : ' ' },
722 MIX : {start : 35, len : 3, def : ' ' },
723 MAP : {start : 35, len : 3, def : ' ' },
724 SCO : {start : 35, len : 3, def : ' ' },
725 REC : {start : 35, len : 3, def : ' ' },
726 COM : {start : 35, len : 3, def : ' ' }
731 BKS : {start : 38, len : 1, def : ' ' },
732 SER : {start : 38, len : 1, def : ' ' },
733 VIS : {start : 38, len : 1, def : ' ' },
734 MIX : {start : 38, len : 1, def : ' ' },
735 MAP : {start : 38, len : 1, def : ' ' },
736 SCO : {start : 38, len : 1, def : ' ' },
737 REC : {start : 38, len : 1, def : ' ' },
738 COM : {start : 38, len : 1, def : ' ' }
743 BKS : {start : 6, len : 1, def : ' ' },
744 SER : {start : 6, len : 1, def : 'c' },
745 VIS : {start : 6, len : 1, def : ' ' },
746 MIX : {start : 6, len : 1, def : ' ' },
747 MAP : {start : 6, len : 1, def : ' ' },
748 SCO : {start : 6, len : 1, def : ' ' },
749 REC : {start : 6, len : 1, def : ' ' },
750 COM : {start : 6, len : 1, def : ' ' }
755 BKS : {start : 6, len : 1, def : 'a' },
756 SER : {start : 6, len : 1, def : 'a' },
757 VIS : {start : 6, len : 1, def : 'g' },
758 MIX : {start : 6, len : 1, def : 'p' },
759 MAP : {start : 6, len : 1, def : 'e' },
760 SCO : {start : 6, len : 1, def : 'c' },
761 REC : {start : 6, len : 1, def : 'i' },
762 COM : {start : 6, len : 1, def : 'm' }
767 BKS : {start : 8, len : 1, def : ' ' },
768 SER : {start : 8, len : 1, def : ' ' },
769 VIS : {start : 8, len : 1, def : ' ' },
770 MIX : {start : 8, len : 1, def : ' ' },
771 MAP : {start : 8, len : 1, def : ' ' },
772 SCO : {start : 8, len : 1, def : ' ' },
773 REC : {start : 8, len : 1, def : ' ' },
774 COM : {start : 8, len : 1, def : ' ' }
779 BKS : {start : 7, len : 1, def : 'm' },
780 SER : {start : 7, len : 1, def : 's' },
781 VIS : {start : 7, len : 1, def : 'm' },
782 MIX : {start : 7, len : 1, def : 'c' },
783 MAP : {start : 7, len : 1, def : 'm' },
784 SCO : {start : 7, len : 1, def : 'm' },
785 REC : {start : 7, len : 1, def : 'm' },
786 COM : {start : 7, len : 1, def : 'm' }
791 BKS : {start : 18, len : 1, def : ' ' },
792 SER : {start : 18, len : 1, def : ' ' },
793 VIS : {start : 18, len : 1, def : ' ' },
794 MIX : {start : 18, len : 1, def : ' ' },
795 MAP : {start : 18, len : 1, def : ' ' },
796 SCO : {start : 18, len : 1, def : ' ' },
797 REC : {start : 18, len : 1, def : ' ' },
798 COM : {start : 18, len : 1, def : ' ' }
803 BKS : {start : 17, len : 1, def : ' ' },
804 SER : {start : 17, len : 1, def : ' ' },
805 VIS : {start : 17, len : 1, def : ' ' },
806 MIX : {start : 17, len : 1, def : ' ' },
807 MAP : {start : 17, len : 1, def : ' ' },
808 SCO : {start : 17, len : 1, def : ' ' },
809 REC : {start : 17, len : 1, def : ' ' },
810 COM : {start : 17, len : 1, def : ' ' }
815 BKS : {start : 31, len : 1, def : '0' },
816 MAP : {start : 31, len : 1, def : '0' }
819 BKS : {start : 14, len : 1, def : '0' },
820 MAP : {start : 14, len : 1, def : '0' }
825 BKS : {start : 7, len : 4, def : ' ' },
826 SER : {start : 7, len : 4, def : ' ' },
827 VIS : {start : 7, len : 4, def : ' ' },
828 MIX : {start : 7, len : 4, def : ' ' },
829 MAP : {start : 7, len : 4, def : ' ' },
830 SCO : {start : 7, len : 4, def : ' ' },
831 REC : {start : 7, len : 4, def : ' ' },
832 COM : {start : 7, len : 4, def : ' ' }
837 BKS : {start : 11, len : 4, def : ' ' },
838 SER : {start : 11, len : 4, def : '9' },
839 VIS : {start : 11, len : 4, def : ' ' },
840 MIX : {start : 11, len : 4, def : ' ' },
841 MAP : {start : 11, len : 4, def : ' ' },
842 SCO : {start : 11, len : 4, def : ' ' },
843 REC : {start : 11, len : 4, def : ' ' },
844 COM : {start : 11, len : 4, def : ' ' }
849 BKS : {start : 33, len : 1, def : '0' }
852 BKS : {start : 16, len : 1, def : '0' }
857 BKS : {start : 34, len : 1, def : ' ' }
860 BKS : {start : 17, len : 1, def : ' ' }
865 BKS : {start : 18, len : 4, def : ' ' }
868 BKS : {start : 1, len : 4, def : ' ' }
873 BKS : {start : 30, len : 1, def : '0' }
876 BKS : {start : 13, len : 1, def : '0' }
881 BKS : {start : 29, len : 1, def : '0' },
882 SER : {start : 29, len : 1, def : '0' }
885 BKS : {start : 12, len : 1, def : '0' },
886 SER : {start : 12, len : 1, def : '0' }
891 BKS : {start : 24, len : 4, def : ' ' },
892 SER : {start : 25, len : 3, def : ' ' }
895 BKS : {start : 7, len : 4, def : ' ' },
896 SER : {start : 8, len : 3, def : ' ' }
901 BKS : {start : 28, len : 1, def : ' ' },
902 SER : {start : 28, len : 1, def : ' ' },
903 VIS : {start : 28, len : 1, def : ' ' },
904 MAP : {start : 28, len : 1, def : ' ' },
905 COM : {start : 28, len : 1, def : ' ' }
908 BKS : {start : 11, len : 1, def : ' ' },
909 SER : {start : 11, len : 1, def : ' ' },
910 VIS : {start : 11, len : 1, def : ' ' },
911 MAP : {start : 11, len : 1, def : ' ' },
912 COM : {start : 11, len : 1, def : ' ' }
917 BKS : {start : 22, len : 1, def : ' ' },
918 SER : {start : 22, len : 1, def : ' ' },
919 VIS : {start : 22, len : 1, def : ' ' },
920 SCO : {start : 22, len : 1, def : ' ' },
921 REC : {start : 22, len : 1, def : ' ' },
922 COM : {start : 22, len : 1, def : ' ' }
925 BKS : {start : 5, len : 1, def : ' ' },
926 SER : {start : 5, len : 1, def : ' ' },
927 VIS : {start : 5, len : 1, def : ' ' },
928 SCO : {start : 5, len : 1, def : ' ' },
929 REC : {start : 5, len : 1, def : ' ' },
930 COM : {start : 5, len : 1, def : ' ' }
935 BKS : {start : 23, len : 1, def : ' ' },
936 SER : {start : 23, len : 1, def : ' ' },
937 VIS : {start : 29, len : 1, def : ' ' },
938 MIX : {start : 23, len : 1, def : ' ' },
939 MAP : {start : 29, len : 1, def : ' ' },
940 SCO : {start : 23, len : 1, def : ' ' },
941 REC : {start : 23, len : 1, def : ' ' }
944 BKS : {start : 6, len : 1, def : ' ' },
945 SER : {start : 6, len : 1, def : ' ' },
946 VIS : {start : 12, len : 1, def : ' ' },
947 MIX : {start : 6, len : 1, def : ' ' },
948 MAP : {start : 12, len : 1, def : ' ' },
949 SCO : {start : 6, len : 1, def : ' ' },
950 REC : {start : 6, len : 1, def : ' ' }
955 SER : {start : 34, len : 1, def : '0' }
958 SER : {start : 17, len : 1, def : '0' }
963 SER : {start : 33, len : 1, def : ' ' }
966 SER : {start : 16, len : 1, def : ' ' }
971 function recordType (rec) {
973 var _l = rec.leader.toString();
975 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
976 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
978 for (var t in rec_type) {
979 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
980 document.getElementById('recordTypeLabel').value = t;
986 alert('FIXME, MARC Editor, recordType: ' + E);
990 function toggleFFE () {
991 var grid = document.getElementById('leaderGrid');
1000 function changeFFEditor (type) {
1001 var grid = document.getElementById('leaderGrid');
1002 grid.setAttribute('type',type);
1005 function fillFixedFields (rec) {
1007 var grid = document.getElementById('leaderGrid');
1009 var rtype = _record_type;
1011 var _l = rec.leader.toString();
1012 var _6 = rec.controlfield.(@tag=='006').toString();
1013 var _7 = rec.controlfield.(@tag=='007').toString();
1014 var _8 = rec.controlfield.(@tag=='008').toString();
1017 var pre_list = grid.getElementsByTagName('label');
1018 for (var i in pre_list) {
1019 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
1020 list.push( pre_list[i] );
1024 for (var i in list) {
1025 var name = list[i].getAttribute('name');
1031 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
1032 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
1034 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
1035 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
1037 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
1038 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
1040 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
1041 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
1046 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
1047 d = ff_pos[name].ldr[rtype].def;
1051 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
1052 d = ff_pos[name]._8[rtype].def;
1056 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
1057 d = ff_pos[name]._6[rtype].def;
1061 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
1062 d = ff_pos[name]._7[rtype].def;
1067 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
1073 list[i].nextSibling.value = value;
1078 alert('FIXME, MARC Editor, fillFixedFields: ' + E);
1082 function updateFixedFields (element) {
1083 var grid = document.getElementById('leaderGrid');
1084 var recGrid = document.getElementById('recGrid');
1086 var rtype = _record_type;
1087 var new_value = element.value;
1090 ldr : _record.leader,
1091 _6 : _record.controlfield.(@tag=='006'),
1092 _7 : _record.controlfield.(@tag=='007'),
1093 _8 : _record.controlfield.(@tag=='008'),
1096 var name = element.getAttribute('name');
1097 for (var i in ff_pos[name]) {
1099 if (!ff_pos[name][i][rtype]) continue;
1100 if (!parts[i]) continue;
1102 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
1103 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
1105 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
1106 new_value += ff_pos[name][i][rtype].def;
1109 parts[i].setChildren( before + new_value + after );
1110 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
1116 function marcLeader (leader) {
1117 var row = createRow(
1118 { class : 'marcLeaderRow',
1123 tooltiptext : $('catStrings').getString('staff.cat.marcedit.marcTag.LDR.label') } ),
1126 class : 'marcInd1' } ),
1129 class : 'marcInd2' } ),
1131 { value : leader.text(),
1132 class : 'marcLeader' } )
1138 function marcControlfield (field) {
1139 tagname = field.@tag.toString().substr(2);
1141 if (tagname == '6' || tagname == '7' || tagname == '8') {
1143 { class : 'marcControlfieldRow',
1144 tag : '_' + tagname },
1146 { value : field.@tag,
1148 context : 'tags_popup',
1149 onmouseover : 'getTooltip(this, "tag");',
1150 tooltipid : 'tag' + field.@tag } ),
1152 { value : field.@ind1,
1154 onmouseover : 'getTooltip(this, "ind1");',
1155 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1157 { value : field.@ind2,
1159 onmouseover : 'getTooltip(this, "ind2");',
1160 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1163 { value : field.text(),
1164 class : 'plain marcEditableControlfield',
1165 name : 'CONTROL' + tagname,
1166 oncontext : 'return false();',
1172 { class : 'marcControlfieldRow',
1173 tag : '_' + tagname },
1175 { value : field.@tag,
1177 onmouseover : 'getTooltip(this, "tag");',
1178 tooltipid : 'tag' + field.@tag } ),
1180 { value : field.@ind1,
1182 onmouseover : 'getTooltip(this, "ind1");',
1183 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1185 { value : field.@ind2,
1187 onmouseover : 'getTooltip(this, "ind2");',
1188 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1190 { value : field.text(),
1191 class : 'marcControlfield' } )
1198 function stackSubfields(checkbox) {
1199 var list = document.getElementsByAttribute('name','sf_box');
1202 if (checkbox.checked) o = 'horizontal';
1204 for (var i = 0; i < list.length; i++) {
1205 if (list[i]) list[i].setAttribute('orient',o);
1209 function marcDatafield (field) {
1210 var row = createRow(
1211 { class : 'marcDatafieldRow' },
1214 { value : field.@tag,
1215 class : 'plain marcTag',
1217 context : 'tags_popup',
1218 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
1221 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
1224 { value : field.@ind1,
1225 class : 'plain marcInd1',
1227 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1230 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
1231 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
1234 { value : field.@ind2,
1235 class : 'plain marcInd2',
1237 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
1240 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
1241 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
1242 createHbox({ name : 'sf_box' })
1245 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
1246 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
1247 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
1249 var sf_box = row.lastChild;
1250 if (document.getElementById('stackSubfields').checked)
1251 sf_box.setAttribute('orient','vertical');
1253 sf_box.addEventListener(
1256 if (sf_box === e.target) {
1257 sf_box.lastChild.lastChild.focus();
1258 } else if (e.target.parentNode === sf_box) {
1259 e.target.lastChild.focus();
1266 for (var i in field.subfield) {
1267 var sf = field.subfield[i];
1272 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
1273 current_focus = sf_box.lastChild.childNodes[1];
1279 function marcSubfield (sf) {
1281 { class : 'marcSubfieldBox' },
1284 class : 'plain marcSubfieldDelimiter',
1285 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
1286 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
1287 //onclick : 'this.nextSibling.focus();',
1288 onfocus : 'this.nextSibling.focus();',
1293 class : 'plain marcSubfieldCode',
1294 name : 'marcSubfieldCode',
1295 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
1296 oncontextmenu : 'getContextMenu(this, "subfield");',
1297 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1302 { value : sf.text(),
1303 name : sf.parent().@tag + ':' + sf.@code,
1304 class : 'plain marcSubfield',
1305 onmouseover : 'getTooltip(this, "subfield");',
1306 contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
1307 size : new String(sf.text()).length + 2,
1308 oninput : "this.setAttribute('size', this.value.length + 2);",
1313 function loadRecord(rec) {
1316 var grid_rows = document.getElementById('recGrid').lastChild;
1318 while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
1320 grid_rows.appendChild( marcLeader( rec.leader ) );
1322 for (var i in rec.controlfield) {
1323 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
1326 for (var i in rec.datafield) {
1327 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
1330 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
1331 changeFFEditor(recordType(rec));
1332 fillFixedFields(rec);
1334 alert('FIXME, MARC Editor, loadRecord: ' + E);
1339 function genToolTips () {
1340 for (var i in bib_data.field) {
1341 var f = bib_data.field[i];
1343 tag_menu.appendChild(
1347 'current_focus.value = "' + f.@tag + '";' +
1348 'var e = document.createEvent("MutationEvents");' +
1349 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1350 'current_focus.inputField.dispatchEvent(e);',
1351 disabled : f.@tag < '010' ? "true" : "false",
1352 tooltiptext : f.description }
1356 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
1357 context_menus.appendChild( i1_popup );
1359 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
1360 context_menus.appendChild( i2_popup );
1362 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
1363 context_menus.appendChild( sf_popup );
1365 tooltip_hash['tag' + f.@tag] = f.description;
1366 for (var j in f.indicator) {
1367 var ind = f.indicator[j];
1368 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
1370 if (ind.@position == 1) {
1371 i1_popup.appendChild(
1373 { label : ind.@value,
1375 'current_focus.value = "' + ind.@value + '";' +
1376 'var e = document.createEvent("MutationEvents");' +
1377 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1378 'current_focus.inputField.dispatchEvent(e);',
1379 tooltiptext : ind.description }
1384 if (ind.@position == 2) {
1385 i2_popup.appendChild(
1387 { label : ind.@value,
1389 'current_focus.value = "' + ind.@value + '";' +
1390 'var e = document.createEvent("MutationEvents");' +
1391 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1392 'current_focus.inputField.dispatchEvent(e);',
1393 tooltiptext : ind.description }
1399 for (var j in f.subfield) {
1400 var sf = f.subfield[j];
1401 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
1403 sf_popup.appendChild(
1407 'current_focus.value = "' + sf.@code + '";' +
1408 'var e = document.createEvent("MutationEvents");' +
1409 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1410 'current_focus.inputField.dispatchEvent(e);',
1411 tooltiptext : sf.description,
1419 function getTooltip (target, type) {
1422 if (type == 'subfield')
1423 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
1426 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
1429 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
1432 tt = 'tag' + target.parentNode.firstChild.value;
1434 if (!document.getElementById( tt )) {
1439 orient : 'vertical',
1440 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
1441 class : 'tooltip' },
1442 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
1447 target.tooltip = tt;
1451 function getContextMenu (target, type) {
1454 if (type == 'subfield')
1455 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
1458 tt = 't' + target.parentNode.firstChild.value + 'i1';
1461 tt = 't' + target.parentNode.firstChild.value + 'i2';
1463 target.setAttribute('context', tt);
1467 var authority_tag_map = {
1468 100 : ['[100,400,500,700]',100],
1469 400 : ['[100,400,500,700]',100],
1470 700 : ['[100,400,500,700]',100],
1471 800 : ['[100,400,500,700]',100],
1472 110 : ['[110,410,510,710]',110],
1473 410 : ['[110,410,510,710]',110],
1474 710 : ['[110,410,510,710]',110],
1475 810 : ['[110,410,510,710]',110],
1476 111 : ['[111,411,511,711]',111],
1477 411 : ['[111,411,511,711]',111],
1478 711 : ['[111,411,511,711]',111],
1479 811 : ['[111,411,511,711]',111],
1480 240 : ['[130,430,530,730]',130],
1481 440 : ['[130,430,530,730]',130],
1482 130 : ['[130,430,530,730]',130],
1483 730 : ['[130,430,530,730]',130],
1484 830 : ['[130,430,530,730]',130],
1485 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
1486 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
1487 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
1488 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155]
1491 function getAuthorityContextMenu (target, sf) {
1492 var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
1494 var old = document.getElementById( menu_id );
1495 if (old) old.parentNode.removeChild(old);
1497 var sf_popup = createPopup({ id : menu_id, flex : 1 });
1498 context_menus.appendChild( sf_popup );
1500 if (!authority_tag_map[sf.parent().@tag]) {
1501 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
1502 target.setAttribute('context', menu_id);
1506 var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
1508 var res = new XML( auth_data.responseText );
1512 var recs = res.gw::payload.gw::array.gw::string;
1513 for (var i in recs) {
1515 var xml = new XML(x.toString());
1516 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1518 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1521 for (var i in main) {
1522 if (main_text) main_text += ' / ';
1523 main_text += main[i];
1526 rec_list.push( [ main_text, xml ] );
1529 for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
1531 var main_text = rec_list[i][0];
1532 var xml = rec_list[i][1];
1533 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1535 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1537 var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
1538 grid.setAttribute('name','-none-');
1539 grid.setAttribute('style','overflow:scroll');
1542 var submenu = createMenu( { label : main_text } );
1544 var popup = createMenuPopup({ flex : "1" });
1545 submenu.appendChild(popup);
1547 var fields = xml.datafield;
1548 for (var j in fields) {
1550 var row = createRow(
1552 createLabel( { value : fields[j].@tag } ),
1553 createLabel( { value : fields[j].@ind1 } ),
1554 createLabel( { value : fields[j].@ind2 } )
1557 var sf_box = createHbox();
1559 var subfields = fields[j].subfield;
1560 for (var k in subfields) {
1563 { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
1564 subfield : subfields[k].@code,
1565 tag : subfields[k].parent().@tag,
1566 value : subfields[k]
1570 row.appendChild(sf_box);
1573 grid.lastChild.appendChild(row);
1576 grid.hidden = false;
1577 popup.appendChild( grid );
1581 { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'),
1582 command : function (event) {
1583 applyAuthority(event.target.previousSibling, target, sf);
1590 sf_popup.appendChild( submenu );
1593 if (sf_popup.childNodes.length == 0)
1594 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.no_authority_match.label') } ) );
1596 target.setAttribute('context', menu_id);
1600 function applyAuthority ( target, ui_sf, e4x_sf ) {
1602 var new_vals = target.getElementsByAttribute('checked','true');
1603 var field = e4x_sf.parent();
1605 for (var i = 0; i < new_vals.length; i++) {
1607 var sf_list = field.subfield;
1608 for (var j in sf_list) {
1610 if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
1611 sf_list[j] = new_vals[i].getAttribute('value');
1612 new_vals[i].setAttribute('subfield','');
1618 for (var i = 0; i < new_vals.length; i++) {
1619 if (!new_vals[i].getAttribute('subfield')) continue;
1621 var val = new_vals[i].getAttribute('value');
1623 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
1624 sf.@code = new_vals[i].getAttribute('subfield');
1626 field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
1629 var row = marcDatafield( field );
1632 while (node.nodeName != 'row') {
1633 node = node.parentNode;
1636 node.parentNode.replaceChild( row, node );
1642 'a' : { 100 : 'a' },
1646 'a' : { 110 : 'a' },
1650 'a' : { 111 : 'a' },
1654 'a' : { 130 : 'a' },
1658 'a' : { 130 : 'a' },
1662 'a' : { 100 : 'a' },
1666 'a' : { 110 : 'a' },
1670 'a' : { 111 : 'a' },
1674 'a' : { 130 : 'a' },
1675 'n' : { 130 : 'n' },
1679 'a' : { 100 : 'a' },
1683 'a' : { 110 : 'a' },
1687 'a' : { 111 : 'a' },
1691 'a' : { 130 : 'a' },
1695 'a' : { 100 : 'a' },
1699 'a' : { 110 : 'a' },
1703 'a' : { 111 : 'a' },
1707 'a' : { 130 : 'a' },
1711 'a' : { 100 : 'a' },
1712 'd' : { 100 : 'd' },
1713 't' : { 100 : 't' },
1740 'a' : { 110 : 'a' },
1741 'd' : { 110 : 'd' },
1742 't' : { 110 : 't' },
1769 'a' : { 111 : 'a' },
1770 'd' : { 111 : 'd' },
1771 't' : { 111 : 't' },
1798 'a' : { 130 : 'a' },
1802 'a' : { 150 : 'a' },
1803 'b' : { 150 : 'b' },
1830 'a' : { 151 : 'a' },
1857 'a' : { 155 : 'a' },
1885 function validateAuthority (button) {
1886 var grid = document.getElementById('recGrid');
1887 var label = button.getAttribute('label');
1890 var rows = grid.lastChild.childNodes;
1891 for (var i = 0; i < rows.length; i++) {
1893 var tag = row.firstChild;
1895 if (!control_map[tag.value]) continue
1897 var ind1 = tag.nextSibling;
1898 var ind2 = ind1.nextSibling;
1899 var subfields = ind2.nextSibling.childNodes;
1901 for (var j = 0; j < subfields.length; j++) {
1902 var sf = subfields[j];
1904 if (!control_map[tag.value][sf.childNodes[1].value]) continue;
1906 button.setAttribute('label', label + ' - ' + tag.value + sf.childNodes[1].value);
1909 for (var k in control_map[tag.value][sf.childNodes[1].value]) {
1910 var x = searchAuthority(sf.childNodes[2].value, k, control_map[tag.value][sf.childNodes[1].value][k], 1);
1911 var res = new XML( x.responseText );
1913 if (res.gw::payload.gw::array.gw::string.length()) {
1920 sf.childNodes[2].inputField.style.color = 'red';
1922 sf.childNodes[2].inputField.style.color = 'black';
1927 button.setAttribute('label', label);
1933 function searchAuthority (term, tag, sf, limit) {
1934 var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
1935 url += '¶m="term"¶m="' + term + '"';
1936 url += '¶m="limit"¶m=' + limit;
1937 url += '¶m="tag"¶m=' + tag;
1938 url += '¶m="subfield"¶m="' + sf + '"';
1941 var req = new XMLHttpRequest();
1942 req.open('GET',url,false);