1 var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
2 var xulns = new Namespace("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
3 default xml namespace = marcns;
10 function createComplexHTMLElement (e, attrs, objects, text) {
11 var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
14 for (var i in attrs) l.setAttribute(i,attrs[i]);
18 for ( var i in objects ) l.appendChild( objects[i] );
22 l.appendChild( document.createTextNode(text) )
28 function createComplexXULElement (e, attrs, objects) {
29 var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
32 for (var i in attrs) {
33 if (typeof attrs[i] == 'function') {
34 l.addEventListener( i, attrs[i], true );
36 l.setAttribute(i,attrs[i]);
42 for ( var i in objects ) l.appendChild( objects[i] );
48 function createDescription (attrs) {
49 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
52 function createTooltip (attrs) {
53 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
56 function createLabel (attrs) {
57 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
60 function createVbox (attrs) {
61 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
64 function createHbox (attrs) {
65 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
68 function createRow (attrs) {
69 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
72 function createTextbox (attrs) {
73 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
76 function createMenu (attrs) {
77 return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
80 function createMenuPopup (attrs) {
81 return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
84 function createPopup (attrs) {
85 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
88 function createMenuitem (attrs) {
89 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
92 function createMARCTextbox (element,attrs) {
94 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
95 box.onkeypress = function (event) {
98 while(node = node.parent()) {
102 var row = event.target;
103 while (row.tagName != 'row') row = row.parentNode;
105 if (element.nodeKind() == 'attribute') element[0]=box.value;
106 else element.setChildren( box.value );
108 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
110 var index_sf, target, move_data;
111 if (element.localName() == 'subfield') {
113 target = event.target.parentNode;
115 var start = event.target.selectionStart;
116 var end = event.target.selectionEnd - event.target.selectionStart ?
117 event.target.selectionEnd :
118 event.target.value.length;
120 move_data = event.target.value.substring(start,end);
121 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
122 event.target.setAttribute('size', event.target.value.length + 2);
124 element.setChildren( event.target.value );
126 } else if (element.localName() == 'code') {
127 index_sf = element.parent();
128 target = event.target.parentNode;
129 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
130 index_sf = element.parent().children()[element.parent().children().length() - 1];
131 target = event.target.parentNode.lastChild.lastChild;
134 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
136 index_sf.parent().insertChildAfter( index_sf, sf );
138 var new_sf = marcSubfield(sf);
140 if (target === target.parentNode.lastChild) {
141 target.parentNode.appendChild( new_sf );
143 target.parentNode.insertBefore( new_sf, target.nextSibling );
146 new_sf.firstChild.nextSibling.focus();
148 event.preventDefault();
151 } else if (event.keyCode == 13 || event.keyCode == 77) {
152 if (event.ctrlKey) { // ctrl+enter
155 if (element.localName() == 'subfield') index = element.parent();
156 if (element.localName() == 'code') index = element.parent().parent();
157 if (element.localName() == 'tag') index = element.parent();
158 if (element.localName() == 'ind1') index = element.parent();
159 if (element.localName() == 'ind2') index = element.parent();
161 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
163 index.parent().insertChildAfter( index, df );
165 var new_df = marcDatafield(df);
167 if (row.parentNode.lastChild === row) {
168 row.parentNode.appendChild( new_df );
170 row.parentNode.insertBefore( new_df, row.nextSibling );
173 new_df.firstChild.focus();
175 event.preventDefault();
178 } else if (event.shiftKey) {
179 if (row.previousSibling.className.match('marcDatafieldRow'))
180 row.previousSibling.firstChild.focus();
182 row.nextSibling.firstChild.focus();
185 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
188 if (element.localName() == 'subfield') index = element.parent();
189 if (element.localName() == 'code') index = element.parent().parent();
190 if (element.localName() == 'tag') index = element.parent();
191 if (element.localName() == 'ind1') index = element.parent();
192 if (element.localName() == 'ind2') index = element.parent();
194 for (var i in index.parent().children()) {
195 if (index === index.parent().children()[i]) {
196 delete index.parent().children()[i];
201 row.previousSibling.firstChild.focus();
202 row.parentNode.removeChild(row);
204 event.preventDefault();
207 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
210 if (element.localName() == 'subfield') index = element;
211 if (element.localName() == 'code') index = element.parent();
214 for (var i in index.parent().children()) {
215 if (index === index.parent().children()[i]) {
216 delete index.parent().children()[i];
221 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
222 event.target.parentNode.previousSibling.lastChild.focus();
224 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
227 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
229 event.preventDefault();
236 box.addEventListener(
239 if (element.nodeKind() == 'attribute') element[0]=box.value;
240 else element.setChildren( box.value );
246 box.addEventListener(
249 if (element.nodeKind() == 'attribute') element[0]=box.value;
250 else element.setChildren( box.value );
256 box.addEventListener(
259 if (element.nodeKind() == 'attribute') element[0]=box.value;
260 else element.setChildren( box.value );
270 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
271 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
272 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
273 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
274 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
275 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
276 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
277 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
283 BKS : {start : 15, len : 3, def : ' ' },
284 SER : {start : 15, len : 3, def : ' ' },
285 VIS : {start : 15, len : 3, def : ' ' },
286 MIX : {start : 15, len : 3, def : ' ' },
287 MAP : {start : 15, len : 3, def : ' ' },
288 SCO : {start : 15, len : 3, def : ' ' },
289 REC : {start : 15, len : 3, def : ' ' },
290 COM : {start : 15, len : 3, def : ' ' },
295 BKS : {start : 35, len : 3, def : ' ' },
296 SER : {start : 35, len : 3, def : ' ' },
297 VIS : {start : 35, len : 3, def : ' ' },
298 MIX : {start : 35, len : 3, def : ' ' },
299 MAP : {start : 35, len : 3, def : ' ' },
300 SCO : {start : 35, len : 3, def : ' ' },
301 REC : {start : 35, len : 3, def : ' ' },
302 COM : {start : 35, len : 3, def : ' ' },
307 BKS : {start : 38, len : 1, def : ' ' },
308 SER : {start : 38, len : 1, def : ' ' },
309 VIS : {start : 38, len : 1, def : ' ' },
310 MIX : {start : 38, len : 1, def : ' ' },
311 MAP : {start : 38, len : 1, def : ' ' },
312 SCO : {start : 38, len : 1, def : ' ' },
313 REC : {start : 38, len : 1, def : ' ' },
314 COM : {start : 38, len : 1, def : ' ' },
319 BKS : {start : 6, len : 1, def : ' ' },
320 SER : {start : 6, len : 1, def : 'c' },
321 VIS : {start : 6, len : 1, def : ' ' },
322 MIX : {start : 6, len : 1, def : ' ' },
323 MAP : {start : 6, len : 1, def : ' ' },
324 SCO : {start : 6, len : 1, def : ' ' },
325 REC : {start : 6, len : 1, def : ' ' },
326 COM : {start : 6, len : 1, def : ' ' },
331 BKS : {start : 6, len : 1, def : 'a' },
332 SER : {start : 6, len : 1, def : 'a' },
333 VIS : {start : 6, len : 1, def : 'g' },
334 MIX : {start : 6, len : 1, def : 'p' },
335 MAP : {start : 6, len : 1, def : 'e' },
336 SCO : {start : 6, len : 1, def : 'c' },
337 REC : {start : 6, len : 1, def : 'i' },
338 COM : {start : 6, len : 1, def : 'm' },
343 BKS : {start : 8, len : 1, def : ' ' },
344 SER : {start : 8, len : 1, def : ' ' },
345 VIS : {start : 8, len : 1, def : ' ' },
346 MIX : {start : 8, len : 1, def : ' ' },
347 MAP : {start : 8, len : 1, def : ' ' },
348 SCO : {start : 8, len : 1, def : ' ' },
349 REC : {start : 8, len : 1, def : ' ' },
350 COM : {start : 8, len : 1, def : ' ' },
355 BKS : {start : 7, len : 1, def : 'm' },
356 SER : {start : 7, len : 1, def : 's' },
357 VIS : {start : 7, len : 1, def : 'm' },
358 MIX : {start : 7, len : 1, def : 'c' },
359 MAP : {start : 7, len : 1, def : 'm' },
360 SCO : {start : 7, len : 1, def : 'm' },
361 REC : {start : 7, len : 1, def : 'm' },
362 COM : {start : 7, len : 1, def : 'm' },
367 BKS : {start : 18, len : 1, def : ' ' },
368 SER : {start : 18, len : 1, def : ' ' },
369 VIS : {start : 18, len : 1, def : ' ' },
370 MIX : {start : 18, len : 1, def : ' ' },
371 MAP : {start : 18, len : 1, def : ' ' },
372 SCO : {start : 18, len : 1, def : ' ' },
373 REC : {start : 18, len : 1, def : ' ' },
374 COM : {start : 18, len : 1, def : ' ' },
379 BKS : {start : 17, len : 1, def : ' ' },
380 SER : {start : 17, len : 1, def : ' ' },
381 VIS : {start : 17, len : 1, def : ' ' },
382 MIX : {start : 17, len : 1, def : ' ' },
383 MAP : {start : 17, len : 1, def : ' ' },
384 SCO : {start : 17, len : 1, def : ' ' },
385 REC : {start : 17, len : 1, def : ' ' },
386 COM : {start : 17, len : 1, def : ' ' },
391 BKS : {start : 31, len : 1, def : '0' },
392 MAP : {start : 31, len : 1, def : '0' },
395 BKS : {start : 14, len : 1, def : '0' },
396 MAP : {start : 14, len : 1, def : '0' },
401 BKS : {start : 7, len : 4, def : ' ' },
402 SER : {start : 7, len : 4, def : ' ' },
403 VIS : {start : 7, len : 4, def : ' ' },
404 MIX : {start : 7, len : 4, def : ' ' },
405 MAP : {start : 7, len : 4, def : ' ' },
406 SCO : {start : 7, len : 4, def : ' ' },
407 REC : {start : 7, len : 4, def : ' ' },
408 COM : {start : 7, len : 4, def : ' ' },
413 BKS : {start : 11, len : 4, def : ' ' },
414 SER : {start : 11, len : 4, def : '9' },
415 VIS : {start : 11, len : 4, def : ' ' },
416 MIX : {start : 11, len : 4, def : ' ' },
417 MAP : {start : 11, len : 4, def : ' ' },
418 SCO : {start : 11, len : 4, def : ' ' },
419 REC : {start : 11, len : 4, def : ' ' },
420 COM : {start : 11, len : 4, def : ' ' },
425 BKS : {start : 33, len : 1, def : '0' },
428 BKS : {start : 16, len : 1, def : '0' },
433 BKS : {start : 34, len : 1, def : ' ' },
436 BKS : {start : 17, len : 1, def : ' ' },
441 BKS : {start : 18, len : 4, def : ' ' },
444 BKS : {start : 1, len : 4, def : ' ' },
449 BKS : {start : 30, len : 1, def : '0' },
452 BKS : {start : 13, len : 1, def : '0' },
457 BKS : {start : 24, len : 4, def : ' ' },
458 SER : {start : 25, len : 3, def : ' ' },
461 BKS : {start : 7, len : 4, def : ' ' },
462 SER : {start : 8, len : 3, def : ' ' },
467 BKS : {start : 28, len : 1, def : ' ' },
468 SER : {start : 28, len : 1, def : ' ' },
469 VIS : {start : 28, len : 1, def : ' ' },
470 MAP : {start : 28, len : 1, def : ' ' },
471 COM : {start : 28, len : 1, def : ' ' },
474 BKS : {start : 11, len : 1, def : ' ' },
475 SER : {start : 11, len : 1, def : ' ' },
476 VIS : {start : 11, len : 1, def : ' ' },
477 MAP : {start : 11, len : 1, def : ' ' },
478 COM : {start : 11, len : 1, def : ' ' },
483 BKS : {start : 22, len : 1, def : ' ' },
484 SER : {start : 22, len : 1, def : ' ' },
485 VIS : {start : 22, len : 1, def : ' ' },
486 SCO : {start : 22, len : 1, def : ' ' },
487 REC : {start : 22, len : 1, def : ' ' },
488 COM : {start : 22, len : 1, def : ' ' },
491 BKS : {start : 5, len : 1, def : ' ' },
492 SER : {start : 5, len : 1, def : ' ' },
493 VIS : {start : 5, len : 1, def : ' ' },
494 SCO : {start : 5, len : 1, def : ' ' },
495 REC : {start : 5, len : 1, def : ' ' },
496 COM : {start : 5, len : 1, def : ' ' },
501 BKS : {start : 23, len : 1, def : ' ' },
502 SER : {start : 23, len : 1, def : ' ' },
503 VIS : {start : 29, len : 1, def : ' ' },
504 MIX : {start : 23, len : 1, def : ' ' },
505 MAP : {start : 29, len : 1, def : ' ' },
506 SCO : {start : 23, len : 1, def : ' ' },
507 REC : {start : 23, len : 1, def : ' ' },
510 BKS : {start : 6, len : 1, def : ' ' },
511 SER : {start : 6, len : 1, def : ' ' },
512 VIS : {start : 12, len : 1, def : ' ' },
513 MIX : {start : 6, len : 1, def : ' ' },
514 MAP : {start : 12, len : 1, def : ' ' },
515 SCO : {start : 6, len : 1, def : ' ' },
516 REC : {start : 6, len : 1, def : ' ' },
521 SER : {start : 34, len : 1, def : '0' },
524 SER : {start : 17, len : 1, def : '0' },
529 SER : {start : 33, len : 1, def : ' ' },
532 SER : {start : 16, len : 1, def : ' ' },
537 function recordType (rec) {
538 var _l = rec.leader.toString();
540 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
541 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
543 for (var t in rec_type) {
544 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
545 document.getElementById('recordTypeLabel').value = t;
552 function toggleFFE () {
553 var grid = document.getElementById('leaderGrid');
562 function changeFFEditor (type) {
563 var grid = document.getElementById('leaderGrid');
564 grid.setAttribute('type',type);
567 function fillFixedFields (rec) {
568 var grid = document.getElementById('leaderGrid');
570 var rtype = _record_type;
572 var _l = rec.leader.toString();
573 var _6 = rec.controlfield.(@tag=='006').toString();
574 var _7 = rec.controlfield.(@tag=='007').toString();
575 var _8 = rec.controlfield.(@tag=='008').toString();
578 var pre_list = grid.getElementsByTagName('label');
579 for (var i in pre_list) {
580 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
581 list.push( pre_list[i] );
585 for (var i in list) {
586 var name = list[i].getAttribute('name');
592 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
593 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
595 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
596 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
598 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
599 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
601 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
602 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
607 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
608 d = ff_pos[name].ldr[rtype].def;
612 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
613 d = ff_pos[name]._8[rtype].def;
617 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
618 d = ff_pos[name]._6[rtype].def;
622 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
623 d = ff_pos[name]._7[rtype].def;
628 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
634 list[i].nextSibling.value = value;
640 function updateFixedFields (element) {
641 var grid = document.getElementById('leaderGrid');
642 var recGrid = document.getElementById('recGrid');
644 var rtype = _record_type;
645 var new_value = element.value;
648 ldr : _record.leader,
649 _6 : _record.controlfield.(@tag=='006'),
650 _7 : _record.controlfield.(@tag=='007'),
651 _8 : _record.controlfield.(@tag=='008'),
654 var name = element.getAttribute('name');
655 for (var i in ff_pos[name]) {
657 if (!ff_pos[name][i][rtype]) continue;
658 if (!parts[i]) continue;
660 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
661 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
663 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
664 new_value += ff_pos[name][i][rtype].def;
667 parts[i].setChildren( before + new_value + after );
668 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
674 function marcLeader (leader) {
676 { class : 'marcLeaderRow',
681 tooltiptext : "MARC Leader" } ),
684 class : 'marcInd1' } ),
687 class : 'marcInd2' } ),
689 { value : leader.text(),
690 class : 'marcLeader' } )
696 function marcControlfield (field) {
697 tagname = field.@tag.toString().substr(2);
699 { class : 'marcControlfieldRow',
700 tag : '_' + tagname },
702 { value : field.@tag,
704 onmouseover : 'getTooltip(this, "tag");',
705 tooltipid : 'tag' + field.@tag } ),
707 { value : field.@ind1,
709 onmouseover : 'getTooltip(this, "ind1");',
710 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
712 { value : field.@ind2,
714 onmouseover : 'getTooltip(this, "ind2");',
715 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
717 { value : field.text(),
718 class : 'marcControlfield' } )
724 function stackSubfields(checkbox) {
725 var list = document.getElementsByAttribute('name','sf_box');
728 if (checkbox.checked) o = 'horizontal';
730 for (var i in list) {
731 if (list[i]) list[i].setAttribute('orient',o);
735 function marcDatafield (field) {
737 { class : 'marcDatafieldRow' },
740 { value : field.@tag,
741 class : 'plain marcTag',
743 context : 'tags_popup',
744 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
747 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
750 { value : field.@ind1,
751 class : 'plain marcInd1',
753 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
756 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
757 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
760 { value : field.@ind2,
761 class : 'plain marcInd2',
763 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
766 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
767 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
768 createHbox({ name : 'sf_box' })
771 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
772 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
773 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
775 var sf_box = row.lastChild;
776 if (document.getElementById('stackSubfields').checked)
777 sf_box.setAttribute('orient','vertical');
779 sf_box.addEventListener(
782 if (sf_box === e.target) {
783 sf_box.lastChild.lastChild.focus();
784 } else if (e.target.parentNode === sf_box) {
785 e.target.lastChild.focus();
792 for (var i in field.subfield) {
793 var sf = field.subfield[i];
798 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
799 current_focus = sf_box.lastChild.childNodes[1];
805 function marcSubfield (sf) {
807 { class : 'marcSubfieldBox' },
810 class : 'plain marcSubfieldDelimiter',
811 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
812 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
813 //onclick : 'this.nextSibling.focus();',
814 onfocus : 'this.nextSibling.focus();',
819 class : 'plain marcSubfieldCode',
820 name : 'marcSubfieldCode',
821 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
822 oncontextmenu : 'getContextMenu(this, "subfield");',
823 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
829 name : sf.parent().@tag + ':' + sf.@code,
830 class : 'plain marcSubfield',
831 onmouseover : 'getTooltip(this, "subfield");',
832 contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
833 size : new String(sf.text()).length + 2,
834 oninput : "this.setAttribute('size', this.value.length + 2);",
839 function loadRecord(rec) {
841 var grid_rows = document.getElementById('recGrid').lastChild;
843 grid_rows.appendChild( marcLeader( rec.leader ) );
845 for (var i in rec.controlfield) {
846 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
849 for (var i in rec.datafield) {
850 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
853 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
854 changeFFEditor(recordType(rec));
855 fillFixedFields(rec);
858 var context_menus = createComplexXULElement('popupset');
859 document.documentElement.appendChild( context_menus );
861 var tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
862 context_menus.appendChild( tag_menu );
864 tag_menu.appendChild(
868 'var e = document.createEvent("KeyEvents");' +
869 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
870 'current_focus.inputField.dispatchEvent(e);',
875 tag_menu.appendChild(
877 { label : 'Remove Row',
879 'var e = document.createEvent("KeyEvents");' +
880 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
881 'current_focus.inputField.dispatchEvent(e);',
886 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
890 function genToolTips () {
891 for (var i in bib_data.field) {
892 var f = bib_data.field[i];
894 tag_menu.appendChild(
898 'current_focus.value = "' + f.@tag + '";' +
899 'var e = document.createEvent("MutationEvents");' +
900 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
901 'current_focus.inputField.dispatchEvent(e);',
902 disabled : f.@tag < '010' ? "true" : "false",
903 tooltiptext : f.description }
907 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
908 context_menus.appendChild( i1_popup );
910 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
911 context_menus.appendChild( i2_popup );
913 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
914 context_menus.appendChild( sf_popup );
916 tooltip_hash['tag' + f.@tag] = f.description;
917 for (var j in f.indicator) {
918 var ind = f.indicator[j];
919 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
921 if (ind.@position == 1) {
922 i1_popup.appendChild(
924 { label : ind.@value,
926 'current_focus.value = "' + ind.@value + '";' +
927 'var e = document.createEvent("MutationEvents");' +
928 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
929 'current_focus.inputField.dispatchEvent(e);',
930 tooltiptext : ind.description }
935 if (ind.@position == 2) {
936 i2_popup.appendChild(
938 { label : ind.@value,
940 'current_focus.value = "' + ind.@value + '";' +
941 'var e = document.createEvent("MutationEvents");' +
942 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
943 'current_focus.inputField.dispatchEvent(e);',
944 tooltiptext : ind.description }
950 for (var j in f.subfield) {
951 var sf = f.subfield[j];
952 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
954 sf_popup.appendChild(
958 'current_focus.value = "' + sf.@code + '";' +
959 'var e = document.createEvent("MutationEvents");' +
960 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
961 'current_focus.inputField.dispatchEvent(e);',
962 tooltiptext : sf.description,
970 var p = createComplexXULElement('popupset');
971 document.documentElement.appendChild( p );
973 function getTooltip (target, type) {
976 if (type == 'subfield')
977 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
980 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
983 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
986 tt = 'tag' + target.parentNode.firstChild.value;
988 if (!document.getElementById( tt )) {
994 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
996 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
1001 target.tooltip = tt;
1005 function getContextMenu (target, type) {
1008 if (type == 'subfield')
1009 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
1012 tt = 't' + target.parentNode.firstChild.value + 'i1';
1015 tt = 't' + target.parentNode.firstChild.value + 'i2';
1017 target.setAttribute('context', tt);
1021 function getAuthorityContextMenu (target, sf) {
1022 var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context';
1024 if (target.getAttribute('context')) return true;
1026 var sf_popup = createPopup({position : 'after_start', id : menu_id });
1027 context_menus.appendChild( sf_popup );
1030 sf_popup.appendChild(
1033 createMenuPopup( {},
1037 'current_focus.value = "' + val + '";' +
1038 'var e = document.createEvent("MutationEvents");' +
1039 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
1040 'current_focus.inputField.dispatchEvent(e);',
1041 tooltiptext : val + ' description'
1048 target.setAttribute('context', menu_id);