Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init() {
- "undefined" == typeof userConfig || null === userConfig ? RDP_EPUB.config = {
- fontSize: 18,
- background: "#fff",
- fontFamily: "Times New Roman",
- color: "#000"
- } : RDP_EPUB.config = {
- fontSize: userConfig.fontSize,
- background: userConfig.background,
- fontFamily: userConfig.fontFamily,
- color: userConfig.color
- },
- localStorage.setItem("rdp-reader-bv3", JSON.stringify(RDP_EPUB.config))
- }
- function newReader(a, b, c) {
- parseEdition(a, b, c)
- }
- function parseEdition(a, b, c) {
- $.ajax({
- type: "GET",
- url: a + "&token=" + b + "×tamp=" + c,
- dataType: "json",
- success: function(a) {
- initEpub(a.epub[0].basePath)
- }
- })
- }
- function initEpub(a) {
- EPUBJS.cssPath = "css/";
- ePubReader(a, {
- reload: !1,
- generatePagination: !1,
- offline: !0,
- minSpreadWidth: 3e3
- })
- }
- function setBackground() {
- $("#main").css("background", RDP_EPUB.config.background),
- $("#main, #titlebar a, #metainfo").css("color", RDP_EPUB.config.color),
- $("#titlebar a").css("opacity", "1"),
- $("iframe").contents().find("body, p, a, span").css({
- background: RDP_EPUB.config.background,
- color: RDP_EPUB.config.color
- }),
- null != userConfig && (userConfig.background = RDP_EPUB.config.background,
- userConfig.color = RDP_EPUB.config.color,
- localStorage.setItem("rdp-reader-bv3", JSON.stringify(userConfig)))
- }
- function setFontFamily() {
- $("iframe").contents().find("body, p, a, span").css({
- fontFamily: RDP_EPUB.config.fontFamily
- }),
- null != userConfig && (userConfig.fontFamily = RDP_EPUB.config.fontFamily,
- localStorage.setItem("rdp-reader-bv3", JSON.stringify(userConfig)))
- }
- function setFontSize() {
- $("iframe").contents().find("body").css({
- fontSize: RDP_EPUB.config.fontSize + "px"
- }),
- null != userConfig && (userConfig.fontSize = RDP_EPUB.config.fontSize,
- localStorage.setItem("rdp-reader-bv3", JSON.stringify(userConfig)))
- }
- function setConfig() {
- setBackground(),
- setFontFamily(),
- setFontSize()
- }
- !function(a) {
- a.widget("ui.swipable", {
- options: {
- preventDefault: !0,
- distance: 150
- },
- _sleeping: !1,
- _startX: null,
- _startY: null,
- _currentX: null,
- _currentY: null,
- _create: function() {
- return "ontouchstart"in document.documentElement ? (this.widgetEventPrefix = "swipe.",
- this._eventify(),
- this) : this
- },
- _eventify: function() {
- var b = this.element.get(0);
- return b.addEventListener("touchstart", a.proxy(this._touchStartHandler, this), !1),
- b.addEventListener("touchmove", a.proxy(this._touchMoveHandler, this), !1),
- b.addEventListener("touchend", a.proxy(this._touchEndHandler, this), !1),
- b.addEventListener("touchcancel", a.proxy(this._touchCancelHandler, this), !1),
- this
- },
- _evalSwipes: function() {
- var a = this._currentX
- , b = this._currentY
- , c = this._startX
- , d = this._startY
- , e = this.options.distance;
- a - c > e && this._swipeRight(),
- c - a > e && this._swipeLeft(),
- b - d > e && this._swipeBottom(),
- d - b > e && this._swipeTop()
- },
- _awake: function() {
- return this._sleeping = !1,
- this
- },
- _sleep: function() {
- return this._sleeping = !0,
- this
- },
- _swipeTop: function() {
- return this._sleep(),
- this._trigger("top"),
- this
- },
- _swipeRight: function() {
- return this._sleep(),
- this._trigger("right"),
- this
- },
- _swipeBottom: function() {
- return this._sleep(),
- this._trigger("bottom"),
- this
- },
- _swipeLeft: function() {
- return this._sleep(),
- this._trigger("left"),
- this
- },
- _setStartTouch: function(a) {
- return this._startX = a.pageX,
- this._startY = a.pageY,
- this
- },
- _setCurrentTouch: function(a) {
- this._currentX = a.pageX,
- this._currentY = a.pageY
- },
- _touchStartHandler: function(a) {
- var b = a.touches;
- if (!(b.length > 1)) {
- var c = b[0];
- this._setStartTouch(c)
- }
- },
- _touchMoveHandler: function(a) {
- var b = a.touches[0];
- this._setCurrentTouch(b),
- !this._sleeping && this._evalSwipes(),
- this.options.preventDefault && a.preventDefault()
- },
- _touchEndHandler: function(a) {
- this._awake()
- },
- _touchCancelHandler: function(a) {
- this._awake()
- }
- })
- }(jQuery),
- !function(a) {
- function b() {
- var a = -1
- , b = this;
- b.append = function(c) {
- var d, e = b.table;
- for (d = 0; d < c.length; d++)
- a = a >>> 8 ^ e[255 & (a ^ c[d])]
- }
- ,
- b.get = function() {
- return ~a
- }
- }
- function c(a, b, c) {
- return a.slice ? a.slice(b, b + c) : a.webkitSlice ? a.webkitSlice(b, b + c) : a.mozSlice ? a.mozSlice(b, b + c) : a.msSlice ? a.msSlice(b, b + c) : void 0
- }
- function d(a, b) {
- var c, d;
- return c = new ArrayBuffer(a),
- d = new Uint8Array(c),
- b && d.set(b, 0),
- {
- buffer: c,
- array: d,
- view: new DataView(c)
- }
- }
- function e() {}
- function f(a) {
- function b(b, c) {
- var f = new Blob([a],{
- type: M
- });
- d = new h(f),
- d.init(function() {
- e.size = d.size,
- b()
- }, c)
- }
- function c(a, b, c, e) {
- d.readUint8Array(a, b, c, e)
- }
- var d, e = this;
- e.size = 0,
- e.init = b,
- e.readUint8Array = c
- }
- function g(b) {
- function c(a) {
- for (var c = b.length; "=" == b.charAt(c - 1); )
- c--;
- f = b.indexOf(",") + 1,
- g.size = Math.floor(.75 * (c - f)),
- a()
- }
- function e(c, e, g) {
- var h, i = d(e), j = 4 * Math.floor(c / 3), k = 4 * Math.ceil((c + e) / 3), l = a.atob(b.substring(j + f, k + f)), m = c - 3 * Math.floor(j / 4);
- for (h = m; m + e > h; h++)
- i.array[h - m] = l.charCodeAt(h);
- g(i.array)
- }
- var f, g = this;
- g.size = 0,
- g.init = c,
- g.readUint8Array = e
- }
- function h(a) {
- function b(b) {
- this.size = a.size,
- b()
- }
- function d(b, d, e, f) {
- var g = new FileReader;
- g.onload = function(a) {
- e(new Uint8Array(a.target.result))
- }
- ,
- g.onerror = f,
- g.readAsArrayBuffer(c(a, b, d))
- }
- var e = this;
- e.size = 0,
- e.init = b,
- e.readUint8Array = d
- }
- function i() {}
- function j(a) {
- function b(a) {
- e = new Blob([],{
- type: M
- }),
- a()
- }
- function c(a, b) {
- e = new Blob([e, A ? a : a.buffer],{
- type: M
- }),
- b()
- }
- function d(b, c) {
- var d = new FileReader;
- d.onload = function(a) {
- b(a.target.result)
- }
- ,
- d.onerror = c,
- d.readAsText(e, a)
- }
- var e, f = this;
- f.init = b,
- f.writeUint8Array = c,
- f.getData = d
- }
- function k(b) {
- function c(a) {
- g += "data:" + (b || "") + ";base64,",
- a()
- }
- function d(b, c) {
- var d, e = h.length, f = h;
- for (h = "",
- d = 0; d < 3 * Math.floor((e + b.length) / 3) - e; d++)
- f += String.fromCharCode(b[d]);
- for (; d < b.length; d++)
- h += String.fromCharCode(b[d]);
- f.length > 2 ? g += a.btoa(f) : h = f,
- c()
- }
- function e(b) {
- b(g + a.btoa(h))
- }
- var f = this
- , g = ""
- , h = "";
- f.init = c,
- f.writeUint8Array = d,
- f.getData = e
- }
- function l(a) {
- function b(b) {
- e = new Blob([],{
- type: a
- }),
- b()
- }
- function c(b, c) {
- e = new Blob([e, A ? b : b.buffer],{
- type: a
- }),
- c()
- }
- function d(a) {
- a(e)
- }
- var e, f = this;
- f.init = b,
- f.writeUint8Array = c,
- f.getData = d
- }
- function m(a, b, c, d, e, f, g, h, i, j) {
- function k() {
- a.removeEventListener(N, l, !1),
- h(o)
- }
- function l(a) {
- var b = a.data
- , d = b.data;
- b.onappend && (o += d.length,
- c.writeUint8Array(d, function() {
- f(!1, d),
- m()
- }, j)),
- b.onflush && (d ? (o += d.length,
- c.writeUint8Array(d, function() {
- f(!1, d),
- k()
- }, j)) : k()),
- b.progress && g && g(n + b.current, e)
- }
- function m() {
- n = p * J,
- e > n ? b.readUint8Array(d + n, Math.min(J, e - n), function(b) {
- a.postMessage({
- append: !0,
- data: b
- }),
- p++,
- g && g(n, e),
- f(!0, b)
- }, i) : a.postMessage({
- flush: !0
- })
- }
- var n, o, p = 0;
- o = 0,
- a.addEventListener(N, l, !1),
- m()
- }
- function n(a, b, c, d, e, f, g, h, i, j) {
- function k() {
- var o;
- l = m * J,
- e > l ? b.readUint8Array(d + l, Math.min(J, e - l), function(b) {
- var h = a.append(b, function() {
- g && g(d + l, e)
- });
- n += h.length,
- f(!0, b),
- c.writeUint8Array(h, function() {
- f(!1, h),
- m++,
- setTimeout(k, 1)
- }, j),
- g && g(l, e)
- }, i) : (o = a.flush(),
- o ? (n += o.length,
- c.writeUint8Array(o, function() {
- f(!1, o),
- h(n)
- }, j)) : h(n))
- }
- var l, m = 0, n = 0;
- k()
- }
- function o(c, d, e, f, g, h, i, j, k) {
- function l(a, b) {
- g && !a && q.append(b)
- }
- function o(a) {
- h(a, q.get())
- }
- var p, q = new b;
- return a.zip.useWebWorkers ? (p = new Worker(a.zip.workerScriptsPath + K),
- m(p, c, d, e, f, l, i, o, j, k)) : n(new a.zip.Inflater, c, d, e, f, l, i, o, j, k),
- p
- }
- function p(c, d, e, f, g, h, i) {
- function j(a, b) {
- a && p.append(b)
- }
- function k(a) {
- f(a, p.get())
- }
- function l() {
- o.removeEventListener(N, l, !1),
- m(o, c, d, 0, c.size, j, g, k, h, i)
- }
- var o, p = new b;
- return a.zip.useWebWorkers ? (o = new Worker(a.zip.workerScriptsPath + L),
- o.addEventListener(N, l, !1),
- o.postMessage({
- init: !0,
- level: e
- })) : n(new a.zip.Deflater, c, d, 0, c.size, j, g, k, h, i),
- o
- }
- function q(a, c, d, e, f, g, h, i, j) {
- function k() {
- var b = l * J;
- e > b ? a.readUint8Array(d + b, Math.min(J, e - b), function(a) {
- f && m.append(a),
- h && h(b, e, a),
- c.writeUint8Array(a, function() {
- l++,
- k()
- }, j)
- }, i) : g(e, m.get())
- }
- var l = 0
- , m = new b;
- k()
- }
- function r(a) {
- var b, c, d = "", e = ["Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "ø", "£", "Ø", "×", "ƒ", "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "®", "¬", "½", "¼", "¡", "«", "»", "_", "_", "_", "¦", "¦", "Á", "Â", "À", "©", "¦", "¦", "+", "+", "¢", "¥", "+", "+", "-", "-", "+", "-", "+", "ã", "Ã", "+", "+", "-", "-", "¦", "-", "+", "¤", "ð", "Ð", "Ê", "Ë", "È", "i", "Í", "Î", "Ï", "+", "+", "_", "_", "¦", "Ì", "_", "Ó", "ß", "Ô", "Ò", "õ", "Õ", "µ", "þ", "Þ", "Ú", "Û", "Ù", "ý", "Ý", "¯", "´", "", "±", "_", "¾", "¶", "§", "÷", "¸", "°", "¨", "·", "¹", "³", "²", "_", " "];
- for (b = 0; b < a.length; b++)
- c = 255 & a.charCodeAt(b),
- d += c > 127 ? e[c - 128] : String.fromCharCode(c);
- return d
- }
- function s(a) {
- return decodeURIComponent(escape(a))
- }
- function t(a) {
- var b, c = "";
- for (b = 0; b < a.length; b++)
- c += String.fromCharCode(a[b]);
- return c
- }
- function u(a) {
- var b = (4294901760 & a) >> 16
- , c = 65535 & a;
- try {
- return new Date(1980 + ((65024 & b) >> 9),((480 & b) >> 5) - 1,31 & b,(63488 & c) >> 11,(2016 & c) >> 5,2 * (31 & c),0)
- } catch (d) {}
- }
- function v(a, b, c, d, e) {
- return a.version = b.view.getUint16(c, !0),
- a.bitFlag = b.view.getUint16(c + 2, !0),
- a.compressionMethod = b.view.getUint16(c + 4, !0),
- a.lastModDateRaw = b.view.getUint32(c + 6, !0),
- a.lastModDate = u(a.lastModDateRaw),
- 1 === (1 & a.bitFlag) ? void e(C) : ((d || 8 != (8 & a.bitFlag)) && (a.crc32 = b.view.getUint32(c + 10, !0),
- a.compressedSize = b.view.getUint32(c + 14, !0),
- a.uncompressedSize = b.view.getUint32(c + 18, !0)),
- 4294967295 === a.compressedSize || 4294967295 === a.uncompressedSize ? void e(D) : (a.filenameLength = b.view.getUint16(c + 22, !0),
- void (a.extraFieldLength = b.view.getUint16(c + 24, !0))))
- }
- function w(a, b) {
- function c() {}
- function e(c, f) {
- a.readUint8Array(a.size - c, c, function(a) {
- var b = d(a.length, a).view;
- 1347093766 != b.getUint32(0) ? e(c + 1, f) : f(b)
- }, function() {
- b(E)
- })
- }
- return c.prototype.getData = function(c, e, f, g) {
- function h(a, b) {
- m && m.terminate(),
- m = null,
- a && a(b)
- }
- function i(a) {
- var b = d(4);
- return b.view.setUint32(0, a),
- n.crc32 == b.view.getUint32(0)
- }
- function j(a, b) {
- g && !i(b) ? k() : c.getData(function(a) {
- h(e, a)
- })
- }
- function k() {
- h(b, H)
- }
- function l() {
- h(b, G)
- }
- var m, n = this;
- a.readUint8Array(n.offset, 30, function(e) {
- var h, i = d(e.length, e);
- return 1347093252 != i.view.getUint32(0) ? void b(B) : (v(n, i, 4, !1, b),
- h = n.offset + 30 + n.filenameLength + n.extraFieldLength,
- void c.init(function() {
- 0 === n.compressionMethod ? q(a, c, h, n.compressedSize, g, j, f, k, l) : m = o(a, c, h, n.compressedSize, g, j, f, k, l)
- }, l))
- }, k)
- }
- ,
- {
- getEntries: function(f) {
- return a.size < 22 ? void b(B) : void e(22, function(e) {
- var g, h;
- g = e.getUint32(16, !0),
- h = e.getUint16(8, !0),
- a.readUint8Array(g, a.size - g, function(a) {
- var e, g, i, j, k = 0, l = [], m = d(a.length, a);
- for (e = 0; h > e; e++) {
- if (g = new c,
- 1347092738 != m.view.getUint32(k))
- return void b(B);
- v(g, m, k + 6, !0, b),
- g.commentLength = m.view.getUint16(k + 32, !0),
- g.directory = 16 == (16 & m.view.getUint8(k + 38)),
- g.offset = m.view.getUint32(k + 42, !0),
- i = t(m.array.subarray(k + 46, k + 46 + g.filenameLength)),
- g.filename = 2048 === (2048 & g.bitFlag) ? s(i) : r(i),
- g.directory || "/" != g.filename.charAt(g.filename.length - 1) || (g.directory = !0),
- j = t(m.array.subarray(k + 46 + g.filenameLength + g.extraFieldLength, k + 46 + g.filenameLength + g.extraFieldLength + g.commentLength)),
- g.comment = 2048 === (2048 & g.bitFlag) ? s(j) : r(j),
- l.push(g),
- k += 46 + g.filenameLength + g.extraFieldLength + g.commentLength
- }
- f(l)
- }, function() {
- b(E)
- })
- })
- },
- close: function(a) {
- a && a()
- }
- }
- }
- function x(a) {
- return unescape(encodeURIComponent(a))
- }
- function y(a) {
- var b, c = [];
- for (b = 0; b < a.length; b++)
- c.push(a.charCodeAt(b));
- return c
- }
- function z(a, b, c) {
- function e(a, b) {
- h && h.terminate(),
- h = null,
- a && a(b)
- }
- function f() {
- e(b, F)
- }
- function g() {
- e(b, H)
- }
- var h, i = {}, j = [], k = 0;
- return {
- add: function(l, m, n, o, r) {
- function s(b) {
- var e;
- z = r.lastModDate || new Date,
- v = d(26),
- i[l] = {
- headerArray: v.array,
- directory: r.directory,
- filename: w,
- offset: k,
- comment: y(x(r.comment || ""))
- },
- v.view.setUint32(0, 335546376),
- r.version && v.view.setUint8(0, r.version),
- c || 0 === r.level || r.directory || v.view.setUint16(4, 2048),
- v.view.setUint16(6, (z.getHours() << 6 | z.getMinutes()) << 5 | z.getSeconds() / 2, !0),
- v.view.setUint16(8, (z.getFullYear() - 1980 << 4 | z.getMonth() + 1) << 5 | z.getDate(), !0),
- v.view.setUint16(22, w.length, !0),
- e = d(30 + w.length),
- e.view.setUint32(0, 1347093252),
- e.array.set(v.array, 4),
- e.array.set(w, 30),
- k += e.array.length,
- a.writeUint8Array(e.array, b, f)
- }
- function t(b, c) {
- var g = d(16);
- k += b || 0,
- g.view.setUint32(0, 1347094280),
- "undefined" != typeof c && (v.view.setUint32(10, c, !0),
- g.view.setUint32(4, c, !0)),
- m && (g.view.setUint32(8, b, !0),
- v.view.setUint32(14, b, !0),
- g.view.setUint32(12, m.size, !0),
- v.view.setUint32(18, m.size, !0)),
- a.writeUint8Array(g.array, function() {
- k += 16,
- e(n)
- }, f)
- }
- function u() {
- return r = r || {},
- l = l.trim(),
- r.directory && "/" != l.charAt(l.length - 1) && (l += "/"),
- i.hasOwnProperty(l) ? void b(I) : (w = y(x(l)),
- j.push(l),
- void s(function() {
- m ? c || 0 === r.level ? q(m, a, 0, m.size, !0, t, o, g, f) : h = p(m, a, r.level, t, o, g, f) : t()
- }, f))
- }
- var v, w, z;
- m ? m.init(u, g) : u()
- },
- close: function(b) {
- var c, g, h, l = 0, m = 0;
- for (g = 0; g < j.length; g++)
- h = i[j[g]],
- l += 46 + h.filename.length + h.comment.length;
- for (c = d(l + 22),
- g = 0; g < j.length; g++)
- h = i[j[g]],
- c.view.setUint32(m, 1347092738),
- c.view.setUint16(m + 4, 5120),
- c.array.set(h.headerArray, m + 6),
- c.view.setUint16(m + 32, h.comment.length, !0),
- h.directory && c.view.setUint8(m + 38, 16),
- c.view.setUint32(m + 42, h.offset, !0),
- c.array.set(h.filename, m + 46),
- c.array.set(h.comment, m + 46 + h.filename.length),
- m += 46 + h.filename.length + h.comment.length;
- c.view.setUint32(m, 1347093766),
- c.view.setUint16(m + 8, j.length, !0),
- c.view.setUint16(m + 10, j.length, !0),
- c.view.setUint32(m + 12, l, !0),
- c.view.setUint32(m + 16, k, !0),
- a.writeUint8Array(c.array, function() {
- e(function() {
- a.getData(b)
- })
- }, f)
- }
- }
- }
- var A, B = "File format is not recognized.", C = "File contains encrypted entry.", D = "File is using Zip64 (4gb+ file size).", E = "Error while reading zip file.", F = "Error while writing zip file.", G = "Error while writing file data.", H = "Error while reading file data.", I = "File already exists.", J = 524288, K = "inflate.js", L = "deflate.js", M = "text/plain", N = "message";
- try {
- A = 0 === new Blob([new DataView(new ArrayBuffer(0))]).size
- } catch (O) {}
- b.prototype.table = function() {
- var a, b, c, d = [];
- for (a = 0; 256 > a; a++) {
- for (c = a,
- b = 0; 8 > b; b++)
- 1 & c ? c = c >>> 1 ^ 3988292384 : c >>>= 1;
- d[a] = c
- }
- return d
- }(),
- f.prototype = new e,
- f.prototype.constructor = f,
- g.prototype = new e,
- g.prototype.constructor = g,
- h.prototype = new e,
- h.prototype.constructor = h,
- i.prototype.getData = function(a) {
- a(this.data)
- }
- ,
- j.prototype = new i,
- j.prototype.constructor = j,
- k.prototype = new i,
- k.prototype.constructor = k,
- l.prototype = new i,
- l.prototype.constructor = l,
- a.zip = {
- Reader: e,
- Writer: i,
- BlobReader: h,
- Data64URIReader: g,
- TextReader: f,
- BlobWriter: l,
- Data64URIWriter: k,
- TextWriter: j,
- createReader: function(a, b, c) {
- a.init(function() {
- b(w(a, c))
- }, c)
- },
- createWriter: function(a, b, c, d) {
- a.init(function() {
- b(z(a, c, d))
- }, c)
- },
- workerScriptsPath: "",
- useWebWorkers: !0
- }
- }(this),
- function() {
- function a(a) {
- function b(b) {
- this.size = a.uncompressedSize,
- b()
- }
- function c(b) {
- f.data ? b() : a.getData(new r, function(a) {
- f.data = a,
- e = new v(a),
- b()
- }, null, f.checkCrc32)
- }
- function d(a, b, d, f) {
- c(function() {
- e.readUint8Array(a, b, d, f)
- }, f)
- }
- var e, f = this;
- f.size = 0,
- f.init = b,
- f.readUint8Array = d
- }
- function b(a) {
- function b(a) {
- c += a.uncompressedSize || 0,
- a.children.forEach(b)
- }
- var c = 0;
- return b(a),
- c
- }
- function c(a, b, d) {
- function e() {
- g++,
- g < a.children.length ? f(a.children[g]) : b()
- }
- function f(a) {
- a.directory ? c(a, e, d) : (a.reader = new a.Reader(a.data,d),
- a.reader.init(function() {
- a.uncompressedSize = a.reader.size,
- e()
- }))
- }
- var g = 0;
- a.children.length ? f(a.children[g]) : b()
- }
- function d(a) {
- var b = a.parent.children;
- b.forEach(function(c, d) {
- c.id == a.id && b.splice(d, 1)
- })
- }
- function e(a, b, c, d, e) {
- function f(a, b, c, d, e) {
- function h() {
- var j = b.children[i];
- j ? a.add(j.getFullname(), j.reader, function() {
- g += j.uncompressedSize || 0,
- f(a, j, function() {
- i++,
- h()
- }, d, e)
- }, function(a) {
- d && d(g + a, e)
- }, {
- directory: j.directory,
- version: j.zipVersion
- }) : c()
- }
- var i = 0;
- h()
- }
- var g = 0;
- f(a, b, c, d, e)
- }
- function f(a, b, c, d) {
- function e(a, b) {
- a.isDirectory && a.createReader().readEntries(b),
- a.isFile && b([])
- }
- function f(a, b, c) {
- e(b, function(b) {
- function e(b) {
- function c(a) {
- f(a, b, function() {
- h++,
- g()
- })
- }
- b.isDirectory && c(a.addDirectory(b.name)),
- b.isFile && b.file(function(d) {
- var e = a.addBlob(b.name, d);
- e.uncompressedSize = d.size,
- c(e)
- }, d)
- }
- function g() {
- var a = b[h];
- a ? e(a) : c()
- }
- var h = 0;
- g()
- })
- }
- b.isDirectory ? f(a, b, c) : b.file(function(d) {
- a.addBlob(b.name, d),
- c()
- }, d)
- }
- function g(a, b, c, d, e, f, g) {
- function h(a, b, c, d, e, f) {
- function j(b) {
- function c(a) {
- i += b.uncompressedSize || 0,
- h(a, b, function() {
- l++,
- k()
- }, d, e, f)
- }
- b.directory ? a.getDirectory(b.name, {
- create: !0
- }, c, e) : a.getFile(b.name, {
- create: !0
- }, function(a) {
- b.getData(new zip.FileWriter(a,zip.getMimeType(b.name)), c, function(a) {
- d && d(i + a, f)
- }, g)
- }, e)
- }
- function k() {
- var a = b.children[l];
- a ? j(a) : c()
- }
- var l = 0;
- k()
- }
- var i = 0;
- b.directory ? h(a, b, c, d, e, f) : b.getData(new zip.FileWriter(a,zip.getMimeType(b.name)), c, d, g)
- }
- function h(a) {
- a.entries = [],
- a.root = new n(a)
- }
- function i(a, b, c, d, e) {
- function f() {
- var h = g * p;
- d && d(h, a.size),
- h < a.size ? a.readUint8Array(h, Math.min(p, a.size - h), function(a) {
- b.writeUint8Array(new Uint8Array(a), function() {
- g++,
- f()
- })
- }, e) : b.getData(c)
- }
- var g = 0;
- f()
- }
- function j(a, b, c, d) {
- var e = this;
- !a || a.constructor == e.Writer && e.data ? b(e.data) : (e.reader || (e.reader = new e.Reader(e.data,d)),
- e.reader.init(function() {
- a.init(function() {
- i(e.reader, a, b, c, d)
- }, d)
- }))
- }
- function k(a, b, c, d) {
- if (a.directory)
- return d ? new n(a.fs,b,c,a) : new m(a.fs,b,c,a);
- throw "Parent entry is not a directory."
- }
- function l() {}
- function m(a, b, c, d) {
- var e = this;
- l.prototype.init.call(e, a, b, c, d),
- e.Reader = c.Reader,
- e.Writer = c.Writer,
- e.data = c.data,
- e.getData = c.getData || j
- }
- function n(a, b, c, d) {
- var e = this;
- l.prototype.init.call(e, a, b, c, d),
- e.directory = !0
- }
- function o() {
- h(this)
- }
- var p = 524288
- , q = zip.TextWriter
- , r = zip.BlobWriter
- , s = zip.Data64URIWriter
- , t = zip.Reader
- , u = zip.TextReader
- , v = zip.BlobReader
- , w = zip.Data64URIReader
- , x = zip.createReader
- , y = zip.createWriter;
- a.prototype = new t,
- a.prototype.constructor = a,
- a.prototype.checkCrc32 = !1,
- l.prototype = {
- init: function(a, b, c, d) {
- var e = this;
- if (a.root && d && d.getChildByName(b))
- throw "Entry filename already exists.";
- c || (c = {}),
- e.fs = a,
- e.name = b,
- e.id = a.entries.length,
- e.parent = d,
- e.children = [],
- e.zipVersion = c.zipVersion || 20,
- e.uncompressedSize = 0,
- a.entries.push(e),
- d && e.parent.children.push(e)
- },
- getFileEntry: function(a, d, e, f, h) {
- var i = this;
- c(i, function() {
- g(a, i, d, e, f, b(i), h)
- }, f)
- },
- moveTo: function(a) {
- var b = this;
- if (!a.directory)
- throw "Target entry is not a directory.";
- if (a.isDescendantOf(b))
- throw "Entry is a ancestor of target entry.";
- if (b != a) {
- if (a.getChildByName(b.name))
- throw "Entry filename already exists.";
- d(b),
- b.parent = a,
- a.children.push(b)
- }
- },
- getFullname: function() {
- for (var a = this, b = a.name, c = a.parent; c; )
- b = (c.name ? c.name + "/" : "") + b,
- c = c.parent;
- return b
- },
- isDescendantOf: function(a) {
- for (var b = this.parent; b && b.id != a.id; )
- b = b.parent;
- return !!b
- }
- },
- l.prototype.constructor = l;
- var z;
- m.prototype = z = new l,
- z.constructor = m,
- z.getText = function(a, b, c, d) {
- this.getData(new q(d), a, b, c)
- }
- ,
- z.getBlob = function(a, b, c, d) {
- this.getData(new r(a), b, c, d)
- }
- ,
- z.getData64URI = function(a, b, c, d) {
- this.getData(new s(a), b, c, d)
- }
- ;
- var A;
- n.prototype = A = new l,
- A.constructor = n,
- A.addDirectory = function(a) {
- return k(this, a, null, !0)
- }
- ,
- A.addText = function(a, b) {
- return k(this, a, {
- data: b,
- Reader: u,
- Writer: q
- })
- }
- ,
- A.addBlob = function(a, b) {
- return k(this, a, {
- data: b,
- Reader: v,
- Writer: r
- })
- }
- ,
- A.addData64URI = function(a, b) {
- return k(this, a, {
- data: b,
- Reader: w,
- Writer: s
- })
- }
- ,
- A.addFileEntry = function(a, b, c) {
- f(this, a, b, c)
- }
- ,
- A.addData = function(a, b) {
- return k(this, a, b)
- }
- ,
- A.importBlob = function(a, b, c) {
- this.importZip(new v(a), b, c)
- }
- ,
- A.importText = function(a, b, c) {
- this.importZip(new u(a), b, c)
- }
- ,
- A.importData64URI = function(a, b, c) {
- this.importZip(new w(a), b, c)
- }
- ,
- A.exportBlob = function(a, b, c) {
- this.exportZip(new r("application/zip"), a, b, c)
- }
- ,
- A.exportText = function(a, b, c) {
- this.exportZip(new q, a, b, c)
- }
- ,
- A.exportFileEntry = function(a, b, c, d) {
- this.exportZip(new zip.FileWriter(a,"application/zip"), b, c, d)
- }
- ,
- A.exportData64URI = function(a, b, c) {
- this.exportZip(new s("application/zip"), a, b, c)
- }
- ,
- A.importZip = function(b, c, d) {
- var e = this;
- x(b, function(b) {
- b.getEntries(function(b) {
- b.forEach(function(b) {
- var c = e
- , d = b.filename.split("/")
- , f = d.pop();
- d.forEach(function(a) {
- c = c.getChildByName(a) || new n(e.fs,a,null,c)
- }),
- b.directory || k(c, f, {
- data: b,
- Reader: a
- })
- }),
- c()
- })
- }, d)
- }
- ,
- A.exportZip = function(a, d, f, g) {
- var h = this;
- c(h, function() {
- y(a, function(a) {
- e(a, h, function() {
- a.close(d)
- }, f, b(h))
- }, g)
- }, g)
- }
- ,
- A.getChildByName = function(a) {
- var b, c, d = this;
- for (b = 0; b < d.children.length; b++)
- if (c = d.children[b],
- c.name == a)
- return c
- }
- ,
- o.prototype = {
- remove: function(a) {
- d(a),
- this.entries[a.id] = null
- },
- find: function(a) {
- var b, c = a.split("/"), d = this.root;
- for (b = 0; d && b < c.length; b++)
- d = d.getChildByName(c[b]);
- return d
- },
- getById: function(a) {
- return this.entries[a]
- },
- importBlob: function(a, b, c) {
- h(this),
- this.root.importBlob(a, b, c)
- },
- importText: function(a, b, c) {
- h(this),
- this.root.importText(a, b, c)
- },
- importData64URI: function(a, b, c) {
- h(this),
- this.root.importData64URI(a, b, c)
- },
- exportBlob: function(a, b, c) {
- this.root.exportBlob(a, b, c)
- },
- exportText: function(a, b, c) {
- this.root.exportText(a, b, c)
- },
- exportFileEntry: function(a, b, c, d) {
- this.root.exportFileEntry(a, b, c, d)
- },
- exportData64URI: function(a, b, c) {
- this.root.exportData64URI(a, b, c)
- }
- },
- zip.fs = {
- FS: o,
- ZipDirectoryEntry: n,
- ZipFileEntry: m
- },
- zip.getMimeType = function() {
- return "application/octet-stream"
- }
- }(),
- function() {
- function a(a) {
- function b(b, c) {
- var d;
- e.data ? b() : (d = new XMLHttpRequest,
- d.addEventListener("load", function() {
- e.size || (e.size = Number(d.getResponseHeader("Content-Length"))),
- e.data = new Uint8Array(d.response),
- b()
- }, !1),
- d.addEventListener("error", c, !1),
- d.open("GET", a),
- d.responseType = "arraybuffer",
- d.send())
- }
- function c(b, c) {
- var d = new XMLHttpRequest;
- d.addEventListener("load", function() {
- e.size = Number(d.getResponseHeader("Content-Length")),
- b()
- }, !1),
- d.addEventListener("error", c, !1),
- d.open("HEAD", a),
- d.send()
- }
- function d(a, c, d, f) {
- b(function() {
- d(new Uint8Array(e.data.subarray(a, a + c)))
- }, f)
- }
- var e = this;
- e.size = 0,
- e.init = c,
- e.readUint8Array = d
- }
- function b(a) {
- function b(b, c) {
- var d = new XMLHttpRequest;
- d.addEventListener("load", function() {
- e.size = Number(d.getResponseHeader("Content-Length")),
- "bytes" == d.getResponseHeader("Accept-Ranges") ? b() : c(h)
- }, !1),
- d.addEventListener("error", c, !1),
- d.open("HEAD", a),
- d.send()
- }
- function c(b, c, d, e) {
- var f = new XMLHttpRequest;
- f.open("GET", a),
- f.responseType = "arraybuffer",
- f.setRequestHeader("Range", "bytes=" + b + "-" + (b + c - 1)),
- f.addEventListener("load", function() {
- d(f.response)
- }, !1),
- f.addEventListener("error", e, !1),
- f.send()
- }
- function d(a, b, d, e) {
- c(a, b, function(a) {
- d(new Uint8Array(a))
- }, e)
- }
- var e = this;
- e.size = 0,
- e.init = b,
- e.readUint8Array = d
- }
- function c(a) {
- function b(b) {
- d.size = a.byteLength,
- b()
- }
- function c(b, c, d) {
- d(new Uint8Array(a.slice(b, b + c)))
- }
- var d = this;
- d.size = 0,
- d.init = b,
- d.readUint8Array = c
- }
- function d() {
- function a(a) {
- d = new Uint8Array,
- a()
- }
- function b(a, b) {
- var c = new Uint8Array(d.length + a.length);
- c.set(d),
- c.set(a, d.length),
- d = c,
- b()
- }
- function c(a) {
- a(d.buffer)
- }
- var d, e = this;
- e.init = a,
- e.writeUint8Array = b,
- e.getData = c
- }
- function e(a, b) {
- function c(b, c) {
- a.createWriter(function(a) {
- f = a,
- b()
- }, c)
- }
- function d(a, c, d) {
- var e = new Blob([g ? a : a.buffer],{
- type: b
- });
- f.onwrite = function() {
- f.onwrite = null,
- c()
- }
- ,
- f.onerror = d,
- f.write(e)
- }
- function e(b) {
- a.file(b)
- }
- var f, h = this;
- h.init = c,
- h.writeUint8Array = d,
- h.getData = e
- }
- var f, g, h = "HTTP Range not supported.", i = zip.Reader, j = zip.Writer;
- try {
- g = 0 === new Blob([new DataView(new ArrayBuffer(0))]).size
- } catch (k) {}
- a.prototype = new i,
- a.prototype.constructor = a,
- b.prototype = new i,
- b.prototype.constructor = b,
- c.prototype = new i,
- c.prototype.constructor = c,
- d.prototype = new j,
- d.prototype.constructor = d,
- e.prototype = new j,
- e.prototype.constructor = e,
- zip.FileWriter = e,
- zip.HttpReader = a,
- zip.HttpRangeReader = b,
- zip.ArrayBufferReader = c,
- zip.ArrayBufferWriter = d,
- zip.fs && (f = zip.fs.ZipDirectoryEntry,
- f.prototype.addHttpContent = function(c, d, e) {
- function g(a, b, c, d) {
- if (a.directory)
- return d ? new f(a.fs,b,c,a) : new zip.fs.ZipFileEntry(a.fs,b,c,a);
- throw "Parent entry is not a directory."
- }
- return g(this, c, {
- data: d,
- Reader: e ? b : a
- })
- }
- ,
- f.prototype.importHttpContent = function(c, d, e, f) {
- this.importZip(d ? new b(c) : new a(c), e, f)
- }
- ,
- zip.fs.FS.prototype.importHttpContent = function(a, b, c, d) {
- this.entries = [],
- this.root = new f(this),
- this.root.importHttpContent(a, b, c, d)
- }
- )
- }(),
- function() {
- var a = {
- application: {
- "andrew-inset": "ez",
- annodex: "anx",
- "atom+xml": "atom",
- "atomcat+xml": "atomcat",
- "atomserv+xml": "atomsrv",
- bbolin: "lin",
- cap: ["cap", "pcap"],
- "cu-seeme": "cu",
- "davmount+xml": "davmount",
- dsptype: "tsp",
- ecmascript: ["es", "ecma"],
- futuresplash: "spl",
- hta: "hta",
- "java-archive": "jar",
- "java-serialized-object": "ser",
- "java-vm": "class",
- javascript: "js",
- m3g: "m3g",
- "mac-binhex40": "hqx",
- mathematica: ["nb", "ma", "mb"],
- msaccess: "mdb",
- msword: ["doc", "dot"],
- mxf: "mxf",
- oda: "oda",
- ogg: "ogx",
- pdf: "pdf",
- "pgp-keys": "key",
- "pgp-signature": ["asc", "sig"],
- "pics-rules": "prf",
- postscript: ["ps", "ai", "eps", "epsi", "epsf", "eps2", "eps3"],
- rar: "rar",
- "rdf+xml": "rdf",
- "rss+xml": "rss",
- rtf: "rtf",
- smil: ["smi", "smil"],
- "xhtml+xml": ["xhtml", "xht"],
- xml: ["xml", "xsl", "xsd"],
- "xspf+xml": "xspf",
- zip: "zip",
- "vnd.android.package-archive": "apk",
- "vnd.cinderella": "cdy",
- "vnd.google-earth.kml+xml": "kml",
- "vnd.google-earth.kmz": "kmz",
- "vnd.mozilla.xul+xml": "xul",
- "vnd.ms-excel": ["xls", "xlb", "xlt", "xlm", "xla", "xlc", "xlw"],
- "vnd.ms-pki.seccat": "cat",
- "vnd.ms-pki.stl": "stl",
- "vnd.ms-powerpoint": ["ppt", "pps", "pot"],
- "vnd.oasis.opendocument.chart": "odc",
- "vnd.oasis.opendocument.database": "odb",
- "vnd.oasis.opendocument.formula": "odf",
- "vnd.oasis.opendocument.graphics": "odg",
- "vnd.oasis.opendocument.graphics-template": "otg",
- "vnd.oasis.opendocument.image": "odi",
- "vnd.oasis.opendocument.presentation": "odp",
- "vnd.oasis.opendocument.presentation-template": "otp",
- "vnd.oasis.opendocument.spreadsheet": "ods",
- "vnd.oasis.opendocument.spreadsheet-template": "ots",
- "vnd.oasis.opendocument.text": "odt",
- "vnd.oasis.opendocument.text-master": "odm",
- "vnd.oasis.opendocument.text-template": "ott",
- "vnd.oasis.opendocument.text-web": "oth",
- "vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
- "vnd.openxmlformats-officedocument.spreadsheetml.template": "xltx",
- "vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
- "vnd.openxmlformats-officedocument.presentationml.slideshow": "ppsx",
- "vnd.openxmlformats-officedocument.presentationml.template": "potx",
- "vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
- "vnd.openxmlformats-officedocument.wordprocessingml.template": "dotx",
- "vnd.smaf": "mmf",
- "vnd.stardivision.calc": "sdc",
- "vnd.stardivision.chart": "sds",
- "vnd.stardivision.draw": "sda",
- "vnd.stardivision.impress": "sdd",
- "vnd.stardivision.math": ["sdf", "smf"],
- "vnd.stardivision.writer": ["sdw", "vor"],
- "vnd.stardivision.writer-global": "sgl",
- "vnd.sun.xml.calc": "sxc",
- "vnd.sun.xml.calc.template": "stc",
- "vnd.sun.xml.draw": "sxd",
- "vnd.sun.xml.draw.template": "std",
- "vnd.sun.xml.impress": "sxi",
- "vnd.sun.xml.impress.template": "sti",
- "vnd.sun.xml.math": "sxm",
- "vnd.sun.xml.writer": "sxw",
- "vnd.sun.xml.writer.global": "sxg",
- "vnd.sun.xml.writer.template": "stw",
- "vnd.symbian.install": ["sis", "sisx"],
- "vnd.visio": ["vsd", "vst", "vss", "vsw"],
- "vnd.wap.wbxml": "wbxml",
- "vnd.wap.wmlc": "wmlc",
- "vnd.wap.wmlscriptc": "wmlsc",
- "vnd.wordperfect": "wpd",
- "vnd.wordperfect5.1": "wp5",
- "x-123": "wk",
- "x-7z-compressed": "7z",
- "x-abiword": "abw",
- "x-apple-diskimage": "dmg",
- "x-bcpio": "bcpio",
- "x-bittorrent": "torrent",
- "x-cbr": ["cbr", "cba", "cbt", "cb7"],
- "x-cbz": "cbz",
- "x-cdf": ["cdf", "cda"],
- "x-cdlink": "vcd",
- "x-chess-pgn": "pgn",
- "x-cpio": "cpio",
- "x-csh": "csh",
- "x-debian-package": ["deb", "udeb"],
- "x-director": ["dcr", "dir", "dxr", "cst", "cct", "cxt", "w3d", "fgd", "swa"],
- "x-dms": "dms",
- "x-doom": "wad",
- "x-dvi": "dvi",
- "x-httpd-eruby": "rhtml",
- "x-font": "pcf.Z",
- "x-freemind": "mm",
- "x-gnumeric": "gnumeric",
- "x-go-sgf": "sgf",
- "x-graphing-calculator": "gcf",
- "x-gtar": ["gtar", "taz"],
- "x-hdf": "hdf",
- "x-httpd-php": ["phtml", "pht", "php"],
- "x-httpd-php-source": "phps",
- "x-httpd-php3": "php3",
- "x-httpd-php3-preprocessed": "php3p",
- "x-httpd-php4": "php4",
- "x-httpd-php5": "php5",
- "x-ica": "ica",
- "x-info": "info",
- "x-internet-signup": ["ins", "isp"],
- "x-iphone": "iii",
- "x-iso9660-image": "iso",
- "x-java-jnlp-file": "jnlp",
- "x-jmol": "jmz",
- "x-killustrator": "kil",
- "x-koan": ["skp", "skd", "skt", "skm"],
- "x-kpresenter": ["kpr", "kpt"],
- "x-kword": ["kwd", "kwt"],
- "x-latex": "latex",
- "x-lha": "lha",
- "x-lyx": "lyx",
- "x-lzh": "lzh",
- "x-lzx": "lzx",
- "x-maker": ["frm", "maker", "frame", "fm", "fb", "book", "fbdoc"],
- "x-ms-wmd": "wmd",
- "x-ms-wmz": "wmz",
- "x-msdos-program": ["com", "exe", "bat", "dll"],
- "x-msi": "msi",
- "x-netcdf": ["nc", "cdf"],
- "x-ns-proxy-autoconfig": ["pac", "dat"],
- "x-nwc": "nwc",
- "x-object": "o",
- "x-oz-application": "oza",
- "x-pkcs7-certreqresp": "p7r",
- "x-python-code": ["pyc", "pyo"],
- "x-qgis": ["qgs", "shp", "shx"],
- "x-quicktimeplayer": "qtl",
- "x-redhat-package-manager": "rpm",
- "x-ruby": "rb",
- "x-sh": "sh",
- "x-shar": "shar",
- "x-shockwave-flash": ["swf", "swfl"],
- "x-silverlight": "scr",
- "x-stuffit": "sit",
- "x-sv4cpio": "sv4cpio",
- "x-sv4crc": "sv4crc",
- "x-tar": "tar",
- "x-tcl": "tcl",
- "x-tex-gf": "gf",
- "x-tex-pk": "pk",
- "x-texinfo": ["texinfo", "texi"],
- "x-trash": ["~", "%", "bak", "old", "sik"],
- "x-troff": ["t", "tr", "roff"],
- "x-troff-man": "man",
- "x-troff-me": "me",
- "x-troff-ms": "ms",
- "x-ustar": "ustar",
- "x-wais-source": "src",
- "x-wingz": "wz",
- "x-x509-ca-cert": ["crt", "der", "cer"],
- "x-xcf": "xcf",
- "x-xfig": "fig",
- "x-xpinstall": "xpi",
- applixware: "aw",
- "atomsvc+xml": "atomsvc",
- "ccxml+xml": "ccxml",
- "cdmi-capability": "cdmia",
- "cdmi-container": "cdmic",
- "cdmi-domain": "cdmid",
- "cdmi-object": "cdmio",
- "cdmi-queue": "cdmiq",
- "docbook+xml": "dbk",
- "dssc+der": "dssc",
- "dssc+xml": "xdssc",
- "emma+xml": "emma",
- "epub+zip": "epub",
- exi: "exi",
- "font-tdpfr": "pfr",
- "gml+xml": "gml",
- "gpx+xml": "gpx",
- gxf: "gxf",
- hyperstudio: "stk",
- "inkml+xml": ["ink", "inkml"],
- ipfix: "ipfix",
- json: "json",
- "jsonml+json": "jsonml",
- "lost+xml": "lostxml",
- "mads+xml": "mads",
- marc: "mrc",
- "marcxml+xml": "mrcx",
- "mathml+xml": "mathml",
- mbox: "mbox",
- "mediaservercontrol+xml": "mscml",
- "metalink+xml": "metalink",
- "metalink4+xml": "meta4",
- "mets+xml": "mets",
- "mods+xml": "mods",
- mp21: ["m21", "mp21"],
- mp4: "mp4s",
- "oebps-package+xml": "opf",
- "omdoc+xml": "omdoc",
- onenote: ["onetoc", "onetoc2", "onetmp", "onepkg"],
- oxps: "oxps",
- "patch-ops-error+xml": "xer",
- "pgp-encrypted": "pgp",
- pkcs10: "p10",
- "pkcs7-mime": ["p7m", "p7c"],
- "pkcs7-signature": "p7s",
- pkcs8: "p8",
- "pkix-attr-cert": "ac",
- "pkix-crl": "crl",
- "pkix-pkipath": "pkipath",
- pkixcmp: "pki",
- "pls+xml": "pls",
- "prs.cww": "cww",
- "pskc+xml": "pskcxml",
- "reginfo+xml": "rif",
- "relax-ng-compact-syntax": "rnc",
- "resource-lists+xml": "rl",
- "resource-lists-diff+xml": "rld",
- "rls-services+xml": "rs",
- "rpki-ghostbusters": "gbr",
- "rpki-manifest": "mft",
- "rpki-roa": "roa",
- "rsd+xml": "rsd",
- "sbml+xml": "sbml",
- "scvp-cv-request": "scq",
- "scvp-cv-response": "scs",
- "scvp-vp-request": "spq",
- "scvp-vp-response": "spp",
- sdp: "sdp",
- "set-payment-initiation": "setpay",
- "set-registration-initiation": "setreg",
- "shf+xml": "shf",
- "sparql-query": "rq",
- "sparql-results+xml": "srx",
- srgs: "gram",
- "srgs+xml": "grxml",
- "sru+xml": "sru",
- "ssdl+xml": "ssdl",
- "ssml+xml": "ssml",
- "tei+xml": ["tei", "teicorpus"],
- "thraud+xml": "tfi",
- "timestamped-data": "tsd",
- "vnd.3gpp.pic-bw-large": "plb",
- "vnd.3gpp.pic-bw-small": "psb",
- "vnd.3gpp.pic-bw-var": "pvb",
- "vnd.3gpp2.tcap": "tcap",
- "vnd.3m.post-it-notes": "pwn",
- "vnd.accpac.simply.aso": "aso",
- "vnd.accpac.simply.imp": "imp",
- "vnd.acucobol": "acu",
- "vnd.acucorp": ["atc", "acutc"],
- "vnd.adobe.air-application-installer-package+zip": "air",
- "vnd.adobe.formscentral.fcdt": "fcdt",
- "vnd.adobe.fxp": ["fxp", "fxpl"],
- "vnd.adobe.xdp+xml": "xdp",
- "vnd.adobe.xfdf": "xfdf",
- "vnd.ahead.space": "ahead",
- "vnd.airzip.filesecure.azf": "azf",
- "vnd.airzip.filesecure.azs": "azs",
- "vnd.amazon.ebook": "azw",
- "vnd.americandynamics.acc": "acc",
- "vnd.amiga.ami": "ami",
- "vnd.anser-web-certificate-issue-initiation": "cii",
- "vnd.anser-web-funds-transfer-initiation": "fti",
- "vnd.antix.game-component": "atx",
- "vnd.apple.installer+xml": "mpkg",
- "vnd.apple.mpegurl": "m3u8",
- "vnd.aristanetworks.swi": "swi",
- "vnd.astraea-software.iota": "iota",
- "vnd.audiograph": "aep",
- "vnd.blueice.multipass": "mpm",
- "vnd.bmi": "bmi",
- "vnd.businessobjects": "rep",
- "vnd.chemdraw+xml": "cdxml",
- "vnd.chipnuts.karaoke-mmd": "mmd",
- "vnd.claymore": "cla",
- "vnd.cloanto.rp9": "rp9",
- "vnd.clonk.c4group": ["c4g", "c4d", "c4f", "c4p", "c4u"],
- "vnd.cluetrust.cartomobile-config": "c11amc",
- "vnd.cluetrust.cartomobile-config-pkg": "c11amz",
- "vnd.commonspace": "csp",
- "vnd.contact.cmsg": "cdbcmsg",
- "vnd.cosmocaller": "cmc",
- "vnd.crick.clicker": "clkx",
- "vnd.crick.clicker.keyboard": "clkk",
- "vnd.crick.clicker.palette": "clkp",
- "vnd.crick.clicker.template": "clkt",
- "vnd.crick.clicker.wordbank": "clkw",
- "vnd.criticaltools.wbs+xml": "wbs",
- "vnd.ctc-posml": "pml",
- "vnd.cups-ppd": "ppd",
- "vnd.curl.car": "car",
- "vnd.curl.pcurl": "pcurl",
- "vnd.dart": "dart",
- "vnd.data-vision.rdz": "rdz",
- "vnd.dece.data": ["uvf", "uvvf", "uvd", "uvvd"],
- "vnd.dece.ttml+xml": ["uvt", "uvvt"],
- "vnd.dece.unspecified": ["uvx", "uvvx"],
- "vnd.dece.zip": ["uvz", "uvvz"],
- "vnd.denovo.fcselayout-link": "fe_launch",
- "vnd.dna": "dna",
- "vnd.dolby.mlp": "mlp",
- "vnd.dpgraph": "dpg",
- "vnd.dreamfactory": "dfac",
- "vnd.ds-keypoint": "kpxx",
- "vnd.dvb.ait": "ait",
- "vnd.dvb.service": "svc",
- "vnd.dynageo": "geo",
- "vnd.ecowin.chart": "mag",
- "vnd.enliven": "nml",
- "vnd.epson.esf": "esf",
- "vnd.epson.msf": "msf",
- "vnd.epson.quickanime": "qam",
- "vnd.epson.salt": "slt",
- "vnd.epson.ssf": "ssf",
- "vnd.eszigno3+xml": ["es3", "et3"],
- "vnd.ezpix-album": "ez2",
- "vnd.ezpix-package": "ez3",
- "vnd.fdf": "fdf",
- "vnd.fdsn.mseed": "mseed",
- "vnd.fdsn.seed": ["seed", "dataless"],
- "vnd.flographit": "gph",
- "vnd.fluxtime.clip": "ftc",
- "vnd.framemaker": ["fm", "frame", "maker", "book"],
- "vnd.frogans.fnc": "fnc",
- "vnd.frogans.ltf": "ltf",
- "vnd.fsc.weblaunch": "fsc",
- "vnd.fujitsu.oasys": "oas",
- "vnd.fujitsu.oasys2": "oa2",
- "vnd.fujitsu.oasys3": "oa3",
- "vnd.fujitsu.oasysgp": "fg5",
- "vnd.fujitsu.oasysprs": "bh2",
- "vnd.fujixerox.ddd": "ddd",
- "vnd.fujixerox.docuworks": "xdw",
- "vnd.fujixerox.docuworks.binder": "xbd",
- "vnd.fuzzysheet": "fzs",
- "vnd.genomatix.tuxedo": "txd",
- "vnd.geogebra.file": "ggb",
- "vnd.geogebra.tool": "ggt",
- "vnd.geometry-explorer": ["gex", "gre"],
- "vnd.geonext": "gxt",
- "vnd.geoplan": "g2w",
- "vnd.geospace": "g3w",
- "vnd.gmx": "gmx",
- "vnd.grafeq": ["gqf", "gqs"],
- "vnd.groove-account": "gac",
- "vnd.groove-help": "ghf",
- "vnd.groove-identity-message": "gim",
- "vnd.groove-injector": "grv",
- "vnd.groove-tool-message": "gtm",
- "vnd.groove-tool-template": "tpl",
- "vnd.groove-vcard": "vcg",
- "vnd.hal+xml": "hal",
- "vnd.handheld-entertainment+xml": "zmm",
- "vnd.hbci": "hbci",
- "vnd.hhe.lesson-player": "les",
- "vnd.hp-hpgl": "hpgl",
- "vnd.hp-hpid": "hpid",
- "vnd.hp-hps": "hps",
- "vnd.hp-jlyt": "jlt",
- "vnd.hp-pcl": "pcl",
- "vnd.hp-pclxl": "pclxl",
- "vnd.hydrostatix.sof-data": "sfd-hdstx",
- "vnd.ibm.minipay": "mpy",
- "vnd.ibm.modcap": ["afp", "listafp", "list3820"],
- "vnd.ibm.rights-management": "irm",
- "vnd.ibm.secure-container": "sc",
- "vnd.iccprofile": ["icc", "icm"],
- "vnd.igloader": "igl",
- "vnd.immervision-ivp": "ivp",
- "vnd.immervision-ivu": "ivu",
- "vnd.insors.igm": "igm",
- "vnd.intercon.formnet": ["xpw", "xpx"],
- "vnd.intergeo": "i2g",
- "vnd.intu.qbo": "qbo",
- "vnd.intu.qfx": "qfx",
- "vnd.ipunplugged.rcprofile": "rcprofile",
- "vnd.irepository.package+xml": "irp",
- "vnd.is-xpr": "xpr",
- "vnd.isac.fcs": "fcs",
- "vnd.jam": "jam",
- "vnd.jcp.javame.midlet-rms": "rms",
- "vnd.jisp": "jisp",
- "vnd.joost.joda-archive": "joda",
- "vnd.kahootz": ["ktz", "ktr"],
- "vnd.kde.karbon": "karbon",
- "vnd.kde.kchart": "chrt",
- "vnd.kde.kformula": "kfo",
- "vnd.kde.kivio": "flw",
- "vnd.kde.kontour": "kon",
- "vnd.kde.kpresenter": ["kpr", "kpt"],
- "vnd.kde.kspread": "ksp",
- "vnd.kde.kword": ["kwd", "kwt"],
- "vnd.kenameaapp": "htke",
- "vnd.kidspiration": "kia",
- "vnd.kinar": ["kne", "knp"],
- "vnd.koan": ["skp", "skd", "skt", "skm"],
- "vnd.kodak-descriptor": "sse",
- "vnd.las.las+xml": "lasxml",
- "vnd.llamagraphics.life-balance.desktop": "lbd",
- "vnd.llamagraphics.life-balance.exchange+xml": "lbe",
- "vnd.lotus-1-2-3": "123",
- "vnd.lotus-approach": "apr",
- "vnd.lotus-freelance": "pre",
- "vnd.lotus-notes": "nsf",
- "vnd.lotus-organizer": "org",
- "vnd.lotus-screencam": "scm",
- "vnd.lotus-wordpro": "lwp",
- "vnd.macports.portpkg": "portpkg",
- "vnd.mcd": "mcd",
- "vnd.medcalcdata": "mc1",
- "vnd.mediastation.cdkey": "cdkey",
- "vnd.mfer": "mwf",
- "vnd.mfmp": "mfm",
- "vnd.micrografx.flo": "flo",
- "vnd.micrografx.igx": "igx",
- "vnd.mif": "mif",
- "vnd.mobius.daf": "daf",
- "vnd.mobius.dis": "dis",
- "vnd.mobius.mbk": "mbk",
- "vnd.mobius.mqy": "mqy",
- "vnd.mobius.msl": "msl",
- "vnd.mobius.plc": "plc",
- "vnd.mobius.txf": "txf",
- "vnd.mophun.application": "mpn",
- "vnd.mophun.certificate": "mpc",
- "vnd.ms-artgalry": "cil",
- "vnd.ms-cab-compressed": "cab",
- "vnd.ms-excel.addin.macroenabled.12": "xlam",
- "vnd.ms-excel.sheet.binary.macroenabled.12": "xlsb",
- "vnd.ms-excel.sheet.macroenabled.12": "xlsm",
- "vnd.ms-excel.template.macroenabled.12": "xltm",
- "vnd.ms-fontobject": "eot",
- "vnd.ms-htmlhelp": "chm",
- "vnd.ms-ims": "ims",
- "vnd.ms-lrm": "lrm",
- "vnd.ms-officetheme": "thmx",
- "vnd.ms-powerpoint.addin.macroenabled.12": "ppam",
- "vnd.ms-powerpoint.presentation.macroenabled.12": "pptm",
- "vnd.ms-powerpoint.slide.macroenabled.12": "sldm",
- "vnd.ms-powerpoint.slideshow.macroenabled.12": "ppsm",
- "vnd.ms-powerpoint.template.macroenabled.12": "potm",
- "vnd.ms-project": ["mpp", "mpt"],
- "vnd.ms-word.document.macroenabled.12": "docm",
- "vnd.ms-word.template.macroenabled.12": "dotm",
- "vnd.ms-works": ["wps", "wks", "wcm", "wdb"],
- "vnd.ms-wpl": "wpl",
- "vnd.ms-xpsdocument": "xps",
- "vnd.mseq": "mseq",
- "vnd.musician": "mus",
- "vnd.muvee.style": "msty",
- "vnd.mynfc": "taglet",
- "vnd.neurolanguage.nlu": "nlu",
- "vnd.nitf": ["ntf", "nitf"],
- "vnd.noblenet-directory": "nnd",
- "vnd.noblenet-sealer": "nns",
- "vnd.noblenet-web": "nnw",
- "vnd.nokia.n-gage.data": "ngdat",
- "vnd.nokia.n-gage.symbian.install": "n-gage",
- "vnd.nokia.radio-preset": "rpst",
- "vnd.nokia.radio-presets": "rpss",
- "vnd.novadigm.edm": "edm",
- "vnd.novadigm.edx": "edx",
- "vnd.novadigm.ext": "ext",
- "vnd.oasis.opendocument.chart-template": "otc",
- "vnd.oasis.opendocument.formula-template": "odft",
- "vnd.oasis.opendocument.image-template": "oti",
- "vnd.olpc-sugar": "xo",
- "vnd.oma.dd2+xml": "dd2",
- "vnd.openofficeorg.extension": "oxt",
- "vnd.openxmlformats-officedocument.presentationml.slide": "sldx",
- "vnd.osgeo.mapguide.package": "mgp",
- "vnd.osgi.dp": "dp",
- "vnd.osgi.subsystem": "esa",
- "vnd.palm": ["pdb", "pqa", "oprc"],
- "vnd.pawaafile": "paw",
- "vnd.pg.format": "str",
- "vnd.pg.osasli": "ei6",
- "vnd.picsel": "efif",
- "vnd.pmi.widget": "wg",
- "vnd.pocketlearn": "plf",
- "vnd.powerbuilder6": "pbd",
- "vnd.previewsystems.box": "box",
- "vnd.proteus.magazine": "mgz",
- "vnd.publishare-delta-tree": "qps",
- "vnd.pvi.ptid1": "ptid",
- "vnd.quark.quarkxpress": ["qxd", "qxt", "qwd", "qwt", "qxl", "qxb"],
- "vnd.realvnc.bed": "bed",
- "vnd.recordare.musicxml": "mxl",
- "vnd.recordare.musicxml+xml": "musicxml",
- "vnd.rig.cryptonote": "cryptonote",
- "vnd.rn-realmedia": "rm",
- "vnd.rn-realmedia-vbr": "rmvb",
- "vnd.route66.link66+xml": "link66",
- "vnd.sailingtracker.track": "st",
- "vnd.seemail": "see",
- "vnd.sema": "sema",
- "vnd.semd": "semd",
- "vnd.semf": "semf",
- "vnd.shana.informed.formdata": "ifm",
- "vnd.shana.informed.formtemplate": "itp",
- "vnd.shana.informed.interchange": "iif",
- "vnd.shana.informed.package": "ipk",
- "vnd.simtech-mindmapper": ["twd", "twds"],
- "vnd.smart.teacher": "teacher",
- "vnd.solent.sdkm+xml": ["sdkm", "sdkd"],
- "vnd.spotfire.dxp": "dxp",
- "vnd.spotfire.sfs": "sfs",
- "vnd.stepmania.package": "smzip",
- "vnd.stepmania.stepchart": "sm",
- "vnd.sus-calendar": ["sus", "susp"],
- "vnd.svd": "svd",
- "vnd.syncml+xml": "xsm",
- "vnd.syncml.dm+wbxml": "bdm",
- "vnd.syncml.dm+xml": "xdm",
- "vnd.tao.intent-module-archive": "tao",
- "vnd.tcpdump.pcap": ["pcap", "cap", "dmp"],
- "vnd.tmobile-livetv": "tmo",
- "vnd.trid.tpt": "tpt",
- "vnd.triscape.mxs": "mxs",
- "vnd.trueapp": "tra",
- "vnd.ufdl": ["ufd", "ufdl"],
- "vnd.uiq.theme": "utz",
- "vnd.umajin": "umj",
- "vnd.unity": "unityweb",
- "vnd.uoml+xml": "uoml",
- "vnd.vcx": "vcx",
- "vnd.visionary": "vis",
- "vnd.vsf": "vsf",
- "vnd.webturbo": "wtb",
- "vnd.wolfram.player": "nbp",
- "vnd.wqd": "wqd",
- "vnd.wt.stf": "stf",
- "vnd.xara": "xar",
- "vnd.xfdl": "xfdl",
- "vnd.yamaha.hv-dic": "hvd",
- "vnd.yamaha.hv-script": "hvs",
- "vnd.yamaha.hv-voice": "hvp",
- "vnd.yamaha.openscoreformat": "osf",
- "vnd.yamaha.openscoreformat.osfpvg+xml": "osfpvg",
- "vnd.yamaha.smaf-audio": "saf",
- "vnd.yamaha.smaf-phrase": "spf",
- "vnd.yellowriver-custom-menu": "cmp",
- "vnd.zul": ["zir", "zirz"],
- "vnd.zzazz.deck+xml": "zaz",
- "voicexml+xml": "vxml",
- widget: "wgt",
- winhlp: "hlp",
- "wsdl+xml": "wsdl",
- "wspolicy+xml": "wspolicy",
- "x-ace-compressed": "ace",
- "x-authorware-bin": ["aab", "x32", "u32", "vox"],
- "x-authorware-map": "aam",
- "x-authorware-seg": "aas",
- "x-blorb": ["blb", "blorb"],
- "x-bzip": "bz",
- "x-bzip2": ["bz2", "boz"],
- "x-cfs-compressed": "cfs",
- "x-chat": "chat",
- "x-conference": "nsc",
- "x-dgc-compressed": "dgc",
- "x-dtbncx+xml": "ncx",
- "x-dtbook+xml": "dtb",
- "x-dtbresource+xml": "res",
- "x-eva": "eva",
- "x-font-bdf": "bdf",
- "x-font-ghostscript": "gsf",
- "x-font-linux-psf": "psf",
- "x-font-otf": "otf",
- "x-font-pcf": "pcf",
- "x-font-snf": "snf",
- "x-font-ttf": ["ttf", "ttc"],
- "x-font-type1": ["pfa", "pfb", "pfm", "afm"],
- "x-font-woff": "woff",
- "x-freearc": "arc",
- "x-gca-compressed": "gca",
- "x-glulx": "ulx",
- "x-gramps-xml": "gramps",
- "x-install-instructions": "install",
- "x-lzh-compressed": ["lzh", "lha"],
- "x-mie": "mie",
- "x-mobipocket-ebook": ["prc", "mobi"],
- "x-ms-application": "application",
- "x-ms-shortcut": "lnk",
- "x-ms-xbap": "xbap",
- "x-msbinder": "obd",
- "x-mscardfile": "crd",
- "x-msclip": "clp",
- "x-msdownload": ["exe", "dll", "com", "bat", "msi"],
- "x-msmediaview": ["mvb", "m13", "m14"],
- "x-msmetafile": ["wmf", "wmz", "emf", "emz"],
- "x-msmoney": "mny",
- "x-mspublisher": "pub",
- "x-msschedule": "scd",
- "x-msterminal": "trm",
- "x-mswrite": "wri",
- "x-nzb": "nzb",
- "x-pkcs12": ["p12", "pfx"],
- "x-pkcs7-certificates": ["p7b", "spc"],
- "x-research-info-systems": "ris",
- "x-silverlight-app": "xap",
- "x-sql": "sql",
- "x-stuffitx": "sitx",
- "x-subrip": "srt",
- "x-t3vm-image": "t3",
- "x-tads": "gam",
- "x-tex": "tex",
- "x-tex-tfm": "tfm",
- "x-tgif": "obj",
- "x-xliff+xml": "xlf",
- "x-xz": "xz",
- "x-zmachine": ["z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8"],
- "xaml+xml": "xaml",
- "xcap-diff+xml": "xdf",
- "xenc+xml": "xenc",
- "xml-dtd": "dtd",
- "xop+xml": "xop",
- "xproc+xml": "xpl",
- "xslt+xml": "xslt",
- "xv+xml": ["mxml", "xhvml", "xvml", "xvm"],
- yang: "yang",
- "yin+xml": "yin",
- envoy: "evy",
- fractals: "fif",
- "internet-property-stream": "acx",
- olescript: "axs",
- "vnd.ms-outlook": "msg",
- "vnd.ms-pkicertstore": "sst",
- "x-compress": "z",
- "x-compressed": "tgz",
- "x-gzip": "gz",
- "x-perfmon": ["pma", "pmc", "pml", "pmr", "pmw"],
- "x-pkcs7-mime": ["p7c", "p7m"],
- "ynd.ms-pkipko": "pko"
- },
- audio: {
- amr: "amr",
- "amr-wb": "awb",
- annodex: "axa",
- basic: ["au", "snd"],
- flac: "flac",
- midi: ["mid", "midi", "kar", "rmi"],
- mpeg: ["mpga", "mpega", "mp2", "mp3", "m4a", "mp2a", "m2a", "m3a"],
- mpegurl: "m3u",
- ogg: ["oga", "ogg", "spx"],
- "prs.sid": "sid",
- "x-aiff": ["aif", "aiff", "aifc"],
- "x-gsm": "gsm",
- "x-ms-wma": "wma",
- "x-ms-wax": "wax",
- "x-pn-realaudio": "ram",
- "x-realaudio": "ra",
- "x-sd2": "sd2",
- "x-wav": "wav",
- adpcm: "adp",
- mp4: "mp4a",
- s3m: "s3m",
- silk: "sil",
- "vnd.dece.audio": ["uva", "uvva"],
- "vnd.digital-winds": "eol",
- "vnd.dra": "dra",
- "vnd.dts": "dts",
- "vnd.dts.hd": "dtshd",
- "vnd.lucent.voice": "lvp",
- "vnd.ms-playready.media.pya": "pya",
- "vnd.nuera.ecelp4800": "ecelp4800",
- "vnd.nuera.ecelp7470": "ecelp7470",
- "vnd.nuera.ecelp9600": "ecelp9600",
- "vnd.rip": "rip",
- webm: "weba",
- "x-aac": "aac",
- "x-caf": "caf",
- "x-matroska": "mka",
- "x-pn-realaudio-plugin": "rmp",
- xm: "xm",
- mid: ["mid", "rmi"]
- },
- chemical: {
- "x-alchemy": "alc",
- "x-cache": ["cac", "cache"],
- "x-cache-csf": "csf",
- "x-cactvs-binary": ["cbin", "cascii", "ctab"],
- "x-cdx": "cdx",
- "x-chem3d": "c3d",
- "x-cif": "cif",
- "x-cmdf": "cmdf",
- "x-cml": "cml",
- "x-compass": "cpa",
- "x-crossfire": "bsd",
- "x-csml": ["csml", "csm"],
- "x-ctx": "ctx",
- "x-cxf": ["cxf", "cef"],
- "x-embl-dl-nucleotide": ["emb", "embl"],
- "x-gamess-input": ["inp", "gam", "gamin"],
- "x-gaussian-checkpoint": ["fch", "fchk"],
- "x-gaussian-cube": "cub",
- "x-gaussian-input": ["gau", "gjc", "gjf"],
- "x-gaussian-log": "gal",
- "x-gcg8-sequence": "gcg",
- "x-genbank": "gen",
- "x-hin": "hin",
- "x-isostar": ["istr", "ist"],
- "x-jcamp-dx": ["jdx", "dx"],
- "x-kinemage": "kin",
- "x-macmolecule": "mcm",
- "x-macromodel-input": ["mmd", "mmod"],
- "x-mdl-molfile": "mol",
- "x-mdl-rdfile": "rd",
- "x-mdl-rxnfile": "rxn",
- "x-mdl-sdfile": ["sd", "sdf"],
- "x-mdl-tgf": "tgf",
- "x-mmcif": "mcif",
- "x-mol2": "mol2",
- "x-molconn-Z": "b",
- "x-mopac-graph": "gpt",
- "x-mopac-input": ["mop", "mopcrt", "mpc", "zmt"],
- "x-mopac-out": "moo",
- "x-ncbi-asn1": "asn",
- "x-ncbi-asn1-ascii": ["prt", "ent"],
- "x-ncbi-asn1-binary": ["val", "aso"],
- "x-pdb": ["pdb", "ent"],
- "x-rosdal": "ros",
- "x-swissprot": "sw",
- "x-vamas-iso14976": "vms",
- "x-vmd": "vmd",
- "x-xtel": "xtel",
- "x-xyz": "xyz"
- },
- image: {
- gif: "gif",
- ief: "ief",
- jpeg: ["jpeg", "jpg", "jpe"],
- pcx: "pcx",
- png: "png",
- "svg+xml": ["svg", "svgz"],
- tiff: ["tiff", "tif"],
- "vnd.djvu": ["djvu", "djv"],
- "vnd.wap.wbmp": "wbmp",
- "x-canon-cr2": "cr2",
- "x-canon-crw": "crw",
- "x-cmu-raster": "ras",
- "x-coreldraw": "cdr",
- "x-coreldrawpattern": "pat",
- "x-coreldrawtemplate": "cdt",
- "x-corelphotopaint": "cpt",
- "x-epson-erf": "erf",
- "x-icon": "ico",
- "x-jg": "art",
- "x-jng": "jng",
- "x-nikon-nef": "nef",
- "x-olympus-orf": "orf",
- "x-photoshop": "psd",
- "x-portable-anymap": "pnm",
- "x-portable-bitmap": "pbm",
- "x-portable-graymap": "pgm",
- "x-portable-pixmap": "ppm",
- "x-rgb": "rgb",
- "x-xbitmap": "xbm",
- "x-xpixmap": "xpm",
- "x-xwindowdump": "xwd",
- bmp: "bmp",
- cgm: "cgm",
- g3fax: "g3",
- ktx: "ktx",
- "prs.btif": "btif",
- sgi: "sgi",
- "vnd.dece.graphic": ["uvi", "uvvi", "uvg", "uvvg"],
- "vnd.dwg": "dwg",
- "vnd.dxf": "dxf",
- "vnd.fastbidsheet": "fbs",
- "vnd.fpx": "fpx",
- "vnd.fst": "fst",
- "vnd.fujixerox.edmics-mmr": "mmr",
- "vnd.fujixerox.edmics-rlc": "rlc",
- "vnd.ms-modi": "mdi",
- "vnd.ms-photo": "wdp",
- "vnd.net-fpx": "npx",
- "vnd.xiff": "xif",
- webp: "webp",
- "x-3ds": "3ds",
- "x-cmx": "cmx",
- "x-freehand": ["fh", "fhc", "fh4", "fh5", "fh7"],
- "x-pict": ["pic", "pct"],
- "x-tga": "tga",
- "cis-cod": "cod",
- pipeg: "jfif"
- },
- message: {
- rfc822: ["eml", "mime", "mht", "mhtml", "nws"]
- },
- model: {
- iges: ["igs", "iges"],
- mesh: ["msh", "mesh", "silo"],
- vrml: ["wrl", "vrml"],
- "x3d+vrml": ["x3dv", "x3dvz"],
- "x3d+xml": ["x3d", "x3dz"],
- "x3d+binary": ["x3db", "x3dbz"],
- "vnd.collada+xml": "dae",
- "vnd.dwf": "dwf",
- "vnd.gdl": "gdl",
- "vnd.gtw": "gtw",
- "vnd.mts": "mts",
- "vnd.vtu": "vtu"
- },
- text: {
- "cache-manifest": ["manifest", "appcache"],
- calendar: ["ics", "icz", "ifb"],
- css: "css",
- csv: "csv",
- h323: "323",
- html: ["html", "htm", "shtml", "stm"],
- iuls: "uls",
- mathml: "mml",
- plain: ["txt", "text", "brf", "conf", "def", "list", "log", "in", "bas"],
- richtext: "rtx",
- scriptlet: ["sct", "wsc"],
- texmacs: ["tm", "ts"],
- "tab-separated-values": "tsv",
- "vnd.sun.j2me.app-descriptor": "jad",
- "vnd.wap.wml": "wml",
- "vnd.wap.wmlscript": "wmls",
- "x-bibtex": "bib",
- "x-boo": "boo",
- "x-c++hdr": ["h++", "hpp", "hxx", "hh"],
- "x-c++src": ["c++", "cpp", "cxx", "cc"],
- "x-component": "htc",
- "x-dsrc": "d",
- "x-diff": ["diff", "patch"],
- "x-haskell": "hs",
- "x-java": "java",
- "x-literate-haskell": "lhs",
- "x-moc": "moc",
- "x-pascal": ["p", "pas"],
- "x-pcs-gcd": "gcd",
- "x-perl": ["pl", "pm"],
- "x-python": "py",
- "x-scala": "scala",
- "x-setext": "etx",
- "x-tcl": ["tcl", "tk"],
- "x-tex": ["tex", "ltx", "sty", "cls"],
- "x-vcalendar": "vcs",
- "x-vcard": "vcf",
- n3: "n3",
- "prs.lines.tag": "dsc",
- sgml: ["sgml", "sgm"],
- troff: ["t", "tr", "roff", "man", "me", "ms"],
- turtle: "ttl",
- "uri-list": ["uri", "uris", "urls"],
- vcard: "vcard",
- "vnd.curl": "curl",
- "vnd.curl.dcurl": "dcurl",
- "vnd.curl.scurl": "scurl",
- "vnd.curl.mcurl": "mcurl",
- "vnd.dvb.subtitle": "sub",
- "vnd.fly": "fly",
- "vnd.fmi.flexstor": "flx",
- "vnd.graphviz": "gv",
- "vnd.in3d.3dml": "3dml",
- "vnd.in3d.spot": "spot",
- "x-asm": ["s", "asm"],
- "x-c": ["c", "cc", "cxx", "cpp", "h", "hh", "dic"],
- "x-fortran": ["f", "for", "f77", "f90"],
- "x-opml": "opml",
- "x-nfo": "nfo",
- "x-sfv": "sfv",
- "x-uuencode": "uu",
- webviewhtml: "htt"
- },
- video: {
- "3gpp": "3gp",
- annodex: "axv",
- dl: "dl",
- dv: ["dif", "dv"],
- fli: "fli",
- gl: "gl",
- mpeg: ["mpeg", "mpg", "mpe", "m1v", "m2v", "mp2", "mpa", "mpv2"],
- mp4: ["mp4", "mp4v", "mpg4"],
- quicktime: ["qt", "mov"],
- ogg: "ogv",
- "vnd.mpegurl": ["mxu", "m4u"],
- "x-flv": "flv",
- "x-la-asf": ["lsf", "lsx"],
- "x-mng": "mng",
- "x-ms-asf": ["asf", "asx", "asr"],
- "x-ms-wm": "wm",
- "x-ms-wmv": "wmv",
- "x-ms-wmx": "wmx",
- "x-ms-wvx": "wvx",
- "x-msvideo": "avi",
- "x-sgi-movie": "movie",
- "x-matroska": ["mpv", "mkv", "mk3d", "mks"],
- "3gpp2": "3g2",
- h261: "h261",
- h263: "h263",
- h264: "h264",
- jpeg: "jpgv",
- jpm: ["jpm", "jpgm"],
- mj2: ["mj2", "mjp2"],
- "vnd.dece.hd": ["uvh", "uvvh"],
- "vnd.dece.mobile": ["uvm", "uvvm"],
- "vnd.dece.pd": ["uvp", "uvvp"],
- "vnd.dece.sd": ["uvs", "uvvs"],
- "vnd.dece.video": ["uvv", "uvvv"],
- "vnd.dvb.file": "dvb",
- "vnd.fvt": "fvt",
- "vnd.ms-playready.media.pyv": "pyv",
- "vnd.uvvu.mp4": ["uvu", "uvvu"],
- "vnd.vivo": "viv",
- webm: "webm",
- "x-f4v": "f4v",
- "x-m4v": "m4v",
- "x-ms-vob": "vob",
- "x-smv": "smv"
- },
- "x-conference": {
- "x-cooltalk": "ice"
- },
- "x-world": {
- "x-vrml": ["vrm", "vrml", "wrl", "flr", "wrz", "xaf", "xof"]
- }
- }
- , b = function() {
- var b, c, d, e, f = {};
- for (b in a)
- if (a.hasOwnProperty(b))
- for (c in a[b])
- if (a[b].hasOwnProperty(c))
- if (d = a[b][c],
- "string" == typeof d)
- f[d] = b + "/" + c;
- else
- for (e = 0; e < d.length; e++)
- f[d[e]] = b + "/" + c;
- return f
- }();
- zip.getMimeType = function(a) {
- var c = "application/octet-stream";
- return a && b[a.split(".").pop().toLowerCase()] || c
- }
- }(),
- function() {
- "use strict";
- function a(a) {
- return "function" == typeof a || "object" == typeof a && null !== a
- }
- function b(a) {
- return "function" == typeof a
- }
- function c(a) {
- return "object" == typeof a && null !== a
- }
- function d() {}
- function e(a, b) {
- for (var c = 0, d = a.length; c < d; c++)
- if (a[c] === b)
- return c;
- return -1
- }
- function f(a) {
- var b = a._promiseCallbacks;
- return b || (b = a._promiseCallbacks = {}),
- b
- }
- function g(a, b) {
- return "onerror" === a ? void wa.on("error", b) : 2 !== arguments.length ? wa[a] : void (wa[a] = b)
- }
- function h() {
- setTimeout(function() {
- for (var a, b = 0; b < xa.length; b++) {
- a = xa[b];
- var c = a.payload;
- c.guid = c.key + c.id,
- c.childGuid = c.key + c.childId,
- c.error && (c.stack = c.error.stack),
- wa.trigger(a.name, a.payload)
- }
- xa.length = 0
- }, 50)
- }
- function i(a, b, c) {
- 1 === xa.push({
- name: a,
- payload: {
- key: b._guidKey,
- id: b._id,
- eventName: a,
- detail: b._result,
- childId: c && c._id,
- label: b._label,
- timeStamp: ta(),
- error: wa["instrument-with-stack"] ? new Error(b._label) : null
- }
- }) && h()
- }
- function j() {
- return new TypeError("A promises callback cannot return that same promise.")
- }
- function k() {}
- function l(a) {
- try {
- return a.then
- } catch (b) {
- return Ca.error = b,
- Ca
- }
- }
- function m(a, b, c, d) {
- try {
- a.call(b, c, d)
- } catch (e) {
- return e
- }
- }
- function n(a, b, c) {
- wa.async(function(a) {
- var d = !1
- , e = m(c, b, function(c) {
- d || (d = !0,
- b !== c ? q(a, c) : s(a, c))
- }, function(b) {
- d || (d = !0,
- t(a, b))
- }, "Settle: " + (a._label || " unknown promise"));
- !d && e && (d = !0,
- t(a, e))
- }, a)
- }
- function o(a, b) {
- b._state === Aa ? s(a, b._result) : b._state === Ba ? (b._onError = null,
- t(a, b._result)) : u(b, void 0, function(c) {
- b !== c ? q(a, c) : s(a, c)
- }, function(b) {
- t(a, b)
- })
- }
- function p(a, c) {
- if (c.constructor === a.constructor)
- o(a, c);
- else {
- var d = l(c);
- d === Ca ? t(a, Ca.error) : void 0 === d ? s(a, c) : b(d) ? n(a, c, d) : s(a, c)
- }
- }
- function q(b, c) {
- b === c ? s(b, c) : a(c) ? p(b, c) : s(b, c)
- }
- function r(a) {
- a._onError && a._onError(a._result),
- v(a)
- }
- function s(a, b) {
- a._state === za && (a._result = b,
- a._state = Aa,
- 0 === a._subscribers.length ? wa.instrument && ya("fulfilled", a) : wa.async(v, a))
- }
- function t(a, b) {
- a._state === za && (a._state = Ba,
- a._result = b,
- wa.async(r, a))
- }
- function u(a, b, c, d) {
- var e = a._subscribers
- , f = e.length;
- a._onError = null,
- e[f] = b,
- e[f + Aa] = c,
- e[f + Ba] = d,
- 0 === f && a._state && wa.async(v, a)
- }
- function v(a) {
- var b = a._subscribers
- , c = a._state;
- if (wa.instrument && ya(c === Aa ? "fulfilled" : "rejected", a),
- 0 !== b.length) {
- for (var d, e, f = a._result, g = 0; g < b.length; g += 3)
- d = b[g],
- e = b[g + c],
- d ? y(c, d, e, f) : e(f);
- a._subscribers.length = 0
- }
- }
- function w() {
- this.error = null
- }
- function x(a, b) {
- try {
- return a(b)
- } catch (c) {
- return Da.error = c,
- Da
- }
- }
- function y(a, c, d, e) {
- var f, g, h, i, k = b(d);
- if (k) {
- if (f = x(d, e),
- f === Da ? (i = !0,
- g = f.error,
- f = null) : h = !0,
- c === f)
- return void t(c, j())
- } else
- f = e,
- h = !0;
- c._state !== za || (k && h ? q(c, f) : i ? t(c, g) : a === Aa ? s(c, f) : a === Ba && t(c, f))
- }
- function z(a, b) {
- var c = !1;
- try {
- b(function(b) {
- c || (c = !0,
- q(a, b))
- }, function(b) {
- c || (c = !0,
- t(a, b))
- })
- } catch (d) {
- t(a, d)
- }
- }
- function A(a, b, c) {
- return a === Aa ? {
- state: "fulfilled",
- value: c
- } : {
- state: "rejected",
- reason: c
- }
- }
- function B(a, b, c, d) {
- var e = this;
- e._instanceConstructor = a,
- e.promise = new a(k,d),
- e._abortOnReject = c,
- e._validateInput(b) ? (e._input = b,
- e.length = b.length,
- e._remaining = b.length,
- e._init(),
- 0 === e.length ? s(e.promise, e._result) : (e.length = e.length || 0,
- e._enumerate(),
- 0 === e._remaining && s(e.promise, e._result))) : t(e.promise, e._validationError())
- }
- function C(a, b) {
- return new Ea(this,a,(!0),b).promise
- }
- function D(a, b) {
- function c(a) {
- q(f, a)
- }
- function d(a) {
- t(f, a)
- }
- var e = this
- , f = new e(k,b);
- if (!sa(a))
- return t(f, new TypeError("You must pass an array to race.")),
- f;
- for (var g = a.length, h = 0; f._state === za && h < g; h++)
- u(e.resolve(a[h]), void 0, c, d);
- return f
- }
- function E(a, b) {
- var c = this;
- if (a && "object" == typeof a && a.constructor === c)
- return a;
- var d = new c(k,b);
- return q(d, a),
- d
- }
- function F(a, b) {
- var c = this
- , d = new c(k,b);
- return t(d, a),
- d
- }
- function G() {
- throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")
- }
- function H() {
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")
- }
- function I(a, c) {
- var d = this;
- d._id = Ka++,
- d._label = c,
- d._state = void 0,
- d._result = void 0,
- d._subscribers = [],
- wa.instrument && ya("created", d),
- k !== a && (b(a) || G(),
- d instanceof I || H(),
- z(d, a))
- }
- function J(a, b, c) {
- this._superConstructor(a, b, !1, c)
- }
- function K(a, b) {
- return new J(La,a,b).promise
- }
- function L(a, b) {
- return La.all(a, b)
- }
- function M(a, b) {
- Xa[Qa] = a,
- Xa[Qa + 1] = b,
- Qa += 2,
- 2 === Qa && Na()
- }
- function N() {
- var a = process.nextTick
- , b = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
- return Array.isArray(b) && "0" === b[1] && "10" === b[2] && (a = setImmediate),
- function() {
- a(S)
- }
- }
- function O() {
- return function() {
- Ma(S)
- }
- }
- function P() {
- var a = 0
- , b = new Ua(S)
- , c = document.createTextNode("");
- return b.observe(c, {
- characterData: !0
- }),
- function() {
- c.data = a = ++a % 2
- }
- }
- function Q() {
- var a = new MessageChannel;
- return a.port1.onmessage = S,
- function() {
- a.port2.postMessage(0)
- }
- }
- function R() {
- return function() {
- setTimeout(S, 1)
- }
- }
- function S() {
- for (var a = 0; a < Qa; a += 2) {
- var b = Xa[a]
- , c = Xa[a + 1];
- b(c),
- Xa[a] = void 0,
- Xa[a + 1] = void 0
- }
- Qa = 0
- }
- function T() {
- try {
- var a = require
- , b = a("vertx");
- return Ma = b.runOnLoop || b.runOnContext,
- O()
- } catch (c) {
- return R()
- }
- }
- function U(a) {
- var b = {};
- return b.promise = new La(function(a, c) {
- b.resolve = a,
- b.reject = c
- }
- ,a),
- b
- }
- function V(a, c, d) {
- return La.all(a, d).then(function(a) {
- if (!b(c))
- throw new TypeError("You must pass a function as filter's second argument.");
- for (var e = a.length, f = new Array(e), g = 0; g < e; g++)
- f[g] = c(a[g]);
- return La.all(f, d).then(function(b) {
- for (var c = new Array(e), d = 0, f = 0; f < e; f++)
- b[f] && (c[d] = a[f],
- d++);
- return c.length = d,
- c
- })
- })
- }
- function W(a, b, c) {
- this._superConstructor(a, b, !0, c)
- }
- function X(a, b, c) {
- this._superConstructor(a, b, !1, c)
- }
- function Y(a, b) {
- return new X(La,a,b).promise
- }
- function Z(a, b) {
- return new $a(La,a,b).promise
- }
- function _(a, c, d) {
- return La.all(a, d).then(function(a) {
- if (!b(c))
- throw new TypeError("You must pass a function as map's second argument.");
- for (var e = a.length, f = new Array(e), g = 0; g < e; g++)
- f[g] = c(a[g]);
- return La.all(f, d)
- })
- }
- function aa() {
- this.value = void 0
- }
- function ba(a) {
- try {
- return a.then
- } catch (b) {
- return db.value = b,
- db
- }
- }
- function ca(a, b, c) {
- try {
- a.apply(b, c)
- } catch (d) {
- return db.value = d,
- db
- }
- }
- function da(a, b) {
- for (var c, d, e = {}, f = a.length, g = new Array(f), h = 0; h < f; h++)
- g[h] = a[h];
- for (d = 0; d < b.length; d++)
- c = b[d],
- e[c] = g[d + 1];
- return e
- }
- function ea(a) {
- for (var b = a.length, c = new Array(b - 1), d = 1; d < b; d++)
- c[d - 1] = a[d];
- return c
- }
- function fa(a, b) {
- return {
- then: function(c, d) {
- return a.call(b, c, d)
- }
- }
- }
- function ga(a, b) {
- var c = function() {
- for (var c, d = this, e = arguments.length, f = new Array(e + 1), g = !1, h = 0; h < e; ++h) {
- if (c = arguments[h],
- !g) {
- if (g = ja(c),
- g === eb) {
- var i = new La(k);
- return t(i, eb.value),
- i
- }
- g && g !== !0 && (c = fa(g, c))
- }
- f[h] = c
- }
- var j = new La(k);
- return f[e] = function(a, c) {
- a ? t(j, a) : void 0 === b ? q(j, c) : b === !0 ? q(j, ea(arguments)) : sa(b) ? q(j, da(arguments, b)) : q(j, c)
- }
- ,
- g ? ia(j, f, a, d) : ha(j, f, a, d)
- };
- return c.__proto__ = a,
- c
- }
- function ha(a, b, c, d) {
- var e = ca(c, d, b);
- return e === db && t(a, e.value),
- a
- }
- function ia(a, b, c, d) {
- return La.all(b).then(function(b) {
- var e = ca(c, d, b);
- return e === db && t(a, e.value),
- a
- })
- }
- function ja(a) {
- return !(!a || "object" != typeof a) && (a.constructor === La || ba(a))
- }
- function ka(a, b) {
- return La.race(a, b)
- }
- function la(a, b) {
- return La.reject(a, b)
- }
- function ma(a, b) {
- return La.resolve(a, b)
- }
- function na(a) {
- throw setTimeout(function() {
- throw a
- }),
- a
- }
- function oa(a, b) {
- wa.async(a, b)
- }
- function pa() {
- wa.on.apply(wa, arguments)
- }
- function qa() {
- wa.off.apply(wa, arguments)
- }
- $.fn.isOnScreen = function() {
- for (var a = $(this), b = [], c = 0; c < a.length; c++) {
- var d = a[c].getBoundingClientRect();
- d.left > 0 && d.left < window.innerWidth && b.push(a[c])
- }
- return b
- }
- ;
- var ra;
- ra = Array.isArray ? Array.isArray : function(a) {
- return "[object Array]" === Object.prototype.toString.call(a)
- }
- ;
- var sa = ra
- , ta = Date.now || function() {
- return (new Date).getTime()
- }
- , ua = Object.create || function(a) {
- if (arguments.length > 1)
- throw new Error("Second argument not supported");
- if ("object" != typeof a)
- throw new TypeError("Argument must be an object");
- return d.prototype = a,
- new d
- }
- , va = {
- mixin: function(a) {
- return a.on = this.on,
- a.off = this.off,
- a.trigger = this.trigger,
- a._promiseCallbacks = void 0,
- a
- },
- on: function(a, b) {
- if ("function" != typeof b)
- throw new TypeError("Callback must be a function");
- var c, d = f(this);
- c = d[a],
- c || (c = d[a] = []),
- e(c, b) === -1 && c.push(b)
- },
- off: function(a, b) {
- var c, d, g = f(this);
- return b ? (c = g[a],
- d = e(c, b),
- void (d !== -1 && c.splice(d, 1))) : void (g[a] = [])
- },
- trigger: function(a, b, c) {
- var d, e, g = f(this);
- if (d = g[a])
- for (var h = 0; h < d.length; h++)
- (e = d[h])(b, c)
- }
- }
- , wa = {
- instrument: !1
- };
- va.mixin(wa);
- var xa = []
- , ya = i
- , za = void 0
- , Aa = 1
- , Ba = 2
- , Ca = new w
- , Da = new w
- , Ea = B;
- B.prototype._validateInput = function(a) {
- return sa(a)
- }
- ,
- B.prototype._validationError = function() {
- return new Error("Array Methods must be provided an Array")
- }
- ,
- B.prototype._init = function() {
- this._result = new Array(this.length)
- }
- ,
- B.prototype._enumerate = function() {
- for (var a = this, b = a.length, c = a.promise, d = a._input, e = 0; c._state === za && e < b; e++)
- a._eachEntry(d[e], e)
- }
- ,
- B.prototype._eachEntry = function(a, b) {
- var d = this
- , e = d._instanceConstructor;
- c(a) ? a.constructor === e && a._state !== za ? (a._onError = null,
- d._settledAt(a._state, b, a._result)) : d._willSettleAt(e.resolve(a), b) : (d._remaining--,
- d._result[b] = d._makeResult(Aa, b, a))
- }
- ,
- B.prototype._settledAt = function(a, b, c) {
- var d = this
- , e = d.promise;
- e._state === za && (d._remaining--,
- d._abortOnReject && a === Ba ? t(e, c) : d._result[b] = d._makeResult(a, b, c)),
- 0 === d._remaining && s(e, d._result)
- }
- ,
- B.prototype._makeResult = function(a, b, c) {
- return c
- }
- ,
- B.prototype._willSettleAt = function(a, b) {
- var c = this;
- u(a, void 0, function(a) {
- c._settledAt(Aa, b, a)
- }, function(a) {
- c._settledAt(Ba, b, a)
- })
- }
- ;
- var Fa = C
- , Ga = D
- , Ha = E
- , Ia = F
- , Ja = "rsvp_" + ta() + "-"
- , Ka = 0
- , La = I;
- I.cast = Ha,
- I.all = Fa,
- I.race = Ga,
- I.resolve = Ha,
- I.reject = Ia,
- I.prototype = {
- constructor: I,
- _guidKey: Ja,
- _onError: function(a) {
- var b = this;
- wa.after(function() {
- b._onError && wa.trigger("error", a, b._label)
- })
- },
- then: function(a, b, c) {
- var d = this
- , e = d._state;
- if (e === Aa && !a || e === Ba && !b)
- return wa.instrument && ya("chained", d, d),
- d;
- d._onError = null;
- var f = new d.constructor(k,c)
- , g = d._result;
- if (wa.instrument && ya("chained", d, f),
- e) {
- var h = arguments[e - 1];
- wa.async(function() {
- y(e, f, h, g)
- })
- } else
- u(d, f, a, b);
- return f
- },
- "catch": function(a, b) {
- return this.then(void 0, a, b)
- },
- "finally": function(a, b) {
- var c = this
- , d = c.constructor;
- return c.then(function(b) {
- return d.resolve(a()).then(function() {
- return b
- })
- }, function(b) {
- return d.resolve(a()).then(function() {
- throw b
- })
- }, b)
- }
- },
- J.prototype = ua(Ea.prototype),
- J.prototype._superConstructor = Ea,
- J.prototype._makeResult = A,
- J.prototype._validationError = function() {
- return new Error("allSettled must be called with an array")
- }
- ;
- var Ma, Na, Oa = K, Pa = L, Qa = 0, Ra = ({}.toString,
- M), Sa = "undefined" != typeof window ? window : void 0, Ta = Sa || {}, Ua = Ta.MutationObserver || Ta.WebKitMutationObserver, Va = "undefined" == typeof self && "undefined" != typeof process && "[object process]" === {}.toString.call(process), Wa = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel, Xa = new Array(1e3);
- Na = Va ? N() : Ua ? P() : Wa ? Q() : void 0 === Sa && "function" == typeof require ? T() : R();
- var Ya = U
- , Za = V
- , $a = W;
- W.prototype = ua(Ea.prototype),
- W.prototype._superConstructor = Ea,
- W.prototype._init = function() {
- this._result = {}
- }
- ,
- W.prototype._validateInput = function(a) {
- return a && "object" == typeof a
- }
- ,
- W.prototype._validationError = function() {
- return new Error("Promise.hash must be called with an object")
- }
- ,
- W.prototype._enumerate = function() {
- var a = this
- , b = a.promise
- , c = a._input
- , d = [];
- for (var e in c)
- b._state === za && Object.prototype.hasOwnProperty.call(c, e) && d.push({
- position: e,
- entry: c[e]
- });
- var f = d.length;
- a._remaining = f;
- for (var g, h = 0; b._state === za && h < f; h++)
- g = d[h],
- a._eachEntry(g.entry, g.position)
- }
- ,
- X.prototype = ua($a.prototype),
- X.prototype._superConstructor = Ea,
- X.prototype._makeResult = A,
- X.prototype._validationError = function() {
- return new Error("hashSettled must be called with an object")
- }
- ;
- var _a, ab = Y, bb = Z, cb = _, db = new aa, eb = new aa, fb = ga;
- if ("object" == typeof self)
- _a = self;
- else {
- if ("object" != typeof global)
- throw new Error("no global: `self` or `global` found");
- _a = global
- }
- var gb = _a
- , hb = ka
- , ib = la
- , jb = ma
- , kb = na;
- wa.async = Ra,
- wa.after = function(a) {
- setTimeout(a, 0)
- }
- ;
- if ("undefined" != typeof window && "object" == typeof window.__PROMISE_INSTRUMENTATION__) {
- var lb = window.__PROMISE_INSTRUMENTATION__;
- g("instrument", !0);
- for (var mb in lb)
- lb.hasOwnProperty(mb) && pa(mb, lb[mb])
- }
- var nb = {
- race: hb,
- Promise: La,
- allSettled: Oa,
- hash: bb,
- hashSettled: ab,
- denodeify: fb,
- on: pa,
- off: qa,
- map: cb,
- filter: Za,
- resolve: jb,
- reject: ib,
- all: Pa,
- rethrow: kb,
- defer: Ya,
- EventTarget: va,
- configure: g,
- async: oa
- };
- "function" == typeof define && define.amd ? define(function() {
- return nb
- }) : "undefined" != typeof module && module.exports ? module.exports = nb : "undefined" != typeof gb && (gb.RSVP = nb)
- }
- .call(this);
- var EPUBJS = EPUBJS || {};
- EPUBJS.VERSION = "0.2.7",
- EPUBJS.plugins = EPUBJS.plugins || {},
- EPUBJS.filePath = EPUBJS.filePath || "/epubjs/",
- EPUBJS.Render = {},
- function(a) {
- var b = (a.ePub || {},
- a.ePub = function() {
- var a, b;
- return "undefined" != typeof arguments[0] && "string" == typeof arguments[0] && (a = arguments[0],
- arguments[1] && "object" == typeof arguments[1] ? (b = arguments[1],
- b.bookPath = a) : b = {
- bookPath: a
- }),
- arguments[0] && "object" == typeof arguments[0] && (b = arguments[0]),
- new EPUBJS.Book(b)
- }
- );
- "function" == typeof define && define.amd ? define(["rsvp"], function() {
- return b
- }) : "undefined" != typeof module && module.exports && (module.exports = b)
- }(window),
- EPUBJS.Book = function(a) {
- this.settings = EPUBJS.core.defaults(a || {}, {
- bookPath: void 0,
- bookKey: void 0,
- packageUrl: void 0,
- storage: !1,
- fromStorage: !1,
- saved: !1,
- online: !0,
- contained: !1,
- width: void 0,
- height: void 0,
- layoutOveride: "auto",
- orientation: void 0,
- minSpreadWidth: 768,
- gap: "auto",
- version: 1,
- restore: !1,
- reload: !1,
- "goto": !1,
- styles: {},
- headTags: {},
- withCredentials: !1,
- render_method: "Iframe"
- }),
- this.settings.EPUBJSVERSION = EPUBJS.VERSION,
- this.spinePos = 0,
- this.stored = !1,
- this.online = this.settings.online || navigator.onLine,
- this.networkListeners(),
- this.ready = {
- manifest: new RSVP.defer,
- spine: new RSVP.defer,
- metadata: new RSVP.defer,
- cover: new RSVP.defer,
- toc: new RSVP.defer,
- pageList: new RSVP.defer
- },
- this.readyPromises = [this.ready.manifest.promise, this.ready.spine.promise, this.ready.metadata.promise, this.ready.cover.promise, this.ready.toc.promise],
- this.pageList = [],
- this.pagination = new EPUBJS.Pagination,
- this.pageListReady = this.ready.pageList.promise,
- this.ready.all = RSVP.all(this.readyPromises),
- this.ready.all.then(this._ready.bind(this)),
- this.isRendered = !1,
- this._q = EPUBJS.core.queue(this),
- this._rendering = !1,
- this._displayQ = EPUBJS.core.queue(this),
- this._moving = !1,
- this._gotoQ = EPUBJS.core.queue(this),
- this.renderer = new EPUBJS.Renderer(this.settings.render_method),
- this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth),
- this.renderer.setGap(this.settings.gap),
- this.listenToRenderer(this.renderer),
- this.defer_opened = new RSVP.defer,
- this.opened = this.defer_opened.promise,
- this.store = !1,
- this.settings.storage !== !1 && this.fromStorage(!0),
- "string" == typeof this.settings.bookPath && this.open(this.settings.bookPath, this.settings.reload),
- window.addEventListener("beforeunload", this.unload.bind(this), !1)
- }
- ,
- EPUBJS.Book.prototype.open = function(a, b) {
- var c, d = this, e = new RSVP.defer;
- return this.settings.bookPath = a,
- this.bookUrl = this.urlFrom(a),
- this.settings.contained || this.isContained(a) ? (this.settings.contained = this.contained = !0,
- this.bookUrl = "",
- c = this.unarchive(a).then(function() {
- return d.loadPackage()
- })) : c = this.loadPackage(),
- this.settings.restore && !b && localStorage ? c.then(function(a) {
- var b = d.packageIdentifier(a)
- , c = d.restore(b);
- c || d.unpack(a),
- e.resolve(),
- d.defer_opened.resolve()
- }) : c.then(function(a) {
- d.unpack(a),
- e.resolve(),
- d.defer_opened.resolve()
- }),
- this._registerReplacements(this.renderer),
- e.promise
- }
- ,
- EPUBJS.Book.prototype.loadPackage = function(a) {
- var b, c = this, d = new EPUBJS.Parser, e = a || "META-INF/container.xml";
- return b = this.settings.packageUrl ? c.loadXml(c.settings.packageUrl) : c.loadXml(c.bookUrl + e).then(function(a) {
- return d.container(a)
- }).then(function(a) {
- return c.settings.contentsPath = c.bookUrl + a.basePath,
- c.settings.packageUrl = c.bookUrl + a.packagePath,
- c.settings.encoding = a.encoding,
- c.loadXml(c.settings.packageUrl)
- }),
- b["catch"](function(a) {
- console.error("Could not load book at: " + e),
- c.trigger("book:loadFailed", e)
- }),
- b
- }
- ,
- EPUBJS.Book.prototype.packageIdentifier = function(a) {
- var b = new EPUBJS.Parser;
- return b.identifier(a)
- }
- ,
- EPUBJS.Book.prototype.unpack = function(a) {
- var b = this
- , c = new EPUBJS.Parser;
- b.contents = c.packageContents(a, b.settings.contentsPath),
- b.manifest = b.contents.manifest,
- b.spine = b.contents.spine,
- RDP_EPUB.tocx = b.contents.spine,
- b.spineIndexByURL = b.contents.spineIndexByURL,
- b.metadata = b.contents.metadata,
- b.settings.bookKey || (b.settings.bookKey = b.generateBookKey(b.metadata.identifier)),
- b.globalLayoutProperties = b.parseLayoutProperties(b.metadata),
- b.contents.coverPath && (b.cover = b.contents.cover = b.settings.contentsPath + b.contents.coverPath),
- b.spineNodeIndex = b.contents.spineNodeIndex,
- b.ready.manifest.resolve(b.contents.manifest),
- b.ready.spine.resolve(b.contents.spine),
- b.ready.metadata.resolve(b.contents.metadata),
- b.ready.cover.resolve(b.contents.cover),
- b.locations = new EPUBJS.Locations(b.spine,b.store,b.settings.withCredentials),
- b.contents.navPath ? (b.settings.navUrl = b.settings.contentsPath + b.contents.navPath,
- b.loadXml(b.settings.navUrl).then(function(a) {
- return c.nav(a, b.spineIndexByURL, b.spine)
- }).then(function(a) {
- b.toc = b.contents.toc = a,
- b.ready.toc.resolve(b.contents.toc)
- }, function(a) {
- b.ready.toc.resolve(!1)
- }),
- b.loadXml(b.settings.navUrl).then(function(a) {
- return c.pageList(a, b.spineIndexByURL, b.spine)
- }).then(function(a) {
- var c = new EPUBJS.EpubCFI
- , d = 0;
- 0 !== a.length && (b.pageList = b.contents.pageList = a,
- b.pageList.forEach(function(a) {
- a.cfi || (d += 1,
- c.generateCfiFromHref(a.href, b).then(function(c) {
- a.cfi = c,
- a.packageUrl = b.settings.packageUrl,
- d -= 1,
- 0 === d && (b.pagination.process(b.pageList),
- b.ready.pageList.resolve(b.pageList))
- }))
- }),
- d || (b.pagination.process(b.pageList),
- b.ready.pageList.resolve(b.pageList)))
- }, function(a) {
- b.ready.pageList.resolve([])
- })) : b.contents.tocPath ? (b.settings.tocUrl = b.settings.contentsPath + b.contents.tocPath,
- b.loadXml(b.settings.tocUrl).then(function(a) {
- return c.toc(a, b.spineIndexByURL, b.spine)
- }).then(function(a) {
- b.toc = b.contents.toc = a,
- b.ready.toc.resolve(b.contents.toc)
- }, function(a) {
- b.ready.toc.resolve(!1)
- })) : b.ready.toc.resolve(!1)
- }
- ,
- EPUBJS.Book.prototype.createHiddenRender = function(a, b, c) {
- var d, e, f = this.element.getBoundingClientRect(), g = b || this.settings.width || f.width, h = c || this.settings.height || f.height;
- return a.setMinSpreadWidth(this.settings.minSpreadWidth),
- a.setGap(this.settings.gap),
- this._registerReplacements(a),
- this.settings.forceSingle && a.forceSingle(!0),
- d = document.createElement("div"),
- d.style.visibility = "hidden",
- d.style.overflow = "hidden",
- d.style.width = "0",
- d.style.height = "0",
- this.element.appendChild(d),
- e = document.createElement("div"),
- e.style.visibility = "hidden",
- e.style.overflow = "hidden",
- e.style.width = g + "px",
- e.style.height = h + "px",
- d.appendChild(e),
- a.initialize(e),
- d
- }
- ,
- EPUBJS.Book.prototype.generatePageList = function(a, b) {
- var c = []
- , d = new EPUBJS.Renderer(this.settings.render_method,(!1))
- , e = this.createHiddenRender(d, a, b)
- , f = new RSVP.defer
- , g = -1
- , h = this.spine.length
- , i = 0
- , j = function(a) {
- var b, e = g + 1, f = a || new RSVP.defer;
- return e >= h ? f.resolve() : (g = e,
- b = new EPUBJS.Chapter(this.spine[g],this.store),
- d.displayChapter(b, this.globalLayoutProperties).then(function(a) {
- d.pageMap.forEach(function(a) {
- i += 1,
- c.push({
- cfi: a.start,
- page: i
- })
- }),
- d.pageMap.length % 2 > 0 && d.spreads && (i += 1,
- c.push({
- cfi: d.pageMap[d.pageMap.length - 1].end,
- page: i
- })),
- setTimeout(function() {
- j(f)
- }, 1)
- })),
- f.promise
- }
- .bind(this);
- j().then(function() {
- d.remove(),
- this.element.removeChild(e),
- f.resolve(c)
- }
- .bind(this));
- return f.promise
- }
- ,
- EPUBJS.Book.prototype.generatePagination = function(a, b) {
- var c = this
- , d = new RSVP.defer;
- return this.ready.spine.promise.then(function() {
- c.generatePageList(a, b).then(function(a) {
- c.pageList = c.contents.pageList = a,
- c.pagination.process(a),
- c.ready.pageList.resolve(c.pageList),
- d.resolve(c.pageList)
- })
- }),
- d.promise
- }
- ,
- EPUBJS.Book.prototype.loadPagination = function(a) {
- var b = JSON.parse(a);
- return b && b.length && (this.pageList = b,
- this.pagination.process(this.pageList),
- this.ready.pageList.resolve(this.pageList)),
- this.pageList
- }
- ,
- EPUBJS.Book.prototype.getPageList = function() {
- return this.ready.pageList.promise
- }
- ,
- EPUBJS.Book.prototype.getMetadata = function() {
- return this.ready.metadata.promise
- }
- ,
- EPUBJS.Book.prototype.getToc = function() {
- return this.ready.toc.promise
- }
- ,
- EPUBJS.Book.prototype.networkListeners = function() {
- var a = this;
- window.addEventListener("offline", function(b) {
- a.online = !1,
- a.settings.storage && a.fromStorage(!0),
- a.trigger("book:offline")
- }, !1),
- window.addEventListener("online", function(b) {
- a.online = !0,
- a.settings.storage && a.fromStorage(!1),
- a.trigger("book:online")
- }, !1)
- }
- ,
- EPUBJS.Book.prototype.listenToRenderer = function(a) {
- var b = this;
- a.Events.forEach(function(c) {
- a.on(c, function(a) {
- b.trigger(c, a)
- })
- }),
- a.on("renderer:visibleRangeChanged", function(a) {
- var b, c, d, e = [];
- this.pageList.length > 0 && (b = this.pagination.pageFromCfi(a.start),
- d = this.pagination.percentageFromPage(b),
- e.push(b),
- a.end && (c = this.pagination.pageFromCfi(a.end),
- e.push(c)),
- this.trigger("book:pageChanged", {
- anchorPage: b,
- percentage: d,
- pageRange: e
- }))
- }
- .bind(this)),
- a.on("render:loaded", this.loadChange.bind(this))
- }
- ,
- EPUBJS.Book.prototype.loadChange = function(a) {
- var b, c, d = EPUBJS.core.uri(a), e = EPUBJS.core.uri(this.currentChapter.absolute);
- d.path != e.path ? (console.warn("Miss Match", d.path, this.currentChapter.absolute),
- b = this.spineIndexByURL[d.filename],
- c = new EPUBJS.Chapter(this.spine[b],this.store),
- this.currentChapter = c,
- this.renderer.currentChapter = c,
- this.renderer.afterLoad(this.renderer.render.docEl),
- this.renderer.beforeDisplay(function() {
- this.renderer.afterDisplay()
- }
- .bind(this))) : this._rendering || this.renderer.reformat()
- }
- ,
- EPUBJS.Book.prototype.unlistenToRenderer = function(a) {
- a.Events.forEach(function(b) {
- a.off(b)
- })
- }
- ,
- EPUBJS.Book.prototype.loadXml = function(a) {
- return this.settings.fromStorage ? this.store.getXml(a, this.settings.encoding) : this.settings.contained ? this.zip.getXml(a, this.settings.encoding) : EPUBJS.core.request(a, "xml", this.settings.withCredentials)
- }
- ,
- EPUBJS.Book.prototype.urlFrom = function(a) {
- var b, c = EPUBJS.core.uri(a), d = c.protocol, e = "/" == c.path[0], f = window.location, g = f.origin || f.protocol + "//" + f.host, h = document.getElementsByTagName("base");
- return h.length && (b = h[0].href),
- c.protocol ? c.origin + c.path : !d && e ? (b || g) + c.path : d || e ? void 0 : EPUBJS.core.resolveUrl(b || f.pathname, c.path)
- }
- ,
- EPUBJS.Book.prototype.unarchive = function(a) {
- return this.zip = new EPUBJS.Unarchiver,
- this.store = this.zip,
- this.zip.open(a)
- }
- ,
- EPUBJS.Book.prototype.isContained = function(a) {
- var b = EPUBJS.core.uri(a);
- return !(!b.extension || "epub" != b.extension && "zip" != b.extension)
- }
- ,
- EPUBJS.Book.prototype.isSaved = function(a) {
- var b;
- return !!localStorage && (b = localStorage.getItem(a),
- !(!localStorage || null === b))
- }
- ,
- EPUBJS.Book.prototype.generateBookKey = function(a) {
- return "epubjs:" + EPUBJS.VERSION + ":" + window.location.host + ":" + a
- }
- ,
- EPUBJS.Book.prototype.saveContents = function() {
- return !!localStorage && void localStorage.setItem(this.settings.bookKey, JSON.stringify(this.contents))
- }
- ,
- EPUBJS.Book.prototype.removeSavedContents = function() {
- return !!localStorage && void localStorage.removeItem(this.settings.bookKey)
- }
- ,
- EPUBJS.Book.prototype.renderTo = function(a) {
- var b, c = this;
- if (EPUBJS.core.isElement(a))
- this.element = a;
- else {
- if ("string" != typeof a)
- return void console.error("Not an Element");
- this.element = EPUBJS.core.getEl(a)
- }
- return b = this.opened.then(function() {
- return c.renderer.initialize(c.element, c.settings.width, c.settings.height),
- c.metadata.direction && c.renderer.setDirection(c.metadata.direction),
- c._rendered(),
- c.startDisplay()
- })
- }
- ,
- EPUBJS.Book.prototype.startDisplay = function() {
- var a;
- return a = this.settings["goto"] ? this["goto"](this.settings["goto"]) : this.settings.previousLocationCfi ? this.gotoCfi(this.settings.previousLocationCfi) : this.displayChapter(this.spinePos)
- }
- ,
- EPUBJS.Book.prototype.restore = function(a) {
- var b, c = this, d = ["manifest", "spine", "metadata", "cover", "toc", "spineNodeIndex", "spineIndexByURL", "globalLayoutProperties"], e = !1, f = this.generateBookKey(a), g = localStorage.getItem(f), h = d.length;
- if (this.settings.clearSaved && (e = !0),
- !e && "undefined" != g && null !== g)
- for (c.contents = JSON.parse(g),
- b = 0; b < h; b++) {
- var i = d[b];
- if (!c.contents[i]) {
- e = !0;
- break
- }
- c[i] = c.contents[i]
- }
- return !(e || !g || !this.contents || !this.settings.contentsPath) && (this.settings.bookKey = f,
- this.ready.manifest.resolve(this.manifest),
- this.ready.spine.resolve(this.spine),
- this.ready.metadata.resolve(this.metadata),
- this.ready.cover.resolve(this.cover),
- this.ready.toc.resolve(this.toc),
- !0)
- }
- ,
- EPUBJS.Book.prototype.displayChapter = function(a, b, c) {
- var d, e, f, g, h = this, i = c || new RSVP.defer;
- return this.isRendered ? this._rendering || this._rendering ? (this._displayQ.enqueue("displayChapter", [a, b, i]),
- i.promise) : (EPUBJS.core.isNumber(a) ? f = a : (e = new EPUBJS.EpubCFI(a),
- f = e.spinePos),
- (f < 0 || f >= this.spine.length) && (console.warn("Not A Valid Location"),
- f = 0,
- b = !1,
- e = !1),
- g = new EPUBJS.Chapter(this.spine[f],this.store),
- this._rendering = !0,
- this._needsAssetReplacement() && g.registerHook("beforeChapterRender", [EPUBJS.replace.head, EPUBJS.replace.resources, EPUBJS.replace.svg], !0),
- h.currentChapter = g,
- d = h.renderer.displayChapter(g, this.globalLayoutProperties),
- e ? h.renderer.gotoCfi(e) : b && h.renderer.lastPage(),
- d.then(function(a) {
- h.spinePos = f,
- i.resolve(h.renderer),
- h.settings.fromStorage === !1 && h.settings.contained === !1 && h.preloadNextChapter(),
- h._rendering = !1,
- h._displayQ.dequeue(),
- 0 === h._displayQ.length() && h._gotoQ.dequeue()
- }, function(a) {
- console.error("Could not load Chapter: " + g.absolute, a),
- h.trigger("book:chapterLoadFailed", g.absolute),
- h._rendering = !1,
- i.reject(a)
- }),
- i.promise) : (this._q.enqueue("displayChapter", arguments),
- i.reject({
- message: "Rendering",
- stack: (new Error).stack
- }),
- $("iframe").contents().find("body").css({
- fontSize: RDP_EPUB.config.fontSize + "px",
- fontFamily: RDP_EPUB.config.fontFamily,
- color: RDP_EPUB.config.color,
- background: RDP_EPUB.config.background
- }),
- $("iframe").contents().find("img").css("height", "auto"),
- i.promise)
- }
- ,
- EPUBJS.Book.prototype.nextPage = function() {
- var a;
- return this.isRendered ? (a = this.renderer.nextPage()) ? ($("iframe").contents().find("body").css({
- fontSize: RDP_EPUB.config.fontSize + "px",
- fontFamily: RDP_EPUB.config.fontFamily,
- color: RDP_EPUB.config.color,
- background: RDP_EPUB.config.background
- }),
- $("iframe").contents().find("img").css("height", "auto"),
- void $("iframe").contents().find("body").css({
- "-webkit-user-select": "none",
- "-moz-user-select": "none",
- "-ms-user-select": "none",
- "user-select": "none"
- })) : this.nextChapter() : this._q.enqueue("nextPage", arguments)
- }
- ,
- EPUBJS.Book.prototype.prevPage = function() {
- var a;
- return this.isRendered ? (a = this.renderer.prevPage()) ? ($("iframe").contents().find("body").css({
- fontSize: RDP_EPUB.config.fontSize + "px",
- fontFamily: RDP_EPUB.config.fontFamily,
- color: RDP_EPUB.config.color,
- background: RDP_EPUB.config.background
- }),
- $("iframe").contents().find("img").css("height", "auto"),
- $("iframe").contents().find("body").css({
- "-webkit-user-select": "none",
- "-moz-user-select": "none",
- "-ms-user-select": "none",
- "user-select": "none"
- }),
- void console.log($("iframe").contents().find(".divider-pageview").isOnScreen())) : this.prevChapter() : this._q.enqueue("prevPage", arguments)
- }
- ,
- EPUBJS.Book.prototype.nextChapter = function() {
- var a;
- if (this.spinePos < this.spine.length - 1) {
- for (a = this.spinePos + 1; this.spine[a] && this.spine[a].linear && "no" == this.spine[a].linear; )
- a++;
- if (a < this.spine.length)
- return this.displayChapter(a);
- this.trigger("book:atEnd")
- } else
- this.trigger("book:atEnd")
- }
- ,
- EPUBJS.Book.prototype.prevChapter = function() {
- var a;
- if (this.spinePos > 0) {
- for (a = this.spinePos - 1; this.spine[a] && this.spine[a].linear && "no" == this.spine[a].linear; )
- a--;
- if (a >= 0)
- return this.displayChapter(a, !0);
- this.trigger("book:atStart")
- } else
- this.trigger("book:atStart")
- }
- ,
- EPUBJS.Book.prototype.getCurrentLocationCfi = function() {
- return !!this.isRendered && this.renderer.currentLocationCfi
- }
- ,
- EPUBJS.Book.prototype["goto"] = function(a) {
- return 0 === a.indexOf("epubcfi(") ? this.gotoCfi(a) : a.indexOf("%") === a.length - 1 ? this.gotoPercentage(parseInt(a.substring(0, a.length - 1)) / 100) : "number" == typeof a || isNaN(a) === !1 ? this.gotoPage(a) : this.gotoHref(a)
- }
- ,
- EPUBJS.Book.prototype.gotoCfi = function(a, b) {
- var c, d, e, f = b || new RSVP.defer;
- return this.isRendered ? this._moving || this._rendering ? (console.warn("Renderer is moving"),
- this._gotoQ.enqueue("gotoCfi", [a, f]),
- !1) : (c = new EPUBJS.EpubCFI(a),
- d = c.spinePos,
- d != -1 && (e = this.spine[d],
- promise = f.promise,
- this._moving = !0,
- this.currentChapter && this.spinePos === d ? (this.renderer.gotoCfi(c),
- this._moving = !1,
- f.resolve(this.renderer.currentLocationCfi)) : (e && d != -1 || (d = 0,
- e = this.spine[d]),
- this.currentChapter = new EPUBJS.Chapter(e,this.store),
- this.currentChapter && (this.spinePos = d,
- render = this.renderer.displayChapter(this.currentChapter, this.globalLayoutProperties),
- this.renderer.gotoCfi(c),
- render.then(function(a) {
- this._moving = !1,
- f.resolve(a.currentLocationCfi)
- }
- .bind(this)))),
- promise.then(function() {
- this._gotoQ.dequeue()
- }
- .bind(this)),
- promise)) : (console.warn("Not yet Rendered"),
- this.settings.previousLocationCfi = a,
- !1)
- }
- ,
- EPUBJS.Book.prototype.gotoHref = function(a, b) {
- var c, d, e, f, g, h = b || new RSVP.defer;
- return this.isRendered ? this._moving || this._rendering ? (this._gotoQ.enqueue("gotoHref", [a, h]),
- !1) : (c = a.split("#"),
- d = c[0],
- e = c[1] || !1,
- f = d.replace(this.settings.contentsPath, ""),
- g = this.spineIndexByURL[f],
- d || (g = this.currentChapter ? this.currentChapter.spinePos : 0),
- "number" == typeof g && (this.currentChapter && g == this.currentChapter.spinePos ? (e ? this.renderer.section(e) : this.renderer.firstPage(),
- h.resolve(this.renderer.currentLocationCfi),
- h.promise.then(function() {
- this._gotoQ.dequeue()
- }
- .bind(this)),
- h.promise) : this.displayChapter(g).then(function() {
- e && this.renderer.section(e),
- h.resolve(this.renderer.currentLocationCfi)
- }
- .bind(this)))) : (this.settings["goto"] = a,
- !1)
- }
- ,
- EPUBJS.Book.prototype.gotoPage = function(a) {
- var b = this.pagination.cfiFromPage(a);
- return this.gotoCfi(b)
- }
- ,
- EPUBJS.Book.prototype.gotoPercentage = function(a) {
- var b = this.pagination.pageFromPercentage(a);
- return this.gotoPage(b)
- }
- ,
- EPUBJS.Book.prototype.preloadNextChapter = function() {
- var a, b = this.spinePos + 1;
- return !(b >= this.spine.length) && (a = new EPUBJS.Chapter(this.spine[b]),
- void (a && EPUBJS.core.request(a.absolute)))
- }
- ,
- EPUBJS.Book.prototype.storeOffline = function() {
- var a = this
- , b = EPUBJS.core.values(this.manifest);
- return this.store.put(b).then(function() {
- a.settings.stored = !0,
- a.trigger("book:stored")
- })
- }
- ,
- EPUBJS.Book.prototype.availableOffline = function() {
- return this.settings.stored > 0
- }
- ,
- EPUBJS.Book.prototype.toStorage = function() {
- var a = this.settings.bookKey;
- this.store.isStored(a).then(function(b) {
- return b === !0 ? (this.settings.stored = !0,
- !0) : this.storeOffline().then(function() {
- this.store.token(a, !0)
- }
- .bind(this))
- }
- .bind(this))
- }
- ,
- EPUBJS.Book.prototype.fromStorage = function(a) {
- [EPUBJS.replace.head, EPUBJS.replace.resources, EPUBJS.replace.svg];
- this.contained || this.settings.contained || (this.online && this.opened.then(this.toStorage.bind(this)),
- this.store && this.settings.fromStorage && a === !1 ? (this.settings.fromStorage = !1,
- this.store.off("offline"),
- this.store = !1) : this.settings.fromStorage || (this.store = new EPUBJS.Storage(this.settings.credentials),
- this.store.on("offline", function(a) {
- a ? (this.offline = !0,
- this.settings.fromStorage = !0,
- this.trigger("book:offline")) : (this.offline = !1,
- this.settings.fromStorage = !1,
- this.trigger("book:online"))
- }
- .bind(this))))
- }
- ,
- EPUBJS.Book.prototype.setStyle = function(a, b, c) {
- var d = ["color", "background", "background-color"];
- return this.isRendered ? (this.settings.styles[a] = b,
- this.renderer.setStyle(a, b, c),
- void (d.indexOf(a) === -1 && this.renderer.reformat())) : this._q.enqueue("setStyle", arguments)
- }
- ,
- EPUBJS.Book.prototype.removeStyle = function(a) {
- return this.isRendered ? (this.renderer.removeStyle(a),
- this.renderer.reformat(),
- void delete this.settings.styles[a]) : this._q.enqueue("removeStyle", arguments)
- }
- ,
- EPUBJS.Book.prototype.addHeadTag = function(a, b) {
- return this.isRendered ? void (this.settings.headTags[a] = b) : this._q.enqueue("addHeadTag", arguments)
- }
- ,
- EPUBJS.Book.prototype.useSpreads = function(a) {
- console.warn("useSpreads is deprecated, use forceSingle or set a layoutOveride instead"),
- a === !1 ? this.forceSingle(!0) : this.forceSingle(!1)
- }
- ,
- EPUBJS.Book.prototype.forceSingle = function(a) {
- var b = "undefined" == typeof a || a;
- this.renderer.forceSingle(b),
- this.settings.forceSingle = b,
- this.isRendered && this.renderer.reformat()
- }
- ,
- EPUBJS.Book.prototype.setMinSpreadWidth = function(a) {
- this.settings.minSpreadWidth = a,
- this.isRendered && (this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth),
- this.renderer.reformat())
- }
- ,
- EPUBJS.Book.prototype.setGap = function(a) {
- this.settings.gap = a,
- this.isRendered && (this.renderer.setGap(this.settings.gap),
- this.renderer.reformat())
- }
- ,
- EPUBJS.Book.prototype.chapter = function(a) {
- var b, c, d = this.spineIndexByURL[a];
- return d && (b = this.spine[d],
- c = new EPUBJS.Chapter(b,this.store,this.settings.withCredentials),
- c.load()),
- c
- }
- ,
- EPUBJS.Book.prototype.unload = function() {
- this.settings.restore && localStorage && this.saveContents(),
- this.unlistenToRenderer(this.renderer),
- this.trigger("book:unload")
- }
- ,
- EPUBJS.Book.prototype.destroy = function() {
- window.removeEventListener("beforeunload", this.unload),
- this.currentChapter && this.currentChapter.unload(),
- this.unload(),
- this.renderer && this.renderer.remove()
- }
- ,
- EPUBJS.Book.prototype._ready = function() {
- this.trigger("book:ready")
- }
- ,
- EPUBJS.Book.prototype._rendered = function(a) {
- this.isRendered = !0,
- this.trigger("book:rendered"),
- this._q.flush()
- }
- ,
- EPUBJS.Book.prototype.applyStyles = function(a, b) {
- a.applyStyles(this.settings.styles),
- b()
- }
- ,
- EPUBJS.Book.prototype.applyHeadTags = function(a, b) {
- a.applyHeadTags(this.settings.headTags),
- b()
- }
- ,
- EPUBJS.Book.prototype._registerReplacements = function(a) {
- a.registerHook("beforeChapterDisplay", this.applyStyles.bind(this, a), !0),
- a.registerHook("beforeChapterDisplay", this.applyHeadTags.bind(this, a), !0),
- a.registerHook("beforeChapterDisplay", EPUBJS.replace.hrefs.bind(this), !0)
- }
- ,
- EPUBJS.Book.prototype._needsAssetReplacement = function() {
- return !!this.settings.fromStorage || !!this.settings.contained
- }
- ,
- EPUBJS.Book.prototype.parseLayoutProperties = function(a) {
- var b = this.layoutOveride && this.layoutOveride.layout || a.layout || "reflowable"
- , c = this.layoutOveride && this.layoutOveride.spread || a.spread || "auto"
- , d = this.layoutOveride && this.layoutOveride.orientation || a.orientation || "auto";
- return {
- layout: b,
- spread: c,
- orientation: d
- }
- }
- ,
- RSVP.EventTarget.mixin(EPUBJS.Book.prototype),
- RSVP.on("error", function(a) {}),
- RSVP.configure("instrument", !1),
- EPUBJS.Chapter = function(a, b, c) {
- this.href = a.href,
- this.absolute = a.url,
- this.id = a.id,
- this.spinePos = a.index,
- this.cfiBase = a.cfiBase,
- this.properties = a.properties,
- this.manifestProperties = a.manifestProperties,
- this.linear = a.linear,
- this.pages = 1,
- this.store = b,
- this.credentials = c,
- this.epubcfi = new EPUBJS.EpubCFI,
- this.deferred = new RSVP.defer,
- this.loaded = this.deferred.promise,
- EPUBJS.Hooks.mixin(this),
- this.getHooks("beforeChapterRender"),
- this.caches = {}
- }
- ,
- EPUBJS.Chapter.prototype.load = function(a, b) {
- var c, d = a || this.store, e = b || this.credentials;
- return c = d ? d.getXml(this.absolute) : EPUBJS.core.request(this.absolute, "xml", e),
- c.then(function(a) {
- this.setDocument(a),
- this.deferred.resolve(this)
- }
- .bind(this)),
- c
- }
- ,
- EPUBJS.Chapter.prototype.render = function(a) {
- return this.load().then(function(a) {
- var b = a.querySelector("head")
- , c = a.createElement("base");
- return c.setAttribute("href", this.absolute),
- b.insertBefore(c, b.firstChild),
- this.contents = a,
- new RSVP.Promise(function(b, c) {
- this.triggerHooks("beforeChapterRender", function() {
- b(a)
- }
- .bind(this), this)
- }
- .bind(this))
- }
- .bind(this)).then(function(a) {
- var b = new XMLSerializer
- , c = b.serializeToString(a);
- return c
- }
- .bind(this))
- }
- ,
- EPUBJS.Chapter.prototype.url = function(a) {
- var b, c = new RSVP.defer, d = a || this.store, e = this;
- return d ? this.tempUrl ? (b = this.tempUrl,
- c.resolve(b)) : d.getUrl(this.absolute).then(function(a) {
- e.tempUrl = a,
- c.resolve(a)
- }) : (b = this.absolute,
- c.resolve(b)),
- c.promise
- }
- ,
- EPUBJS.Chapter.prototype.setPages = function(a) {
- this.pages = a
- }
- ,
- EPUBJS.Chapter.prototype.getPages = function(a) {
- return this.pages
- }
- ,
- EPUBJS.Chapter.prototype.getID = function() {
- return this.ID
- }
- ,
- EPUBJS.Chapter.prototype.unload = function(a) {
- this.document = null,
- this.tempUrl && a && (a.revokeUrl(this.tempUrl),
- this.tempUrl = !1)
- }
- ,
- EPUBJS.Chapter.prototype.setDocument = function(a) {
- var b = a.namespaceURI;
- a.doctype;
- this.document = a.implementation.createDocument(b, null, null),
- this.contents = this.document.importNode(a.documentElement, !0),
- this.document.appendChild(this.contents),
- !this.document.evaluate && document.evaluate && (this.document.evaluate = document.evaluate)
- }
- ,
- EPUBJS.Chapter.prototype.cfiFromRange = function(a) {
- var b, c, d, e, f, g;
- if (this.document) {
- if ("undefined" != typeof document.evaluate) {
- if (c = EPUBJS.core.getElementXPath(a.startContainer),
- d = EPUBJS.core.getElementXPath(a.endContainer),
- e = this.document.evaluate(c, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue,
- a.collapsed || (f = this.document.evaluate(d, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue),
- b = this.document.createRange(),
- e)
- try {
- b.setStart(e, a.startOffset),
- !a.collapsed && f && b.setEnd(f, a.endOffset)
- } catch (h) {
- console.log("missed"),
- e = !1
- }
- e || (console.log("not found, try fuzzy match"),
- cleanStartTextContent = EPUBJS.core.cleanStringForXpath(a.startContainer.textContent),
- c = "//text()[contains(.," + cleanStartTextContent + ")]",
- e = this.document.evaluate(c, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue,
- e && (b.setStart(e, a.startOffset),
- a.collapsed || (g = EPUBJS.core.cleanStringForXpath(a.endContainer.textContent),
- d = "//text()[contains(.," + g + ")]",
- f = this.document.evaluate(d, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue,
- f && b.setEnd(f, a.endOffset))))
- } else
- b = a;
- return this.epubcfi.generateCfiFromRange(b, this.cfiBase)
- }
- }
- ,
- EPUBJS.Chapter.prototype.find = function(a) {
- var b = this
- , c = []
- , d = a.toLowerCase()
- , e = function(a) {
- for (var e, f, g, h = a.textContent.toLowerCase(), i = b.document.createRange(), j = -1, k = 150; f != -1; )
- f = h.indexOf(d, j + 1),
- f != -1 && (i = b.document.createRange(),
- i.setStart(a, f),
- i.setEnd(a, f + d.length),
- e = b.cfiFromRange(i),
- a.textContent.length < k ? g = a.textContent : (g = a.textContent.substring(f - k / 2, f + k / 2),
- g = "..." + g + "..."),
- c.push({
- cfi: e,
- excerpt: g
- })),
- j = f
- };
- return this.textSprint(this.document, function(a) {
- e(a)
- }),
- c
- }
- ,
- EPUBJS.Chapter.prototype.textSprint = function(a, b) {
- for (var c, d = document.createTreeWalker(a, NodeFilter.SHOW_TEXT, {
- acceptNode: function(a) {
- return a.data && !/^\s*$/.test(a.data) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
- }
- }, !1); c = d.nextNode(); )
- b(c)
- }
- ,
- EPUBJS.Chapter.prototype.replace = function(a, b, c, d) {
- var e = this.contents.querySelectorAll(a)
- , f = Array.prototype.slice.call(e)
- , g = f.length;
- return 0 === g ? void c(!1) : void f.forEach(function(a) {
- var e = !1
- , f = function(a, b) {
- e === !1 && (g--,
- d && d(a, b, g),
- g <= 0 && c && c(!0),
- e = !0)
- };
- b(a, f)
- }
- .bind(this))
- }
- ,
- EPUBJS.Chapter.prototype.replaceWithStored = function(a, b, c, d) {
- var e, f = {}, g = this.store, h = this.caches[a], i = EPUBJS.core.uri(this.absolute), j = i.base, k = b, l = 5, m = function(a, b, c) {
- f[b] = a
- }, n = function(a) {
- d && d(),
- EPUBJS.core.values(e).forEach(function(a) {
- g.revokeUrl(a)
- }),
- h = f
- };
- g && (h || (h = {}),
- e = EPUBJS.core.clone(h),
- this.replace(a, function(b, d) {
- var h = b.getAttribute(k)
- , i = EPUBJS.core.resolveUrl(j, h)
- , m = function(c) {
- var e;
- b.onload = function() {
- clearTimeout(e),
- d(c, i)
- }
- ,
- b.onerror = function(a) {
- clearTimeout(e),
- d(c, i),
- console.error(a)
- }
- ,
- "image" == a && b.setAttribute("externalResourcesRequired", "true"),
- "link[href]" == a && "stylesheet" !== b.getAttribute("rel") ? d(c, i) : e = setTimeout(function() {
- d(c, i)
- }, l),
- b.setAttribute(k, c)
- };
- i in e ? (m(e[i]),
- f[i] = e[i],
- delete e[i]) : c(g, i, m, b)
- }, n, m))
- }
- ;
- var EPUBJS = EPUBJS || {};
- EPUBJS.core = {},
- EPUBJS.core.getEl = function(a) {
- return document.getElementById(a)
- }
- ,
- EPUBJS.core.getEls = function(a) {
- return document.getElementsByClassName(a)
- }
- ,
- EPUBJS.core.request = function(a, b, c) {
- function d() {
- if (this.readyState === this.DONE)
- if (200 === this.status || 0 === this.status && this.response) {
- var a;
- a = "xml" == b ? this.responseXML : "json" == b ? JSON.parse(this.response) : "blob" == b ? e ? this.response : new Blob([this.response]) : this.response,
- g.resolve(a)
- } else
- g.reject({
- message: this.response,
- stack: (new Error).stack
- })
- }
- var e = window.URL
- , f = e ? "blob" : "arraybuffer"
- , g = new RSVP.defer
- , h = new XMLHttpRequest
- , i = XMLHttpRequest.prototype;
- return "overrideMimeType"in i || Object.defineProperty(i, "overrideMimeType", {
- value: function(a) {}
- }),
- c && (h.withCredentials = !0),
- h.open("GET", a, !0),
- h.onreadystatechange = d,
- "blob" == b && (h.responseType = f),
- "json" == b && h.setRequestHeader("Accept", "application/json"),
- "xml" == b && h.overrideMimeType("text/xml"),
- "binary" == b && (h.responseType = "arraybuffer"),
- h.send(),
- g.promise
- }
- ,
- EPUBJS.core.toArray = function(a) {
- var b = [];
- for (var c in a) {
- var d;
- a.hasOwnProperty(c) && (d = a[c],
- d.ident = c,
- b.push(d))
- }
- return b
- }
- ,
- EPUBJS.core.uri = function(a) {
- var b, c, d, e = {
- protocol: "",
- host: "",
- path: "",
- origin: "",
- directory: "",
- base: "",
- filename: "",
- extension: "",
- fragment: "",
- href: a
- }, f = a.indexOf("blob:"), g = a.indexOf("://"), h = a.indexOf("?"), i = a.indexOf("#");
- return 0 === f ? (e.protocol = "blob",
- e.base = a.indexOf(0, i),
- e) : (i != -1 && (e.fragment = a.slice(i + 1),
- a = a.slice(0, i)),
- h != -1 && (e.search = a.slice(h + 1),
- a = a.slice(0, h),
- href = a),
- g != -1 ? (e.protocol = a.slice(0, g),
- b = a.slice(g + 3),
- d = b.indexOf("/"),
- d === -1 ? (e.host = e.path,
- e.path = "") : (e.host = b.slice(0, d),
- e.path = b.slice(d)),
- e.origin = e.protocol + "://" + e.host,
- e.directory = EPUBJS.core.folder(e.path),
- e.base = e.origin + e.directory) : (e.path = a,
- e.directory = EPUBJS.core.folder(a),
- e.base = e.directory),
- e.filename = a.replace(e.base, ""),
- c = e.filename.lastIndexOf("."),
- c != -1 && (e.extension = e.filename.slice(c + 1)),
- e)
- }
- ,
- EPUBJS.core.folder = function(a) {
- var b = a.lastIndexOf("/");
- if (b == -1)
- var c = "";
- return c = a.slice(0, b + 1)
- }
- ,
- EPUBJS.core.dataURLToBlob = function(a) {
- var b, c, d, e, f, g = ";base64,";
- if (a.indexOf(g) == -1)
- return b = a.split(","),
- c = b[0].split(":")[1],
- d = b[1],
- new Blob([d],{
- type: c
- });
- b = a.split(g),
- c = b[0].split(":")[1],
- d = window.atob(b[1]),
- e = d.length,
- f = new Uint8Array(e);
- for (var h = 0; h < e; ++h)
- f[h] = d.charCodeAt(h);
- return new Blob([f],{
- type: c
- })
- }
- ,
- EPUBJS.core.addScript = function(a, b, c) {
- var d, e;
- e = !1,
- d = document.createElement("script"),
- d.type = "text/javascript",
- d.async = !1,
- d.src = a,
- d.onload = d.onreadystatechange = function() {
- e || this.readyState && "complete" != this.readyState || (e = !0,
- b && b())
- }
- ,
- c = c || document.body,
- c.appendChild(d)
- }
- ,
- EPUBJS.core.addScripts = function(a, b, c) {
- var d = a.length
- , e = 0
- , f = function() {
- e++,
- d == e ? b && b() : EPUBJS.core.addScript(a[e], f, c)
- };
- EPUBJS.core.addScript(a[e], f, c)
- }
- ,
- EPUBJS.core.addCss = function(a, b, c) {
- var d, e;
- e = !1,
- d = document.createElement("link"),
- d.type = "text/css",
- d.rel = "stylesheet",
- d.href = a,
- d.onload = d.onreadystatechange = function() {
- e || this.readyState && "complete" != this.readyState || (e = !0,
- b && b())
- }
- ,
- c = c || document.body,
- c.appendChild(d)
- }
- ,
- EPUBJS.core.prefixed = function(a) {
- var b = ["Webkit", "Moz", "O", "ms"]
- , c = a[0].toUpperCase() + a.slice(1)
- , d = b.length;
- if ("undefined" != typeof document.documentElement.style[a])
- return a;
- for (var e = 0; e < d; e++)
- if ("undefined" != typeof document.documentElement.style[b[e] + c])
- return b[e] + c;
- return a
- }
- ,
- EPUBJS.core.resolveUrl = function(a, b) {
- var c, d, e = [], f = EPUBJS.core.uri(b), g = a.split("/");
- return f.host ? b : (g.pop(),
- d = b.split("/"),
- d.forEach(function(a) {
- ".." === a ? g.pop() : e.push(a)
- }),
- c = g.concat(e),
- c.join("/"))
- }
- ,
- EPUBJS.core.uuid = function() {
- var a = (new Date).getTime()
- , b = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(b) {
- var c = (a + 16 * Math.random()) % 16 | 0;
- return a = Math.floor(a / 16),
- ("x" == b ? c : 7 & c | 8).toString(16)
- });
- return b
- }
- ,
- EPUBJS.core.insert = function(a, b, c) {
- var d = EPUBJS.core.locationOf(a, b, c);
- return b.splice(d, 0, a),
- d
- }
- ,
- EPUBJS.core.locationOf = function(a, b, c, d, e) {
- var f, g = d || 0, h = e || b.length, i = parseInt(g + (h - g) / 2);
- return c || (c = function(a, b) {
- return a > b ? 1 : a < b ? -1 : (a = b) ? 0 : void 0
- }
- ),
- h - g <= 0 ? i : (f = c(b[i], a),
- h - g === 1 ? f > 0 ? i : i + 1 : 0 === f ? i : f === -1 ? EPUBJS.core.locationOf(a, b, c, i, h) : EPUBJS.core.locationOf(a, b, c, g, i))
- }
- ,
- EPUBJS.core.indexOfSorted = function(a, b, c, d, e) {
- var f, g = d || 0, h = e || b.length, i = parseInt(g + (h - g) / 2);
- return c || (c = function(a, b) {
- return a > b ? 1 : a < b ? -1 : (a = b) ? 0 : void 0
- }
- ),
- h - g <= 0 ? -1 : (f = c(b[i], a),
- h - g === 1 ? 0 === f ? i : -1 : 0 === f ? i : f === -1 ? EPUBJS.core.indexOfSorted(a, b, c, i, h) : EPUBJS.core.indexOfSorted(a, b, c, g, i))
- }
- ,
- EPUBJS.core.queue = function(a) {
- var b = []
- , c = a
- , d = function(a, c, d) {
- return b.push({
- funcName: a,
- args: c,
- context: d
- }),
- b
- }
- , e = function() {
- var a;
- b.length && (a = b.shift(),
- c[a.funcName].apply(a.context || c, a.args))
- }
- , f = function() {
- for (; b.length; )
- e()
- }
- , g = function() {
- b = []
- }
- , h = function() {
- return b.length
- };
- return {
- enqueue: d,
- dequeue: e,
- flush: f,
- clear: g,
- length: h
- }
- }
- ,
- EPUBJS.core.getElementXPath = function(a) {
- return a && a.id ? '//*[@id="' + a.id + '"]' : EPUBJS.core.getElementTreeXPath(a)
- }
- ,
- EPUBJS.core.getElementTreeXPath = function(a) {
- var b, c, d, e, f = [], g = "http://www.w3.org/1999/xhtml" === a.ownerDocument.documentElement.getAttribute("xmlns");
- for (a.nodeType === Node.TEXT_NODE && (b = EPUBJS.core.indexOfTextNode(a) + 1,
- f.push("text()[" + b + "]"),
- a = a.parentNode); a && 1 == a.nodeType; a = a.parentNode) {
- b = 0;
- for (var h = a.previousSibling; h; h = h.previousSibling)
- h.nodeType != Node.DOCUMENT_TYPE_NODE && h.nodeName == a.nodeName && ++b;
- c = a.nodeName.toLowerCase(),
- d = g ? "xhtml:" + c : c,
- e = b ? "[" + (b + 1) + "]" : "",
- f.splice(0, 0, d + e)
- }
- return f.length ? "./" + f.join("/") : null
- }
- ,
- EPUBJS.core.nsResolver = function(a) {
- var b = {
- xhtml: "http://www.w3.org/1999/xhtml",
- epub: "http://www.idpf.org/2007/ops"
- };
- return b[a] || null
- }
- ,
- EPUBJS.core.cleanStringForXpath = function(a) {
- var b = a.match(/[^'"]+|['"]/g);
- return b = b.map(function(a) {
- return "'" === a ? '"\'"' : '"' === a ? "'\"'" : "'" + a + "'"
- }),
- "concat(''," + b.join(",") + ")"
- }
- ,
- EPUBJS.core.indexOfTextNode = function(a) {
- for (var b, c = a.parentNode, d = c.childNodes, e = -1, f = 0; f < d.length && (b = d[f],
- b.nodeType === Node.TEXT_NODE && e++,
- b != a); f++)
- ;
- return e
- }
- ,
- EPUBJS.core.defaults = function(a) {
- for (var b = 1, c = arguments.length; b < c; b++) {
- var d = arguments[b];
- for (var e in d)
- void 0 === a[e] && (a[e] = d[e])
- }
- return a
- }
- ,
- EPUBJS.core.extend = function(a) {
- var b = [].slice.call(arguments, 1);
- return b.forEach(function(b) {
- b && Object.getOwnPropertyNames(b).forEach(function(c) {
- Object.defineProperty(a, c, Object.getOwnPropertyDescriptor(b, c))
- })
- }),
- a
- }
- ,
- EPUBJS.core.clone = function(a) {
- return EPUBJS.core.isArray(a) ? a.slice() : EPUBJS.core.extend({}, a)
- }
- ,
- EPUBJS.core.isElement = function(a) {
- return !(!a || 1 != a.nodeType)
- }
- ,
- EPUBJS.core.isNumber = function(a) {
- return !isNaN(parseFloat(a)) && isFinite(a)
- }
- ,
- EPUBJS.core.isString = function(a) {
- return "string" == typeof a || a instanceof String
- }
- ,
- EPUBJS.core.isArray = Array.isArray || function(a) {
- return "[object Array]" === Object.prototype.toString.call(a)
- }
- ,
- EPUBJS.core.values = function(a) {
- var b, c, d, e = -1;
- if (!a)
- return [];
- for (b = Object.keys(a),
- c = b.length,
- d = Array(c); ++e < c; )
- d[e] = a[b[e]];
- return d
- }
- ,
- EPUBJS.EpubCFI = function(a) {
- if (a)
- return this.parse(a)
- }
- ,
- EPUBJS.EpubCFI.prototype.generateChapterComponent = function(a, b, c) {
- var d = parseInt(b)
- , e = a + 1
- , f = "/" + e + "/";
- return f += 2 * (d + 1),
- c && (f += "[" + c + "]"),
- f
- }
- ,
- EPUBJS.EpubCFI.prototype.generatePathComponent = function(a) {
- var b = [];
- return a.forEach(function(a) {
- var c = "";
- c += 2 * (a.index + 1),
- a.id && (c += "[" + a.id + "]"),
- b.push(c)
- }),
- b.join("/")
- }
- ,
- EPUBJS.EpubCFI.prototype.generateCfiFromElement = function(a, b) {
- var c = this.pathTo(a)
- , d = this.generatePathComponent(c);
- return d.length ? "epubcfi(" + b + "!" + d + "/1:0)" : "epubcfi(" + b + "!/4/)"
- }
- ,
- EPUBJS.EpubCFI.prototype.pathTo = function(a) {
- for (var b, c = []; a && null !== a.parentNode && 9 != a.parentNode.nodeType; )
- b = a.parentNode.children,
- c.unshift({
- id: a.id,
- tagName: a.tagName,
- index: b ? Array.prototype.indexOf.call(b, a) : 0
- }),
- a = a.parentNode;
- return c
- }
- ,
- EPUBJS.EpubCFI.prototype.getChapterComponent = function(a) {
- var b = a.split("!");
- return b[0]
- }
- ,
- EPUBJS.EpubCFI.prototype.getPathComponent = function(a) {
- var b = a.split("!")
- , c = b[1] ? b[1].split(":") : "";
- return c[0]
- }
- ,
- EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent = function(a) {
- var b = a.split(":");
- return b[1] || ""
- }
- ,
- EPUBJS.EpubCFI.prototype.parse = function(a) {
- var b, c, d, e, f, g, h, i, j, k = {}, l = function(a) {
- var b, c, d, e;
- return b = "element",
- c = parseInt(a) / 2 - 1,
- d = a.match(/\[(.*)\]/),
- d && d[1] && (e = d[1]),
- {
- type: b,
- index: c,
- id: e || !1
- }
- };
- return "string" != typeof a ? {
- spinePos: -1
- } : (k.str = a,
- 0 === a.indexOf("epubcfi(") && ")" === a[a.length - 1] && (a = a.slice(8, a.length - 1)),
- c = this.getChapterComponent(a),
- d = this.getPathComponent(a) || "",
- e = this.getCharecterOffsetComponent(a),
- c && (b = c.split("/")[2] || "") ? (k.spinePos = parseInt(b) / 2 - 1 || 0,
- g = b.match(/\[(.*)\]/),
- k.spineId = !!g && g[1],
- d.indexOf(",") != -1 && console.warn("CFI Ranges are not supported"),
- h = d.split("/"),
- i = h.pop(),
- k.steps = [],
- h.forEach(function(a) {
- var b;
- a && (b = l(a),
- k.steps.push(b))
- }),
- j = parseInt(i),
- isNaN(j) || (j % 2 === 0 ? k.steps.push(l(i)) : k.steps.push({
- type: "text",
- index: (j - 1) / 2
- })),
- f = e.match(/\[(.*)\]/),
- f && f[1] ? (k.characterOffset = parseInt(e.split("[")[0]),
- k.textLocationAssertion = f[1]) : k.characterOffset = parseInt(e),
- k) : {
- spinePos: -1
- })
- }
- ,
- EPUBJS.EpubCFI.prototype.addMarker = function(a, b, c) {
- var d, e, f, g, h = b || document, i = c || this.createMarker(h);
- return "string" == typeof a && (a = this.parse(a)),
- e = a.steps[a.steps.length - 1],
- a.spinePos !== -1 && (!!(d = this.findParent(a, h)) && (e && "text" === e.type ? (f = d.childNodes[e.index],
- a.characterOffset ? (g = f.splitText(a.characterOffset),
- i.classList.add("EPUBJS-CFI-SPLIT"),
- d.insertBefore(i, g)) : d.insertBefore(i, f)) : d.insertBefore(i, d.firstChild),
- i))
- }
- ,
- EPUBJS.EpubCFI.prototype.createMarker = function(a) {
- var b = a || document
- , c = b.createElement("span");
- return c.id = "EPUBJS-CFI-MARKER:" + EPUBJS.core.uuid(),
- c.classList.add("EPUBJS-CFI-MARKER"),
- c
- }
- ,
- EPUBJS.EpubCFI.prototype.removeMarker = function(a, b) {
- b || document;
- a.classList.contains("EPUBJS-CFI-SPLIT") ? (nextSib = a.nextSibling,
- prevSib = a.previousSibling,
- nextSib && prevSib && 3 === nextSib.nodeType && 3 === prevSib.nodeType && (prevSib.textContent += nextSib.textContent,
- a.parentNode.removeChild(nextSib)),
- a.parentNode.removeChild(a)) : a.classList.contains("EPUBJS-CFI-MARKER") && a.parentNode.removeChild(a)
- }
- ,
- EPUBJS.EpubCFI.prototype.findParent = function(a, b) {
- var c, d, e, f = b || document, g = f.getElementsByTagName("html")[0], h = Array.prototype.slice.call(g.children);
- if ("string" == typeof a && (a = this.parse(a)),
- d = a.steps.slice(0),
- !d.length)
- return f.getElementsByTagName("body")[0];
- for (; d && d.length > 0; ) {
- if (c = d.shift(),
- "text" === c.type ? (e = g.childNodes[c.index],
- g = e.parentNode || g) : g = c.id ? f.getElementById(c.id) : h[c.index],
- "undefined" == typeof g)
- return console.error("No Element For", c, a.str),
- !1;
- h = Array.prototype.slice.call(g.children)
- }
- return g
- }
- ,
- EPUBJS.EpubCFI.prototype.compare = function(a, b) {
- if ("string" == typeof a && (a = new EPUBJS.EpubCFI(a)),
- "string" == typeof b && (b = new EPUBJS.EpubCFI(b)),
- a.spinePos > b.spinePos)
- return 1;
- if (a.spinePos < b.spinePos)
- return -1;
- for (var c = 0; c < a.steps.length; c++) {
- if (!b.steps[c])
- return 1;
- if (a.steps[c].index > b.steps[c].index)
- return 1;
- if (a.steps[c].index < b.steps[c].index)
- return -1
- }
- return a.steps.length < b.steps.length ? -1 : a.characterOffset > b.characterOffset ? 1 : a.characterOffset < b.characterOffset ? -1 : 0
- }
- ,
- EPUBJS.EpubCFI.prototype.generateCfiFromHref = function(a, b) {
- var c, d, e = EPUBJS.core.uri(a), f = e.path, g = e.fragment, h = b.spineIndexByURL[f], i = new RSVP.defer, j = new EPUBJS.EpubCFI;
- return "undefined" != typeof h && (d = b.spine[h],
- c = b.loadXml(d.url),
- c.then(function(a) {
- var b, c = a.getElementById(g);
- b = j.generateCfiFromElement(c, d.cfiBase),
- i.resolve(b)
- })),
- i.promise
- }
- ,
- EPUBJS.EpubCFI.prototype.generateCfiFromTextNode = function(a, b, c) {
- var d = a.parentNode
- , e = this.pathTo(d)
- , f = this.generatePathComponent(e)
- , g = 1 + 2 * Array.prototype.indexOf.call(d.childNodes, a);
- return "epubcfi(" + c + "!" + f + "/" + g + ":" + (b || 0) + ")"
- }
- ,
- EPUBJS.EpubCFI.prototype.generateCfiFromRangeAnchor = function(a, b) {
- var c = a.anchorNode
- , d = a.anchorOffset;
- return this.generateCfiFromTextNode(c, d, b)
- }
- ,
- EPUBJS.EpubCFI.prototype.generateCfiFromRange = function(a, b) {
- var c, d, e, f, g, h, i, j, k, l, m, n;
- if (c = a.startContainer,
- 3 === c.nodeType)
- d = c.parentNode,
- h = 1 + 2 * EPUBJS.core.indexOfTextNode(c),
- e = this.pathTo(d);
- else {
- if (a.collapsed)
- return this.generateCfiFromElement(c, b);
- e = this.pathTo(c)
- }
- return f = this.generatePathComponent(e),
- g = a.startOffset,
- a.collapsed ? "epubcfi(" + b + "!" + f + "/" + h + ":" + g + ")" : (i = a.endContainer,
- 3 === i.nodeType ? (j = i.parentNode,
- n = 1 + 2 * EPUBJS.core.indexOfTextNode(i),
- k = this.pathTo(j)) : k = this.pathTo(i),
- l = this.generatePathComponent(k),
- m = a.endOffset,
- l = l.replace(f, ""),
- l.length && (l += "/"),
- "epubcfi(" + b + "!" + f + "/" + h + ":" + g + "," + l + n + ":" + m + ")")
- }
- ,
- EPUBJS.EpubCFI.prototype.generateXpathFromSteps = function(a) {
- var b = [".", "*"];
- return a.forEach(function(a) {
- var c = a.index + 1;
- a.id ? b.push("*[position()=" + c + " and @id='" + a.id + "']") : "text" === a.type ? b.push("text()[" + c + "]") : b.push("*[" + c + "]")
- }),
- b.join("/")
- }
- ,
- EPUBJS.EpubCFI.prototype.generateQueryFromSteps = function(a) {
- var b = ["html"];
- return a.forEach(function(a) {
- var c = a.index + 1;
- a.id ? b.push("#" + a.id) : "text" === a.type || b.push("*:nth-child(" + c + ")")
- }),
- b.join(">")
- }
- ,
- EPUBJS.EpubCFI.prototype.generateRangeFromCfi = function(a, b) {
- var c, d, e, f, g, h, i = b || document, j = i.createRange();
- return "string" == typeof a && (a = this.parse(a)),
- a.spinePos !== -1 && (c = a.steps[a.steps.length - 1],
- "undefined" != typeof document.evaluate ? (d = this.generateXpathFromSteps(a.steps),
- e = i.evaluate(d, i, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) : (g = this.generateQueryFromSteps(a.steps),
- h = i.querySelector(g),
- h && "text" == c.type && (e = h.childNodes[c.index])),
- e ? (e && a.characterOffset >= 0 ? (f = e.length,
- a.characterOffset < f ? (j.setStart(e, a.characterOffset),
- j.setEnd(e, f)) : (console.debug("offset greater than length:", a.characterOffset, f),
- j.setStart(e, f - 1),
- j.setEnd(e, f))) : e && j.selectNode(e),
- j) : null)
- }
- ,
- EPUBJS.EpubCFI.prototype.isCfiString = function(a) {
- return "string" == typeof a && 0 === a.indexOf("epubcfi(")
- }
- ,
- EPUBJS.Events = function(a, b) {
- return this.events = {},
- b ? this.el = b : this.el = document.createElement("div"),
- a.createEvent = this.createEvent,
- a.tell = this.tell,
- a.listen = this.listen,
- a.deafen = this.deafen,
- a.listenUntil = this.listenUntil,
- this
- }
- ,
- EPUBJS.Events.prototype.createEvent = function(a) {
- var b = new CustomEvent(a);
- return this.events[a] = b,
- b
- }
- ,
- EPUBJS.Events.prototype.tell = function(a, b) {
- var c;
- this.events[a] ? c = this.events[a] : (console.warn("No event:", a, "defined yet, creating."),
- c = this.createEvent(a)),
- b && (c.msg = b),
- this.el.dispatchEvent(c)
- }
- ,
- EPUBJS.Events.prototype.listen = function(a, b, c) {
- return this.events[a] ? void (c ? this.el.addEventListener(a, b.bind(c), !1) : this.el.addEventListener(a, b, !1)) : (console.warn("No event:", a, "defined yet, creating."),
- void this.createEvent(a))
- }
- ,
- EPUBJS.Events.prototype.deafen = function(a, b) {
- this.el.removeEventListener(a, b, !1)
- }
- ,
- EPUBJS.Events.prototype.listenUntil = function(a, b, c, d) {
- function e() {
- this.deafen(a, c),
- this.deafen(b, e)
- }
- this.listen(a, c, d),
- this.listen(b, e, this)
- }
- ,
- EPUBJS.hooks = {},
- EPUBJS.Hooks = function() {
- function a() {}
- return a.prototype.getHooks = function() {
- var a;
- this.hooks = {},
- Array.prototype.slice.call(arguments).forEach(function(a) {
- this.hooks[a] = []
- }, this);
- for (var b in this.hooks)
- a = EPUBJS.core.values(EPUBJS.hooks[b]),
- a.forEach(function(a) {
- this.registerHook(b, a)
- }, this)
- }
- ,
- a.prototype.registerHook = function(a, b, c) {
- "undefined" != typeof this.hooks[a] ? "function" == typeof b ? c ? this.hooks[a].unshift(b) : this.hooks[a].push(b) : Array.isArray(b) && b.forEach(function(b) {
- c ? this.hooks[a].unshift(b) : this.hooks[a].push(b)
- }, this) : (this.hooks[a] = [b],
- "function" == typeof b ? this.hooks[a] = [b] : Array.isArray(b) && (this.hooks[a] = [],
- b.forEach(function(b) {
- this.hooks[a].push(b)
- }, this)))
- }
- ,
- a.prototype.removeHook = function(a, b) {
- var c;
- "undefined" != typeof this.hooks[a] && ("function" == typeof b ? (c = this.hooks[a].indexOf(b),
- c > -1 && this.hooks[a].splice(c, 1)) : Array.isArray(b) && b.forEach(function(b) {
- c = this.hooks[a].indexOf(b),
- c > -1 && this.hooks[a].splice(c, 1)
- }, this))
- }
- ,
- a.prototype.triggerHooks = function(a, b, c) {
- function d() {
- f--,
- f <= 0 && b && b()
- }
- var e, f;
- return "undefined" != typeof this.hooks[a] && (e = this.hooks[a],
- f = e.length,
- 0 === f && b && b(),
- void e.forEach(function(a) {
- a(d, c)
- }))
- }
- ,
- {
- register: function(a) {
- if (void 0 === EPUBJS.hooks[a] && (EPUBJS.hooks[a] = {}),
- "object" != typeof EPUBJS.hooks[a])
- throw "Already registered: " + a;
- return EPUBJS.hooks[a]
- },
- mixin: function(b) {
- for (var c in a.prototype)
- b[c] = a.prototype[c]
- }
- }
- }(),
- EPUBJS.Layout = EPUBJS.Layout || {},
- EPUBJS.Layout.Reflowable = function() {
- this.documentElement = null,
- this.spreadWidth = null
- }
- ,
- EPUBJS.Layout.Reflowable.prototype.format = function(a, b, c, d) {
- var e = EPUBJS.core.prefixed("columnAxis")
- , f = EPUBJS.core.prefixed("columnGap")
- , g = EPUBJS.core.prefixed("columnWidth")
- , h = EPUBJS.core.prefixed("columnFill")
- , i = Math.floor(b)
- , j = Math.floor(i / 8)
- , k = d >= 0 ? d : j % 2 === 0 ? j : j - 1;
- return this.documentElement = a,
- this.spreadWidth = i + k,
- a.style.overflow = "hidden",
- a.style.width = i + "px",
- a.style.height = c + "px",
- a.style[e] = "horizontal",
- a.style[h] = "auto",
- a.style[g] = i + "px",
- a.style[f] = k + "px",
- this.colWidth = i,
- this.gap = k,
- {
- pageWidth: this.spreadWidth,
- pageHeight: c
- }
- }
- ,
- EPUBJS.Layout.Reflowable.prototype.calculatePages = function() {
- var a, b;
- return this.documentElement.style.width = "auto",
- a = this.documentElement.scrollWidth,
- b = Math.ceil(a / this.spreadWidth),
- {
- displayedPages: b,
- pageCount: b
- }
- }
- ,
- EPUBJS.Layout.ReflowableSpreads = function() {
- this.documentElement = null,
- this.spreadWidth = null
- }
- ,
- EPUBJS.Layout.ReflowableSpreads.prototype.format = function(a, b, c, d) {
- var e = EPUBJS.core.prefixed("columnAxis")
- , f = EPUBJS.core.prefixed("columnGap")
- , g = EPUBJS.core.prefixed("columnWidth")
- , h = EPUBJS.core.prefixed("columnFill")
- , i = 2
- , j = Math.floor(b)
- , k = j % 2 === 0 ? j : j - 1
- , l = Math.floor(k / 8)
- , m = d >= 0 ? d : l % 2 === 0 ? l : l - 1
- , n = Math.floor((k - m) / i);
- return this.documentElement = a,
- this.spreadWidth = (n + m) * i,
- a.style.overflow = "hidden",
- a.style.width = k + "px",
- a.style.height = c + "px",
- a.style[e] = "horizontal",
- a.style[h] = "auto",
- a.style[f] = m + "px",
- a.style[g] = n + "px",
- this.colWidth = n,
- this.gap = m,
- {
- pageWidth: this.spreadWidth,
- pageHeight: c
- }
- }
- ,
- EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function() {
- var a = this.documentElement.scrollWidth
- , b = Math.ceil(a / this.spreadWidth);
- return this.documentElement.style.width = b * this.spreadWidth - this.gap + "px",
- {
- displayedPages: b,
- pageCount: 2 * b
- }
- }
- ,
- EPUBJS.Layout.Fixed = function() {
- this.documentElement = null
- }
- ,
- EPUBJS.Layout.Fixed.prototype.format = function(a, b, c, d) {
- var e, f, g, h, i = EPUBJS.core.prefixed("columnWidth"), j = a.querySelector("[name=viewport]");
- return this.documentElement = a,
- j && j.hasAttribute("content") && (e = j.getAttribute("content"),
- f = e.split(","),
- f[0] && (g = f[0].replace("width=", "")),
- f[1] && (h = f[1].replace("height=", ""))),
- a.style.width = g + "px" || "auto",
- a.style.height = h + "px" || "auto",
- a.style[i] = "auto",
- a.style.overflow = "auto",
- this.colWidth = g,
- this.gap = 0,
- {
- pageWidth: g,
- pageHeight: h
- }
- }
- ,
- EPUBJS.Layout.Fixed.prototype.calculatePages = function() {
- return {
- displayedPages: 1,
- pageCount: 1
- }
- }
- ,
- EPUBJS.Locations = function(a, b, c) {
- this.spine = a,
- this.store = b,
- this.credentials = c,
- this.epubcfi = new EPUBJS.EpubCFI,
- this._locations = [],
- this.total = 0,
- this["break"] = 150,
- this._current = 0
- }
- ,
- EPUBJS.Locations.prototype.generate = function(a) {
- var b = new RSVP.defer
- , c = -1
- , d = this.spine.length
- , e = function(a) {
- var b, f = c + 1, g = a || new RSVP.defer;
- return f >= d ? g.resolve() : (c = f,
- b = new EPUBJS.Chapter(this.spine[c],this.store,this.credentials),
- this.process(b).then(function() {
- setTimeout(function() {
- e(g)
- }, 1)
- })),
- g.promise
- }
- .bind(this);
- e().then(function() {
- this.total = this._locations.length - 1,
- this._currentCfi && (this.currentLocation = this._currentCfi),
- b.resolve(this._locations)
- }
- .bind(this));
- return b.promise
- }
- ,
- EPUBJS.Locations.prototype.process = function(a) {
- return a.load().then(function(b) {
- var c, d, e = b, f = e.documentElement.querySelector("body"), g = 0;
- this.sprint(f, function(b) {
- var f, h = b.length, i = 0;
- for (0 === g && (c = e.createRange(),
- c.setStart(b, 0)),
- f = this["break"] - g,
- f > h && (g += h,
- i = h); i < h; )
- g = this["break"],
- i += this["break"],
- i >= h ? g = h - (i - this["break"]) : (c.setEnd(b, i),
- cfi = a.cfiFromRange(c),
- this._locations.push(cfi),
- g = 0,
- i += 1,
- c = e.createRange(),
- c.setStart(b, i));
- d = b
- }
- .bind(this)),
- c && (c.setEnd(d, d.length),
- cfi = a.cfiFromRange(c),
- this._locations.push(cfi),
- g = 0)
- }
- .bind(this))
- }
- ,
- EPUBJS.Locations.prototype.sprint = function(a, b) {
- for (var c = document.createTreeWalker(a, NodeFilter.SHOW_TEXT, null, !1); node = c.nextNode(); )
- b(node)
- }
- ,
- EPUBJS.Locations.prototype.locationFromCfi = function(a) {
- return 0 === this._locations.length ? -1 : EPUBJS.core.locationOf(a, this._locations, this.epubcfi.compare)
- }
- ,
- EPUBJS.Locations.prototype.percentageFromCfi = function(a) {
- var b = this.locationFromCfi(a);
- return this.percentageFromLocation(b)
- }
- ,
- EPUBJS.Locations.prototype.percentageFromLocation = function(a) {
- return a && this.total ? a / this.total : 0
- }
- ,
- EPUBJS.Locations.prototype.cfiFromLocation = function(a) {
- var b = -1;
- return "number" != typeof a && (a = parseInt(a)),
- a >= 0 && a < this._locations.length && (b = this._locations[a]),
- b
- }
- ,
- EPUBJS.Locations.prototype.cfiFromPercentage = function(a) {
- var b = a > 1 ? a / 100 : a
- , c = Math.ceil(this.total * b);
- return this.cfiFromLocation(c)
- }
- ,
- EPUBJS.Locations.prototype.load = function(a) {
- return this._locations = JSON.parse(a),
- this.total = this._locations.length - 1,
- this._locations
- }
- ,
- EPUBJS.Locations.prototype.save = function(a) {
- return JSON.stringify(this._locations)
- }
- ,
- EPUBJS.Locations.prototype.getCurrent = function(a) {
- return this._current
- }
- ,
- EPUBJS.Locations.prototype.setCurrent = function(a) {
- var b;
- if ("string" == typeof a)
- this._currentCfi = a;
- else {
- if ("number" != typeof a)
- return;
- this._current = a
- }
- 0 !== this._locations.length && ("string" == typeof a ? (b = this.locationFromCfi(a),
- this._current = b) : b = a,
- this.trigger("changed", {
- percentage: this.percentageFromLocation(b)
- }))
- }
- ,
- Object.defineProperty(EPUBJS.Locations.prototype, "currentLocation", {
- get: function() {
- return this._current
- },
- set: function(a) {
- this.setCurrent(a)
- }
- }),
- RSVP.EventTarget.mixin(EPUBJS.Locations.prototype),
- EPUBJS.Pagination = function(a) {
- this.pages = [],
- this.locations = [],
- this.epubcfi = new EPUBJS.EpubCFI,
- a && a.length && this.process(a)
- }
- ,
- EPUBJS.Pagination.prototype.process = function(a) {
- a.forEach(function(a) {
- this.pages.push(a.page),
- this.locations.push(a.cfi)
- }, this),
- this.pageList = a,
- this.firstPage = parseInt(this.pages[0]),
- this.lastPage = parseInt(this.pages[this.pages.length - 1]),
- this.totalPages = this.lastPage - this.firstPage
- }
- ,
- EPUBJS.Pagination.prototype.pageFromCfi = function(a) {
- var b = -1;
- if (0 === this.locations.length)
- return -1;
- var c = EPUBJS.core.indexOfSorted(a, this.locations, this.epubcfi.compare);
- return c != -1 && c < this.pages.length - 1 ? b = this.pages[c] : (c = EPUBJS.core.locationOf(a, this.locations, this.epubcfi.compare),
- b = c - 1 >= 0 ? this.pages[c - 1] : this.pages[0],
- void 0 !== b || (b = -1)),
- b
- }
- ,
- EPUBJS.Pagination.prototype.cfiFromPage = function(a) {
- var b = -1;
- "number" != typeof a && (a = parseInt(a));
- var c = this.pages.indexOf(a);
- return c != -1 && (b = this.locations[c]),
- b
- }
- ,
- EPUBJS.Pagination.prototype.pageFromPercentage = function(a) {
- var b = Math.round(this.totalPages * a);
- return b
- }
- ,
- EPUBJS.Pagination.prototype.percentageFromPage = function(a) {
- var b = (a - this.firstPage) / this.totalPages;
- return Math.round(1e3 * b) / 1e3
- }
- ,
- EPUBJS.Pagination.prototype.percentageFromCfi = function(a) {
- var b = this.pageFromCfi(a)
- , c = this.percentageFromPage(b);
- return c
- }
- ,
- EPUBJS.Parser = function(a) {
- this.baseUrl = a || ""
- }
- ,
- EPUBJS.Parser.prototype.container = function(a) {
- var b, c, d, e;
- return a ? (b = a.querySelector("rootfile")) ? (c = b.getAttribute("full-path"),
- d = EPUBJS.core.uri(c).directory,
- e = a.xmlEncoding,
- {
- packagePath: c,
- basePath: d,
- encoding: e
- }) : void console.error("No RootFile Found") : void console.error("Container File Not Found")
- }
- ,
- EPUBJS.Parser.prototype.identifier = function(a) {
- var b;
- return a ? (b = a.querySelector("metadata"),
- b ? this.getElementText(b, "identifier") : void console.error("No Metadata Found")) : void console.error("Package File Not Found")
- }
- ,
- EPUBJS.Parser.prototype.packageContents = function(a, b) {
- var c, d, e, f, g, h, i, j, k, l, m, n = this;
- return b && (this.baseUrl = b),
- a ? (c = a.querySelector("metadata")) ? (d = a.querySelector("manifest")) ? (e = a.querySelector("spine")) ? (f = n.manifest(d),
- g = n.findNavPath(d),
- h = n.findTocPath(d, e),
- i = n.findCoverPath(d),
- j = Array.prototype.indexOf.call(e.parentNode.childNodes, e),
- k = n.spine(e, f),
- l = {},
- k.forEach(function(a) {
- l[a.href] = a.index
- }),
- m = n.metadata(c),
- m.direction = e.getAttribute("page-progression-direction"),
- {
- metadata: m,
- spine: k,
- manifest: f,
- navPath: g,
- tocPath: h,
- coverPath: i,
- spineNodeIndex: j,
- spineIndexByURL: l
- }) : void console.error("No Spine Found") : void console.error("No Manifest Found") : void console.error("No Metadata Found") : void console.error("Package File Not Found")
- }
- ,
- EPUBJS.Parser.prototype.findNavPath = function(a) {
- var b = a.querySelector("item[properties$='nav'], item[properties^='nav '], item[properties*=' nav ']");
- return !!b && b.getAttribute("href")
- }
- ,
- EPUBJS.Parser.prototype.findTocPath = function(a, b) {
- var c, d = a.querySelector("item[media-type='application/x-dtbncx+xml']");
- return d || (c = b.getAttribute("toc"),
- c && (d = a.querySelector("item[id='" + c + "']"))),
- !!d && d.getAttribute("href")
- }
- ,
- EPUBJS.Parser.prototype.findCoverPath = function(a) {
- var b = a.querySelector("item[properties='cover-image']");
- return !!b && b.getAttribute("href")
- }
- ,
- EPUBJS.Parser.prototype.metadata = function(a) {
- var b = {}
- , c = this;
- return b.bookTitle = c.getElementText(a, "title"),
- b.creator = c.getElementText(a, "creator"),
- b.description = c.getElementText(a, "description"),
- b.pubdate = c.getElementText(a, "date"),
- b.publisher = c.getElementText(a, "publisher"),
- b.identifier = c.getElementText(a, "identifier"),
- b.language = c.getElementText(a, "language"),
- b.rights = c.getElementText(a, "rights"),
- b.modified_date = c.querySelectorText(a, "meta[property='dcterms:modified']"),
- b.layout = c.querySelectorText(a, "meta[property='rendition:layout']"),
- b.orientation = c.querySelectorText(a, "meta[property='rendition:orientation']"),
- b.spread = c.querySelectorText(a, "meta[property='rendition:spread']"),
- b
- }
- ,
- EPUBJS.Parser.prototype.getElementText = function(a, b) {
- var c, d = a.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", b);
- return d && 0 !== d.length ? (c = d[0],
- c.childNodes.length ? c.childNodes[0].nodeValue : "") : ""
- }
- ,
- EPUBJS.Parser.prototype.querySelectorText = function(a, b) {
- var c = a.querySelector(b);
- return c && c.childNodes.length ? c.childNodes[0].nodeValue : ""
- }
- ,
- EPUBJS.Parser.prototype.manifest = function(a) {
- var b = this.baseUrl
- , c = {}
- , d = a.querySelectorAll("item")
- , e = Array.prototype.slice.call(d);
- return e.forEach(function(a) {
- var d = a.getAttribute("id")
- , e = a.getAttribute("href") || ""
- , f = a.getAttribute("media-type") || ""
- , g = a.getAttribute("properties") || "";
- c[d] = {
- href: e,
- url: b + e,
- type: f,
- properties: g
- }
- }),
- c
- }
- ,
- EPUBJS.Parser.prototype.spine = function(a, b) {
- var c = []
- , d = a.getElementsByTagName("itemref")
- , e = Array.prototype.slice.call(d)
- , f = Array.prototype.indexOf.call(a.parentNode.childNodes, a)
- , g = new EPUBJS.EpubCFI;
- return e.forEach(function(a, d) {
- var e = a.getAttribute("idref")
- , h = g.generateChapterComponent(f, d, e)
- , i = a.getAttribute("properties") || ""
- , j = i.length ? i.split(" ") : []
- , k = b[e].properties
- , l = k.length ? k.split(" ") : []
- , m = {
- id: e,
- linear: a.getAttribute("linear") || "",
- properties: j,
- manifestProperties: l,
- href: b[e].href,
- url: b[e].url,
- index: d,
- cfiBase: h,
- cfi: "epubcfi(" + h + ")"
- };
- c.push(m)
- }),
- c
- }
- ,
- EPUBJS.Parser.prototype.nav = function(a, b, c) {
- function d(a) {
- var b = [];
- return Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "ol" == a.tagName && Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "li" == a.tagName && b.push(a)
- })
- }),
- b
- }
- function e(a) {
- var b = null;
- return Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "a" != a.tagName && "span" != a.tagName || (b = a)
- }),
- b
- }
- function f(a) {
- var g = []
- , i = d(a)
- , j = Array.prototype.slice.call(i)
- , k = j.length;
- return 0 !== k && (j.forEach(function(d) {
- var i = d.getAttribute("id") || !1
- , j = e(d)
- , k = j.getAttribute("href") || ""
- , l = j.textContent || ""
- , m = k.split("#")
- , n = m[0]
- , o = f(d)
- , p = b[n]
- , q = c[p]
- , r = q ? q.cfi : "";
- i || (p ? (q = c[p],
- i = q.id,
- r = q.cfi) : i = "epubjs-autogen-toc-id-" + h++),
- d.setAttribute("id", i),
- g.push({
- id: i,
- href: k,
- label: l,
- subitems: o,
- parent: a ? a.getAttribute("id") : null,
- cfi: r
- })
- }),
- g)
- }
- var g = a.querySelector('nav[*|type="toc"]')
- , h = 0;
- return g ? f(g) : []
- }
- ,
- EPUBJS.Parser.prototype.toc = function(a, b, c) {
- function d(e) {
- var f = []
- , g = a.evaluate("*[local-name()='navPoint']", e, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
- , h = g.snapshotLength;
- if (0 === h)
- return [];
- for (var i = h - 1; i >= 0; i--) {
- var j = g.snapshotItem(i)
- , k = j.getAttribute("id") || !1
- , l = j.querySelector("content")
- , m = l.getAttribute("src")
- , n = j.querySelector("navLabel")
- , o = n.textContent ? n.textContent : ""
- , p = m.split("#")
- , q = p[0]
- , r = b[q]
- , s = c[r]
- , t = d(j)
- , u = s ? s.cfi : "";
- k || (r ? (s = c[r],
- k = s.id,
- u = s.cfi) : k = "epubjs-autogen-toc-id-" + idCounter++),
- f.unshift({
- id: k,
- href: m,
- label: o,
- spinePos: r,
- subitems: t,
- parent: e ? e.getAttribute("id") : null,
- cfi: u
- })
- }
- return f
- }
- var e = a.querySelector("navMap");
- return e ? d(e) : []
- }
- ,
- EPUBJS.Parser.prototype.pageList = function(a, b, c) {
- function d(a) {
- var b = [];
- return Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "ol" == a.tagName && Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "li" == a.tagName && b.push(a)
- })
- }),
- b
- }
- function e(a) {
- var b = null;
- return Array.prototype.slice.call(a.childNodes).forEach(function(a) {
- "a" != a.tagName && "span" != a.tagName || (b = a)
- }),
- b
- }
- function f(a) {
- var b = []
- , c = d(a)
- , f = Array.prototype.slice.call(c)
- , g = f.length;
- return 0 !== g && (f.forEach(function(a) {
- var c, d, f, g = (a.getAttribute("id") || !1,
- e(a)), h = g.getAttribute("href") || "", i = g.textContent || "", j = parseInt(i), k = h.indexOf("epubcfi");
- k != -1 ? (c = h.split("#"),
- d = c[0],
- f = c.length > 1 && c[1],
- b.push({
- cfi: f,
- href: h,
- packageUrl: d,
- page: j
- })) : b.push({
- href: h,
- page: j
- })
- }),
- b)
- }
- var g = a.querySelector('nav[*|type="page-list"]');
- return g ? f(g) : []
- }
- ,
- EPUBJS.Render.Iframe = function() {
- this.iframe = null,
- this.document = null,
- this.window = null,
- this.docEl = null,
- this.bodyEl = null,
- this.leftPos = 0,
- this.pageWidth = 0
- }
- ,
- EPUBJS.Render.Iframe.prototype.create = function() {
- return this.iframe = document.createElement("iframe"),
- this.iframe.id = "epubjs-iframe:" + EPUBJS.core.uuid(),
- this.iframe.scrolling = "no",
- this.iframe.seamless = "seamless",
- this.iframe.style.border = "none",
- this.iframe.addEventListener("load", this.loaded.bind(this), !1),
- this.isMobile = navigator.userAgent.match(/(iPad|iPhone|iPod|Mobile|Android)/g),
- this.transform = EPUBJS.core.prefixed("transform"),
- this.iframe
- }
- ,
- EPUBJS.Render.Iframe.prototype.load = function(a, b) {
- var c = this
- , d = new RSVP.defer;
- return this.window && this.unload(),
- this.iframe.onload = function(a) {
- c.document = c.iframe.contentDocument,
- c.docEl = c.document.documentElement,
- c.headEl = c.document.head,
- c.bodyEl = c.document.body || c.document.querySelector("body"),
- c.window = c.iframe.contentWindow,
- c.window.addEventListener("resize", c.resized.bind(c), !1),
- c.document.oncontextmenu = function() {
- return !1
- }
- ,
- c.document.onkeydown = function(a) {
- if (a = a || window.event,
- a.ctrlKey)
- return !1
- }
- ,
- c.leftPos = 0,
- c.setLeft(0),
- c.bodyEl && (c.bodyEl.style.margin = "0"),
- "rtl" == c.direction && "rtl" != c.docEl.dir && (c.docEl.dir = "rtl",
- c.docEl.style.position = "absolute",
- c.docEl.style.right = "0"),
- d.resolve(c.docEl)
- }
- ,
- this.iframe.onerror = function(a) {
- d.reject({
- message: "Error Loading Contents: " + a,
- stack: (new Error).stack
- })
- }
- ,
- this.document = this.iframe.contentDocument,
- this.document ? (this.document.open(),
- this.document.write(a),
- this.document.close(),
- d.promise) : (d.reject(new Error("No Document Available")),
- d)
- }
- ,
- EPUBJS.Render.Iframe.prototype.loaded = function(a) {
- var b, c, d = this.iframe.contentWindow.location.href;
- this.document = this.iframe.contentDocument,
- this.docEl = this.document.documentElement,
- this.headEl = this.document.head,
- this.bodyEl = this.document.body || this.document.querySelector("body"),
- this.window = this.iframe.contentWindow,
- "about:blank" != d && (b = this.iframe.contentDocument.querySelector("base"),
- c = b.getAttribute("href"),
- this.trigger("render:loaded", c)),
- this.document.oncontextmenu = function() {
- return !1
- }
- }
- ,
- EPUBJS.Render.Iframe.prototype.resize = function(a, b) {
- this.iframe && (this.iframe.height = b,
- isNaN(a) || a % 2 === 0 || (a += 1),
- this.iframe.width = a,
- this.width = this.iframe.getBoundingClientRect().width || a,
- this.height = this.iframe.getBoundingClientRect().height || b)
- }
- ,
- EPUBJS.Render.Iframe.prototype.resized = function(a) {
- this.width = this.iframe.getBoundingClientRect().width,
- this.height = this.iframe.getBoundingClientRect().height
- }
- ,
- EPUBJS.Render.Iframe.prototype.totalWidth = function() {
- return this.docEl.scrollWidth
- }
- ,
- EPUBJS.Render.Iframe.prototype.totalHeight = function() {
- return this.docEl.scrollHeight
- }
- ,
- EPUBJS.Render.Iframe.prototype.setPageDimensions = function(a, b) {
- this.pageWidth = a,
- this.pageHeight = b
- }
- ,
- EPUBJS.Render.Iframe.prototype.setDirection = function(a) {
- this.direction = a,
- this.docEl && "rtl" == this.docEl.dir && (this.docEl.dir = "rtl",
- this.docEl.style.position = "static",
- this.docEl.style.right = "auto")
- }
- ,
- EPUBJS.Render.Iframe.prototype.setLeft = function(a) {
- this.isMobile ? this.docEl.style[this.transform] = "translate(" + -a + "px, 0)" : this.document.defaultView.scrollTo(a, 0)
- }
- ,
- EPUBJS.Render.Iframe.prototype.setStyle = function(a, b, c) {
- c && (a = EPUBJS.core.prefixed(a)),
- this.bodyEl && (this.bodyEl.style[a] = b)
- }
- ,
- EPUBJS.Render.Iframe.prototype.removeStyle = function(a) {
- this.bodyEl && (this.bodyEl.style[a] = "")
- }
- ,
- EPUBJS.Render.Iframe.prototype.addHeadTag = function(a, b, c) {
- var d = c || this.document
- , e = d.createElement(a)
- , f = d.head;
- for (var g in b)
- e.setAttribute(g, b[g]);
- f && f.insertBefore(e, f.firstChild)
- }
- ,
- EPUBJS.Render.Iframe.prototype.page = function(a) {
- this.leftPos = this.pageWidth * (a - 1),
- "rtl" === this.direction && (this.leftPos = this.leftPos * -1),
- this.setLeft(this.leftPos)
- }
- ,
- EPUBJS.Render.Iframe.prototype.getPageNumberByElement = function(a) {
- var b, c;
- if (a)
- return b = this.leftPos + a.getBoundingClientRect().left,
- c = Math.floor(b / this.pageWidth) + 1
- }
- ,
- EPUBJS.Render.Iframe.prototype.getPageNumberByRect = function(a) {
- var b, c;
- return b = this.leftPos + a.left,
- c = Math.floor(b / this.pageWidth) + 1
- }
- ,
- EPUBJS.Render.Iframe.prototype.getBaseElement = function() {
- return this.bodyEl
- }
- ,
- EPUBJS.Render.Iframe.prototype.getDocumentElement = function() {
- return this.docEl
- }
- ,
- EPUBJS.Render.Iframe.prototype.isElementVisible = function(a) {
- var b, c;
- return !!(a && "function" == typeof a.getBoundingClientRect && (b = a.getBoundingClientRect(),
- c = b.left,
- 0 !== b.width && 0 !== b.height && c >= 0 && c < this.pageWidth))
- }
- ,
- EPUBJS.Render.Iframe.prototype.scroll = function(a) {
- a ? this.iframe.scrolling = "yes" : this.iframe.scrolling = "no"
- }
- ,
- EPUBJS.Render.Iframe.prototype.unload = function() {
- this.window.removeEventListener("resize", this.resized),
- this.window.location.reload()
- }
- ,
- RSVP.EventTarget.mixin(EPUBJS.Render.Iframe.prototype),
- EPUBJS.Renderer = function(a, b) {
- this.listenedEvents = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click"],
- this.upEvent = "mouseup",
- this.downEvent = "mousedown",
- "ontouchstart"in document.documentElement && (this.listenedEvents.push("touchstart", "touchend"),
- this.upEvent = "touchend",
- this.downEvent = "touchstart"),
- a && "undefined" != typeof EPUBJS.Render[a] ? this.render = new EPUBJS.Render[a] : console.error("Not a Valid Rendering Method"),
- this.render.on("render:loaded", this.loaded.bind(this)),
- this.caches = {},
- this.epubcfi = new EPUBJS.EpubCFI,
- this.spreads = !0,
- this.isForcedSingle = !1,
- this.resized = this.onResized.bind(this),
- this.layoutSettings = {},
- this.hidden = b || !1,
- EPUBJS.Hooks.mixin(this),
- this.getHooks("beforeChapterDisplay"),
- this._q = EPUBJS.core.queue(this),
- this._moving = !1
- }
- ,
- EPUBJS.Renderer.prototype.Events = ["renderer:keydown", "renderer:keyup", "renderer:keypressed", "renderer:mouseup", "renderer:mousedown", "renderer:click", "renderer:touchstart", "renderer:touchend", "renderer:selected", "renderer:chapterUnloaded", "renderer:chapterDisplayed", "renderer:locationChanged", "renderer:visibleLocationChanged", "renderer:resized", "renderer:spreads"],
- EPUBJS.Renderer.prototype.initialize = function(a, b, c) {
- this.container = a,
- this.element = this.render.create(),
- this.initWidth = b,
- this.initHeight = c,
- this.width = b || this.container.clientWidth,
- this.height = c || this.container.clientHeight,
- this.container.appendChild(this.element),
- b && c ? this.render.resize(this.width, this.height) : this.render.resize("100%", "100%"),
- document.addEventListener("orientationchange", this.onResized)
- }
- ,
- EPUBJS.Renderer.prototype.displayChapter = function(a, b) {
- return this._moving ? void console.error("Rendering In Progress") : (this._moving = !0,
- a.render().then(function(c) {
- return this.currentChapter && (this.currentChapter.unload(),
- this.render.window && this.render.window.removeEventListener("resize", this.resized),
- this.removeEventListeners(),
- this.removeSelectionListeners(),
- this.trigger("renderer:chapterUnloaded"),
- this.contents = null,
- this.doc = null,
- this.pageMap = null),
- this.currentChapter = a,
- this.chapterPos = 1,
- this.currentChapterCfiBase = a.cfiBase,
- this.layoutSettings = this.reconcileLayoutSettings(b, a.properties),
- this.load(c, a.href)
- }
- .bind(this)))
- }
- ,
- EPUBJS.Renderer.prototype.load = function(a, b) {
- var c = new RSVP.defer;
- return this.layoutMethod = this.determineLayout(this.layoutSettings),
- this.layout = new EPUBJS.Layout[this.layoutMethod],
- this.visible(!1),
- render = this.render.load(a, b),
- render.then(function(a) {
- this.afterLoad(a),
- this.beforeDisplay(function() {
- this.afterDisplay(),
- this.visible(!0),
- c.resolve(this)
- }
- .bind(this))
- }
- .bind(this)),
- c.promise
- }
- ,
- EPUBJS.Renderer.prototype.afterLoad = function(a) {
- RDP_EPUB_SECTION = this.currentChapter.spinePos + 1,
- this.currentChapter.setDocument(this.render.document),
- this.contents = a,
- this.doc = this.render.document,
- this.formated = this.layout.format(a, this.render.width, this.render.height, this.gap),
- this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight),
- this.initWidth || this.initHeight || this.render.window.addEventListener("resize", this.resized, !1),
- this.addEventListeners(),
- this.addSelectionListeners()
- }
- ,
- EPUBJS.Renderer.prototype.afterDisplay = function(a) {
- function b() {
- for (var a = 3760, b = $("iframe")[0], e = b.contentDocument.body, f = e.innerHTML, g = new RegExp(/([^<>]{2,})(?=<)/g), h = 0, i = [], j = null, k = []; match = g.exec(f); )
- j = match,
- 0 == i.length && i.push(k),
- k.push(match),
- h += match[0].length,
- h >= a && (h -= a,
- k = [],
- i.push(k));
- j && f > 0 && k.push(j);
- var l = "break_"
- , m = c(i, f, l, !1);
- e.innerHTML = m,
- d(b, l, i.length)
- }
- function c(a, b, c, d) {
- for (var e = b, f = "", g = a.length - 1; g >= 0; g--) {
- var h = a[g];
- if (d) {
- var i = ["red", "blue", "green", "orage", "purple", "yellow"]
- , j = i[Math.floor(Math.random() * i.length)];
- f = "style='background:" + j + ";'"
- }
- for (var k = h.length - 1; k >= 0; k--) {
- var l = h[k]
- , m = l[0].length
- , n = c + g
- , o = '<break id="' + n + '" page_index="' + g + '" letters_count="' + m + '" ' + f + ">";
- e = [e.slice(0, l.index + m), "</break>", e.slice(l.index + m)].join(""),
- e = [e.slice(0, l.index), o, e.slice(l.index)].join("")
- }
- }
- return e
- }
- function d(a, b, c) {
- var d = a.contentWindow || a.contentDocument;
- d.addEventListener("scroll", function() {
- n && clearInterval(n),
- n = setInterval(function() {
- clearInterval(n),
- e(a, b, c)
- }, 500)
- }),
- e(a, b, c)
- }
- function e(a, b, c) {
- for (var d = (a.contentWindow || a.contentDocument,
- a.contentDocument || a.document), e = d.getElementsByTagName("break"), i = 0, j = {}, k = 0; k < e.length; k++) {
- var l = e[k];
- if (l && g(l, a)) {
- var m = l.getAttribute("page_index")
- , n = l.getAttribute("letters_count");
- j[m] || (j[m] = 0);
- var p = parseInt(n)
- , q = j[m] + p;
- i += p,
- j[m] = q
- }
- }
- currentItens = f(j, i);
- var r = JSON.stringify(o)
- , s = JSON.stringify(currentItens);
- r != s && (o = currentItens,
- h(o))
- }
- function f(a, b) {
- var c = [];
- for (var d in a) {
- var e = a[d] / b;
- if (e > .85) {
- c = [],
- c.push(d);
- break
- }
- e > .3 && c.push(d)
- }
- return c = c.sort()
- }
- function g(a, b) {
- var c = b.document || b.contentDocument
- , d = a.getBoundingClientRect();
- return d.top >= 0 && d.left >= 0 && d.bottom <= (b.innerHeight || c.documentElement.clientHeight) && d.right <= (b.innerWidth || c.documentElement.clientWidth)
- }
- function h(a) {
- for (var b = p, c = [], d = 0; d < b.length; d++) {
- for (var e = !1, f = 0; f < a.length; f++)
- if (b[d].page == j(a[f]) && RDP_EPUB_SECTION == b[d].section) {
- e = !0;
- break
- }
- e ? c.push(b[d]) : i(b[d])
- }
- p = c;
- for (var d = 0; d < a.length; d++) {
- for (var e = !1, f = 0; f < b.length; f++)
- if (j(a[d]) == b[f].page && b[f].section == RDP_EPUB_SECTION) {
- e = !0;
- break
- }
- e || p.push({
- section: RDP_EPUB_SECTION,
- page: j(a[d]),
- timestamp: Math.round((new Date).getTime() / 1e3)
- })
- }
- }
- function i(a) {
- var b = location.hash.split("/")[3]
- , c = a.section + "." + a.page
- , d = Math.round((new Date).getTime() / 1e3) - a.timestamp;
- Element.prototype.trackPageView(b, c, d)
- }
- function j(a) {
- return parseInt(a) + 1
- }
- console.log("afterDisplay"),
- $("iframe").contents().find("body").css({
- fontSize: RDP_EPUB.config.fontSize + "px",
- fontFamily: RDP_EPUB.config.fontFamily,
- color: RDP_EPUB.config.color,
- background: RDP_EPUB.config.background
- }),
- $("iframe").contents().find("img").css("height", "auto").css("max-height", window.innerHeight).css("max-width", window.innerWidth - 80);
- var k = this.layout.calculatePages()
- , l = this.currentChapter
- , m = this._q.length();
- this._moving = !1,
- this.updatePages(k),
- this.visibleRangeCfi = this.getVisibleRangeCfi(),
- this.currentLocationCfi = this.visibleRangeCfi.start,
- 0 === m && (this.trigger("renderer:locationChanged", this.currentLocationCfi),
- this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi)),
- l.cfi = this.currentLocationCfi,
- this.trigger("renderer:chapterDisplayed", l),
- $("iframe").contents().find("body").css({
- "-webkit-user-select": "none",
- "-moz-user-select": "none",
- "-ms-user-select": "none",
- "user-select": "none"
- });
- var n, o = [], p = [];
- b()
- }
- ,
- EPUBJS.Renderer.prototype.loaded = function(a) {
- this.trigger("render:loaded", a)
- }
- ,
- EPUBJS.Renderer.prototype.reconcileLayoutSettings = function(a, b) {
- var c = {};
- for (var d in a)
- a.hasOwnProperty(d) && (c[d] = a[d]);
- return b.forEach(function(a) {
- var b, d, e = a.replace("rendition:", ""), f = e.indexOf("-");
- f != -1 && (b = e.slice(0, f),
- d = e.slice(f + 1),
- c[b] = d)
- }),
- c
- }
- ,
- EPUBJS.Renderer.prototype.determineLayout = function(a) {
- var b = this.determineSpreads(this.minSpreadWidth)
- , c = b ? "ReflowableSpreads" : "Reflowable"
- , d = !1;
- return "pre-paginated" === a.layout && (c = "Fixed",
- d = !0,
- b = !1),
- "reflowable" === a.layout && "none" === a.spread && (c = "Reflowable",
- d = !1,
- b = !1),
- "reflowable" === a.layout && "both" === a.spread && (c = "ReflowableSpreads",
- d = !1,
- b = !0),
- this.spreads = b,
- this.render.scroll(d),
- this.trigger("renderer:spreads", b),
- c
- }
- ,
- EPUBJS.Renderer.prototype.beforeDisplay = function(a, b) {
- this.triggerHooks("beforeChapterDisplay", a, this)
- }
- ,
- EPUBJS.Renderer.prototype.updatePages = function(a) {
- this.pageMap = this.mapPage(),
- this.spreads ? this.displayedPages = Math.ceil(this.pageMap.length / 2) : this.displayedPages = this.pageMap.length,
- this.currentChapter.pages = this.pageMap.length,
- this._q.flush()
- }
- ,
- EPUBJS.Renderer.prototype.reformat = function() {
- var a, b = this;
- this.contents && (spreads = this.determineSpreads(this.minSpreadWidth),
- spreads != this.spreads && (this.spreads = spreads,
- this.layoutMethod = this.determineLayout(this.layoutSettings),
- this.layout = new EPUBJS.Layout[this.layoutMethod]),
- this.chapterPos = 1,
- this.render.page(this.chapterPos),
- b.formated = b.layout.format(b.render.docEl, b.render.width, b.render.height, b.gap),
- b.render.setPageDimensions(b.formated.pageWidth, b.formated.pageHeight),
- a = b.layout.calculatePages(),
- b.updatePages(a),
- b.currentLocationCfi && b.gotoCfi(b.currentLocationCfi))
- }
- ,
- EPUBJS.Renderer.prototype.visible = function(a) {
- return "undefined" == typeof a ? this.element.style.visibility : void (a !== !0 || this.hidden ? a === !1 && (this.element.style.visibility = "hidden") : this.element.style.visibility = "visible")
- }
- ,
- EPUBJS.Renderer.prototype.remove = function() {
- this.render.window && (this.render.unload(),
- this.render.window.removeEventListener("resize", this.resized),
- this.removeEventListeners(),
- this.removeSelectionListeners()),
- this.container.removeChild(this.element)
- }
- ,
- EPUBJS.Renderer.prototype.applyStyles = function(a) {
- for (var b in a)
- this.render.setStyle(b, a[b])
- }
- ,
- EPUBJS.Renderer.prototype.setStyle = function(a, b, c) {
- this.render.setStyle(a, b, c)
- }
- ,
- EPUBJS.Renderer.prototype.removeStyle = function(a) {
- this.render.removeStyle(a)
- }
- ,
- EPUBJS.Renderer.prototype.applyHeadTags = function(a) {
- for (var b in a)
- this.render.addHeadTag(b, a[b])
- }
- ,
- EPUBJS.Renderer.prototype.page = function(a) {
- return this.pageMap ? a >= 1 && a <= this.displayedPages && (this.chapterPos = a,
- this.render.page(a),
- this.visibleRangeCfi = this.getVisibleRangeCfi(),
- this.currentLocationCfi = this.visibleRangeCfi.start,
- this.trigger("renderer:locationChanged", this.currentLocationCfi),
- this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi),
- !0) : (console.warn("pageMap not set, queuing"),
- this._q.enqueue("page", arguments),
- !0)
- }
- ,
- EPUBJS.Renderer.prototype.nextPage = function() {
- return this.page(this.chapterPos + 1)
- }
- ,
- EPUBJS.Renderer.prototype.prevPage = function() {
- return this.page(this.chapterPos - 1)
- }
- ,
- EPUBJS.Renderer.prototype.pageByElement = function(a) {
- var b;
- a && (b = this.render.getPageNumberByElement(a),
- this.page(b))
- }
- ,
- EPUBJS.Renderer.prototype.lastPage = function() {
- return this._moving ? this._q.enqueue("lastPage", arguments) : void this.page(this.displayedPages)
- }
- ,
- EPUBJS.Renderer.prototype.firstPage = function() {
- return this._moving ? this._q.enqueue("firstPage", arguments) : void this.page(1)
- }
- ,
- EPUBJS.Renderer.prototype.section = function(a) {
- var b = this.doc.getElementById(a);
- b && this.pageByElement(b)
- }
- ,
- EPUBJS.Renderer.prototype.firstElementisTextNode = function(a) {
- var b = a.childNodes
- , c = b.length;
- return !!(c && b[0] && 3 === b[0].nodeType && b[0].textContent.trim().length)
- }
- ,
- EPUBJS.Renderer.prototype.isGoodNode = function(a) {
- var b = ["audio", "canvas", "embed", "iframe", "img", "math", "object", "svg", "video"];
- return b.indexOf(a.tagName.toLowerCase()) !== -1 || this.firstElementisTextNode(a)
- }
- ,
- EPUBJS.Renderer.prototype.walk = function(a, b, c) {
- for (var d, e, f, g, h = a, i = [h], j = 1e4, k = 0; !d && i.length; ) {
- if (a = i.shift(),
- this.containsPoint(a, b, c) && this.isGoodNode(a) && (d = a),
- !d && a && a.childElementCount > 0) {
- if (e = a.children,
- !e || !e.length)
- return d;
- f = e.length ? e.length : 0;
- for (var l = f - 1; l >= 0; l--)
- e[l] != g && i.unshift(e[l])
- }
- if (!d && 0 === i.length && h && null !== h.parentNode && (i.push(h.parentNode),
- g = h,
- h = h.parentNode),
- k++,
- k > j) {
- console.error("ENDLESS LOOP");
- break
- }
- }
- return d
- }
- ,
- EPUBJS.Renderer.prototype.containsPoint = function(a, b, c) {
- var d;
- return !!(a && "function" == typeof a.getBoundingClientRect && (d = a.getBoundingClientRect(),
- 0 !== d.width && 0 !== d.height && d.left >= b && b <= d.left + d.width))
- }
- ,
- EPUBJS.Renderer.prototype.textSprint = function(a, b) {
- for (var c, d = document.createTreeWalker(a, NodeFilter.SHOW_TEXT, {
- acceptNode: function(a) {
- return /^\s*$/.test(a.data) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
- }
- }, !1); c = d.nextNode(); )
- b(c)
- }
- ,
- EPUBJS.Renderer.prototype.sprint = function(a, b) {
- for (var c, d = document.createTreeWalker(a, NodeFilter.SHOW_ELEMENT, null, !1); c = d.nextNode(); )
- b(c)
- }
- ,
- EPUBJS.Renderer.prototype.mapPage = function() {
- var a, b, c = this, d = [], e = this.render.getBaseElement(), f = 1, g = this.layout.colWidth + this.layout.gap, h = this.formated.pageWidth * (this.chapterPos - 1), i = g * f - h, j = 0, k = function(a) {
- var b, c, d = Array.prototype.slice.call(a.childNodes);
- if (a.nodeType == Node.ELEMENT_NODE) {
- if (c = document.createRange(),
- c.selectNodeContents(a),
- b = c.getBoundingClientRect(),
- !b || 0 === b.width && 0 === b.height)
- return;
- b.left > j && d.forEach(function(a) {
- a.nodeType == Node.TEXT_NODE && a.textContent.trim().length && l(a)
- }),
- b.right > j && d.forEach(function(a) {
- a.nodeType == Node.TEXT_NODE && a.textContent.trim().length && l(a)
- })
- }
- }, l = function(e) {
- var k = c.splitTextNodeIntoWordsRanges(e);
- k.forEach(function(e) {
- var k = e.getBoundingClientRect();
- !k || 0 === k.width && 0 === k.height || (k.left + k.width < i ? d[f - 1] || (e.collapse(!0),
- b = c.currentChapter.cfiFromRange(e),
- d.push({
- start: b,
- end: null
- })) : (a && (a.collapse(!0),
- b = c.currentChapter.cfiFromRange(a),
- d[d.length - 1].end = b),
- e.collapse(!0),
- b = c.currentChapter.cfiFromRange(e),
- d.push({
- start: b,
- end: null
- }),
- f += 1,
- i = g * f - h,
- j = i),
- a = e)
- })
- }, m = this.render.getDocumentElement(), n = m.dir;
- return "rtl" == n && (m.dir = "ltr",
- m.style.position = "static"),
- this.sprint(e, k),
- "rtl" == n && (m.dir = n,
- m.style.left = "auto",
- m.style.right = "0"),
- a && (a.collapse(!0),
- b = c.currentChapter.cfiFromRange(a),
- d[d.length - 1].end = b),
- d.length || (range = this.doc.createRange(),
- range.selectNodeContents(e),
- range.collapse(!0),
- b = c.currentChapter.cfiFromRange(range),
- d.push({
- start: b,
- end: b
- })),
- a = null,
- ranges = null,
- range = null,
- e = null,
- d
- }
- ,
- EPUBJS.Renderer.prototype.indexOfBreakableChar = function(a, b) {
- var c = "- \t\r\n\b\f";
- b || (b = 0);
- for (var d = b; d < a.length; d++)
- if (c.indexOf(a.charAt(d)) != -1)
- return d;
- return -1
- }
- ,
- EPUBJS.Renderer.prototype.splitTextNodeIntoWordsRanges = function(a) {
- var b, c = [], d = a.textContent.trim();
- if (pos = this.indexOfBreakableChar(d),
- pos === -1)
- return b = this.doc.createRange(),
- b.selectNodeContents(a),
- [b];
- for (b = this.doc.createRange(),
- b.setStart(a, 0),
- b.setEnd(a, pos),
- c.push(b),
- b = this.doc.createRange(),
- b.setStart(a, pos + 1); pos != -1; )
- pos = this.indexOfBreakableChar(d, pos + 1),
- pos > 0 && (b && (b.setEnd(a, pos),
- c.push(b)),
- b = this.doc.createRange(),
- b.setStart(a, pos + 1));
- return b && (b.setEnd(a, d.length),
- c.push(b)),
- c
- }
- ,
- EPUBJS.Renderer.prototype.rangePosition = function(a) {
- var b, c;
- return c = a.getClientRects(),
- c.length ? b = c[0] : null
- }
- ,
- EPUBJS.Renderer.prototype.getPageCfi = function() {
- var a;
- return this.spreads ? (a = 2 * this.chapterPos,
- startRange = this.pageMap[a - 2]) : (a = this.chapterPos,
- startRange = this.pageMap[a - 1]),
- this.pageMap[2 * this.chapterPos - 1].start
- }
- ,
- EPUBJS.Renderer.prototype.getRange = function(a, b, c) {
- var d, e = this.doc.createRange();
- return c = !0,
- "undefined" == typeof document.caretPositionFromPoint || c ? "undefined" == typeof document.caretRangeFromPoint || c ? (this.visibileEl = this.findElementAfter(a, b),
- e.setStart(this.visibileEl, 1)) : e = this.doc.caretRangeFromPoint(a, b) : (d = this.doc.caretPositionFromPoint(a, b),
- e.setStart(d.offsetNode, d.offset)),
- e
- }
- ,
- EPUBJS.Renderer.prototype.pagesInCurrentChapter = function() {
- var a, b;
- return this.pageMap ? (b = this.pageMap.length,
- a = this.spreads ? Math.ceil(b / 2) : b) : (console.warn("page map not loaded"),
- !1)
- }
- ,
- EPUBJS.Renderer.prototype.currentRenderedPage = function() {
- var a;
- return this.pageMap ? a = this.spreads && this.layout.pageCount > 1 ? 2 * this.chapterPos : this.chapterPos : (console.warn("page map not loaded"),
- !1)
- }
- ,
- EPUBJS.Renderer.prototype.getRenderedPagesLeft = function() {
- var a, b, c;
- return this.pageMap ? (b = this.pageMap.length,
- a = this.spreads ? 2 * this.chapterPos : this.chapterPos,
- c = b - a) : (console.warn("page map not loaded"),
- !1)
- }
- ,
- EPUBJS.Renderer.prototype.getVisibleRangeCfi = function() {
- var a, b, c;
- return this.pageMap ? (this.spreads ? (a = 2 * this.chapterPos,
- b = this.pageMap[a - 2],
- c = b,
- this.layout.pageCount > 1 && (c = this.pageMap[a - 1])) : (a = this.chapterPos,
- b = this.pageMap[a - 1],
- c = b),
- b || (console.warn("page range miss:", a, this.pageMap),
- b = this.pageMap[this.pageMap.length - 1],
- c = b),
- {
- start: b.start,
- end: c.end
- }) : (console.warn("page map not loaded"),
- !1)
- }
- ,
- EPUBJS.Renderer.prototype.gotoCfi = function(a) {
- var b, c, d;
- if (this._moving)
- return this._q.enqueue("gotoCfi", arguments);
- if (EPUBJS.core.isString(a) && (a = this.epubcfi.parse(a)),
- "undefined" == typeof document.evaluate)
- c = this.epubcfi.addMarker(a, this.doc),
- c && (b = this.render.getPageNumberByElement(c),
- this.epubcfi.removeMarker(c, this.doc),
- this.page(b));
- else if (d = this.epubcfi.generateRangeFromCfi(a, this.doc)) {
- var e = d.getBoundingClientRect();
- b = e ? this.render.getPageNumberByRect(e) : 1,
- this.page(b),
- this.currentLocationCfi = a.str
- } else
- this.page(1)
- }
- ,
- EPUBJS.Renderer.prototype.findFirstVisible = function(a) {
- var b, c = a || this.render.getBaseElement();
- return b = this.walk(c, 0, 0),
- b ? b : a
- }
- ,
- EPUBJS.Renderer.prototype.findElementAfter = function(a, b, c) {
- var d, e = c || this.render.getBaseElement();
- return d = this.walk(e, a, b),
- d ? d : e
- }
- ,
- EPUBJS.Renderer.prototype.resize = function(a, b, c) {
- this.width = a,
- this.height = b,
- c !== !1 && this.render.resize(this.width, this.height),
- this.contents && this.reformat(),
- this.trigger("renderer:resized", {
- width: this.width,
- height: this.height
- })
- }
- ,
- EPUBJS.Renderer.prototype.onResized = function(a) {
- var b = this.container.clientWidth
- , c = this.container.clientHeight;
- this.resize(b, c, !1)
- }
- ,
- EPUBJS.Renderer.prototype.addEventListeners = function() {
- this.render.document && this.listenedEvents.forEach(function(a) {
- this.render.document.addEventListener(a, this.triggerEvent.bind(this), !1)
- }, this)
- }
- ,
- EPUBJS.Renderer.prototype.removeEventListeners = function() {
- this.render.document && this.listenedEvents.forEach(function(a) {
- this.render.document.removeEventListener(a, this.triggerEvent, !1)
- }, this)
- }
- ,
- EPUBJS.Renderer.prototype.triggerEvent = function(a) {
- this.trigger("renderer:" + a.type, a)
- }
- ,
- EPUBJS.Renderer.prototype.addSelectionListeners = function() {
- this.render.document.addEventListener("selectionchange", this.onSelectionChange.bind(this), !1)
- }
- ,
- EPUBJS.Renderer.prototype.removeSelectionListeners = function() {
- this.render.document && this.doc.removeEventListener("selectionchange", this.onSelectionChange, !1)
- }
- ,
- EPUBJS.Renderer.prototype.onSelectionChange = function(a) {
- this.selectionEndTimeout && clearTimeout(this.selectionEndTimeout),
- this.selectionEndTimeout = setTimeout(function() {
- this.selectedRange = this.render.window.getSelection(),
- this.trigger("renderer:selected", this.selectedRange)
- }
- .bind(this), 500)
- }
- ,
- EPUBJS.Renderer.prototype.setMinSpreadWidth = function(a) {
- this.minSpreadWidth = a,
- this.spreads = this.determineSpreads(a)
- }
- ,
- EPUBJS.Renderer.prototype.determineSpreads = function(a) {
- return !(this.isForcedSingle || !a || this.width < a)
- }
- ,
- EPUBJS.Renderer.prototype.forceSingle = function(a) {
- a ? this.isForcedSingle = !0 : this.isForcedSingle = !1
- }
- ,
- EPUBJS.Renderer.prototype.setGap = function(a) {
- this.gap = a
- }
- ,
- EPUBJS.Renderer.prototype.setDirection = function(a) {
- this.direction = a,
- this.render.setDirection(this.direction)
- }
- ,
- EPUBJS.Renderer.prototype.replace = function(a, b, c, d) {
- var e = this.contents.querySelectorAll(a)
- , f = Array.prototype.slice.call(e)
- , g = f.length;
- return 0 === g ? void c(!1) : void f.forEach(function(a) {
- var e = !1
- , f = function(a, b) {
- e === !1 && (g--,
- d && d(a, b, g),
- g <= 0 && c && c(!0),
- e = !0)
- };
- b(a, f)
- }
- .bind(this))
- }
- ,
- RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype);
- var EPUBJS = EPUBJS || {};
- EPUBJS.replace = {},
- EPUBJS.replace.hrefs = function(a, b) {
- var c = this
- , d = function(a, d) {
- var e, f, g = a.getAttribute("href"), h = g.search("://");
- if (h != -1)
- a.setAttribute("target", "_blank");
- else {
- var i = EPUBJS.core.uri(b.render.window.location.href);
- e = i.directory,
- f = e ? "file" === i.protocol ? EPUBJS.core.resolveUrl(i.base, g) : EPUBJS.core.resolveUrl(e, g) : g,
- a.onclick = function() {
- return c["goto"](f),
- !1
- }
- }
- d()
- };
- b.replace("a[href]", d, a)
- }
- ,
- EPUBJS.replace.head = function(a, b) {
- b.replaceWithStored("link[href]", "href", EPUBJS.replace.links, a)
- }
- ,
- EPUBJS.replace.resources = function(a, b) {
- b.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, a)
- }
- ,
- EPUBJS.replace.svg = function(a, b) {
- b.replaceWithStored("image", "xlink:href", function(a, b, c) {
- a.getUrl(b).then(c)
- }, a)
- }
- ,
- EPUBJS.replace.srcs = function(a, b, c) {
- a.getUrl(b).then(c)
- }
- ,
- EPUBJS.replace.links = function(a, b, c, d) {
- "stylesheet" === d.getAttribute("rel") ? EPUBJS.replace.stylesheets(a, b).then(function(a, b) {
- c(a, b)
- }, function(a) {
- c(null)
- }) : a.getUrl(b).then(c, function(a) {
- c(null)
- })
- }
- ,
- EPUBJS.replace.stylesheets = function(a, b) {
- var c = new RSVP.defer;
- if (a)
- return a.getText(b).then(function(d) {
- EPUBJS.replace.cssUrls(a, b, d).then(function(a) {
- var b = window.URL || window.webkitURL || window.mozURL
- , d = new Blob([a],{
- type: "text/css"
- })
- , e = b.createObjectURL(d);
- c.resolve(e)
- }, function(a) {
- c.reject(a)
- })
- }, function(a) {
- c.reject(a)
- }),
- c.promise
- }
- ,
- EPUBJS.replace.cssUrls = function(a, b, c) {
- var d = new RSVP.defer
- , e = []
- , f = c.match(/url\(\'?\"?([^\'|^\"^\)]*)\'?\"?\)/g);
- if (a)
- return f ? (f.forEach(function(f) {
- var g = EPUBJS.core.resolveUrl(b, f.replace(/url\(|[|\)|\'|\"]/g, ""))
- , h = a.getUrl(g).then(function(a) {
- c = c.replace(f, 'url("' + a + '")')
- }, function(a) {
- d.reject(a)
- });
- e.push(h)
- }),
- RSVP.all(e).then(function() {
- d.resolve(c)
- }),
- d.promise) : (d.resolve(c),
- d.promise)
- }
- ,
- EPUBJS.Storage = function(a) {
- this.checkRequirements(),
- this.urlCache = {},
- this.withCredentials = a,
- this.URL = window.URL || window.webkitURL || window.mozURL,
- this.offline = !1
- }
- ,
- EPUBJS.Storage.prototype.checkRequirements = function(a) {
- "undefined" == typeof localforage && console.error("localForage library not loaded")
- }
- ,
- EPUBJS.Storage.prototype.put = function(a, b) {
- var c = new RSVP.defer
- , d = a.length
- , e = 0
- , f = function(b) {
- var c, g, h = b || new RSVP.defer;
- return e >= d ? h.resolve() : (c = a[e].url,
- g = window.encodeURIComponent(c),
- EPUBJS.core.request(c, "binary").then(function(a) {
- return localforage.setItem(g, a)
- }).then(function(a) {
- e++,
- setTimeout(function() {
- f(h)
- }, 1)
- })),
- h.promise
- }
- .bind(this);
- return Array.isArray(a) || (a = [a]),
- f().then(function() {
- c.resolve()
- }
- .bind(this)),
- c.promise
- }
- ,
- EPUBJS.Storage.prototype.token = function(a, b) {
- var c = window.encodeURIComponent(a);
- return localforage.setItem(c, b).then(function(a) {
- return null !== a
- })
- }
- ,
- EPUBJS.Storage.prototype.isStored = function(a) {
- var b = window.encodeURIComponent(a);
- return localforage.getItem(b).then(function(a) {
- return null !== a
- })
- }
- ,
- EPUBJS.Storage.prototype.getText = function(a) {
- var b = window.encodeURIComponent(a);
- return EPUBJS.core.request(a, "arraybuffer", this.withCredentials).then(function(a) {
- return this.offline && (this.offline = !1,
- this.trigger("offline", !1)),
- localforage.setItem(b, a),
- a
- }
- .bind(this)).then(function(b) {
- var c = new RSVP.defer
- , d = EPUBJS.core.getMimeType(a)
- , e = new Blob([b],{
- type: d
- })
- , f = new FileReader;
- return f.addEventListener("loadend", function() {
- c.resolve(f.result)
- }),
- f.readAsText(e, d),
- c.promise
- })["catch"](function() {
- var c = new RSVP.defer
- , d = localforage.getItem(b);
- return this.offline || (this.offline = !0,
- this.trigger("offline", !0)),
- d ? (d.then(function(b) {
- var d = EPUBJS.core.getMimeType(a)
- , e = new Blob([b],{
- type: d
- })
- , f = new FileReader;
- f.addEventListener("loadend", function() {
- c.resolve(f.result)
- }),
- f.readAsText(e, d)
- }),
- c.promise) : (c.reject({
- message: "File not found in the storage: " + a,
- stack: (new Error).stack
- }),
- c.promise)
- }
- .bind(this))
- }
- ,
- EPUBJS.Storage.prototype.getUrl = function(a) {
- var b = window.encodeURIComponent(a);
- return EPUBJS.core.request(a, "arraybuffer", this.withCredentials).then(function(c) {
- return this.offline && (this.offline = !1,
- this.trigger("offline", !1)),
- localforage.setItem(b, c),
- a
- }
- .bind(this))["catch"](function() {
- var c, d, e = new RSVP.defer, f = window.URL || window.webkitURL || window.mozURL;
- return this.offline || (this.offline = !0,
- this.trigger("offline", !0)),
- b in this.urlCache ? (e.resolve(this.urlCache[b]),
- e.promise) : (c = localforage.getItem(b)) ? (c.then(function(c) {
- var g = new Blob([c],{
- type: EPUBJS.core.getMimeType(a)
- });
- d = f.createObjectURL(g),
- e.resolve(d),
- this.urlCache[b] = d
- }
- .bind(this)),
- e.promise) : (e.reject({
- message: "File not found in the storage: " + a,
- stack: (new Error).stack
- }),
- e.promise)
- }
- .bind(this))
- }
- ,
- EPUBJS.Storage.prototype.getXml = function(a) {
- var b = window.encodeURIComponent(a);
- return EPUBJS.core.request(a, "arraybuffer", this.withCredentials).then(function(a) {
- return this.offline && (this.offline = !1,
- this.trigger("offline", !1)),
- localforage.setItem(b, a),
- a
- }
- .bind(this)).then(function(b) {
- var c = new RSVP.defer
- , d = EPUBJS.core.getMimeType(a)
- , e = new Blob([b],{
- type: d
- })
- , f = new FileReader;
- return f.addEventListener("loadend", function() {
- var a = new DOMParser
- , b = a.parseFromString(f.result, "text/xml");
- c.resolve(b)
- }),
- f.readAsText(e, d),
- c.promise
- })["catch"](function() {
- var c = new RSVP.defer
- , d = localforage.getItem(b);
- return this.offline || (this.offline = !0,
- this.trigger("offline", !0)),
- d ? (d.then(function(b) {
- var d = EPUBJS.core.getMimeType(a)
- , e = new Blob([b],{
- type: d
- })
- , f = new FileReader;
- f.addEventListener("loadend", function() {
- var a = new DOMParser
- , b = a.parseFromString(f.result, "text/xml");
- c.resolve(b)
- }),
- f.readAsText(e, d)
- }),
- c.promise) : (c.reject({
- message: "File not found in the storage: " + a,
- stack: (new Error).stack
- }),
- c.promise)
- }
- .bind(this))
- }
- ,
- EPUBJS.Storage.prototype.revokeUrl = function(a) {
- var b = window.URL || window.webkitURL || window.mozURL
- , c = this.urlCache[a];
- c && b.revokeObjectURL(c)
- }
- ,
- EPUBJS.Storage.prototype.failed = function(a) {
- console.error(a)
- }
- ,
- RSVP.EventTarget.mixin(EPUBJS.Storage.prototype),
- EPUBJS.Unarchiver = function(a) {
- this.checkRequirements(),
- this.urlCache = {}
- }
- ,
- EPUBJS.Unarchiver.prototype.checkRequirements = function(a) {
- "undefined" == typeof JSZip && console.error("JSZip lib not loaded")
- }
- ,
- EPUBJS.Unarchiver.prototype.open = function(a, b) {
- new RSVP.defer;
- return EPUBJS.core.request(a, "binary").then(function(a) {
- this.zip = new JSZip(a)
- }
- .bind(this))
- }
- ,
- EPUBJS.Unarchiver.prototype.getXml = function(a, b) {
- var c = window.decodeURIComponent(a);
- return this.getText(c, b).then(function(a) {
- var b = new DOMParser;
- return b.parseFromString(a, "text/xml")
- })
- }
- ,
- EPUBJS.Unarchiver.prototype.getUrl = function(a, b) {
- var c, d, e = this, f = new RSVP.defer, g = window.decodeURIComponent(a), h = this.zip.file(g), i = window.URL || window.webkitURL || window.mozURL;
- return h ? a in this.urlCache ? (f.resolve(this.urlCache[a]),
- f.promise) : (d = new Blob([h.asUint8Array()],{
- type: EPUBJS.core.getMimeType(h.name)
- }),
- c = i.createObjectURL(d),
- f.resolve(c),
- e.urlCache[a] = c,
- f.promise) : (f.reject({
- message: "File not found in the epub: " + a,
- stack: (new Error).stack
- }),
- f.promise)
- }
- ,
- EPUBJS.Unarchiver.prototype.getText = function(a, b) {
- var c, d = new RSVP.defer, e = window.decodeURIComponent(a), f = this.zip.file(e);
- return f ? (c = f.asText(),
- d.resolve(c),
- d.promise) : (d.reject({
- message: "File not found in the epub: " + a,
- stack: (new Error).stack
- }),
- d.promise)
- }
- ,
- EPUBJS.Unarchiver.prototype.revokeUrl = function(a) {
- var b = window.URL || window.webkitURL || window.mozURL
- , c = this.urlCache[a];
- c && b.revokeObjectURL(c)
- }
- ,
- EPUBJS.Unarchiver.prototype.failed = function(a) {
- console.error(a)
- }
- ,
- EPUBJS.Unarchiver.prototype.afterSaved = function(a) {
- this.callback()
- }
- ,
- EPUBJS.Unarchiver.prototype.toStorage = function(a) {
- function b() {
- f--,
- 0 === f && e.afterSaved()
- }
- var c = 0
- , d = 20
- , e = this
- , f = a.length;
- a.forEach(function(a) {
- setTimeout(function(a) {
- e.saveEntryFileToStorage(a, b)
- }, c, a),
- c += d
- }),
- console.log("time", c)
- }
- ,
- function() {
- "use strict";
- var a = {
- application: {
- ecmascript: ["es", "ecma"],
- javascript: "js",
- ogg: "ogx",
- pdf: "pdf",
- postscript: ["ps", "ai", "eps", "epsi", "epsf", "eps2", "eps3"],
- "rdf+xml": "rdf",
- smil: ["smi", "smil"],
- "xhtml+xml": ["xhtml", "xht"],
- xml: ["xml", "xsl", "xsd"],
- zip: "zip",
- "x-httpd-eruby": "rhtml",
- "x-latex": "latex",
- "x-maker": ["frm", "maker", "frame", "fm", "fb", "book", "fbdoc"],
- "x-object": "o",
- "x-shockwave-flash": ["swf", "swfl"],
- "x-silverlight": "scr",
- "epub+zip": "epub",
- "font-tdpfr": "pfr",
- "inkml+xml": ["ink", "inkml"],
- json: "json",
- "jsonml+json": "jsonml",
- "mathml+xml": "mathml",
- "metalink+xml": "metalink",
- mp4: "mp4s",
- "oebps-package+xml": "opf",
- "omdoc+xml": "omdoc",
- oxps: "oxps",
- "vnd.amazon.ebook": "azw",
- widget: "wgt",
- "x-dtbncx+xml": "ncx",
- "x-dtbook+xml": "dtb",
- "x-dtbresource+xml": "res",
- "x-font-bdf": "bdf",
- "x-font-ghostscript": "gsf",
- "x-font-linux-psf": "psf",
- "x-font-otf": "otf",
- "x-font-pcf": "pcf",
- "x-font-snf": "snf",
- "x-font-ttf": ["ttf", "ttc"],
- "x-font-type1": ["pfa", "pfb", "pfm", "afm"],
- "x-font-woff": "woff",
- "x-mobipocket-ebook": ["prc", "mobi"],
- "x-mspublisher": "pub",
- "x-nzb": "nzb",
- "x-tgif": "obj",
- "xaml+xml": "xaml",
- "xml-dtd": "dtd",
- "xproc+xml": "xpl",
- "xslt+xml": "xslt",
- "internet-property-stream": "acx",
- "x-compress": "z",
- "x-compressed": "tgz",
- "x-gzip": "gz"
- },
- audio: {
- flac: "flac",
- midi: ["mid", "midi", "kar", "rmi"],
- mpeg: ["mpga", "mpega", "mp2", "mp3", "m4a", "mp2a", "m2a", "m3a"],
- mpegurl: "m3u",
- ogg: ["oga", "ogg", "spx"],
- "x-aiff": ["aif", "aiff", "aifc"],
- "x-ms-wma": "wma",
- "x-wav": "wav",
- adpcm: "adp",
- mp4: "mp4a",
- webm: "weba",
- "x-aac": "aac",
- "x-caf": "caf",
- "x-matroska": "mka",
- "x-pn-realaudio-plugin": "rmp",
- xm: "xm",
- mid: ["mid", "rmi"]
- },
- image: {
- gif: "gif",
- ief: "ief",
- jpeg: ["jpeg", "jpg", "jpe"],
- pcx: "pcx",
- png: "png",
- "svg+xml": ["svg", "svgz"],
- tiff: ["tiff", "tif"],
- "x-icon": "ico",
- bmp: "bmp",
- webp: "webp",
- "x-pict": ["pic", "pct"],
- "x-tga": "tga",
- "cis-cod": "cod"
- },
- message: {
- rfc822: ["eml", "mime", "mht", "mhtml", "nws"]
- },
- text: {
- "cache-manifest": ["manifest", "appcache"],
- calendar: ["ics", "icz", "ifb"],
- css: "css",
- csv: "csv",
- h323: "323",
- html: ["html", "htm", "shtml", "stm"],
- iuls: "uls",
- mathml: "mml",
- plain: ["txt", "text", "brf", "conf", "def", "list", "log", "in", "bas"],
- richtext: "rtx",
- "tab-separated-values": "tsv",
- "x-bibtex": "bib",
- "x-dsrc": "d",
- "x-diff": ["diff", "patch"],
- "x-haskell": "hs",
- "x-java": "java",
- "x-literate-haskell": "lhs",
- "x-moc": "moc",
- "x-pascal": ["p", "pas"],
- "x-pcs-gcd": "gcd",
- "x-perl": ["pl", "pm"],
- "x-python": "py",
- "x-scala": "scala",
- "x-setext": "etx",
- "x-tcl": ["tcl", "tk"],
- "x-tex": ["tex", "ltx", "sty", "cls"],
- "x-vcard": "vcf",
- sgml: ["sgml", "sgm"],
- "x-c": ["c", "cc", "cxx", "cpp", "h", "hh", "dic"],
- "x-fortran": ["f", "for", "f77", "f90"],
- "x-opml": "opml",
- "x-nfo": "nfo",
- "x-sfv": "sfv",
- "x-uuencode": "uu",
- webviewhtml: "htt"
- },
- video: {
- mpeg: ["mpeg", "mpg", "mpe", "m1v", "m2v", "mp2", "mpa", "mpv2"],
- mp4: ["mp4", "mp4v", "mpg4"],
- quicktime: ["qt", "mov"],
- ogg: "ogv",
- "vnd.mpegurl": ["mxu", "m4u"],
- "x-flv": "flv",
- "x-la-asf": ["lsf", "lsx"],
- "x-mng": "mng",
- "x-ms-asf": ["asf", "asx", "asr"],
- "x-ms-wm": "wm",
- "x-ms-wmv": "wmv",
- "x-ms-wmx": "wmx",
- "x-ms-wvx": "wvx",
- "x-msvideo": "avi",
- "x-sgi-movie": "movie",
- "x-matroska": ["mpv", "mkv", "mk3d", "mks"],
- "3gpp2": "3g2",
- h261: "h261",
- h263: "h263",
- h264: "h264",
- jpeg: "jpgv",
- jpm: ["jpm", "jpgm"],
- mj2: ["mj2", "mjp2"],
- "vnd.ms-playready.media.pyv": "pyv",
- "vnd.uvvu.mp4": ["uvu", "uvvu"],
- "vnd.vivo": "viv",
- webm: "webm",
- "x-f4v": "f4v",
- "x-m4v": "m4v",
- "x-ms-vob": "vob",
- "x-smv": "smv"
- }
- }
- , b = function() {
- var b, c, d, e, f = {};
- for (b in a)
- if (a.hasOwnProperty(b))
- for (c in a[b])
- if (a[b].hasOwnProperty(c))
- if (d = a[b][c],
- "string" == typeof d)
- f[d] = b + "/" + c;
- else
- for (e = 0; e < d.length; e++)
- f[d[e]] = b + "/" + c;
- return f
- }();
- EPUBJS.core.getMimeType = function(a) {
- var c = "text/plain";
- return a && b[a.split(".").pop().toLowerCase()] || c
- }
- }(),
- EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(a, b) {
- var c = b.contents.querySelectorAll("a[href]")
- , d = Array.prototype.slice.call(c)
- , e = "epub:type"
- , f = "noteref"
- , g = EPUBJS.core.folder(location.pathname)
- , h = (g + EPUBJS.cssPath || g,
- {});
- EPUBJS.core.addCss("http://cdn-html5.s3.amazonaws.com/reader_epub/1.0/css/popup.css", !1, b.render.document.head),
- d.forEach(function(a) {
- function c() {
- var c, e, f = b.height, j = b.width, p = 225;
- o || (c = l.cloneNode(!0),
- o = c.querySelector("p")),
- h[k] || (h[k] = document.createElement("div"),
- h[k].setAttribute("class", "popup"),
- pop_content = document.createElement("div"),
- h[k].appendChild(pop_content),
- pop_content.appendChild(o),
- pop_content.setAttribute("class", "pop_content"),
- b.render.document.body.appendChild(h[k]),
- h[k].addEventListener("mouseover", d, !1),
- h[k].addEventListener("mouseout", g, !1),
- b.on("renderer:pageChanged", i, this),
- b.on("renderer:pageChanged", g, this)),
- c = h[k],
- e = a.getBoundingClientRect(),
- m = e.left,
- n = e.top,
- c.classList.add("show"),
- popRect = c.getBoundingClientRect(),
- c.style.left = m - popRect.width / 2 + "px",
- c.style.top = n + "px",
- p > f / 2.5 && (p = f / 2.5,
- pop_content.style.maxHeight = p + "px"),
- popRect.height + n >= f - 25 ? (c.style.top = n - popRect.height + "px",
- c.classList.add("above")) : c.classList.remove("above"),
- m - popRect.width <= 0 ? (c.style.left = m + "px",
- c.classList.add("left")) : c.classList.remove("left"),
- m + popRect.width / 2 >= j ? (c.style.left = m - 300 + "px",
- popRect = c.getBoundingClientRect(),
- c.style.left = m - popRect.width + "px",
- popRect.height + n >= f - 25 ? (c.style.top = n - popRect.height + "px",
- c.classList.add("above")) : c.classList.remove("above"),
- c.classList.add("right")) : c.classList.remove("right")
- }
- function d() {
- h[k].classList.add("on")
- }
- function g() {
- h[k].classList.remove("on")
- }
- function i() {
- setTimeout(function() {
- h[k].classList.remove("show")
- }, 100)
- }
- var j, k, l, m, n, o, p = a.getAttribute(e);
- p == f && (j = a.getAttribute("href"),
- k = j.replace("#", ""),
- l = b.render.document.getElementById(k),
- a.addEventListener("mouseover", c, !1),
- a.addEventListener("mouseout", i, !1))
- }),
- a && a()
- }
- ,
- EPUBJS.Hooks.register("beforeChapterDisplay").mathml = function(a, b) {
- if (-1 !== b.currentChapter.manifestProperties.indexOf("mathml")) {
- b.render.iframe.contentWindow.mathmlCallback = a;
- var c = document.createElement("script");
- c.type = "text/x-mathjax-config",
- c.innerHTML = ' MathJax.Hub.Register.StartupHook("End",function () { window.mathmlCallback(); }); MathJax.Hub.Config({jax: ["input/TeX","input/MathML","output/SVG"],extensions: ["tex2jax.js","mml2jax.js","MathEvents.js"],TeX: {extensions: ["noErrors.js","noUndefined.js","autoload-all.js"]},MathMenu: {showRenderer: false},menuSettings: {zoom: "Click"},messageStyle: "none"}); ',
- b.doc.body.appendChild(c),
- EPUBJS.core.addScript("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML", null, b.doc.head)
- } else
- a && a()
- }
- ,
- EPUBJS.Hooks.register("beforeChapterDisplay").smartimages = function(a, b) {
- var c = b.contents.querySelectorAll("img")
- , d = Array.prototype.slice.call(c)
- , e = b.height;
- return "reflowable" != b.layoutSettings.layout ? void a() : (d.forEach(function(a) {
- function c() {
- var c, d = a.getBoundingClientRect(), f = d.height, g = d.top, h = a.getAttribute("data-height"), i = h || f, j = Number(getComputedStyle(a, "").fontSize.match(/(\d*(\.\d*)?)px/)[1]), k = j ? j / 2 : 0;
- e = b.contents.clientHeight,
- 0 > g && (g = 0),
- i + g >= e ? (e / 2 > g ? (c = e - g - k,
- a.style.maxHeight = c + "px",
- a.style.width = "auto") : (i > e && (a.style.maxHeight = e + "px",
- a.style.width = "auto",
- d = a.getBoundingClientRect(),
- i = d.height),
- a.style.display = "block",
- a.style.WebkitColumnBreakBefore = "always",
- a.style.breakBefore = "column"),
- a.setAttribute("data-height", c)) : (a.style.removeProperty("max-height"),
- a.style.removeProperty("margin-top"))
- }
- a.addEventListener("load", c, !1),
- b.on("renderer:resized", c),
- b.on("renderer:chapterUnloaded", function() {
- a.removeEventListener("load", c),
- b.off("renderer:resized", c)
- }),
- c()
- }),
- void (a && a()))
- }
- ,
- EPUBJS.Hooks.register("beforeChapterDisplay").transculsions = function(a, b) {
- var c = b.contents.querySelectorAll("[transclusion]")
- , d = Array.prototype.slice.call(c);
- d.forEach(function(a) {
- function c() {
- j = g,
- k = h,
- j > chapter.colWidth && (d = chapter.colWidth / j,
- j = chapter.colWidth,
- k *= d),
- f.width = j,
- f.height = k
- }
- var d, e = a.getAttribute("ref"), f = document.createElement("iframe"), g = a.getAttribute("width"), h = a.getAttribute("height"), i = a.parentNode, j = g, k = h;
- c(),
- b.listenUntil("renderer:resized", "renderer:chapterUnloaded", c),
- f.src = e,
- i.replaceChild(f, a)
- }),
- a && a()
- }
- ,
- EPUBJS.reader = {},
- EPUBJS.reader.plugins = {},
- function(a) {
- var b = (a.ePubReader || {},
- a.ePubReader = function(a, b) {
- return new EPUBJS.Reader(a,b)
- }
- );
- "function" == typeof define && define.amd ? define(function() {
- return Reader
- }) : "undefined" != typeof module && module.exports && (module.exports = b)
- }(window, jQuery),
- EPUBJS.Reader = function(a, b) {
- var c, d, e, f = this, g = $("#viewer"), h = window.location.search;
- this.settings = EPUBJS.core.defaults(b || {}, {
- bookPath: a,
- restore: !0,
- reload: !1,
- bookmarks: void 0,
- annotations: void 0,
- contained: void 0,
- bookKey: void 0,
- styles: void 0,
- sidebarReflow: !1,
- generatePagination: !1,
- history: !0
- }),
- h && (e = h.slice(1).split("&"),
- e.forEach(function(a) {
- var b = a.split("=")
- , c = b[0]
- , d = b[1] || "";
- f.settings[c] = decodeURIComponent(d)
- })),
- this.setBookKey(this.settings.bookPath),
- this.settings.restore && this.isSaved() && this.applySavedSettings(),
- this.settings.styles = this.settings.styles || {
- fontSize: "100%"
- },
- this.book = c = new EPUBJS.Book(this.settings),
- this.settings.previousLocationCfi && c.gotoCfi(this.settings.previousLocationCfi),
- this.offline = !1,
- this.sidebarOpen = !1,
- this.settings.bookmarks || (this.settings.bookmarks = []),
- this.settings.annotations || (this.settings.annotations = []),
- this.settings.generatePagination && c.generatePagination(g.width(), g.height()),
- c.renderTo("viewer"),
- f.ReaderController = EPUBJS.reader.ReaderController.call(f, c),
- f.SettingsController = EPUBJS.reader.SettingsController.call(f, c),
- f.ControlsController = EPUBJS.reader.ControlsController.call(f, c),
- f.SidebarController = EPUBJS.reader.SidebarController.call(f, c),
- f.BookmarksController = EPUBJS.reader.BookmarksController.call(f, c),
- f.NotesController = EPUBJS.reader.NotesController.call(f, c);
- for (d in EPUBJS.reader.plugins)
- EPUBJS.reader.plugins.hasOwnProperty(d) && (f[d] = EPUBJS.reader.plugins[d].call(f, c));
- return c.ready.all.then(function() {
- f.ReaderController.hideLoader()
- }),
- c.getMetadata().then(function(a) {
- f.MetaController = EPUBJS.reader.MetaController.call(f, a)
- }),
- c.getToc().then(function(a) {
- f.TocController = EPUBJS.reader.TocController.call(f, a)
- }),
- window.addEventListener("beforeunload", this.unload.bind(this), !1),
- window.addEventListener("hashchange", this.hashChanged.bind(this), !1),
- document.addEventListener("keydown", this.adjustFontSize.bind(this), !1),
- c.on("renderer:keydown", this.adjustFontSize.bind(this)),
- c.on("renderer:keydown", f.ReaderController.arrowKeys.bind(this)),
- c.on("renderer:selected", this.selectedRange.bind(this)),
- this
- }
- ,
- EPUBJS.Reader.prototype.adjustFontSize = function(a) {
- var b, c = 2, d = 187, e = 189, f = 48, g = a.ctrlKey || a.metaKey;
- this.settings.styles && (this.settings.styles.fontSize || (this.settings.styles.fontSize = "100%"),
- b = parseInt(this.settings.styles.fontSize.slice(0, -1)),
- g && a.keyCode == d && (a.preventDefault(),
- this.book.setStyle("fontSize", b + c + "%")),
- g && a.keyCode == e && (a.preventDefault(),
- this.book.setStyle("fontSize", b - c + "%")),
- g && a.keyCode == f && (a.preventDefault(),
- this.book.setStyle("fontSize", "100%")))
- }
- ,
- EPUBJS.Reader.prototype.addBookmark = function(a) {
- var b = this.isBookmarked(a);
- b > -1 || (this.settings.bookmarks.push(a),
- this.trigger("reader:bookmarked", a))
- }
- ,
- EPUBJS.Reader.prototype.removeBookmark = function(a) {
- var b = this.isBookmarked(a);
- -1 !== b && (this.settings.bookmarks.splice(b, 1),
- this.trigger("reader:unbookmarked", b))
- }
- ,
- EPUBJS.Reader.prototype.isBookmarked = function(a) {
- var b = this.settings.bookmarks;
- return b.indexOf(a)
- }
- ,
- EPUBJS.Reader.prototype.clearBookmarks = function() {
- this.settings.bookmarks = []
- }
- ,
- EPUBJS.Reader.prototype.addNote = function(a) {
- this.settings.annotations.push(a)
- }
- ,
- EPUBJS.Reader.prototype.removeNote = function(a) {
- var b = this.settings.annotations.indexOf(a);
- -1 !== b && delete this.settings.annotations[b]
- }
- ,
- EPUBJS.Reader.prototype.clearNotes = function() {
- this.settings.annotations = []
- }
- ,
- EPUBJS.Reader.prototype.setBookKey = function(a) {
- return this.settings.bookKey || (this.settings.bookKey = "epubjsreader:" + EPUBJS.VERSION + ":" + window.location.host + ":" + a),
- this.settings.bookKey
- }
- ,
- EPUBJS.Reader.prototype.isSaved = function() {
- var a;
- return !!localStorage && (a = localStorage.getItem(this.settings.bookKey),
- null !== a)
- }
- ,
- EPUBJS.Reader.prototype.removeSavedSettings = function() {
- return !!localStorage && void localStorage.removeItem(this.settings.bookKey)
- }
- ,
- EPUBJS.Reader.prototype.applySavedSettings = function() {
- var a;
- if (!localStorage)
- return !1;
- try {
- a = JSON.parse(localStorage.getItem(this.settings.bookKey))
- } catch (b) {
- return !1
- }
- return !!a && (a.styles && (this.settings.styles = EPUBJS.core.defaults(this.settings.styles || {}, a.styles)),
- this.settings = EPUBJS.core.defaults(this.settings, a),
- !0)
- }
- ,
- EPUBJS.Reader.prototype.saveSettings = function() {
- return this.book && (this.settings.previousLocationCfi = this.book.getCurrentLocationCfi()),
- !!localStorage && void localStorage.setItem(this.settings.bookKey, JSON.stringify(this.settings))
- }
- ,
- EPUBJS.Reader.prototype.unload = function() {
- this.settings.restore && localStorage && this.saveSettings()
- }
- ,
- EPUBJS.Reader.prototype.hashChanged = function() {
- var a = window.location.hash.slice(1);
- this.book["goto"](a)
- }
- ,
- EPUBJS.Reader.prototype.selectedRange = function(a) {
- var b = new EPUBJS.EpubCFI
- , c = b.generateCfiFromRangeAnchor(a, this.book.renderer.currentChapter.cfiBase)
- , d = window.location.origin + window.location.pathname + window.location.hash;
- this.settings.history && window.location.hash != d && (history.pushState({}, "", d),
- this.currentLocationCfi = c)
- }
- ,
- RSVP.EventTarget.mixin(EPUBJS.Reader.prototype),
- EPUBJS.reader.BookmarksController = function() {
- var a = this.book
- , b = $("#bookmarksView")
- , c = b.find("#bookmarks")
- , d = document.createDocumentFragment()
- , e = function() {
- b.show()
- }
- , f = function() {
- b.hide()
- }
- , g = 0
- , h = function(b) {
- var c = document.createElement("li")
- , d = document.createElement("a");
- return c.id = "bookmark-" + g,
- c.classList.add("list_item"),
- d.textContent = b,
- d.href = b,
- d.classList.add("bookmark_link"),
- d.addEventListener("click", function(b) {
- var c = this.getAttribute("href");
- a.gotoCfi(c),
- b.preventDefault()
- }, !1),
- c.appendChild(d),
- g++,
- c
- };
- return this.settings.bookmarks.forEach(function(a) {
- var b = h(a);
- d.appendChild(b)
- }),
- c.append(d),
- this.on("reader:bookmarked", function(a) {
- var b = h(a);
- c.append(b)
- }),
- this.on("reader:unbookmarked", function(a) {
- var b = $("#bookmark-" + a);
- b.remove()
- }),
- {
- show: e,
- hide: f
- }
- }
- ,
- EPUBJS.reader.ControlsController = function(a) {
- var b = this
- , c = ($("#store"),
- $("#fullscreen"))
- , d = ($("#fullscreenicon"),
- $("#cancelfullscreenicon"),
- $("#slider"))
- , e = ($("#main"),
- $("#sidebar"),
- $("#setting"))
- , f = $("#bookmark")
- , g = function() {
- b.offline = !1
- }
- , h = function() {
- b.offline = !0
- }
- , i = !1;
- return a.on("book:online", g),
- a.on("book:offline", h),
- d.on("click", function() {
- b.sidebarOpen ? (b.SidebarController.hide(),
- d.addClass("icon-menu"),
- d.removeClass("icon-right")) : (b.SidebarController.show(),
- d.addClass("icon-right"),
- d.removeClass("icon-menu"))
- }),
- "undefined" != typeof screenfull && (c.on("click", function() {
- screenfull.toggle($("#container")[0])
- }),
- screenfull.raw && document.addEventListener(screenfull.raw.fullscreenchange, function() {
- i = screenfull.isFullscreen,
- i ? c.addClass("icon-resize-small").removeClass("icon-resize-full") : c.addClass("icon-resize-full").removeClass("icon-resize-small")
- })),
- e.on("click", function() {
- b.SettingsController.show()
- }),
- f.on("click", function() {
- var a = b.book.getCurrentLocationCfi()
- , c = b.isBookmarked(a);
- -1 === c ? (b.addBookmark(a),
- f.addClass("icon-bookmark").removeClass("icon-bookmark-empty")) : (b.removeBookmark(a),
- f.removeClass("icon-bookmark").addClass("icon-bookmark-empty"))
- }),
- a.on("renderer:locationChanged", function(a) {
- var c = "#" + a
- , d = b.isBookmarked(a);
- -1 === d ? f.removeClass("icon-bookmark").addClass("icon-bookmark-empty") : f.addClass("icon-bookmark").removeClass("icon-bookmark-empty"),
- b.currentLocationCfi = a,
- b.settings.history && window.location.hash != c && history.pushState({}, "", window.location.origin + window.location.pathname + window.location.hash)
- }),
- a.on("book:pageChanged", function() {}),
- {}
- }
- ,
- EPUBJS.reader.MetaController = function(a) {
- var b = a.bookTitle
- , c = a.creator
- , d = $("#book-title")
- , e = $("#chapter-title")
- , f = $("#title-seperator");
- document.title = b + " – " + c,
- d.html(b),
- e.html(c),
- f.show()
- }
- ,
- EPUBJS.reader.NotesController = function() {
- var a = this.book
- , b = this
- , c = $("#notesView")
- , d = $("#notes")
- , e = $("#note-text")
- , f = $("#note-anchor")
- , g = b.settings.annotations
- , h = a.renderer
- , i = []
- , j = new EPUBJS.EpubCFI
- , k = function() {
- c.show()
- }
- , l = function() {
- c.hide()
- }
- , m = function(c) {
- var d, g, h, i, k, l = a.renderer.doc;
- if (l.caretPositionFromPoint ? (d = l.caretPositionFromPoint(c.clientX, c.clientY),
- g = d.offsetNode,
- h = d.offset) : l.caretRangeFromPoint && (d = l.caretRangeFromPoint(c.clientX, c.clientY),
- g = d.startContainer,
- h = d.startOffset),
- 3 !== g.nodeType)
- for (var p = 0; p < g.childNodes.length; p++)
- if (3 == g.childNodes[p].nodeType) {
- g = g.childNodes[p];
- break
- }
- h = g.textContent.indexOf(".", h),
- -1 === h ? h = g.length : h += 1,
- i = j.generateCfiFromTextNode(g, h, a.renderer.currentChapter.cfiBase),
- k = {
- annotatedAt: new Date,
- anchor: i,
- body: e.val()
- },
- b.addNote(k),
- n(k),
- o(k),
- e.val(""),
- f.text("Attach"),
- e.prop("disabled", !1),
- a.off("renderer:click", m)
- }
- , n = function(b) {
- var c = document.createElement("li")
- , e = document.createElement("a");
- c.innerHTML = b.body,
- e.innerHTML = " context »",
- e.href = "#" + b.anchor,
- e.onclick = function() {
- return a.gotoCfi(b.anchor),
- !1
- }
- ,
- c.appendChild(e),
- d.append(c)
- }
- , o = function(b) {
- var c = a.renderer.doc
- , d = document.createElement("span")
- , e = document.createElement("a");
- d.classList.add("footnotesuperscript", "reader_generated"),
- d.style.verticalAlign = "super",
- d.style.fontSize = ".75em",
- d.style.lineHeight = "1em",
- e.style.padding = "2px",
- e.style.backgroundColor = "#fffa96",
- e.style.borderRadius = "5px",
- e.style.cursor = "pointer",
- d.id = "note-" + EPUBJS.core.uuid(),
- e.innerHTML = g.indexOf(b) + 1 + "[Reader]",
- d.appendChild(e),
- j.addMarker(b.anchor, c, d),
- p(d, b.body)
- }
- , p = function(a, c) {
- var d = a.id
- , e = function() {
- var b, e, k, l, m = h.height, n = h.width, o = 225;
- i[d] || (i[d] = document.createElement("div"),
- i[d].setAttribute("class", "popup"),
- pop_content = document.createElement("div"),
- i[d].appendChild(pop_content),
- pop_content.innerHTML = c,
- pop_content.setAttribute("class", "pop_content"),
- h.render.document.body.appendChild(i[d]),
- i[d].addEventListener("mouseover", f, !1),
- i[d].addEventListener("mouseout", g, !1),
- h.on("renderer:locationChanged", j, this),
- h.on("renderer:locationChanged", g, this)),
- b = i[d],
- e = a.getBoundingClientRect(),
- k = e.left,
- l = e.top,
- b.classList.add("show"),
- popRect = b.getBoundingClientRect(),
- b.style.left = k - popRect.width / 2 + "px",
- b.style.top = l + "px",
- o > m / 2.5 && (o = m / 2.5,
- pop_content.style.maxHeight = o + "px"),
- popRect.height + l >= m - 25 ? (b.style.top = l - popRect.height + "px",
- b.classList.add("above")) : b.classList.remove("above"),
- k - popRect.width <= 0 ? (b.style.left = k + "px",
- b.classList.add("left")) : b.classList.remove("left"),
- k + popRect.width / 2 >= n ? (b.style.left = k - 300 + "px",
- popRect = b.getBoundingClientRect(),
- b.style.left = k - popRect.width + "px",
- popRect.height + l >= m - 25 ? (b.style.top = l - popRect.height + "px",
- b.classList.add("above")) : b.classList.remove("above"),
- b.classList.add("right")) : b.classList.remove("right")
- }
- , f = function() {
- i[d].classList.add("on")
- }
- , g = function() {
- i[d].classList.remove("on")
- }
- , j = function() {
- setTimeout(function() {
- i[d].classList.remove("show")
- }, 100)
- }
- , l = function() {
- b.ReaderController.slideOut(),
- k()
- };
- a.addEventListener("mouseover", e, !1),
- a.addEventListener("mouseout", j, !1),
- a.addEventListener("click", l, !1)
- };
- return f.on("click", function() {
- f.text("Cancel"),
- e.prop("disabled", "true"),
- a.on("renderer:click", m)
- }),
- g.forEach(function(a) {
- n(a)
- }),
- h.registerHook("beforeChapterDisplay", function(a, b) {
- var c = b.currentChapter;
- g.forEach(function(a) {
- var b = j.parse(a.anchor);
- if (b.spinePos === c.spinePos)
- try {
- o(a)
- } catch (d) {
- console.log("anchoring failed", a.anchor)
- }
- }),
- a()
- }, !0),
- {
- show: k,
- hide: l
- }
- }
- ,
- EPUBJS.reader.ReaderController = function(a) {
- var b = $("#main")
- , c = $("#divider")
- , d = $("#loader")
- , e = $("#next")
- , f = $("#prev")
- , g = this
- , a = this.book
- , h = function() {
- var c = a.getCurrentLocationCfi();
- g.settings.sidebarReflow ? (b.removeClass("single"),
- b.one("transitionend", function() {
- a.gotoCfi(c)
- })) : b.removeClass("closed")
- }
- , i = function() {
- var c = a.getCurrentLocationCfi();
- g.settings.sidebarReflow ? (b.addClass("single"),
- b.one("transitionend", function() {
- a.gotoCfi(c)
- })) : b.addClass("closed")
- }
- , j = function() {
- d.show(),
- m()
- }
- , k = function() {
- d.hide()
- }
- , l = function() {
- c.addClass("show")
- }
- , m = function() {
- c.removeClass("show")
- }
- , n = !1
- , o = function(b) {
- 37 == b.keyCode && ("rtl" === a.metadata.direction ? a.nextPage() : a.prevPage(),
- f.addClass("active"),
- n = !0,
- setTimeout(function() {
- n = !1,
- f.removeClass("active")
- }, 100),
- b.preventDefault()),
- 39 == b.keyCode && ("rtl" === a.metadata.direction ? a.prevPage() : a.nextPage(),
- e.addClass("active"),
- n = !0,
- setTimeout(function() {
- n = !1,
- e.removeClass("active")
- }, 100),
- b.preventDefault())
- };
- return document.addEventListener("keydown", o, !1),
- e.on("click", function(b) {
- "rtl" === a.metadata.direction ? a.prevPage() : a.nextPage(),
- b.preventDefault()
- }),
- f.on("click", function(b) {
- "rtl" === a.metadata.direction ? a.nextPage() : a.prevPage(),
- b.preventDefault()
- }),
- a.on("renderer:spreads", function(a) {
- a ? l() : m()
- }),
- {
- slideOut: i,
- slideIn: h,
- showLoader: j,
- hideLoader: k,
- showDivider: l,
- hideDivider: m,
- arrowKeys: o
- }
- }
- ,
- EPUBJS.reader.SettingsController = function() {
- var a = (this.book,
- this)
- , b = $("#settings-modal")
- , c = $(".overlay")
- , d = function() {
- b.addClass("md-show")
- }
- , e = function() {
- b.removeClass("md-show")
- }
- , f = $("#sidebarReflow");
- return f.on("click", function() {
- a.settings.sidebarReflow = !a.settings.sidebarReflow
- }),
- b.find(".closer").on("click", function() {
- e()
- }),
- c.on("click", function() {
- e()
- }),
- {
- show: d,
- hide: e
- }
- }
- ,
- EPUBJS.reader.SidebarController = function() {
- var a = this
- , b = $("#sidebar")
- , c = $("#panels")
- , d = "Toc"
- , e = function(b) {
- var e = b + "Controller";
- d != b && "undefined" != typeof a[e] && (a[d + "Controller"].hide(),
- a[e].show(),
- d = b,
- c.find(".active").removeClass("active"),
- c.find("#show-" + b).addClass("active"))
- }
- , f = function() {
- return d
- }
- , g = function() {
- a.sidebarOpen = !0,
- a.ReaderController.slideOut(),
- b.addClass("open")
- }
- , h = function() {
- a.sidebarOpen = !1,
- a.ReaderController.slideIn(),
- b.removeClass("open")
- };
- return c.find(".show_view").on("click", function(a) {
- var b = $(this).data("view");
- e(b),
- a.preventDefault()
- }),
- {
- show: g,
- hide: h,
- getActivePanel: f,
- changePanelTo: e
- }
- }
- ,
- EPUBJS.reader.TocController = function(a) {
- var b = this.book
- , c = $("#tocView")
- , d = document.createDocumentFragment()
- , e = !1
- , f = function(a, b) {
- var c = document.createElement("ul");
- return b || (b = 1),
- a.forEach(function(a) {
- var d = document.createElement("li")
- , e = document.createElement("a");
- toggle = document.createElement("a");
- var g;
- d.id = "toc-" + a.id,
- d.classList.add("list_item"),
- e.textContent = a.label,
- e.href = a.href,
- e.classList.add("toc_link"),
- d.appendChild(e),
- a.subitems.length > 0 && (b++,
- g = f(a.subitems, b),
- toggle.classList.add("toc_toggle"),
- d.insertBefore(toggle, e),
- d.appendChild(g)),
- c.appendChild(d)
- }),
- c
- }
- , g = function() {
- c.show()
- }
- , h = function() {
- c.hide()
- }
- , i = function(a) {
- var b = a.id
- , d = c.find("#toc-" + b)
- , f = c.find(".currentChapter");
- c.find(".openChapter"),
- d.length && (d != f && d.has(e).length > 0 && f.removeClass("currentChapter"),
- d.addClass("currentChapter"),
- d.parents("li").addClass("openChapter"))
- };
- b.on("renderer:chapterDisplayed", i);
- var j = f(a);
- return d.appendChild(j),
- c.append(d),
- c.find(".toc_link").on("click", function(a) {
- var d = this.getAttribute("href");
- a.preventDefault(),
- b["goto"](d),
- c.find(".currentChapter").addClass("openChapter").removeClass("currentChapter"),
- $(this).parent("li").addClass("currentChapter")
- }),
- c.find(".toc_toggle").on("click", function(a) {
- var b = $(this).parent("li")
- , c = b.hasClass("openChapter");
- a.preventDefault(),
- c ? b.removeClass("openChapter") : b.addClass("openChapter")
- }),
- {
- show: g,
- hide: h
- }
- }
- ,
- EPUBJS.reader.search = {},
- EPUBJS.reader.search.SERVER = "https://pacific-cliffs-3579.herokuapp.com",
- EPUBJS.reader.search.request = function(a, b) {
- var c = $.ajax({
- dataType: "json",
- url: EPUBJS.reader.search.SERVER + "/search?q=" + encodeURIComponent(a)
- });
- c.fail(function(a) {
- console.error(a)
- }),
- c.done(function(a) {
- b(a)
- })
- }
- ,
- EPUBJS.reader.plugins.SearchController = function(a) {
- var b, c = this, d = $("#searchBox"), e = $("#searchResults"), f = $("#searchView"), g = !1, h = function() {
- j(),
- g = !0,
- f.addClass("shown")
- }, i = function() {
- g = !1,
- f.removeClass("shown")
- }, j = function() {
- var c = d.val();
- "" != c && (e.empty(),
- e.append("<li><p>Searching...</p></li>"),
- EPUBJS.reader.search.request(c, function(d) {
- var f = d.results;
- return e.empty(),
- b && $(b).find("body").unhighlight(),
- 0 == f.length ? void e.append("<li><p>No Results Found</p></li>") : (b = $("#viewer iframe")[0].contentDocument,
- $(b).find("body").highlight(c, {
- element: "span"
- }),
- void f.forEach(function(d) {
- var f = $("<li></li>")
- , g = $("<a href='" + d.href + "' data-cfi='" + d.cfi + "'><span>" + d.title + "</span><p>" + d.highlight + "</p></a>");
- g.on("click", function(d) {
- var e = $(this)
- , f = e.data("cfi");
- d.preventDefault(),
- a.gotoCfi(f + "/1:0"),
- a.on("renderer:chapterDisplayed", function() {
- b = $("#viewer iframe")[0].contentDocument,
- $(b).find("body").highlight(c, {
- element: "span"
- })
- })
- }),
- f.append(g),
- e.append(f)
- }))
- }))
- };
- return d.on("search", function(a) {
- var f = d.val();
- return "" == f ? (e.empty(),
- "Search" == c.SidebarController.getActivePanel() && c.SidebarController.changePanelTo("Toc"),
- $(b).find("body").unhighlight(),
- void (b = !1)) : (c.SidebarController.changePanelTo("Search"),
- void a.preventDefault())
- }),
- {
- show: h,
- hide: i
- }
- }
- ,
- jQuery.extend({
- highlight: function(a, b, c, d) {
- if (3 === a.nodeType) {
- var e = a.data.match(b);
- if (e) {
- var f = document.createElement(c || "span");
- f.className = d || "highlight";
- var g = a.splitText(e.index);
- g.splitText(e[0].length);
- var h = g.cloneNode(!0);
- return f.appendChild(h),
- g.parentNode.replaceChild(f, g),
- 1
- }
- } else if (1 === a.nodeType && a.childNodes && !/(script|style)/i.test(a.tagName) && (a.tagName !== c.toUpperCase() || a.className !== d))
- for (var i = 0; i < a.childNodes.length; i++)
- i += jQuery.highlight(a.childNodes[i], b, c, d);
- return 0
- }
- }),
- jQuery.fn.unhighlight = function(a) {
- var b = {
- className: "highlight",
- element: "span"
- };
- return jQuery.extend(b, a),
- this.find(b.element + "." + b.className).each(function() {
- var a = this.parentNode;
- a.replaceChild(this.firstChild, this),
- a.normalize()
- }).end()
- }
- ,
- jQuery.fn.highlight = function(a, b) {
- var c = {
- className: "highlight",
- element: "span",
- caseSensitive: !1,
- wordsOnly: !1
- };
- if (jQuery.extend(c, b),
- a.constructor === String && (a = [a]),
- a = jQuery.grep(a, function(a, b) {
- return "" != a
- }),
- a = jQuery.map(a, function(a, b) {
- return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
- }),
- 0 == a.length)
- return this;
- var d = c.caseSensitive ? "" : "i"
- , e = "(" + a.join("|") + ")";
- c.wordsOnly && (e = "\\b" + e + "\\b");
- var f = new RegExp(e,d);
- return this.each(function() {
- jQuery.highlight(this, f, c.element, c.className)
- })
- }
- ,
- EPUBJS.Hooks.register("beforeChapterDisplay").highlight = function(a, b) {
- var c = document.createElement("style");
- c.innerHTML = ".highlight { background: yellow; font-weight: normal; }",
- b.render.document.head.appendChild(c),
- a && a()
- }
- ,
- !function(a, b) {
- "use strict";
- var c = "undefined" != typeof Element && "ALLOW_KEYBOARD_INPUT"in Element
- , d = function() {
- for (var a, c, d = [["requestFullscreen", "exitFullscreen", "fullscreenElement", "fullscreenEnabled", "fullscreenchange", "fullscreenerror"], ["webkitRequestFullscreen", "webkitExitFullscreen", "webkitFullscreenElement", "webkitFullscreenEnabled", "webkitfullscreenchange", "webkitfullscreenerror"], ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitCurrentFullScreenElement", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitfullscreenerror"], ["mozRequestFullScreen", "mozCancelFullScreen", "mozFullScreenElement", "mozFullScreenEnabled", "mozfullscreenchange", "mozfullscreenerror"], ["msRequestFullscreen", "msExitFullscreen", "msFullscreenElement", "msFullscreenEnabled", "MSFullscreenchange", "MSFullscreenerror"]], e = 0, f = d.length, g = {}; f > e; e++)
- if (a = d[e],
- a && a[1]in b) {
- for (e = 0,
- c = a.length; c > e; e++)
- g[d[0][e]] = a[e];
- return g
- }
- return !1
- }()
- , e = {
- request: function(a) {
- var e = d.requestFullscreen;
- a = a || b.documentElement,
- /5\.1[\.\d]* Safari/.test(navigator.userAgent) ? a[e]() : a[e](c && Element.ALLOW_KEYBOARD_INPUT)
- },
- exit: function() {
- b[d.exitFullscreen]()
- },
- toggle: function(a) {
- this.isFullscreen ? this.exit() : this.request(a)
- },
- onchange: function() {},
- onerror: function() {},
- raw: d
- };
- return d ? (Object.defineProperties(e, {
- isFullscreen: {
- get: function() {
- return !!b[d.fullscreenElement]
- }
- },
- element: {
- enumerable: !0,
- get: function() {
- return b[d.fullscreenElement]
- }
- },
- enabled: {
- enumerable: !0,
- get: function() {
- return !!b[d.fullscreenEnabled]
- }
- }
- }),
- b.addEventListener(d.fullscreenchange, function(a) {
- e.onchange.call(e, a)
- }),
- b.addEventListener(d.fullscreenerror, function(a) {
- e.onerror.call(e, a)
- }),
- void (a.screenfull = e)) : void (a.screenfull = !1)
- }(window, document),
- function(a, b) {
- "function" == typeof define && define.amd ? define([], b) : "object" == typeof exports ? module.exports = b() : a.X2JS = b()
- }(this, function() {
- return function(a) {
- "use strict";
- function b() {
- void 0 === a.escapeMode && (a.escapeMode = !0),
- a.attributePrefix = a.attributePrefix || "_",
- a.arrayAccessForm = a.arrayAccessForm || "none",
- a.emptyNodeForm = a.emptyNodeForm || "text",
- void 0 === a.enableToStringFunc && (a.enableToStringFunc = !0),
- a.arrayAccessFormPaths = a.arrayAccessFormPaths || [],
- void 0 === a.skipEmptyTextNodesForObj && (a.skipEmptyTextNodesForObj = !0),
- void 0 === a.stripWhitespaces && (a.stripWhitespaces = !0),
- a.datetimeAccessFormPaths = a.datetimeAccessFormPaths || [],
- void 0 === a.useDoubleQuotes && (a.useDoubleQuotes = !1),
- a.xmlElementsFilter = a.xmlElementsFilter || [],
- a.jsonPropertiesFilter = a.jsonPropertiesFilter || [],
- void 0 === a.keepCData && (a.keepCData = !1)
- }
- function c() {}
- function d(a) {
- var b = a.localName;
- return null == b && (b = a.baseName),
- null != b && "" != b || (b = a.nodeName),
- b
- }
- function e(a) {
- return a.prefix
- }
- function f(a) {
- return "string" == typeof a ? a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'") : a
- }
- function g(a, b, c, d) {
- for (var e = 0; e < a.length; e++) {
- var f = a[e];
- if ("string" == typeof f) {
- if (f == d)
- break
- } else if (f instanceof RegExp) {
- if (f.test(d))
- break
- } else if ("function" == typeof f && f(b, c, d))
- break
- }
- return e != a.length
- }
- function h(b, c, d) {
- switch (a.arrayAccessForm) {
- case "property":
- b[c]instanceof Array ? b[c + "_asArray"] = b[c] : b[c + "_asArray"] = [b[c]]
- }
- !(b[c]instanceof Array) && a.arrayAccessFormPaths.length > 0 && g(a.arrayAccessFormPaths, b, c, d) && (b[c] = [b[c]])
- }
- function i(a) {
- var b = a.split(/[-T:+Z]/g)
- , c = new Date(b[0],b[1] - 1,b[2])
- , d = b[5].split(".");
- if (c.setHours(b[3], b[4], d[0]),
- d.length > 1 && c.setMilliseconds(d[1]),
- b[6] && b[7]) {
- var e = 60 * b[6] + Number(b[7])
- , f = /\d\d-\d\d:\d\d$/.test(a) ? "-" : "+";
- e = 0 + ("-" == f ? -1 * e : e),
- c.setMinutes(c.getMinutes() - e - c.getTimezoneOffset())
- } else
- a.indexOf("Z", a.length - 1) !== -1 && (c = new Date(Date.UTC(c.getFullYear(), c.getMonth(), c.getDate(), c.getHours(), c.getMinutes(), c.getSeconds(), c.getMilliseconds())));
- return c
- }
- function j(b, c, d) {
- if (a.datetimeAccessFormPaths.length > 0) {
- var e = d.split(".#")[0];
- return g(a.datetimeAccessFormPaths, b, c, e) ? i(b) : b
- }
- return b
- }
- function k(b, c, d, e) {
- return !(c == z.ELEMENT_NODE && a.xmlElementsFilter.length > 0) || g(a.xmlElementsFilter, b, d, e)
- }
- function l(b, c) {
- if (b.nodeType == z.DOCUMENT_NODE) {
- for (var f = new Object, g = b.childNodes, i = 0; i < g.length; i++) {
- var m = g.item(i);
- if (m.nodeType == z.ELEMENT_NODE) {
- var n = d(m);
- f[n] = l(m, n)
- }
- }
- return f
- }
- if (b.nodeType == z.ELEMENT_NODE) {
- var f = new Object;
- f.__cnt = 0;
- for (var g = b.childNodes, i = 0; i < g.length; i++) {
- var m = g.item(i)
- , n = d(m);
- if (m.nodeType != z.COMMENT_NODE) {
- var o = c + "." + n;
- k(f, m.nodeType, n, o) && (f.__cnt++,
- null == f[n] ? (f[n] = l(m, o),
- h(f, n, o)) : (null != f[n] && (f[n]instanceof Array || (f[n] = [f[n]],
- h(f, n, o))),
- f[n][f[n].length] = l(m, o)))
- }
- }
- for (var p = 0; p < b.attributes.length; p++) {
- var q = b.attributes.item(p);
- f.__cnt++,
- f[a.attributePrefix + q.name] = q.value
- }
- var r = e(b);
- return null != r && "" != r && (f.__cnt++,
- f.__prefix = r),
- null != f["#text"] && (f.__text = f["#text"],
- f.__text instanceof Array && (f.__text = f.__text.join("\n")),
- a.stripWhitespaces && (f.__text = f.__text.trim()),
- delete f["#text"],
- "property" == a.arrayAccessForm && delete f["#text_asArray"],
- f.__text = j(f.__text, n, c + "." + n)),
- null != f["#cdata-section"] && (f.__cdata = f["#cdata-section"],
- delete f["#cdata-section"],
- "property" == a.arrayAccessForm && delete f["#cdata-section_asArray"]),
- 0 == f.__cnt && "text" == a.emptyNodeForm ? f = "" : 1 == f.__cnt && null != f.__text ? f = f.__text : 1 != f.__cnt || null == f.__cdata || a.keepCData ? f.__cnt > 1 && null != f.__text && a.skipEmptyTextNodesForObj && (a.stripWhitespaces && "" == f.__text || "" == f.__text.trim()) && delete f.__text : f = f.__cdata,
- delete f.__cnt,
- !a.enableToStringFunc || null == f.__text && null == f.__cdata || (f.toString = function() {
- return (null != this.__text ? this.__text : "") + (null != this.__cdata ? this.__cdata : "")
- }
- ),
- f
- }
- if (b.nodeType == z.TEXT_NODE || b.nodeType == z.CDATA_SECTION_NODE)
- return b.nodeValue
- }
- function m(b, c, d, e) {
- var g = "<" + (null != b && null != b.__prefix ? b.__prefix + ":" : "") + c;
- if (null != d)
- for (var h = 0; h < d.length; h++) {
- var i = d[h]
- , j = b[i];
- a.escapeMode && (j = f(j)),
- g += " " + i.substr(a.attributePrefix.length) + "=",
- g += a.useDoubleQuotes ? '"' + j + '"' : "'" + j + "'"
- }
- return g += e ? "/>" : ">"
- }
- function n(a, b) {
- return "</" + (null != a.__prefix ? a.__prefix + ":" : "") + b + ">"
- }
- function o(a, b) {
- return a.indexOf(b, a.length - b.length) !== -1
- }
- function p(b, c) {
- return !!("property" == a.arrayAccessForm && o(c.toString(), "_asArray") || 0 == c.toString().indexOf(a.attributePrefix) || 0 == c.toString().indexOf("__") || b[c]instanceof Function)
- }
- function q(a) {
- var b = 0;
- if (a instanceof Object)
- for (var c in a)
- p(a, c) || b++;
- return b
- }
- function r(b, c, d) {
- return 0 == a.jsonPropertiesFilter.length || "" == d || g(a.jsonPropertiesFilter, b, c, d)
- }
- function s(b) {
- var c = [];
- if (b instanceof Object)
- for (var d in b)
- d.toString().indexOf("__") == -1 && 0 == d.toString().indexOf(a.attributePrefix) && c.push(d);
- return c
- }
- function t(b) {
- var c = "";
- return null != b.__cdata && (c += "<![CDATA[" + b.__cdata + "]]>"),
- null != b.__text && (c += a.escapeMode ? f(b.__text) : b.__text),
- c
- }
- function u(b) {
- var c = "";
- return b instanceof Object ? c += t(b) : null != b && (c += a.escapeMode ? f(b) : b),
- c
- }
- function v(a, b) {
- return "" === a ? b : a + "." + b
- }
- function w(a, b, c, d) {
- var e = "";
- if (0 == a.length)
- e += m(a, b, c, !0);
- else
- for (var f = 0; f < a.length; f++)
- e += m(a[f], b, s(a[f]), !1),
- e += x(a[f], v(d, b)),
- e += n(a[f], b);
- return e
- }
- function x(a, b) {
- var c = ""
- , d = q(a);
- if (d > 0)
- for (var e in a)
- if (!p(a, e) && ("" == b || r(a, e, v(b, e)))) {
- var f = a[e]
- , g = s(f);
- if (null == f || void 0 == f)
- c += m(f, e, g, !0);
- else if (f instanceof Object)
- if (f instanceof Array)
- c += w(f, e, g, b);
- else if (f instanceof Date)
- c += m(f, e, g, !1),
- c += f.toISOString(),
- c += n(f, e);
- else {
- var h = q(f);
- h > 0 || null != f.__text || null != f.__cdata ? (c += m(f, e, g, !1),
- c += x(f, v(b, e)),
- c += n(f, e)) : c += m(f, e, g, !0)
- }
- else
- c += m(f, e, g, !1),
- c += u(f),
- c += n(f, e)
- }
- return c += u(a)
- }
- var y = "1.2.0";
- a = a || {},
- b(),
- c();
- var z = {
- ELEMENT_NODE: 1,
- TEXT_NODE: 3,
- CDATA_SECTION_NODE: 4,
- COMMENT_NODE: 8,
- DOCUMENT_NODE: 9
- };
- this.parseXmlString = function(a) {
- var b = window.ActiveXObject || "ActiveXObject"in window;
- if (void 0 === a)
- return null;
- var c;
- if (window.DOMParser) {
- var d = new window.DOMParser
- , e = null;
- if (!b)
- try {
- e = d.parseFromString("INVALID", "text/xml").getElementsByTagName("parsererror")[0].namespaceURI
- } catch (f) {
- e = null
- }
- try {
- c = d.parseFromString(a, "text/xml"),
- null != e && c.getElementsByTagNameNS(e, "parsererror").length > 0 && (c = null)
- } catch (f) {
- c = null
- }
- } else
- 0 == a.indexOf("<?") && (a = a.substr(a.indexOf("?>") + 2)),
- c = new ActiveXObject("Microsoft.XMLDOM"),
- c.async = "false",
- c.loadXML(a);
- return c
- }
- ,
- this.asArray = function(a) {
- return void 0 === a || null == a ? [] : a instanceof Array ? a : [a]
- }
- ,
- this.toXmlDateTime = function(a) {
- return a instanceof Date ? a.toISOString() : "number" == typeof a ? new Date(a).toISOString() : null
- }
- ,
- this.asDateTime = function(a) {
- return "string" == typeof a ? i(a) : a
- }
- ,
- this.xml2json = function(a) {
- return l(a)
- }
- ,
- this.xml_str2json = function(a) {
- var b = this.parseXmlString(a);
- return null != b ? this.xml2json(b) : null
- }
- ,
- this.json2xml_str = function(a) {
- return x(a, "")
- }
- ,
- this.json2xml = function(a) {
- var b = this.json2xml_str(a);
- return this.parseXmlString(b)
- }
- ,
- this.getVersion = function() {
- return y
- }
- }
- });
- var x2js = new X2JS
- , RDP_EPUB = {};
- RDP_EPUB.timer = function() {
- var a, b, c, d, e;
- return c = {},
- e = {},
- a = function(a) {
- return null == e[a] && (e[a] = (new Date).getTime()),
- null == c[a] && (c[a] = (new Date).getTime()),
- e[a] - c[a]
- }
- ,
- b = function(a) {
- return c[a] = (new Date).getTime(),
- e[a] = null
- }
- ,
- d = function(a) {
- if (null == e[a] && (e[a] = (new Date).getTime()),
- null == c[a])
- return c[a] = e[a]
- }
- ,
- {
- start: b,
- stop: d,
- getTime: a
- }
- }();
- var userConfig = JSON.parse(localStorage.getItem("rdp-reader-bv3"));
- init(),
- $(document).ready(function() {
- setConfig(),
- "#fff" == RDP_EPUB.config.background ? ($(".set-white-font").addClass("active"),
- $(".page-nav-btn").css("background-color", "#C7C7C7")) : "#242424" == RDP_EPUB.config.background ? ($(".set-black-font").addClass("active"),
- $(".page-nav-btn").css("background-color", "#353535")) : "#B9AE9A" == RDP_EPUB.config.background && ($(".set-sepia-font").addClass("active"),
- $(".page-nav-btn").css("background-color", "#9A9283")),
- "Arial" == RDP_EPUB.config.fontFamily ? $(".set-arial-font").addClass("font-active") : "Courier New" == RDP_EPUB.config.fontFamily ? $(".set-courier-new-font").addClass("font-active") : "Helvetica" == RDP_EPUB.config.fontFamily ? $(".set-helvetica-font").addClass("font-active") : "Times New Roman" == RDP_EPUB.config.fontFamily && $(".set-times-new-roman-font").addClass("font-active"),
- $("body").on("click", ".decrease-font", function() {
- RDP_EPUB.config.fontSize = RDP_EPUB.config.fontSize - 1,
- setConfig()
- }),
- $("body").on("click", ".increase-font", function() {
- RDP_EPUB.config.fontSize = RDP_EPUB.config.fontSize + 1,
- setConfig()
- }),
- $("body").on("click", ".set-black-font", function() {
- RDP_EPUB.config.background = "#242424",
- RDP_EPUB.config.color = "#fff",
- $(this).addClass("active"),
- $(".set-white-font, .set-sepia-font").removeClass("active"),
- $(".page-nav-btn").css("background-color", "#353535"),
- setConfig()
- }),
- $("body").on("click", ".set-white-font", function() {
- RDP_EPUB.config.background = "#fff",
- RDP_EPUB.config.color = "#000",
- $(this).addClass("active"),
- $(".set-black-font, .set-sepia-font").removeClass("active"),
- $(".page-nav-btn").css("background-color", "#C7C7C7"),
- setConfig()
- }),
- $("body").on("click", ".set-sepia-font", function() {
- RDP_EPUB.config.background = "#B9AE9A",
- RDP_EPUB.config.color = "#333332",
- $(this).addClass("active"),
- $(".set-black-font, .set-white-font").removeClass("active"),
- $(".page-nav-btn").css("background-color", "#9A9283"),
- setConfig()
- }),
- $("body").on("click", ".set-arial-font", function() {
- $(this).addClass("font-active"),
- $(".set-helvetica-font, .set-times-new-roman-font, .set-courier-new-font").removeClass("font-active"),
- RDP_EPUB.config.fontFamily = "Arial",
- setConfig()
- }),
- $("body").on("click", ".set-helvetica-font", function() {
- $(".set-arial-font, .set-times-new-roman-font, .set-courier-new-font").removeClass("font-active"),
- $(this).addClass("font-active"),
- RDP_EPUB.config.fontFamily = "Helvetica",
- setConfig()
- }),
- $("body").on("click", ".set-times-new-roman-font", function() {
- $(".set-helvetica-font, .set-arial-font, .set-courier-new-font").removeClass("font-active"),
- $(this).addClass("font-active"),
- RDP_EPUB.config.fontFamily = "Times New Roman",
- setConfig()
- }),
- $("body").on("click", ".set-courier-new-font", function() {
- $(".set-helvetica-font, .set-times-new-roman-font, .set-arial-font").removeClass("font-active"),
- $(this).addClass("font-active"),
- RDP_EPUB.config.fontFamily = "Courier New",
- setConfig()
- }),
- $("body").on("click", ".open-config", function() {
- $(".config-overlay").fadeIn()
- }),
- $("body").on("click", ".config-close-area, .modal-close", function() {
- $(".config-overlay").fadeOut()
- }),
- $("body").on("click", ".open-epub-summary", function() {
- $("#tocView").show()
- }),
- $("body").on("click", ".summary-back", function() {
- $("#tocView").hide()
- })
- });
Add Comment
Please, Sign In to add comment