|
Lines 1-4
Link Here
|
| 1 |
define( [ 'marc-record' ], function( MARC ) { |
1 |
define( [ 'marc-record' ], function( MARC ) { |
|
|
2 |
// Convert any characters for display |
| 3 |
function _sanitize( text ) { |
| 4 |
return text.replace( '$', '{dollar}' ); |
| 5 |
} |
| 6 |
|
| 7 |
// Undo conversion |
| 8 |
function _desanitize( text ) { |
| 9 |
return text.replace( '{dollar}', '$' ); |
| 10 |
} |
| 2 |
return { |
11 |
return { |
| 3 |
RecordToText: function( record ) { |
12 |
RecordToText: function( record ) { |
| 4 |
var lines = []; |
13 |
var lines = []; |
|
Lines 8-14
define( [ 'marc-record' ], function( MARC ) {
Link Here
|
| 8 |
var field = fields[i]; |
17 |
var field = fields[i]; |
| 9 |
|
18 |
|
| 10 |
if ( field.isControlField() ) { |
19 |
if ( field.isControlField() ) { |
| 11 |
lines.push( field.tagnumber() + ' ' + field.subfield( '@' ) ); |
20 |
lines.push( field.tagnumber() + ' ' + _sanitize( field.subfield( '@' ) ) ); |
| 12 |
} else { |
21 |
} else { |
| 13 |
var result = [ field.tagnumber() + ' ' ]; |
22 |
var result = [ field.tagnumber() + ' ' ]; |
| 14 |
|
23 |
|
|
Lines 16-22
define( [ 'marc-record' ], function( MARC ) {
Link Here
|
| 16 |
result.push( field.indicator(1) == ' ' ? '_' : field.indicator(1), ' ' ); |
25 |
result.push( field.indicator(1) == ' ' ? '_' : field.indicator(1), ' ' ); |
| 17 |
|
26 |
|
| 18 |
$.each( field.subfields(), function( i, subfield ) { |
27 |
$.each( field.subfields(), function( i, subfield ) { |
| 19 |
result.push( '$' + subfield[0] + ' ' + subfield[1] ); |
28 |
result.push( '$' + subfield[0] + ' ' + _sanitize( subfield[1] ) ); |
| 20 |
} ); |
29 |
} ); |
| 21 |
|
30 |
|
| 22 |
lines.push( result.join('') ); |
31 |
lines.push( result.join('') ); |
|
Lines 40-46
define( [ 'marc-record' ], function( MARC ) {
Link Here
|
| 40 |
tagNumber = tagNumber[1]; |
49 |
tagNumber = tagNumber[1]; |
| 41 |
|
50 |
|
| 42 |
if ( tagNumber < '010' ) { |
51 |
if ( tagNumber < '010' ) { |
| 43 |
var field = new MARC.Field( tagNumber, ' ', ' ', [ [ '@', line.substring( 4 ) ] ] ); |
52 |
var field = new MARC.Field( tagNumber, ' ', ' ', [ [ '@', _desanitize( line.substring( 4 ) ) ] ] ); |
| 44 |
field.sourceLine = i; |
53 |
field.sourceLine = i; |
| 45 |
record.addField( field ); |
54 |
record.addField( field ); |
| 46 |
} else { |
55 |
} else { |
|
Lines 64-70
define( [ 'marc-record' ], function( MARC ) {
Link Here
|
| 64 |
$.each( subfields, function( i, subfield ) { |
73 |
$.each( subfields, function( i, subfield ) { |
| 65 |
var next = subfields[ i + 1 ]; |
74 |
var next = subfields[ i + 1 ]; |
| 66 |
|
75 |
|
| 67 |
field.addSubfield( [ subfield.code, line.substring( subfield.ch + 3, next ? next.ch : line.length ) ] ); |
76 |
field.addSubfield( [ subfield.code, _desanitize( line.substring( subfield.ch + 3, next ? next.ch : line.length ) ) ] ); |
| 68 |
} ); |
77 |
} ); |
| 69 |
|
78 |
|
| 70 |
field.sourceLine = i; |
79 |
field.sourceLine = i; |