txt.py, infoview fixes
This commit is contained in:
parent
0dbc92d027
commit
16989e9990
3 changed files with 51 additions and 38 deletions
|
|
@ -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,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue