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 $(id) { return document.getElementById(id); }
19 function mangle_005() {
21 var y = now.getUTCFullYear();
23 var m = now.getUTCMonth() + 1;
24 if (m < 10) m = '0' + m;
26 var d = now.getUTCDate();
27 if (d < 10) d = '0' + d;
29 var H = now.getUTCHours();
30 if (H < 10) H = '0' + H;
32 var M = now.getUTCMinutes();
33 if (M < 10) M = '0' + M;
35 var S = now.getUTCSeconds();
36 if (S < 10) S = '0' + S;
39 var stamp = '' + y + m + d + H + M + S + '.0';
40 createControlField('005',stamp);
44 function createControlField (tag,data) {
45 // first, remove the old field, if any;
46 for (var i in xml_record.controlfield.(@tag == tag)) delete xml_record.controlfield.(@tag == tag)[i];
48 var cf = <controlfield tag="" xmlns="http://www.loc.gov/MARC21/slim">{ data }</controlfield>;
51 // then, find the right position and insert it
53 var cfields = xml_record.controlfield;
54 var base = Number(tag.substring(2));
55 for (var i in cfields) {
56 var t = Number(cfields[i].@tag.toString().substring(2));
58 xml_record.insertChildBefore( cfields[i], cf );
64 if (!done) xml_record.insertChildBefore( xml_record.datafield[0], cf );
69 function xml_escape_unicode ( str ) {
72 function (r,s) { return "&#x" + s.charCodeAt(0).toString(16) + ";"; }
78 // Fake xulG for standalone...
83 window.xulG.record = {};
84 window.xulG.save = {};
86 window.xulG.save.label = $('catStrings').getString('staff.cat.marcedit.save.label');
87 window.xulG.save.func = function (r) { alert(r); }
90 var _rid = cgi.param('record');
92 window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
97 document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
98 document.getElementById('save-button').setAttribute('oncommand',
100 'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' +
101 'window.xulG.save.func( xml_string ); ' +
102 'loadRecord(xml_record);'
105 if (window.xulG.record.url) {
106 var req = new XMLHttpRequest();
107 req.open('GET',window.xulG.record.url,false);
109 window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
112 xml_record = new XML( window.xulG.record.marc );
113 if (xml_record..record[0]) xml_record = xml_record..record[0];
115 // Get the tooltip xml all async like
116 req = new XMLHttpRequest();
118 // Set a default locale in case preferences fail us
119 var locale = "en-US";
121 // Try to get the locale from our preferences
122 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
124 const Cc = Components.classes;
125 const Ci = Components.interfaces;
126 locale = Cc["@mozilla.org/preferences-service;1"].
127 getService(Ci.nsIPrefBranch).
128 getCharPref("general.useragent.locale");
132 // Get the locale-specific tooltips
133 // TODO: We should send a HEAD request to check for the existence of the desired file
134 // then fall back to the default locale if preferred locale is not necessary
135 req.open('GET','/xul/server/locale/' + locale + '/marcedit-tooltips.xml',true);
137 req.onreadystatechange = function () {
138 if (req.readyState == 4) {
139 bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
145 loadRecord(xml_record);
147 alert('FIXME, MARC Editor, my_init: ' + E);
152 function createComplexHTMLElement (e, attrs, objects, text) {
153 var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
156 for (var i in attrs) l.setAttribute(i,attrs[i]);
160 for ( var i in objects ) l.appendChild( objects[i] );
164 l.appendChild( document.createTextNode(text) )
170 function createComplexXULElement (e, attrs, objects) {
171 var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
174 for (var i in attrs) {
175 if (typeof attrs[i] == 'function') {
176 l.addEventListener( i, attrs[i], true );
178 l.setAttribute(i,attrs[i]);
184 for ( var i in objects ) l.appendChild( objects[i] );
190 function createDescription (attrs) {
191 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
194 function createTooltip (attrs) {
195 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
198 function createLabel (attrs) {
199 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
202 function createVbox (attrs) {
203 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
206 function createHbox (attrs) {
207 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
210 function createRow (attrs) {
211 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
214 function createTextbox (attrs) {
215 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
218 function createMenu (attrs) {
219 return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
222 function createMenuPopup (attrs) {
223 return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
226 function createPopup (attrs) {
227 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
230 function createMenuitem (attrs) {
231 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
234 function createCheckbox (attrs) {
235 return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
238 function createMARCTextbox (element,attrs) {
240 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
241 box.onkeypress = function (event) {
244 while(node = node.parent()) {
248 var row = event.target;
249 while (row.tagName != 'row') row = row.parentNode;
251 if (element.nodeKind() == 'attribute') element[0]=box.value;
252 else element.setChildren( box.value );
254 if (element.localName() != 'controlfield') {
255 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
257 var index_sf, target, move_data;
258 if (element.localName() == 'subfield') {
260 target = event.target.parentNode;
262 var start = event.target.selectionStart;
263 var end = event.target.selectionEnd - event.target.selectionStart ?
264 event.target.selectionEnd :
265 event.target.value.length;
267 move_data = event.target.value.substring(start,end);
268 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
269 event.target.setAttribute('size', event.target.value.length + 2);
271 element.setChildren( event.target.value );
273 } else if (element.localName() == 'code') {
274 index_sf = element.parent();
275 target = event.target.parentNode;
276 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
277 index_sf = element.parent().children()[element.parent().children().length() - 1];
278 target = event.target.parentNode.lastChild.lastChild;
281 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
283 index_sf.parent().insertChildAfter( index_sf, sf );
285 var new_sf = marcSubfield(sf);
287 if (target === target.parentNode.lastChild) {
288 target.parentNode.appendChild( new_sf );
290 target.parentNode.insertBefore( new_sf, target.nextSibling );
293 new_sf.firstChild.nextSibling.focus();
295 event.preventDefault();
298 } else if (event.keyCode == 13 || event.keyCode == 77) {
299 if (event.ctrlKey) { // ctrl+enter
302 if (element.localName() == 'subfield') index = element.parent();
303 if (element.localName() == 'code') index = element.parent().parent();
304 if (element.localName() == 'tag') index = element.parent();
305 if (element.localName() == 'ind1') index = element.parent();
306 if (element.localName() == 'ind2') index = element.parent();
308 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
310 if (event.shiftKey) { // ctrl+shift+enter
311 index.parent().insertChildBefore( index, df );
313 index.parent().insertChildAfter( index, df );
316 var new_df = marcDatafield(df);
318 if (row.parentNode.lastChild === row) {
319 row.parentNode.appendChild( new_df );
321 if (event.shiftKey) { // ctrl+shift+enter
322 row.parentNode.insertBefore( new_df, row );
324 row.parentNode.insertBefore( new_df, row.nextSibling );
328 new_df.firstChild.focus();
330 event.preventDefault();
333 } else if (event.shiftKey) {
334 if (row.previousSibling.className.match('marcDatafieldRow'))
335 row.previousSibling.firstChild.focus();
337 row.nextSibling.firstChild.focus();
340 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
343 if (element.localName() == 'subfield') index = element.parent();
344 if (element.localName() == 'code') index = element.parent().parent();
345 if (element.localName() == 'tag') index = element.parent();
346 if (element.localName() == 'ind1') index = element.parent();
347 if (element.localName() == 'ind2') index = element.parent();
349 for (var i in index.parent().children()) {
350 if (index === index.parent().children()[i]) {
351 delete index.parent().children()[i];
356 row.previousSibling.firstChild.focus();
357 row.parentNode.removeChild(row);
359 event.preventDefault();
362 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
365 if (element.localName() == 'subfield') index = element;
366 if (element.localName() == 'code') index = element.parent();
369 for (var i in index.parent().children()) {
370 if (index === index.parent().children()[i]) {
371 delete index.parent().children()[i];
376 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
377 event.target.parentNode.previousSibling.lastChild.focus();
379 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
382 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
384 event.preventDefault();
387 } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
388 createControlField('006','');
389 loadRecord(xml_record);
390 } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
391 createControlField('007','');
392 loadRecord(xml_record);
393 } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
394 createControlField('008','');
395 loadRecord(xml_record);
401 box.addEventListener(
404 if (element.nodeKind() == 'attribute') element[0]=box.value;
405 else element.setChildren( box.value );
411 box.addEventListener(
414 if (element.nodeKind() == 'attribute') element[0]=box.value;
415 else element.setChildren( box.value );
421 box.addEventListener(
424 if (element.nodeKind() == 'attribute') element[0]=box.value;
425 else element.setChildren( box.value );
431 box.addEventListener(
434 if (element.localName() == 'controlfield')
435 eval('fillFixedFields(xml_record);');
444 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
445 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
446 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
447 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
448 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
449 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
450 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
451 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
457 SCO : {start : 33, len : 1, def : ' ' },
458 REC : {start : 33, len : 1, def : 'n' }
461 SCO : {start : 16, len : 1, def : ' ' },
462 REC : {start : 16, len : 1, def : 'n' }
467 VIS : {start : 33, len : 1, def : ' ' }
470 VIS : {start : 16, len : 1, def : ' ' }
475 VIS : {start : 18, len : 3, def : ' ' }
478 VIS : {start : 1, len : 3, def : ' ' }
483 VIS : {start : 34, len : 1, def : 'n' }
486 VIS : {start : 17, len : 1, def : 'n' }
491 SER : {start : 21, len : 1, def : ' ' }
494 SER : {start : 4, len : 1, def : ' ' }
499 BKS : {start : 39, len : 1, def : 'd' },
500 SER : {start : 39, len : 1, def : 'd' },
501 VIS : {start : 39, len : 1, def : 'd' },
502 MIX : {start : 39, len : 1, def : 'd' },
503 MAP : {start : 39, len : 1, def : 'd' },
504 SCO : {start : 39, len : 1, def : 'd' },
505 REC : {start : 39, len : 1, def : 'd' },
506 COM : {start : 39, len : 1, def : 'd' }
511 MAP : {start : 33, len : 2, def : ' ' }
514 MAP : {start : 16, len : 2, def : ' ' }
519 MAP : {start : 18, len : 4, def : ' ' }
522 MAP : {start : 1, len : 4, def : ' ' }
527 SER : {start : 19, len : 1, def : ' ' }
530 SER : {start : 2, len : 1, def : ' ' }
535 MAP : {start : 22, len : 2, def : ' ' }
538 MAP : {start : 5, len : 2, def : ' ' }
543 SCO : {start : 21, len : 1, def : ' ' },
544 REC : {start : 21, len : 1, def : 'n' }
547 SCO : {start : 4, len : 1, def : ' ' },
548 REC : {start : 4, len : 1, def : 'n' }
553 SER : {start : 22, len : 1, def : ' ' }
556 SER : {start : 5, len : 1, def : ' ' }
561 SCO : {start : 30, len : 2, def : ' ' },
562 REC : {start : 30, len : 2, def : ' ' }
565 SCO : {start : 13, len : 2, def : ' ' },
566 REC : {start : 13, len : 2, def : ' ' }
571 SER : {start : 18, len : 1, def : ' ' }
574 SER : {start : 1, len : 1, def : ' ' }
579 SCO : {start : 20, len : 1, def : ' ' },
580 REC : {start : 20, len : 1, def : 'n' }
583 SCO : {start : 3, len : 1, def : ' ' },
584 REC : {start : 3, len : 1, def : 'n' }
589 COM : {start : 26, len : 1, def : 'u' }
592 COM : {start : 9, len : 1, def : 'u' }
597 SER : {start : 24, len : 1, def : ' ' }
600 SER : {start : 7, len : 1, def : ' ' }
605 SCO : {start : 24, len : 6, def : ' ' },
606 REC : {start : 24, len : 6, def : ' ' }
609 SCO : {start : 7, len : 6, def : ' ' },
610 REC : {start : 7, len : 6, def : ' ' }
615 SCO : {start : 18, len : 2, def : ' ' },
616 REC : {start : 18, len : 2, def : ' ' }
619 SCO : {start : 1, len : 2, def : ' ' },
620 REC : {start : 1, len : 2, def : ' ' }
625 MAP : {start : 25, len : 1, def : ' ' }
628 MAP : {start : 8, len : 1, def : ' ' }
633 BKS : {start : 15, len : 3, def : ' ' },
634 SER : {start : 15, len : 3, def : ' ' },
635 VIS : {start : 15, len : 3, def : ' ' },
636 MIX : {start : 15, len : 3, def : ' ' },
637 MAP : {start : 15, len : 3, def : ' ' },
638 SCO : {start : 15, len : 3, def : ' ' },
639 REC : {start : 15, len : 3, def : ' ' },
640 COM : {start : 15, len : 3, def : ' ' }
645 BKS : {start : 35, len : 3, def : ' ' },
646 SER : {start : 35, len : 3, def : ' ' },
647 VIS : {start : 35, len : 3, def : ' ' },
648 MIX : {start : 35, len : 3, def : ' ' },
649 MAP : {start : 35, len : 3, def : ' ' },
650 SCO : {start : 35, len : 3, def : ' ' },
651 REC : {start : 35, len : 3, def : ' ' },
652 COM : {start : 35, len : 3, def : ' ' }
657 BKS : {start : 38, len : 1, def : ' ' },
658 SER : {start : 38, len : 1, def : ' ' },
659 VIS : {start : 38, len : 1, def : ' ' },
660 MIX : {start : 38, len : 1, def : ' ' },
661 MAP : {start : 38, len : 1, def : ' ' },
662 SCO : {start : 38, len : 1, def : ' ' },
663 REC : {start : 38, len : 1, def : ' ' },
664 COM : {start : 38, len : 1, def : ' ' }
669 BKS : {start : 6, len : 1, def : ' ' },
670 SER : {start : 6, len : 1, def : 'c' },
671 VIS : {start : 6, len : 1, def : ' ' },
672 MIX : {start : 6, len : 1, def : ' ' },
673 MAP : {start : 6, len : 1, def : ' ' },
674 SCO : {start : 6, len : 1, def : ' ' },
675 REC : {start : 6, len : 1, def : ' ' },
676 COM : {start : 6, len : 1, def : ' ' }
681 BKS : {start : 6, len : 1, def : 'a' },
682 SER : {start : 6, len : 1, def : 'a' },
683 VIS : {start : 6, len : 1, def : 'g' },
684 MIX : {start : 6, len : 1, def : 'p' },
685 MAP : {start : 6, len : 1, def : 'e' },
686 SCO : {start : 6, len : 1, def : 'c' },
687 REC : {start : 6, len : 1, def : 'i' },
688 COM : {start : 6, len : 1, def : 'm' }
693 BKS : {start : 8, len : 1, def : ' ' },
694 SER : {start : 8, len : 1, def : ' ' },
695 VIS : {start : 8, len : 1, def : ' ' },
696 MIX : {start : 8, len : 1, def : ' ' },
697 MAP : {start : 8, len : 1, def : ' ' },
698 SCO : {start : 8, len : 1, def : ' ' },
699 REC : {start : 8, len : 1, def : ' ' },
700 COM : {start : 8, len : 1, def : ' ' }
705 BKS : {start : 7, len : 1, def : 'm' },
706 SER : {start : 7, len : 1, def : 's' },
707 VIS : {start : 7, len : 1, def : 'm' },
708 MIX : {start : 7, len : 1, def : 'c' },
709 MAP : {start : 7, len : 1, def : 'm' },
710 SCO : {start : 7, len : 1, def : 'm' },
711 REC : {start : 7, len : 1, def : 'm' },
712 COM : {start : 7, len : 1, def : 'm' }
717 BKS : {start : 18, len : 1, def : ' ' },
718 SER : {start : 18, len : 1, def : ' ' },
719 VIS : {start : 18, len : 1, def : ' ' },
720 MIX : {start : 18, len : 1, def : ' ' },
721 MAP : {start : 18, len : 1, def : ' ' },
722 SCO : {start : 18, len : 1, def : ' ' },
723 REC : {start : 18, len : 1, def : ' ' },
724 COM : {start : 18, len : 1, def : ' ' }
729 BKS : {start : 17, len : 1, def : ' ' },
730 SER : {start : 17, len : 1, def : ' ' },
731 VIS : {start : 17, len : 1, def : ' ' },
732 MIX : {start : 17, len : 1, def : ' ' },
733 MAP : {start : 17, len : 1, def : ' ' },
734 SCO : {start : 17, len : 1, def : ' ' },
735 REC : {start : 17, len : 1, def : ' ' },
736 COM : {start : 17, len : 1, def : ' ' }
741 BKS : {start : 31, len : 1, def : '0' },
742 MAP : {start : 31, len : 1, def : '0' }
745 BKS : {start : 14, len : 1, def : '0' },
746 MAP : {start : 14, len : 1, def : '0' }
751 BKS : {start : 7, len : 4, def : ' ' },
752 SER : {start : 7, len : 4, def : ' ' },
753 VIS : {start : 7, len : 4, def : ' ' },
754 MIX : {start : 7, len : 4, def : ' ' },
755 MAP : {start : 7, len : 4, def : ' ' },
756 SCO : {start : 7, len : 4, def : ' ' },
757 REC : {start : 7, len : 4, def : ' ' },
758 COM : {start : 7, len : 4, def : ' ' }
763 BKS : {start : 11, len : 4, def : ' ' },
764 SER : {start : 11, len : 4, def : '9' },
765 VIS : {start : 11, len : 4, def : ' ' },
766 MIX : {start : 11, len : 4, def : ' ' },
767 MAP : {start : 11, len : 4, def : ' ' },
768 SCO : {start : 11, len : 4, def : ' ' },
769 REC : {start : 11, len : 4, def : ' ' },
770 COM : {start : 11, len : 4, def : ' ' }
775 BKS : {start : 33, len : 1, def : '0' }
778 BKS : {start : 16, len : 1, def : '0' }
783 BKS : {start : 34, len : 1, def : ' ' }
786 BKS : {start : 17, len : 1, def : ' ' }
791 BKS : {start : 18, len : 4, def : ' ' }
794 BKS : {start : 1, len : 4, def : ' ' }
799 BKS : {start : 30, len : 1, def : '0' }
802 BKS : {start : 13, len : 1, def : '0' }
807 BKS : {start : 29, len : 1, def : '0' },
808 SER : {start : 29, len : 1, def : '0' }
811 BKS : {start : 12, len : 1, def : '0' },
812 SER : {start : 12, len : 1, def : '0' }
817 BKS : {start : 24, len : 4, def : ' ' },
818 SER : {start : 25, len : 3, def : ' ' }
821 BKS : {start : 7, len : 4, def : ' ' },
822 SER : {start : 8, len : 3, def : ' ' }
827 BKS : {start : 28, len : 1, def : ' ' },
828 SER : {start : 28, len : 1, def : ' ' },
829 VIS : {start : 28, len : 1, def : ' ' },
830 MAP : {start : 28, len : 1, def : ' ' },
831 COM : {start : 28, len : 1, def : ' ' }
834 BKS : {start : 11, len : 1, def : ' ' },
835 SER : {start : 11, len : 1, def : ' ' },
836 VIS : {start : 11, len : 1, def : ' ' },
837 MAP : {start : 11, len : 1, def : ' ' },
838 COM : {start : 11, len : 1, def : ' ' }
843 BKS : {start : 22, len : 1, def : ' ' },
844 SER : {start : 22, len : 1, def : ' ' },
845 VIS : {start : 22, len : 1, def : ' ' },
846 SCO : {start : 22, len : 1, def : ' ' },
847 REC : {start : 22, len : 1, def : ' ' },
848 COM : {start : 22, len : 1, def : ' ' }
851 BKS : {start : 5, len : 1, def : ' ' },
852 SER : {start : 5, len : 1, def : ' ' },
853 VIS : {start : 5, len : 1, def : ' ' },
854 SCO : {start : 5, len : 1, def : ' ' },
855 REC : {start : 5, len : 1, def : ' ' },
856 COM : {start : 5, len : 1, def : ' ' }
861 BKS : {start : 23, len : 1, def : ' ' },
862 SER : {start : 23, len : 1, def : ' ' },
863 VIS : {start : 29, len : 1, def : ' ' },
864 MIX : {start : 23, len : 1, def : ' ' },
865 MAP : {start : 29, len : 1, def : ' ' },
866 SCO : {start : 23, len : 1, def : ' ' },
867 REC : {start : 23, len : 1, def : ' ' }
870 BKS : {start : 6, len : 1, def : ' ' },
871 SER : {start : 6, len : 1, def : ' ' },
872 VIS : {start : 12, len : 1, def : ' ' },
873 MIX : {start : 6, len : 1, def : ' ' },
874 MAP : {start : 12, len : 1, def : ' ' },
875 SCO : {start : 6, len : 1, def : ' ' },
876 REC : {start : 6, len : 1, def : ' ' }
881 SER : {start : 34, len : 1, def : '0' }
884 SER : {start : 17, len : 1, def : '0' }
889 SER : {start : 33, len : 1, def : ' ' }
892 SER : {start : 16, len : 1, def : ' ' }
897 function recordType (rec) {
899 var _l = rec.leader.toString();
901 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
902 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
904 for (var t in rec_type) {
905 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
906 document.getElementById('recordTypeLabel').value = t;
912 alert('FIXME, MARC Editor, recordType: ' + E);
916 function toggleFFE () {
917 var grid = document.getElementById('leaderGrid');
926 function changeFFEditor (type) {
927 var grid = document.getElementById('leaderGrid');
928 grid.setAttribute('type',type);
931 function fillFixedFields (rec) {
933 var grid = document.getElementById('leaderGrid');
935 var rtype = _record_type;
937 var _l = rec.leader.toString();
938 var _6 = rec.controlfield.(@tag=='006').toString();
939 var _7 = rec.controlfield.(@tag=='007').toString();
940 var _8 = rec.controlfield.(@tag=='008').toString();
943 var pre_list = grid.getElementsByTagName('label');
944 for (var i in pre_list) {
945 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
946 list.push( pre_list[i] );
950 for (var i in list) {
951 var name = list[i].getAttribute('name');
957 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
958 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
960 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
961 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
963 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
964 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
966 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
967 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
972 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
973 d = ff_pos[name].ldr[rtype].def;
977 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
978 d = ff_pos[name]._8[rtype].def;
982 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
983 d = ff_pos[name]._6[rtype].def;
987 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
988 d = ff_pos[name]._7[rtype].def;
993 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
999 list[i].nextSibling.value = value;
1004 alert('FIXME, MARC Editor, fillFixedFields: ' + E);
1008 function updateFixedFields (element) {
1009 var grid = document.getElementById('leaderGrid');
1010 var recGrid = document.getElementById('recGrid');
1012 var rtype = _record_type;
1013 var new_value = element.value;
1016 ldr : _record.leader,
1017 _6 : _record.controlfield.(@tag=='006'),
1018 _7 : _record.controlfield.(@tag=='007'),
1019 _8 : _record.controlfield.(@tag=='008'),
1022 var name = element.getAttribute('name');
1023 for (var i in ff_pos[name]) {
1025 if (!ff_pos[name][i][rtype]) continue;
1026 if (!parts[i]) continue;
1028 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
1029 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
1031 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
1032 new_value += ff_pos[name][i][rtype].def;
1035 parts[i].setChildren( before + new_value + after );
1036 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
1042 function marcLeader (leader) {
1043 var row = createRow(
1044 { class : 'marcLeaderRow',
1049 tooltiptext : $('catStrings').getString('staff.cat.marcedit.marcTag.LDR.label') } ),
1052 class : 'marcInd1' } ),
1055 class : 'marcInd2' } ),
1057 { value : leader.text(),
1058 class : 'marcLeader' } )
1064 function marcControlfield (field) {
1065 tagname = field.@tag.toString().substr(2);
1067 if (tagname == '6' || tagname == '7' || tagname == '8') {
1069 { class : 'marcControlfieldRow',
1070 tag : '_' + tagname },
1072 { value : field.@tag,
1074 context : 'tags_popup',
1075 onmouseover : 'getTooltip(this, "tag");',
1076 tooltipid : 'tag' + field.@tag } ),
1078 { value : field.@ind1,
1080 onmouseover : 'getTooltip(this, "ind1");',
1081 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1083 { value : field.@ind2,
1085 onmouseover : 'getTooltip(this, "ind2");',
1086 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1089 { value : field.text(),
1090 class : 'plain marcEditableControlfield',
1091 name : 'CONTROL' + tagname,
1092 oncontext : 'return false();',
1098 { class : 'marcControlfieldRow',
1099 tag : '_' + tagname },
1101 { value : field.@tag,
1103 onmouseover : 'getTooltip(this, "tag");',
1104 tooltipid : 'tag' + field.@tag } ),
1106 { value : field.@ind1,
1108 onmouseover : 'getTooltip(this, "ind1");',
1109 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
1111 { value : field.@ind2,
1113 onmouseover : 'getTooltip(this, "ind2");',
1114 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
1116 { value : field.text(),
1117 class : 'marcControlfield' } )
1124 function stackSubfields(checkbox) {
1125 var list = document.getElementsByAttribute('name','sf_box');
1128 if (checkbox.checked) o = 'horizontal';
1130 for (var i = 0; i < list.length; i++) {
1131 if (list[i]) list[i].setAttribute('orient',o);
1135 function marcDatafield (field) {
1136 var row = createRow(
1137 { class : 'marcDatafieldRow' },
1140 { value : field.@tag,
1141 class : 'plain marcTag',
1143 context : 'tags_popup',
1144 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
1147 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
1150 { value : field.@ind1,
1151 class : 'plain marcInd1',
1153 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1156 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
1157 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
1160 { value : field.@ind2,
1161 class : 'plain marcInd2',
1163 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
1166 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
1167 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
1168 createHbox({ name : 'sf_box' })
1171 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
1172 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
1173 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
1175 var sf_box = row.lastChild;
1176 if (document.getElementById('stackSubfields').checked)
1177 sf_box.setAttribute('orient','vertical');
1179 sf_box.addEventListener(
1182 if (sf_box === e.target) {
1183 sf_box.lastChild.lastChild.focus();
1184 } else if (e.target.parentNode === sf_box) {
1185 e.target.lastChild.focus();
1192 for (var i in field.subfield) {
1193 var sf = field.subfield[i];
1198 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
1199 current_focus = sf_box.lastChild.childNodes[1];
1205 function marcSubfield (sf) {
1207 { class : 'marcSubfieldBox' },
1210 class : 'plain marcSubfieldDelimiter',
1211 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
1212 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
1213 //onclick : 'this.nextSibling.focus();',
1214 onfocus : 'this.nextSibling.focus();',
1219 class : 'plain marcSubfieldCode',
1220 name : 'marcSubfieldCode',
1221 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
1222 oncontextmenu : 'getContextMenu(this, "subfield");',
1223 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
1228 { value : sf.text(),
1229 name : sf.parent().@tag + ':' + sf.@code,
1230 class : 'plain marcSubfield',
1231 onmouseover : 'getTooltip(this, "subfield");',
1232 contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
1233 size : new String(sf.text()).length + 2,
1234 oninput : "this.setAttribute('size', this.value.length + 2);",
1239 function loadRecord(rec) {
1242 var grid_rows = document.getElementById('recGrid').lastChild;
1244 while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
1246 grid_rows.appendChild( marcLeader( rec.leader ) );
1248 for (var i in rec.controlfield) {
1249 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
1252 for (var i in rec.datafield) {
1253 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
1256 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
1257 changeFFEditor(recordType(rec));
1258 fillFixedFields(rec);
1260 alert('FIXME, MARC Editor, loadRecord: ' + E);
1264 var context_menus = createComplexXULElement('popupset');
1265 document.documentElement.appendChild( context_menus );
1267 var tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
1268 context_menus.appendChild( tag_menu );
1270 tag_menu.appendChild(
1272 { label : $('catStrings').getString('staff.cat.marcedit.add_row.label'),
1274 'var e = document.createEvent("KeyEvents");' +
1275 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
1276 'current_focus.inputField.dispatchEvent(e);'
1281 tag_menu.appendChild(
1283 { label : $('catStrings').getString('staff.cat.marcedit.remove_row.label'),
1285 'var e = document.createEvent("KeyEvents");' +
1286 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
1287 'current_focus.inputField.dispatchEvent(e);'
1292 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
1294 tag_menu.appendChild(
1296 { label : $('catStrings').getString('staff.cat.marcedit.replace_006.label'),
1298 'var e = document.createEvent("KeyEvents");' +
1299 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
1300 'current_focus.inputField.dispatchEvent(e);'
1305 tag_menu.appendChild(
1307 { label : $('catStrings').getString('staff.cat.marcedit.replace_007.label'),
1309 'var e = document.createEvent("KeyEvents");' +
1310 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
1311 'current_focus.inputField.dispatchEvent(e);'
1316 tag_menu.appendChild(
1318 { label : $('catStrings').getString('staff.cat.marcedit.replace_008.label'),
1320 'var e = document.createEvent("KeyEvents");' +
1321 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
1322 'current_focus.inputField.dispatchEvent(e);'
1327 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
1331 function genToolTips () {
1332 for (var i in bib_data.field) {
1333 var f = bib_data.field[i];
1335 tag_menu.appendChild(
1339 'current_focus.value = "' + f.@tag + '";' +
1340 'var e = document.createEvent("MutationEvents");' +
1341 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1342 'current_focus.inputField.dispatchEvent(e);',
1343 disabled : f.@tag < '010' ? "true" : "false",
1344 tooltiptext : f.description }
1348 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
1349 context_menus.appendChild( i1_popup );
1351 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
1352 context_menus.appendChild( i2_popup );
1354 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
1355 context_menus.appendChild( sf_popup );
1357 tooltip_hash['tag' + f.@tag] = f.description;
1358 for (var j in f.indicator) {
1359 var ind = f.indicator[j];
1360 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
1362 if (ind.@position == 1) {
1363 i1_popup.appendChild(
1365 { label : ind.@value,
1367 'current_focus.value = "' + ind.@value + '";' +
1368 'var e = document.createEvent("MutationEvents");' +
1369 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1370 'current_focus.inputField.dispatchEvent(e);',
1371 tooltiptext : ind.description }
1376 if (ind.@position == 2) {
1377 i2_popup.appendChild(
1379 { label : ind.@value,
1381 'current_focus.value = "' + ind.@value + '";' +
1382 'var e = document.createEvent("MutationEvents");' +
1383 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1384 'current_focus.inputField.dispatchEvent(e);',
1385 tooltiptext : ind.description }
1391 for (var j in f.subfield) {
1392 var sf = f.subfield[j];
1393 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
1395 sf_popup.appendChild(
1399 'current_focus.value = "' + sf.@code + '";' +
1400 'var e = document.createEvent("MutationEvents");' +
1401 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1402 'current_focus.inputField.dispatchEvent(e);',
1403 tooltiptext : sf.description,
1411 var p = createComplexXULElement('popupset');
1412 document.documentElement.appendChild( p );
1414 function getTooltip (target, type) {
1417 if (type == 'subfield')
1418 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
1421 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
1424 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
1427 tt = 'tag' + target.parentNode.firstChild.value;
1429 if (!document.getElementById( tt )) {
1434 orient : 'vertical',
1435 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
1436 class : 'tooltip' },
1437 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
1442 target.tooltip = tt;
1446 function getContextMenu (target, type) {
1449 if (type == 'subfield')
1450 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
1453 tt = 't' + target.parentNode.firstChild.value + 'i1';
1456 tt = 't' + target.parentNode.firstChild.value + 'i2';
1458 target.setAttribute('context', tt);
1462 var authority_tag_map = {
1463 100 : ['[100,400,500,700]',100],
1464 400 : ['[100,400,500,700]',100],
1465 700 : ['[100,400,500,700]',100],
1466 800 : ['[100,400,500,700]',100],
1467 110 : ['[110,410,510,710]',110],
1468 410 : ['[110,410,510,710]',110],
1469 710 : ['[110,410,510,710]',110],
1470 810 : ['[110,410,510,710]',110],
1471 111 : ['[111,411,511,711]',111],
1472 411 : ['[111,411,511,711]',111],
1473 711 : ['[111,411,511,711]',111],
1474 811 : ['[111,411,511,711]',111],
1475 240 : ['[130,430,530,730]',130],
1476 440 : ['[130,430,530,730]',130],
1477 130 : ['[130,430,530,730]',130],
1478 730 : ['[130,430,530,730]',130],
1479 830 : ['[130,430,530,730]',130],
1480 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
1481 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
1482 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
1483 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155]
1486 function getAuthorityContextMenu (target, sf) {
1487 var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
1489 var old = document.getElementById( menu_id );
1490 if (old) old.parentNode.removeChild(old);
1492 var sf_popup = createPopup({ id : menu_id, flex : 1 });
1493 context_menus.appendChild( sf_popup );
1495 if (!authority_tag_map[sf.parent().@tag]) {
1496 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
1497 target.setAttribute('context', menu_id);
1501 var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
1503 var res = new XML( auth_data.responseText );
1507 var recs = res.gw::payload.gw::array.gw::string;
1508 for (var i in recs) {
1510 var xml = new XML(x.toString());
1511 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1513 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1516 for (var i in main) {
1517 if (main_text) main_text += ' / ';
1518 main_text += main[i];
1521 rec_list.push( [ main_text, xml ] );
1524 for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
1526 var main_text = rec_list[i][0];
1527 var xml = rec_list[i][1];
1528 var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
1530 if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
1532 var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
1533 grid.setAttribute('name','-none-');
1534 grid.setAttribute('style','overflow:scroll');
1537 var submenu = createMenu( { label : main_text } );
1539 var popup = createMenuPopup({ flex : "1" });
1540 submenu.appendChild(popup);
1542 var fields = xml.datafield;
1543 for (var j in fields) {
1545 var row = createRow(
1547 createLabel( { value : fields[j].@tag } ),
1548 createLabel( { value : fields[j].@ind1 } ),
1549 createLabel( { value : fields[j].@ind2 } )
1552 var sf_box = createHbox();
1554 var subfields = fields[j].subfield;
1555 for (var k in subfields) {
1558 { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
1559 subfield : subfields[k].@code,
1560 tag : subfields[k].parent().@tag,
1561 value : subfields[k]
1565 row.appendChild(sf_box);
1568 grid.lastChild.appendChild(row);
1571 grid.hidden = false;
1572 popup.appendChild( grid );
1576 { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'),
1577 command : function (event) {
1578 applyAuthority(event.target.previousSibling, target, sf);
1585 sf_popup.appendChild( submenu );
1588 if (sf_popup.childNodes.length == 0)
1589 sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.no_authority_match.label') } ) );
1591 target.setAttribute('context', menu_id);
1595 function applyAuthority ( target, ui_sf, e4x_sf ) {
1597 var new_vals = target.getElementsByAttribute('checked','true');
1598 var field = e4x_sf.parent();
1600 for (var i = 0; i < new_vals.length; i++) {
1602 var sf_list = field.subfield;
1603 for (var j in sf_list) {
1605 if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
1606 sf_list[j] = new_vals[i].getAttribute('value');
1607 new_vals[i].setAttribute('subfield','');
1613 for (var i = 0; i < new_vals.length; i++) {
1614 if (!new_vals[i].getAttribute('subfield')) continue;
1616 var val = new_vals[i].getAttribute('value');
1618 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
1619 sf.@code = new_vals[i].getAttribute('subfield');
1621 field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
1624 var row = marcDatafield( field );
1627 while (node.nodeName != 'row') {
1628 node = node.parentNode;
1631 node.parentNode.replaceChild( row, node );
1637 'a' : { 100 : 'a' },
1641 'a' : { 110 : 'a' },
1645 'a' : { 111 : 'a' },
1649 'a' : { 130 : 'a' },
1653 'a' : { 130 : 'a' },
1657 'a' : { 100 : 'a' },
1661 'a' : { 110 : 'a' },
1665 'a' : { 111 : 'a' },
1669 'a' : { 130 : 'a' },
1670 'n' : { 130 : 'n' },
1674 'a' : { 100 : 'a' },
1678 'a' : { 110 : 'a' },
1682 'a' : { 111 : 'a' },
1686 'a' : { 130 : 'a' },
1690 'a' : { 100 : 'a' },
1694 'a' : { 110 : 'a' },
1698 'a' : { 111 : 'a' },
1702 'a' : { 130 : 'a' },
1706 'a' : { 100 : 'a' },
1707 'd' : { 100 : 'd' },
1708 't' : { 100 : 't' },
1735 'a' : { 110 : 'a' },
1736 'd' : { 110 : 'd' },
1737 't' : { 110 : 't' },
1764 'a' : { 111 : 'a' },
1765 'd' : { 111 : 'd' },
1766 't' : { 111 : 't' },
1793 'a' : { 130 : 'a' },
1797 'a' : { 150 : 'a' },
1798 'b' : { 150 : 'b' },
1825 'a' : { 151 : 'a' },
1852 'a' : { 155 : 'a' },
1880 function validateAuthority (button) {
1881 var grid = document.getElementById('recGrid');
1882 var label = button.getAttribute('label');
1885 var rows = grid.lastChild.childNodes;
1886 for (var i = 0; i < rows.length; i++) {
1888 var tag = row.firstChild;
1890 if (!control_map[tag.value]) continue
1892 var ind1 = tag.nextSibling;
1893 var ind2 = ind1.nextSibling;
1894 var subfields = ind2.nextSibling.childNodes;
1896 for (var j = 0; j < subfields.length; j++) {
1897 var sf = subfields[j];
1899 if (!control_map[tag.value][sf.childNodes[1].value]) continue;
1901 button.setAttribute('label', label + ' - ' + tag.value + sf.childNodes[1].value);
1904 for (var k in control_map[tag.value][sf.childNodes[1].value]) {
1905 var x = searchAuthority(sf.childNodes[2].value, k, control_map[tag.value][sf.childNodes[1].value][k], 1);
1906 var res = new XML( x.responseText );
1908 if (res.gw::payload.gw::array.gw::string.length()) {
1915 sf.childNodes[2].inputField.style.color = 'red';
1917 sf.childNodes[2].inputField.style.color = 'black';
1922 button.setAttribute('label', label);
1928 function searchAuthority (term, tag, sf, limit) {
1929 var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
1930 url += '¶m="term"¶m="' + term + '"';
1931 url += '¶m="limit"¶m=' + limit;
1932 url += '¶m="tag"¶m=' + tag;
1933 url += '¶m="subfield"¶m="' + sf + '"';
1936 var req = new XMLHttpRequest();
1937 req.open('GET',url,false);