60 lines
2.2 KiB
JavaScript
60 lines
2.2 KiB
JavaScript
this.txtjs = {};
|
|
|
|
txtjs.open = function(url) {
|
|
Ox.load(function() {
|
|
Ox.get(url, function(text) {
|
|
var $body = Ox.$('body')
|
|
.css({
|
|
backgroundColor: 'rgb(255, 255, 255)',
|
|
overflowX: 'hidden'
|
|
}),
|
|
$text = Ox.$('<div>')
|
|
.css({
|
|
padding: '10% 20% 10% 10%',
|
|
fontFamily: 'Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif',
|
|
fontSize: '20px',
|
|
lineHeight: '30px'
|
|
})
|
|
.appendTo($body),
|
|
$scroll = Ox.$('<div>')
|
|
.css({
|
|
position: 'fixed',
|
|
right: '24px',
|
|
top: '16px',
|
|
width: '7%',
|
|
bottom: '16px',
|
|
overflow: 'hidden'
|
|
})
|
|
.appendTo($body),
|
|
$scrollText = Ox.$('<div>')
|
|
.css({
|
|
fontSize: '2px',
|
|
lineHeight: '3px',
|
|
cursor: 'pointer',
|
|
WebkitUserSelect: 'none'
|
|
})
|
|
.on({
|
|
mousedown: function(e) {
|
|
var offset = 'offsetY' in e ? e.offsetY : e.layerY;
|
|
document.documentElement.scrollTop = offset / factor + margin - 16;
|
|
}
|
|
})
|
|
.appendTo($scroll),
|
|
factor, margin;
|
|
text = Ox.encodeHTMLEntities(text)
|
|
.replace(/\r\n/g, '\n')
|
|
.replace(/[\r\n]/g, '<br>');
|
|
$text.html(text);
|
|
$scrollText.html(text);
|
|
window.onresize = function() {
|
|
margin = $text.width() * 0.1;
|
|
factor = $scrollText[0].clientHeight / $text[0].clientHeight;
|
|
};
|
|
window.onscroll = function() {
|
|
$scroll[0].scrollTop = (window.pageYOffset - margin + 16) * factor;
|
|
};
|
|
window.onresize();
|
|
});
|
|
});
|
|
};
|
|
|