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) l.setAttribute(i,attrs[i]);
36 for ( var i in objects ) l.appendChild( objects[i] );
42 function createDescription (attrs) {
43 return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
46 function createTooltip (attrs) {
47 return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
50 function createLabel (attrs) {
51 return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
54 function createVbox (attrs) {
55 return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
58 function createHbox (attrs) {
59 return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
62 function createRow (attrs) {
63 return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
66 function createTextbox (attrs) {
67 return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
70 function createPopup (attrs) {
71 return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
74 function createMenuitem (attrs) {
75 return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
78 function createMARCTextbox (element,attrs) {
80 var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
81 box.onkeypress = function (event) {
84 while(node = node.parent()) {
88 var row = event.target;
89 while (row.tagName != 'row') row = row.parentNode;
91 if (element.nodeKind() == 'attribute') element[0]=box.value;
92 else element.setChildren( box.value );
94 if (event.charCode == 100 && event.ctrlKey) { // ctrl+d
96 var index_sf, target, move_data;
97 if (element.localName() == 'subfield') {
99 target = event.target.parentNode;
101 var start = event.target.selectionStart;
102 var end = event.target.selectionEnd - event.target.selectionStart ?
103 event.target.selectionEnd :
104 event.target.value.length;
106 move_data = event.target.value.substring(start,end);
107 event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
108 event.target.setAttribute('size', event.target.value.length + 2);
110 element.setChildren( event.target.value );
112 } else if (element.localName() == 'code') {
113 index_sf = element.parent();
114 target = event.target.parentNode;
115 } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
116 index_sf = element.parent().children()[element.parent().children().length() - 1];
117 target = event.target.parentNode.lastChild.lastChild;
120 var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
122 index_sf.parent().insertChildAfter( index_sf, sf );
124 var new_sf = marcSubfield(sf);
126 if (target === target.parentNode.lastChild) {
127 target.parentNode.appendChild( new_sf );
129 target.parentNode.insertBefore( new_sf, target.nextSibling );
132 new_sf.firstChild.nextSibling.focus();
134 event.preventDefault();
137 } else if (event.keyCode == 13 || event.keyCode == 77) {
138 if (event.ctrlKey) { // ctrl+enter
141 if (element.localName() == 'subfield') index = element.parent();
142 if (element.localName() == 'code') index = element.parent().parent();
143 if (element.localName() == 'tag') index = element.parent();
144 if (element.localName() == 'ind1') index = element.parent();
145 if (element.localName() == 'ind2') index = element.parent();
147 var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
149 index.parent().insertChildAfter( index, df );
151 var new_df = marcDatafield(df);
153 if (row.parentNode.lastChild === row) {
154 row.parentNode.appendChild( new_df );
156 row.parentNode.insertBefore( new_df, row.nextSibling );
159 new_df.firstChild.focus();
161 event.preventDefault();
164 } else if (event.shiftKey) {
165 if (row.previousSibling.className.match('marcDatafieldRow'))
166 row.previousSibling.firstChild.focus();
168 row.nextSibling.firstChild.focus();
171 } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
174 if (element.localName() == 'subfield') index = element.parent();
175 if (element.localName() == 'code') index = element.parent().parent();
176 if (element.localName() == 'tag') index = element.parent();
177 if (element.localName() == 'ind1') index = element.parent();
178 if (element.localName() == 'ind2') index = element.parent();
180 for (var i in index.parent().children()) {
181 if (index === index.parent().children()[i]) {
182 delete index.parent().children()[i];
187 row.previousSibling.firstChild.focus();
188 row.parentNode.removeChild(row);
190 event.preventDefault();
193 } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
196 if (element.localName() == 'subfield') index = element;
197 if (element.localName() == 'code') index = element.parent();
200 for (var i in index.parent().children()) {
201 if (index === index.parent().children()[i]) {
202 delete index.parent().children()[i];
207 if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
208 event.target.parentNode.previousSibling.lastChild.focus();
210 event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
213 event.target.parentNode.parentNode.removeChild(event.target.parentNode);
215 event.preventDefault();
222 box.addEventListener(
225 if (element.nodeKind() == 'attribute') element[0]=box.value;
226 else element.setChildren( box.value );
232 box.addEventListener(
235 if (element.nodeKind() == 'attribute') element[0]=box.value;
236 else element.setChildren( box.value );
242 box.addEventListener(
245 if (element.nodeKind() == 'attribute') element[0]=box.value;
246 else element.setChildren( box.value );
256 BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
257 SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
258 VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
259 MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
260 MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
261 SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
262 REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
263 COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
269 BKS : {start : 15, len : 3, def : ' ' },
270 SER : {start : 15, len : 3, def : ' ' },
271 VIS : {start : 15, len : 3, def : ' ' },
272 MIX : {start : 15, len : 3, def : ' ' },
273 MAP : {start : 15, len : 3, def : ' ' },
274 SCO : {start : 15, len : 3, def : ' ' },
275 REC : {start : 15, len : 3, def : ' ' },
276 COM : {start : 15, len : 3, def : ' ' },
281 BKS : {start : 35, len : 3, def : ' ' },
282 SER : {start : 35, len : 3, def : ' ' },
283 VIS : {start : 35, len : 3, def : ' ' },
284 MIX : {start : 35, len : 3, def : ' ' },
285 MAP : {start : 35, len : 3, def : ' ' },
286 SCO : {start : 35, len : 3, def : ' ' },
287 REC : {start : 35, len : 3, def : ' ' },
288 COM : {start : 35, len : 3, def : ' ' },
293 BKS : {start : 38, len : 1, def : ' ' },
294 SER : {start : 38, len : 1, def : ' ' },
295 VIS : {start : 38, len : 1, def : ' ' },
296 MIX : {start : 38, len : 1, def : ' ' },
297 MAP : {start : 38, len : 1, def : ' ' },
298 SCO : {start : 38, len : 1, def : ' ' },
299 REC : {start : 38, len : 1, def : ' ' },
300 COM : {start : 38, len : 1, def : ' ' },
305 BKS : {start : 6, len : 1, def : ' ' },
306 SER : {start : 6, len : 1, def : 'c' },
307 VIS : {start : 6, len : 1, def : ' ' },
308 MIX : {start : 6, len : 1, def : ' ' },
309 MAP : {start : 6, len : 1, def : ' ' },
310 SCO : {start : 6, len : 1, def : ' ' },
311 REC : {start : 6, len : 1, def : ' ' },
312 COM : {start : 6, len : 1, def : ' ' },
317 BKS : {start : 6, len : 1, def : 'a' },
318 SER : {start : 6, len : 1, def : 'a' },
319 VIS : {start : 6, len : 1, def : 'g' },
320 MIX : {start : 6, len : 1, def : 'p' },
321 MAP : {start : 6, len : 1, def : 'e' },
322 SCO : {start : 6, len : 1, def : 'c' },
323 REC : {start : 6, len : 1, def : 'i' },
324 COM : {start : 6, len : 1, def : 'm' },
329 BKS : {start : 8, len : 1, def : ' ' },
330 SER : {start : 8, len : 1, def : ' ' },
331 VIS : {start : 8, len : 1, def : ' ' },
332 MIX : {start : 8, len : 1, def : ' ' },
333 MAP : {start : 8, len : 1, def : ' ' },
334 SCO : {start : 8, len : 1, def : ' ' },
335 REC : {start : 8, len : 1, def : ' ' },
336 COM : {start : 8, len : 1, def : ' ' },
341 BKS : {start : 7, len : 1, def : 'm' },
342 SER : {start : 7, len : 1, def : 's' },
343 VIS : {start : 7, len : 1, def : 'm' },
344 MIX : {start : 7, len : 1, def : 'c' },
345 MAP : {start : 7, len : 1, def : 'm' },
346 SCO : {start : 7, len : 1, def : 'm' },
347 REC : {start : 7, len : 1, def : 'm' },
348 COM : {start : 7, len : 1, def : 'm' },
353 BKS : {start : 18, len : 1, def : ' ' },
354 SER : {start : 18, len : 1, def : ' ' },
355 VIS : {start : 18, len : 1, def : ' ' },
356 MIX : {start : 18, len : 1, def : ' ' },
357 MAP : {start : 18, len : 1, def : ' ' },
358 SCO : {start : 18, len : 1, def : ' ' },
359 REC : {start : 18, len : 1, def : ' ' },
360 COM : {start : 18, len : 1, def : ' ' },
365 BKS : {start : 17, len : 1, def : ' ' },
366 SER : {start : 17, len : 1, def : ' ' },
367 VIS : {start : 17, len : 1, def : ' ' },
368 MIX : {start : 17, len : 1, def : ' ' },
369 MAP : {start : 17, len : 1, def : ' ' },
370 SCO : {start : 17, len : 1, def : ' ' },
371 REC : {start : 17, len : 1, def : ' ' },
372 COM : {start : 17, len : 1, def : ' ' },
377 BKS : {start : 31, len : 1, def : '0' },
378 MAP : {start : 31, len : 1, def : '0' },
381 BKS : {start : 14, len : 1, def : '0' },
382 MAP : {start : 14, len : 1, def : '0' },
387 BKS : {start : 7, len : 4, def : ' ' },
388 SER : {start : 7, len : 4, def : ' ' },
389 VIS : {start : 7, len : 4, def : ' ' },
390 MIX : {start : 7, len : 4, def : ' ' },
391 MAP : {start : 7, len : 4, def : ' ' },
392 SCO : {start : 7, len : 4, def : ' ' },
393 REC : {start : 7, len : 4, def : ' ' },
394 COM : {start : 7, len : 4, def : ' ' },
399 BKS : {start : 11, len : 4, def : ' ' },
400 SER : {start : 11, len : 4, def : '9' },
401 VIS : {start : 11, len : 4, def : ' ' },
402 MIX : {start : 11, len : 4, def : ' ' },
403 MAP : {start : 11, len : 4, def : ' ' },
404 SCO : {start : 11, len : 4, def : ' ' },
405 REC : {start : 11, len : 4, def : ' ' },
406 COM : {start : 11, len : 4, def : ' ' },
411 BKS : {start : 33, len : 1, def : '0' },
414 BKS : {start : 16, len : 1, def : '0' },
419 BKS : {start : 34, len : 1, def : ' ' },
422 BKS : {start : 17, len : 1, def : ' ' },
427 BKS : {start : 18, len : 4, def : ' ' },
430 BKS : {start : 1, len : 4, def : ' ' },
435 BKS : {start : 30, len : 1, def : '0' },
438 BKS : {start : 13, len : 1, def : '0' },
443 BKS : {start : 24, len : 4, def : ' ' },
444 SER : {start : 25, len : 3, def : ' ' },
447 BKS : {start : 7, len : 4, def : ' ' },
448 SER : {start : 8, len : 3, def : ' ' },
453 BKS : {start : 28, len : 1, def : ' ' },
454 SER : {start : 28, len : 1, def : ' ' },
455 VIS : {start : 28, len : 1, def : ' ' },
456 MAP : {start : 28, len : 1, def : ' ' },
457 COM : {start : 28, len : 1, def : ' ' },
460 BKS : {start : 11, len : 1, def : ' ' },
461 SER : {start : 11, len : 1, def : ' ' },
462 VIS : {start : 11, len : 1, def : ' ' },
463 MAP : {start : 11, len : 1, def : ' ' },
464 COM : {start : 11, len : 1, def : ' ' },
469 BKS : {start : 22, len : 1, def : ' ' },
470 SER : {start : 22, len : 1, def : ' ' },
471 VIS : {start : 22, len : 1, def : ' ' },
472 SCO : {start : 22, len : 1, def : ' ' },
473 REC : {start : 22, len : 1, def : ' ' },
474 COM : {start : 22, len : 1, def : ' ' },
477 BKS : {start : 5, len : 1, def : ' ' },
478 SER : {start : 5, len : 1, def : ' ' },
479 VIS : {start : 5, len : 1, def : ' ' },
480 SCO : {start : 5, len : 1, def : ' ' },
481 REC : {start : 5, len : 1, def : ' ' },
482 COM : {start : 5, len : 1, def : ' ' },
487 BKS : {start : 23, len : 1, def : ' ' },
488 SER : {start : 23, len : 1, def : ' ' },
489 VIS : {start : 29, len : 1, def : ' ' },
490 MIX : {start : 23, len : 1, def : ' ' },
491 MAP : {start : 29, len : 1, def : ' ' },
492 SCO : {start : 23, len : 1, def : ' ' },
493 REC : {start : 23, len : 1, def : ' ' },
496 BKS : {start : 6, len : 1, def : ' ' },
497 SER : {start : 6, len : 1, def : ' ' },
498 VIS : {start : 12, len : 1, def : ' ' },
499 MIX : {start : 6, len : 1, def : ' ' },
500 MAP : {start : 12, len : 1, def : ' ' },
501 SCO : {start : 6, len : 1, def : ' ' },
502 REC : {start : 6, len : 1, def : ' ' },
507 SER : {start : 34, len : 1, def : '0' },
510 SER : {start : 17, len : 1, def : '0' },
515 SER : {start : 33, len : 1, def : ' ' },
518 SER : {start : 16, len : 1, def : ' ' },
523 function recordType (rec) {
524 var _l = rec.leader.toString();
526 var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
527 var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
529 for (var t in rec_type) {
530 if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
531 document.getElementById('recordTypeLabel').value = t;
538 function toggleFFE () {
539 var grid = document.getElementById('leaderGrid');
548 function changeFFEditor (type) {
549 var grid = document.getElementById('leaderGrid');
550 grid.setAttribute('type',type);
553 function fillFixedFields (rec) {
554 var grid = document.getElementById('leaderGrid');
556 var rtype = _record_type;
558 var _l = rec.leader.toString();
559 var _6 = rec.controlfield.(@tag=='006').toString();
560 var _7 = rec.controlfield.(@tag=='007').toString();
561 var _8 = rec.controlfield.(@tag=='008').toString();
564 var pre_list = grid.getElementsByTagName('label');
565 for (var i in pre_list) {
566 if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
567 list.push( pre_list[i] );
571 for (var i in list) {
572 var name = list[i].getAttribute('name');
578 if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
579 value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
581 if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
582 value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
584 if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
585 value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
587 if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
588 value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
593 if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
594 d = ff_pos[name].ldr[rtype].def;
598 if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
599 d = ff_pos[name]._8[rtype].def;
603 if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
604 d = ff_pos[name]._6[rtype].def;
608 if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
609 d = ff_pos[name]._7[rtype].def;
614 for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
620 list[i].nextSibling.value = value;
626 function updateFixedFields (element) {
627 var grid = document.getElementById('leaderGrid');
628 var recGrid = document.getElementById('recGrid');
630 var rtype = _record_type;
631 var new_value = element.value;
634 ldr : _record.leader,
635 _6 : _record.controlfield.(@tag=='006'),
636 _7 : _record.controlfield.(@tag=='007'),
637 _8 : _record.controlfield.(@tag=='008'),
640 var name = element.getAttribute('name');
641 for (var i in ff_pos[name]) {
643 if (!ff_pos[name][i][rtype]) continue;
644 if (!parts[i]) continue;
646 var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
647 var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
649 for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
650 new_value += ff_pos[name][i][rtype].def;
653 parts[i].setChildren( before + new_value + after );
654 recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
660 function marcLeader (leader) {
662 { class : 'marcLeaderRow',
667 tooltiptext : "MARC Leader" } ),
670 class : 'marcInd1' } ),
673 class : 'marcInd2' } ),
675 { value : leader.text(),
676 class : 'marcLeader' } )
682 function marcControlfield (field) {
683 tagname = field.@tag.toString().substr(2);
685 { class : 'marcControlfieldRow',
686 tag : '_' + tagname },
688 { value : field.@tag,
690 onmouseover : 'getTooltip(this, "tag");',
691 tooltipid : 'tag' + field.@tag } ),
693 { value : field.@ind1,
695 onmouseover : 'getTooltip(this, "ind1");',
696 tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
698 { value : field.@ind2,
700 onmouseover : 'getTooltip(this, "ind2");',
701 tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
703 { value : field.text(),
704 class : 'marcControlfield' } )
710 function stackSubfields(checkbox) {
711 var list = document.getElementsByAttribute('name','sf_box');
714 if (checkbox.checked) o = 'horizontal';
716 for (var i in list) {
717 if (list[i]) list[i].setAttribute('orient',o);
721 function marcDatafield (field) {
723 { class : 'marcDatafieldRow' },
726 { value : field.@tag,
727 class : 'plain marcTag',
729 context : 'tags_popup',
730 oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
733 onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
736 { value : field.@ind1,
737 class : 'plain marcInd1',
739 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
742 onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
743 oncontextmenu : 'getContextMenu(this, "ind1");' } ),
746 { value : field.@ind2,
747 class : 'plain marcInd2',
749 oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
752 onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
753 oncontextmenu : 'getContextMenu(this, "ind2");' } ),
754 createHbox({ name : 'sf_box' })
757 if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
758 if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
759 if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
761 var sf_box = row.lastChild;
762 if (document.getElementById('stackSubfields').checked)
763 sf_box.setAttribute('orient','vertical');
765 sf_box.addEventListener(
768 if (sf_box === e.target) {
769 sf_box.lastChild.lastChild.focus();
770 } else if (e.target.parentNode === sf_box) {
771 e.target.lastChild.focus();
778 for (var i in field.subfield) {
779 var sf = field.subfield[i];
784 if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
785 current_focus = sf_box.lastChild.childNodes[1];
791 function marcSubfield (sf) {
793 { class : 'marcSubfieldBox' },
796 class : 'plain marcSubfieldDelimiter',
797 onmouseover : 'getTooltip(this.nextSibling, "subfield");',
798 oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
799 //onclick : 'this.nextSibling.focus();',
800 onfocus : 'this.nextSibling.focus();',
805 class : 'plain marcSubfieldCode',
806 name : 'marcSubfieldCode',
807 onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
808 oncontextmenu : 'getContextMenu(this, "subfield");',
809 oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
815 class : 'plain marcSubfield',
816 onmouseover : 'getTooltip(this, "subfield");',
817 size : new String(sf.text()).length + 2,
818 oninput : "this.setAttribute('size', this.value.length + 2);",
823 function loadRecord(rec) {
825 var grid_rows = document.getElementById('recGrid').lastChild;
827 grid_rows.appendChild( marcLeader( rec.leader ) );
829 for (var i in rec.controlfield) {
830 grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
833 for (var i in rec.datafield) {
834 grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
837 grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
838 changeFFEditor(recordType(rec));
839 fillFixedFields(rec);
842 var context_menus = createComplexXULElement('popupset');
843 document.documentElement.appendChild( context_menus );
845 var tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
846 context_menus.appendChild( tag_menu );
848 tag_menu.appendChild(
852 'var e = document.createEvent("KeyEvents");' +
853 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
854 'current_focus.inputField.dispatchEvent(e);',
859 tag_menu.appendChild(
861 { label : 'Remove Row',
863 'var e = document.createEvent("KeyEvents");' +
864 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
865 'current_focus.inputField.dispatchEvent(e);',
870 tag_menu.appendChild( createComplexXULElement( 'separator' ) );
874 function genToolTips () {
875 for (var i in bib_data.field) {
876 var f = bib_data.field[i];
878 tag_menu.appendChild(
882 'current_focus.value = "' + f.@tag + '";' +
883 'var e = document.createEvent("MutationEvents");' +
884 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
885 'current_focus.inputField.dispatchEvent(e);',
886 disabled : f.@tag < '010' ? "true" : "false",
887 tooltiptext : f.description }
891 var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
892 context_menus.appendChild( i1_popup );
894 var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
895 context_menus.appendChild( i2_popup );
897 var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
898 context_menus.appendChild( sf_popup );
900 tooltip_hash['tag' + f.@tag] = f.description;
901 for (var j in f.indicator) {
902 var ind = f.indicator[j];
903 tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
905 if (ind.@position == 1) {
906 i1_popup.appendChild(
908 { label : ind.@value,
910 'current_focus.value = "' + ind.@value + '";' +
911 'var e = document.createEvent("MutationEvents");' +
912 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
913 'current_focus.inputField.dispatchEvent(e);',
914 tooltiptext : ind.description }
919 if (ind.@position == 2) {
920 i2_popup.appendChild(
922 { label : ind.@value,
924 'current_focus.value = "' + ind.@value + '";' +
925 'var e = document.createEvent("MutationEvents");' +
926 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
927 'current_focus.inputField.dispatchEvent(e);',
928 tooltiptext : ind.description }
934 for (var j in f.subfield) {
935 var sf = f.subfield[j];
936 tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
938 sf_popup.appendChild(
942 'current_focus.value = "' + sf.@code + '";' +
943 'var e = document.createEvent("MutationEvents");' +
944 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
945 'current_focus.inputField.dispatchEvent(e);',
946 tooltiptext : sf.description,
954 var p = createComplexXULElement('popupset');
955 document.documentElement.appendChild( p );
957 function getTooltip (target, type) {
960 if (type == 'subfield')
961 tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
964 tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
967 tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
970 tt = 'tag' + target.parentNode.firstChild.value;
972 if (!document.getElementById( tt )) {
978 onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
980 createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
989 function getContextMenu (target, type) {
992 if (type == 'subfield')
993 tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
996 tt = 't' + target.parentNode.firstChild.value + 'i1';
999 tt = 't' + target.parentNode.firstChild.value + 'i2';
1001 target.setAttribute('context', tt);