txt.py, infoview fixes
This commit is contained in:
parent
0dbc92d027
commit
16989e9990
3 changed files with 51 additions and 38 deletions
|
@ -99,12 +99,13 @@ oml.ui.infoView = function(identifyData) {
|
|||
+ Ox._(Ox.toTitleCase(key)) + ': </span> ';
|
||||
}
|
||||
|
||||
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 ?
|
||||
'<a href="/' + key + '==' + value + '">' + value + '</a>'
|
||||
: value;
|
||||
}).join(', ');
|
||||
}).join(join || ', ') : '';
|
||||
}
|
||||
|
||||
function identify(data) {
|
||||
|
@ -352,8 +353,8 @@ oml.ui.infoView = function(identifyData) {
|
|||
fontWeight: 'bold'
|
||||
})
|
||||
.html(
|
||||
data.title
|
||||
|| '<span class="OxLight">'
|
||||
data.title ? Ox.encodeHTMLEntities(data.title)
|
||||
: '<span class="OxLight">'
|
||||
+ Ox._('No Title')
|
||||
+ '</span>'
|
||||
)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.$('<div>')
|
||||
.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, '<br>');
|
||||
$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();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -30,10 +30,10 @@ 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,
|
||||
line_,
|
||||
image_size[0] - 2 * margin,
|
||||
# we don't want the last line that ends with an ellipsis
|
||||
max_lines + 1,
|
||||
|
@ -41,11 +41,11 @@ def render(infile, outfile):
|
|||
font_size
|
||||
)
|
||||
|
||||
for line_ in lines:
|
||||
for line__ in lines:
|
||||
drawText(
|
||||
image,
|
||||
(margin, offset),
|
||||
line_,
|
||||
line__,
|
||||
font_file,
|
||||
font_size,
|
||||
(0)
|
||||
|
@ -59,6 +59,9 @@ def render(infile, outfile):
|
|||
if max_lines == 0:
|
||||
break
|
||||
|
||||
if max_lines == 0:
|
||||
break
|
||||
|
||||
image.save(outfile)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue