Comic reader code cleaning
This commit is contained in:
parent
a62fca1e55
commit
98fc1ee0a7
|
@ -15,7 +15,7 @@
|
||||||
* Typed Arrays: http://www.khronos.org/registry/typedarray/specs/latest/#6
|
* Typed Arrays: http://www.khronos.org/registry/typedarray/specs/latest/#6
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/* global screenfull, bitjs, Uint8Array, opera */
|
/* global screenfull, bitjs, Uint8Array, opera, loadArchiveFormats, archiveOpenFile */
|
||||||
/* exported init, event */
|
/* exported init, event */
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,27 +173,23 @@ function initProgressClick() {
|
||||||
var offset = $(this).offset();
|
var offset = $(this).offset();
|
||||||
var x = e.pageX - offset.left;
|
var x = e.pageX - offset.left;
|
||||||
var rate = settings.direction === 0 ? x / $(this).width() : 1 - x / $(this).width();
|
var rate = settings.direction === 0 ? x / $(this).width() : 1 - x / $(this).width();
|
||||||
var page = Math.max(1, Math.ceil(rate * totalImages)) - 1;
|
currentImage = Math.max(1, Math.ceil(rate * totalImages)) - 1;
|
||||||
currentImage = page;
|
|
||||||
updatePage();
|
updatePage();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFromArrayBuffer(ab) {
|
function loadFromArrayBuffer(ab) {
|
||||||
var start = (new Date).getTime();
|
|
||||||
var h = new Uint8Array(ab, 0, 10);
|
|
||||||
var pathToBitJS = "../../static/js/archive/";
|
|
||||||
var lastCompletion = 0;
|
var lastCompletion = 0;
|
||||||
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
|
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
|
||||||
// Open the file as an archive
|
// Open the file as an archive
|
||||||
archiveOpenFile(ab, function (archive, err) {
|
archiveOpenFile(ab, function (archive) {
|
||||||
if (archive) {
|
if (archive) {
|
||||||
totalImages = archive.entries.length
|
totalImages = archive.entries.length
|
||||||
console.info('Uncompressing ' + archive.archive_type + ' ...');
|
console.info('Uncompressing ' + archive.archive_type + ' ...');
|
||||||
archive.entries.forEach(function(e, i) {
|
archive.entries.forEach(function(e, i) {
|
||||||
updateProgress( (i + 1)/ totalImages * 100);
|
updateProgress( (i + 1)/ totalImages * 100);
|
||||||
if (e.is_file) {
|
if (e.is_file) {
|
||||||
var f = e.readData(function(d) {
|
e.readData(function(d) {
|
||||||
// add any new pages based on the filename
|
// add any new pages based on the filename
|
||||||
if (imageFilenames.indexOf(e.name) === -1) {
|
if (imageFilenames.indexOf(e.name) === -1) {
|
||||||
let data = {filename: e.name, fileData: d};
|
let data = {filename: e.name, fileData: d};
|
||||||
|
@ -523,10 +519,6 @@ function keyHandler(evt) {
|
||||||
updateScale(false);
|
updateScale(false);
|
||||||
break;
|
break;
|
||||||
case kthoom.Key.SPACE:
|
case kthoom.Key.SPACE:
|
||||||
var container = $("#mainContent");
|
|
||||||
// var atTop = container.scrollTop() === 0;
|
|
||||||
// var atBottom = container.scrollTop() >= container[0].scrollHeight - container.height();
|
|
||||||
|
|
||||||
if (evt.shiftKey) {
|
if (evt.shiftKey) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
// If it's Shift + Space and the container is at the top of the page
|
// If it's Shift + Space and the container is at the top of the page
|
||||||
|
@ -547,9 +539,7 @@ function init(filename) {
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
request.open("GET", filename);
|
request.open("GET", filename);
|
||||||
request.responseType = "arraybuffer";
|
request.responseType = "arraybuffer";
|
||||||
request.setRequestHeader("X-Test", "test1");
|
request.addEventListener("load", function() {
|
||||||
request.setRequestHeader("X-Test", "test2");
|
|
||||||
request.addEventListener("load", function(event) {
|
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
loadFromArrayBuffer(request.response);
|
loadFromArrayBuffer(request.response);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user