mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-10 04:03:00 +00:00
Update comic reader js
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Copyright(c) 2011 Google Inc.
|
||||
*/
|
||||
|
||||
/* global bitjs */
|
||||
/* global bitjs, Uint8Array */
|
||||
|
||||
var bitjs = bitjs || {};
|
||||
bitjs.archive = bitjs.archive || {};
|
||||
@@ -17,7 +17,7 @@ bitjs.archive = bitjs.archive || {};
|
||||
|
||||
// ===========================================================================
|
||||
// Stolen from Closure because it's the best way to do Java-like inheritance.
|
||||
bitjs.base = function(me, opt_methodName, var_args) {
|
||||
bitjs.base = function(me, optMethodName, varArgs) {
|
||||
var caller = arguments.callee.caller;
|
||||
if (caller.superClass_) {
|
||||
// This is a constructor. Call the superclass constructor.
|
||||
@@ -28,10 +28,10 @@ bitjs.archive = bitjs.archive || {};
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
var foundCaller = false;
|
||||
for (var ctor = me.constructor; ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) {
|
||||
if (ctor.prototype[opt_methodName] === caller) {
|
||||
if (ctor.prototype[optMethodName] === caller) {
|
||||
foundCaller = true;
|
||||
} else if (foundCaller) {
|
||||
return ctor.prototype[opt_methodName].apply(me, args);
|
||||
return ctor.prototype[optMethodName].apply(me, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ bitjs.archive = bitjs.archive || {};
|
||||
// then one of two things happened:
|
||||
// 1) The caller is an instance method.
|
||||
// 2) This method was not called by the right caller.
|
||||
if (me[opt_methodName] === caller) {
|
||||
return me.constructor.prototype[opt_methodName].apply(me, args);
|
||||
if (me[optMethodName] === caller) {
|
||||
return me.constructor.prototype[optMethodName].apply(me, args);
|
||||
} else {
|
||||
throw Error(
|
||||
"goog.base called from a method of one name " +
|
||||
@@ -49,10 +49,10 @@ bitjs.archive = bitjs.archive || {};
|
||||
};
|
||||
bitjs.inherits = function(childCtor, parentCtor) {
|
||||
/** @constructor */
|
||||
function tempCtor() {};
|
||||
tempCtor.prototype = parentCtor.prototype;
|
||||
function TempCtor() {}
|
||||
TempCtor.prototype = parentCtor.prototype;
|
||||
childCtor.superClass_ = parentCtor.prototype;
|
||||
childCtor.prototype = new tempCtor();
|
||||
childCtor.prototype = new TempCtor();
|
||||
childCtor.prototype.constructor = childCtor;
|
||||
};
|
||||
// ===========================================================================
|
||||
@@ -188,10 +188,10 @@ bitjs.archive = bitjs.archive || {};
|
||||
* Base class for all Unarchivers.
|
||||
*
|
||||
* @param {ArrayBuffer} arrayBuffer The Array Buffer.
|
||||
* @param {string} opt_pathToBitJS Optional string for where the BitJS files are located.
|
||||
* @param {string} optPathToBitJS Optional string for where the BitJS files are located.
|
||||
* @constructor
|
||||
*/
|
||||
bitjs.archive.Unarchiver = function(arrayBuffer, opt_pathToBitJS) {
|
||||
bitjs.archive.Unarchiver = function(arrayBuffer, optPathToBitJS) {
|
||||
/**
|
||||
* The ArrayBuffer object.
|
||||
* @type {ArrayBuffer}
|
||||
@@ -204,7 +204,7 @@ bitjs.archive = bitjs.archive || {};
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
this.pathToBitJS_ = opt_pathToBitJS || "/";
|
||||
this.pathToBitJS_ = optPathToBitJS || "/";
|
||||
|
||||
/**
|
||||
* A map from event type to an array of listeners.
|
||||
@@ -319,8 +319,8 @@ bitjs.archive = bitjs.archive || {};
|
||||
* @extends {bitjs.archive.Unarchiver}
|
||||
* @constructor
|
||||
*/
|
||||
bitjs.archive.Unzipper = function(arrayBuffer, opt_pathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, opt_pathToBitJS);
|
||||
bitjs.archive.Unzipper = function(arrayBuffer, optPathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, optPathToBitJS);
|
||||
};
|
||||
bitjs.inherits(bitjs.archive.Unzipper, bitjs.archive.Unarchiver);
|
||||
bitjs.archive.Unzipper.prototype.getScriptFileName = function() {
|
||||
@@ -332,8 +332,8 @@ bitjs.archive = bitjs.archive || {};
|
||||
* @extends {bitjs.archive.Unarchiver}
|
||||
* @constructor
|
||||
*/
|
||||
bitjs.archive.Unrarrer = function(arrayBuffer, opt_pathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, opt_pathToBitJS);
|
||||
bitjs.archive.Unrarrer = function(arrayBuffer, optPathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, optPathToBitJS);
|
||||
};
|
||||
bitjs.inherits(bitjs.archive.Unrarrer, bitjs.archive.Unarchiver);
|
||||
bitjs.archive.Unrarrer.prototype.getScriptFileName = function() {
|
||||
@@ -345,8 +345,8 @@ bitjs.archive = bitjs.archive || {};
|
||||
* @extends {bitjs.archive.Unarchiver}
|
||||
* @constructor
|
||||
*/
|
||||
bitjs.archive.Untarrer = function(arrayBuffer, opt_pathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, opt_pathToBitJS);
|
||||
bitjs.archive.Untarrer = function(arrayBuffer, optPathToBitJS) {
|
||||
bitjs.base(this, arrayBuffer, optPathToBitJS);
|
||||
};
|
||||
bitjs.inherits(bitjs.archive.Untarrer, bitjs.archive.Unarchiver);
|
||||
bitjs.archive.Untarrer.prototype.getScriptFileName = function() {
|
||||
@@ -357,20 +357,19 @@ bitjs.archive = bitjs.archive || {};
|
||||
* Factory method that creates an unarchiver based on the byte signature found
|
||||
* in the arrayBuffer.
|
||||
* @param {ArrayBuffer} ab
|
||||
* @param {string=} opt_pathToBitJS Path to the unarchiver script files.
|
||||
* @param {string=} optPathToBitJS Path to the unarchiver script files.
|
||||
* @return {bitjs.archive.Unarchiver}
|
||||
*/
|
||||
bitjs.archive.GetUnarchiver = function(ab, opt_pathToBitJS) {
|
||||
bitjs.archive.GetUnarchiver = function(ab, optPathToBitJS) {
|
||||
var unarchiver = null;
|
||||
var pathToBitJS = opt_pathToBitJS || '';
|
||||
var pathToBitJS = optPathToBitJS || "";
|
||||
var h = new Uint8Array(ab, 0, 10);
|
||||
|
||||
if (h[0] == 0x52 && h[1] == 0x61 && h[2] == 0x72 && h[3] == 0x21) { // Rar!
|
||||
if (h[0] === 0x52 && h[1] === 0x61 && h[2] === 0x72 && h[3] === 0x21) { // Rar!
|
||||
unarchiver = new bitjs.archive.Unrarrer(ab, pathToBitJS);
|
||||
} else if (h[0] == 80 && h[1] == 75) { // PK (Zip)
|
||||
} else if (h[0] === 80 && h[1] === 75) { // PK (Zip)
|
||||
unarchiver = new bitjs.archive.Unzipper(ab, pathToBitJS);
|
||||
} else { // Try with tar
|
||||
console.log('geter');
|
||||
unarchiver = new bitjs.archive.Untarrer(ab, pathToBitJS);
|
||||
}
|
||||
return unarchiver;
|
||||
|
||||
Reference in New Issue
Block a user