diff --git a/static/js/infoView.js b/static/js/infoView.js index a459c33..a5a79ba 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -99,12 +99,13 @@ oml.ui.infoView = function(identifyData) { + Ox._(Ox.toTitleCase(key)) + ':  '; } - function formatValue(value, key) { - return (Ox.isArray(value) ? value : [value]).map(function(value) { + function formatValue(value, key, join) { + value = Ox.encodeHTMLEntities(value); + return value ? (Ox.isArray(value) ? value : [value]).map(function(value) { return key ? '' + value + '' : value; - }).join(', '); + }).join(join || ', ') : ''; } function identify(data) { @@ -352,8 +353,8 @@ oml.ui.infoView = function(identifyData) { fontWeight: 'bold' }) .html( - data.title - || '' + data.title ? Ox.encodeHTMLEntities(data.title) + : '' + Ox._('No Title') + '' ) @@ -375,10 +376,10 @@ oml.ui.infoView = function(identifyData) { .css({ marginTop: '8px' }) - .text( - (data.place || []).join(' ; ') + .html( + (formatValue(data.place, 'place', ' ; ')) + (data.place && (data.publisher || data.date) ? ' : ' : '') - + (data.publisher || '') + + (formatValue(data.publisher, 'publisher')) + (data.publisher && data.date ? ', ' : '') + (data.date || '') ) @@ -390,10 +391,10 @@ oml.ui.infoView = function(identifyData) { .css({ marginTop: '8px' }) - .text( - (data.edition || '') + .html( + (Ox.encodeHTMLEntities(data.edition || '')) + (data.edition && data.language ? '; ' : '') - + (data.language || '') + + (formatValue(data.language, 'language')) ) .appendTo($info); } @@ -404,7 +405,9 @@ oml.ui.infoView = function(identifyData) { marginTop: '8px', textAlign: 'justify' }) - .html(Ox.encodeHTMLEntities(data.classification)) + .html( + Ox.formatValue(data.classification, 'classification') + ) .appendTo($info); } @@ -414,7 +417,9 @@ oml.ui.infoView = function(identifyData) { marginTop: '8px', textAlign: 'justify' }) - .html(Ox.encodeHTMLEntities(data.description)) + .html( + Ox.encodeHTMLEntities(data.description) + ) .appendTo($info); } diff --git a/static/txt.js/txt.js b/static/txt.js/txt.js index 8687c21..bf07179 100644 --- a/static/txt.js/txt.js +++ b/static/txt.js/txt.js @@ -5,7 +5,8 @@ txtjs.open = function(url) { Ox.get(url, function(text) { var $body = Ox.$('body') .css({ - backgroundColor: 'rgb(255, 255, 255)' + backgroundColor: 'rgb(255, 255, 255)', + overflowX: 'hidden' }), $text = Ox.$('
') .css({ @@ -29,28 +30,32 @@ txtjs.open = function(url) { .css({ fontSize: '2px', lineHeight: '3px', + cursor: 'pointer', WebkitUserSelect: 'none' }) .on({ - click: function(e) { + mousedown: function(e) { var offset = 'offsetY' in e ? e.offsetY : e.layerY; document.body.scrollTop = offset / factor; - Ox.print('!', offset) + //Ox.print('!', offset) } }) .appendTo($scroll), - scale; + textHeight, scrollTextHeight, factor; text = Ox.encodeHTMLEntities(text) .replace(/\r\n/g, '\n') .replace(/[\r\n]/g, '
'); $text.html(text); $scrollText.html(text); - var textHeight = $text[0].clientHeight, - scrollTextHeight = $scrollText[0].clientHeight, + window.onresize = function() { + textHeight = $text[0].clientHeight - window.innerHeight, + scrollTextHeight = $scrollText[0].clientHeight - (window.innerHeight - 32), factor = scrollTextHeight / textHeight; + }; window.onscroll = function() { $scroll[0].scrollTop = window.pageYOffset * factor; }; + window.onresize(); }); }); }; diff --git a/static/txt.js/txt.py b/static/txt.js/txt.py index d20793f..062c59b 100755 --- a/static/txt.js/txt.py +++ b/static/txt.js/txt.py @@ -30,28 +30,31 @@ def render(infile, outfile): for line in f: - line = line.decode('utf-8').strip() + for line_ in line.decode('utf-8').strip().split('\r'): - lines = wrapText( - line, - image_size[0] - 2 * margin, - # we don't want the last line that ends with an ellipsis - max_lines + 1, - 'txt.ttf', - font_size - ) - - for line_ in lines: - drawText( - image, - (margin, offset), + lines = wrapText( line_, - font_file, - font_size, - (0) + image_size[0] - 2 * margin, + # we don't want the last line that ends with an ellipsis + max_lines + 1, + 'txt.ttf', + font_size ) - offset += line_height - max_lines -= 1 + + for line__ in lines: + drawText( + image, + (margin, offset), + line__, + font_file, + font_size, + (0) + ) + offset += line_height + max_lines -= 1 + + if max_lines == 0: + break if max_lines == 0: break