@internetarchive/bookreader
Advanced tools
Comparing version 4.17.0 to 4.18.0
@@ -21,6 +21,9 @@ module.exports = { | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"ecmaVersion": 2020, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"comma-dangle": ["error", "only-multiline"], | ||
"space-before-blocks": ["error"], | ||
"keyword-spacing": [2, {"before": true, "after": true}], | ||
"indent": ["error", 2], | ||
@@ -39,6 +42,3 @@ "no-console": "off", // Used too often behind `debug` options; not dealing with this now | ||
"files": [ | ||
"src/js/BookReader.js", | ||
"src/js/plugins/menu_toggle/plugin.menu_toggle.js", | ||
"src/js/plugins/plugin.archive_analytics.js", | ||
"src/js/plugins/tts/plugin.tts.js", | ||
"src/js/BookReader.js" | ||
], | ||
@@ -45,0 +45,0 @@ "rules": { |
@@ -1,2 +0,2 @@ | ||
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{4851:function(t,e,n){"use strict";n(2526),n(1817),n(2165),n(2222),n(9826),n(1038),n(6992),n(1249),n(7042),n(8309),n(5003),n(489),n(1539),n(8674),n(2419),n(4819),n(4916),n(9714),n(8783),n(3123),n(3948),n(5666);var r=n(7775);function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e,n){return(i="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,o=!1,i=void 0;try{for(var c,a=t[Symbol.iterator]();!(r=(c=a.next()).done)&&(n.push(c.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}}(t,e)||function(t,e){if(t){if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t,e,n,r,o,i,c){try{var a=t[i](c),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,o)}function p(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function c(t){l(i,r,o,c,a,"next",t)}function a(t){l(i,r,o,c,a,"throw",t)}c(void 0)}))}}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),t}var g=window.BookReader,y=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,r.vU)(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,r.G6)();v(this,t),this.djvuPagesPromise=null,this.svgParagraphElement="text",this.svgWordElement="tspan",this.insertNewlines=e,this.pointerEventsOnParagraph=n,e&&(this.svgParagraphElement="g",this.svgWordElement="text")}var e,n;return d(t,[{key:"init",value:function(t){this.djvuPagesPromise=$.ajax({type:"GET",url:"https://cors.archive.org/cors/".concat(t,"/").concat(t,"_djvu.xml"),dataType:"xml",error:function(t){}}).then((function(t){return t&&$(t).find("OBJECT")}))}},{key:"getPageText",value:(n=p(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.djvuPagesPromise;case 2:if(!(n=t.sent)){t.next=5;break}return t.abrupt("return",n[e]);case 5:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"interceptCopy",value:function(t){t[0].addEventListener("copy",(function(t){var e=document.getSelection();t.clipboardData.setData("text/plain",e.toString()),t.preventDefault()}))}},{key:"defaultMode",value:function(t){var e=this;t.classList.remove("selectingSVG"),$(t).on("mousedown.textSelectPluginHandler",(function(n){$(n.target).is(".BRwordElement")&&(n.stopPropagation(),t.classList.add("selectingSVG"),$(t).one("mouseup.textSelectPluginHandler",(function(n){""!=window.getSelection().toString()?(n.stopPropagation(),$(t).off(".textSelectPluginHandler"),e.textSelectingMode(t)):t.classList.remove("selectingSVG")})))}))}},{key:"textSelectingMode",value:function(t){var e=this;$(t).on("mousedown.textSelectPluginHandler",(function(t){$(t.target).is(".BRwordElement")||""!=window.getSelection().toString()&&window.getSelection().removeAllRanges(),t.stopPropagation()})),$(t).on("mouseup.textSelectPluginHandler",(function(n){n.stopPropagation(),""==window.getSelection().toString()&&($(t).off(".textSelectPluginHandler"),e.defaultMode(t))}))}},{key:"stopPageFlip",value:function(t){var e=this,n=t.find("svg.textSelectionSVG");n.length&&(n.each((function(t,n){return e.defaultMode(n)})),this.interceptCopy(t))}},{key:"createTextLayer",value:(e=p(regeneratorRuntime.mark((function t(e,n){var r,o,i,c,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.find(".textSelectionSVG").length){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.getPageText(e);case 5:if(r=t.sent){t.next=8;break}return t.abrupt("return");case 8:o=$(r).attr("width"),i=$(r).attr("height"),(c=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("viewBox","0 0 ".concat(o," ").concat(i)),n.append(c),c.setAttribute("class","textSelectionSVG"),c.setAttribute("preserveAspectRatio","none"),$(c).css({width:"100%",position:"absolute",height:"100%",top:"0",left:"0"}),$(r).find("PARAGRAPH").each((function(t,e){var n=$(e).find("WORD");if(n.length){var r=document.createElementNS("http://www.w3.org/2000/svg",a.svgParagraphElement);r.setAttribute("class","BRparagElement"),a.pointerEventsOnParagraph&&(r.style.pointerEvents="all");for(var o=[],i=0;i<n.length;i++){var u=n[i],f=s($(u).attr("coords").split(",").map(parseFloat),4),l=f[0],p=f[1],v=f[2],h=p-f[3];o.push(h);var d=document.createElementNS("http://www.w3.org/2000/svg",a.svgWordElement);if(d.setAttribute("class","BRwordElement"),d.setAttribute("x",l.toString()),d.setAttribute("y",p.toString()),d.setAttribute("textLength",(v-l).toString()),d.setAttribute("lengthAdjust","spacingAndGlyphs"),d.textContent=u.textContent,r.appendChild(d),i<n.length-1){var g=n[i+1],y=s($(g).attr("coords").split(",").map(parseFloat),4),m=y[0],w=(y[1],y[2],y[3],document.createElementNS("http://www.w3.org/2000/svg",a.svgWordElement));w.setAttribute("class","BRwordElement"),w.setAttribute("x",v.toString()),w.setAttribute("y",p.toString()),m-v>0&&w.setAttribute("textLength",(m-v).toString()),w.setAttribute("lengthAdjust","spacingAndGlyphs"),w.textContent=" ",r.appendChild(w)}i==n.length-1&&a.insertNewlines&&r.appendChild(document.createTextNode("\n"))}o.sort();var b=o[Math.floor(.85*o.length)];r.setAttribute("font-size",b.toString()),c.appendChild(r)}})),this.stopPageFlip(n);case 19:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})}]),t}(),m=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(o,t);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=u(e);if(n){var o=u(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return a(this,t)});function o(){return v(this,o),r.apply(this,arguments)}return d(o,[{key:"init",value:function(){this.enableTextSelection&&(this.textSelectionPlugin=new y,this.textSelectionPlugin.init(this.bookId)),i(u(o.prototype),"init",this).call(this)}},{key:"_createPageContainer",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i(u(o.prototype),"_createPageContainer",this).call(this,t,e);return this.enableTextSelection&&this.mode!=this.constModeThumb&&this.textSelectionPlugin.createTextLayer(t,n),n}}]),o}(g);window.BookReader=m},7775:function(t,e,n){"use strict";function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:navigator.vendor;return/chrome/i.test(t)&&/google inc/i.test(e)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/firefox/i.test(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/safari/i.test(t)&&!/chrome|chromium/i.test(t)}n.d(e,{i7:function(){return r},vU:function(){return o},G6:function(){return i}})},6833:function(t,e,n){var r=n(8113);t.exports=/(iphone|ipod|ipad).*applewebkit/i.test(r)},7065:function(t,e,n){"use strict";var r=n(3099),o=n(111),i=[].slice,c={},a=function(t,e,n){if(!(e in c)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";c[e]=Function("C,a","return new C("+r.join(",")+")")}return c[e](t,n)};t.exports=Function.bind||function(t){var e=r(this),n=i.call(arguments,1),c=function(){var r=n.concat(i.call(arguments));return this instanceof c?a(e,r.length,r):e.apply(t,r)};return o(e.prototype)&&(c.prototype=e.prototype),c}},842:function(t,e,n){var r=n(7854);t.exports=function(t,e){var n=r.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}},408:function(t,e,n){var r=n(9670),o=n(7659),i=n(7466),c=n(9974),a=n(1246),u=n(3411),s=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,e,n,f,l){var p,v,h,d,g,y,m,w=c(e,n,f?2:1);if(l)p=t;else{if("function"!=typeof(v=a(t)))throw TypeError("Target is not iterable");if(o(v)){for(h=0,d=i(t.length);d>h;h++)if((g=f?w(r(m=t[h])[0],m[1]):w(t[h]))&&g instanceof s)return g;return new s(!1)}p=v.call(t)}for(y=p.next;!(m=y.call(p)).done;)if("object"==typeof(g=u(p,w,m.value,f))&&g&&g instanceof s)return g;return new s(!1)}).stop=function(t){return new s(!0,t)}},5948:function(t,e,n){var r,o,i,c,a,u,s,f,l=n(7854),p=n(1236).f,v=n(4326),h=n(261).set,d=n(6833),g=l.MutationObserver||l.WebKitMutationObserver,y=l.process,m=l.Promise,w="process"==v(y),b=p(l,"queueMicrotask"),x=b&&b.value;x||(r=function(){var t,e;for(w&&(t=y.domain)&&t.exit();o;){e=o.fn,o=o.next;try{e()}catch(t){throw o?c():i=void 0,t}}i=void 0,t&&t.enter()},w?c=function(){y.nextTick(r)}:g&&!d?(a=!0,u=document.createTextNode(""),new g(r).observe(u,{characterData:!0}),c=function(){u.data=a=!a}):m&&m.resolve?(s=m.resolve(void 0),f=s.then,c=function(){f.call(s,r)}):c=function(){h.call(l,r)}),t.exports=x||function(t){var e={fn:t,next:void 0};i&&(i.next=e),o||(o=e,c()),i=e}},3366:function(t,e,n){var r=n(7854);t.exports=r.Promise},8523:function(t,e,n){"use strict";var r=n(3099),o=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)};t.exports.f=function(t){return new o(t)}},2534:function(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},9478:function(t,e,n){var r=n(9670),o=n(111),i=n(8523);t.exports=function(t,e){if(r(t),o(e)&&e.constructor===t)return e;var n=i.f(t);return(0,n.resolve)(e),n.promise}},6340:function(t,e,n){"use strict";var r=n(5005),o=n(3070),i=n(5112),c=n(9781),a=i("species");t.exports=function(t){var e=r(t),n=o.f;c&&e&&!e[a]&&n(e,a,{configurable:!0,get:function(){return this}})}},261:function(t,e,n){var r,o,i,c=n(7854),a=n(7293),u=n(4326),s=n(9974),f=n(490),l=n(317),p=n(6833),v=c.location,h=c.setImmediate,d=c.clearImmediate,g=c.process,y=c.MessageChannel,m=c.Dispatch,w=0,b={},x=function(t){if(b.hasOwnProperty(t)){var e=b[t];delete b[t],e()}},S=function(t){return function(){x(t)}},P=function(t){x(t.data)},j=function(t){c.postMessage(t+"",v.protocol+"//"+v.host)};h&&d||(h=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return b[++w]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},r(w),w},d=function(t){delete b[t]},"process"==u(g)?r=function(t){g.nextTick(S(t))}:m&&m.now?r=function(t){m.now(S(t))}:y&&!p?(i=(o=new y).port2,o.port1.onmessage=P,r=s(i.postMessage,i,1)):!c.addEventListener||"function"!=typeof postMessage||c.importScripts||a(j)||"file:"===v.protocol?r="onreadystatechange"in l("script")?function(t){f.appendChild(l("script")).onreadystatechange=function(){f.removeChild(this),x(t)}}:function(t){setTimeout(S(t),0)}:(r=j,c.addEventListener("message",P,!1))),t.exports={set:h,clear:d}},5003:function(t,e,n){var r=n(2109),o=n(7293),i=n(5656),c=n(1236).f,a=n(9781),u=o((function(){c(1)}));r({target:"Object",stat:!0,forced:!a||u,sham:!a},{getOwnPropertyDescriptor:function(t,e){return c(i(t),e)}})},489:function(t,e,n){var r=n(2109),o=n(7293),i=n(7908),c=n(9518),a=n(8544);r({target:"Object",stat:!0,forced:o((function(){c(1)})),sham:!a},{getPrototypeOf:function(t){return c(i(t))}})},8674:function(t,e,n){"use strict";var r,o,i,c,a=n(2109),u=n(1913),s=n(7854),f=n(5005),l=n(3366),p=n(1320),v=n(2248),h=n(8003),d=n(6340),g=n(111),y=n(3099),m=n(5787),w=n(4326),b=n(2788),x=n(408),S=n(7072),P=n(6707),j=n(261).set,E=n(5948),A=n(9478),k=n(842),R=n(8523),O=n(2534),T=n(9909),C=n(4705),$=n(5112),M=n(7392),_=$("species"),G="Promise",B=T.get,D=T.set,L=T.getterFor(G),F=l,H=s.TypeError,N=s.document,I=s.process,V=f("fetch"),W=R.f,U=W,q="process"==w(I),z=!!(N&&N.createEvent&&s.dispatchEvent),J="unhandledrejection",K=C(G,(function(){if(b(F)===String(F)){if(66===M)return!0;if(!q&&"function"!=typeof PromiseRejectionEvent)return!0}if(u&&!F.prototype.finally)return!0;if(M>=51&&/native code/.test(F))return!1;var t=F.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[_]=e,!(t.then((function(){}))instanceof e)})),Q=K||!S((function(t){F.all(t).catch((function(){}))})),X=function(t){var e;return!(!g(t)||"function"!=typeof(e=t.then))&&e},Y=function(t,e,n){if(!e.notified){e.notified=!0;var r=e.reactions;E((function(){for(var o=e.value,i=1==e.state,c=0;r.length>c;){var a,u,s,f=r[c++],l=i?f.ok:f.fail,p=f.resolve,v=f.reject,h=f.domain;try{l?(i||(2===e.rejection&&nt(t,e),e.rejection=1),!0===l?a=o:(h&&h.enter(),a=l(o),h&&(h.exit(),s=!0)),a===f.promise?v(H("Promise-chain cycle")):(u=X(a))?u.call(a,p,v):p(a)):v(o)}catch(t){h&&!s&&h.exit(),v(t)}}e.reactions=[],e.notified=!1,n&&!e.rejection&&tt(t,e)}))}},Z=function(t,e,n){var r,o;z?((r=N.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),s.dispatchEvent(r)):r={promise:e,reason:n},(o=s["on"+t])?o(r):t===J&&k("Unhandled promise rejection",n)},tt=function(t,e){j.call(s,(function(){var n,r=e.value;if(et(e)&&(n=O((function(){q?I.emit("unhandledRejection",r,t):Z(J,t,r)})),e.rejection=q||et(e)?2:1,n.error))throw n.value}))},et=function(t){return 1!==t.rejection&&!t.parent},nt=function(t,e){j.call(s,(function(){q?I.emit("rejectionHandled",t):Z("rejectionhandled",t,e.value)}))},rt=function(t,e,n,r){return function(o){t(e,n,o,r)}},ot=function(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,Y(t,e,!0))},it=function(t,e,n,r){if(!e.done){e.done=!0,r&&(e=r);try{if(t===n)throw H("Promise can't be resolved itself");var o=X(n);o?E((function(){var r={done:!1};try{o.call(n,rt(it,t,r,e),rt(ot,t,r,e))}catch(n){ot(t,r,n,e)}})):(e.value=n,e.state=1,Y(t,e,!1))}catch(n){ot(t,{done:!1},n,e)}}};K&&(F=function(t){m(this,F,G),y(t),r.call(this);var e=B(this);try{t(rt(it,this,e),rt(ot,this,e))}catch(t){ot(this,e,t)}},(r=function(t){D(this,{type:G,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=v(F.prototype,{then:function(t,e){var n=L(this),r=W(P(this,F));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=q?I.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Y(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),o=function(){var t=new r,e=B(t);this.promise=t,this.resolve=rt(it,t,e),this.reject=rt(ot,t,e)},R.f=W=function(t){return t===F||t===i?new o(t):U(t)},u||"function"!=typeof l||(c=l.prototype.then,p(l.prototype,"then",(function(t,e){var n=this;return new F((function(t,e){c.call(n,t,e)})).then(t,e)}),{unsafe:!0}),"function"==typeof V&&a({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return A(F,V.apply(s,arguments))}}))),a({global:!0,wrap:!0,forced:K},{Promise:F}),h(F,G,!1,!0),d(G),i=f(G),a({target:G,stat:!0,forced:K},{reject:function(t){var e=W(this);return e.reject.call(void 0,t),e.promise}}),a({target:G,stat:!0,forced:u||K},{resolve:function(t){return A(u&&this===i?F:this,t)}}),a({target:G,stat:!0,forced:Q},{all:function(t){var e=this,n=W(e),r=n.resolve,o=n.reject,i=O((function(){var n=y(e.resolve),i=[],c=0,a=1;x(t,(function(t){var u=c++,s=!1;i.push(void 0),a++,n.call(e,t).then((function(t){s||(s=!0,i[u]=t,--a||r(i))}),o)})),--a||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=W(e),r=n.reject,o=O((function(){var o=y(e.resolve);x(t,(function(t){o.call(e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}})},2419:function(t,e,n){var r=n(2109),o=n(5005),i=n(3099),c=n(9670),a=n(111),u=n(30),s=n(7065),f=n(7293),l=o("Reflect","construct"),p=f((function(){function t(){}return!(l((function(){}),[],t)instanceof t)})),v=!f((function(){l((function(){}))})),h=p||v;r({target:"Reflect",stat:!0,forced:h,sham:h},{construct:function(t,e){i(t),c(e);var n=arguments.length<3?t:i(arguments[2]);if(v&&!p)return l(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(s.apply(t,r))}var o=n.prototype,f=u(a(o)?o:Object.prototype),h=Function.apply.call(t,f,e);return a(h)?h:f}})},4819:function(t,e,n){var r=n(2109),o=n(111),i=n(9670),c=n(6656),a=n(1236),u=n(9518);r({target:"Reflect",stat:!0},{get:function t(e,n){var r,s,f=arguments.length<3?e:arguments[2];return i(e)===f?e[n]:(r=a.f(e,n))?c(r,"value")?r.value:void 0===r.get?void 0:r.get.call(f):o(s=u(e))?t(s,n,f):void 0}})}},0,[[4851,898]]]); | ||
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{4529:function(t,e,n){"use strict";n(2526),n(1817),n(2165),n(1038),n(2222),n(6992),n(9826),n(1249),n(5827),n(7042),n(8309),n(1539),n(4916),n(9601),n(9714),n(5003),n(8783),n(489),n(5306),n(3123),n(8674),n(3210),n(2419),n(3948),n(4819),n(5666);var r=n(7775);function o(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function a(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c;return null==t?void 0:t.replace(/\{\{([^}]*?)\}\}/g,(function(t,i){if(!i)return t;var a=o(i.split("|").map((function(t){return t.trim()}))),c=a[0],u=a.slice(1);if(!(c in n)&&!(c in e))return t;var s=c in n?n[c]:c in e?e[c]:null;return u.map((function(t){return r[t]})).reduce((function(t,e){return e(t)}),s&&s.toString())}))}var c={urlencode:encodeURIComponent};function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,e,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e){return!e||"object"!==u(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function d(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function g(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){d(i,r,o,a,c,"next",t)}function c(t){d(i,r,o,a,c,"throw",t)}a(void 0)}))}}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function b(t,e,n){return e&&m(t.prototype,e),n&&m(t,n),t}var w=window.BookReader,x={enabled:!0,fullDjvuXmlUrl:null,singlePageDjvuXmlUrl:null},S=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x,n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,r.vU)(),i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,r.G6)();y(this,t),this.options=e,this.optionVariables=n,this.djvuPagesPromise=null,this.svgParagraphElement="text",this.svgWordElement="tspan",this.insertNewlines=o,this.pointerEventsOnParagraph=i,o&&(this.svgParagraphElement="g",this.svgWordElement="text")}var e,n;return b(t,[{key:"init",value:function(){this.options.singlePageDjvuXmlUrl||(this.djvuPagesPromise=$.ajax({type:"GET",url:a(this.options.fullDjvuXmlUrl,this.optionVariables),dataType:"xml",error:function(t){}}).then((function(t){return t&&$(t).find("OBJECT")})))}},{key:"getPageText",value:(n=g(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.fullDjvuXmlUrl){t.next=8;break}return t.next=3,this.djvuPagesPromise;case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",n[e]);case 6:t.next=9;break;case 8:return t.abrupt("return",$.ajax({type:"GET",url:a(this.options.singlePageDjvuXmlUrl,this.optionVariables,{pageIndex:e}),dataType:"xml",error:function(t){}}).then((function(t){return t&&$(t).find("OBJECT")[0]})));case 9:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"interceptCopy",value:function(t){t[0].addEventListener("copy",(function(t){var e=document.getSelection();t.clipboardData.setData("text/plain",e.toString()),t.preventDefault()}))}},{key:"defaultMode",value:function(t){var e=this;t.classList.remove("selectingSVG"),$(t).on("mousedown.textSelectPluginHandler",(function(n){$(n.target).is(".BRwordElement")&&(n.stopPropagation(),t.classList.add("selectingSVG"),$(t).one("mouseup.textSelectPluginHandler",(function(n){""!=window.getSelection().toString()?(n.stopPropagation(),$(t).off(".textSelectPluginHandler"),e.textSelectingMode(t)):t.classList.remove("selectingSVG")})))}))}},{key:"textSelectingMode",value:function(t){var e=this;$(t).on("mousedown.textSelectPluginHandler",(function(t){$(t.target).is(".BRwordElement")||""!=window.getSelection().toString()&&window.getSelection().removeAllRanges(),t.stopPropagation()})),$(t).on("mouseup.textSelectPluginHandler",(function(n){n.stopPropagation(),""==window.getSelection().toString()&&($(t).off(".textSelectPluginHandler"),e.defaultMode(t))}))}},{key:"stopPageFlip",value:function(t){var e=this,n=t.find("svg.textSelectionSVG");n.length&&(n.each((function(t,n){return e.defaultMode(n)})),this.interceptCopy(t))}},{key:"createTextLayer",value:(e=g(regeneratorRuntime.mark((function t(e,n){var r,o,i,a,c=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.find(".textSelectionSVG").length){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.getPageText(e);case 5:if(r=t.sent){t.next=8;break}return t.abrupt("return");case 8:o=$(r).attr("width"),i=$(r).attr("height"),(a=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("viewBox","0 0 ".concat(o," ").concat(i)),n.append(a),a.setAttribute("class","textSelectionSVG"),a.setAttribute("preserveAspectRatio","none"),$(a).css({width:"100%",position:"absolute",height:"100%",top:"0",left:"0"}),$(r).find("PARAGRAPH").each((function(t,e){var n=$(e).find("WORD");if(n.length){var r=document.createElementNS("http://www.w3.org/2000/svg",c.svgParagraphElement);r.setAttribute("class","BRparagElement"),c.pointerEventsOnParagraph&&(r.style.pointerEvents="all");for(var o=[],i=0;i<n.length;i++){var u=n[i],s=v($(u).attr("coords").split(",").map(parseFloat),4),l=s[0],f=s[1],p=s[2],h=f-s[3];o.push(h);var d=document.createElementNS("http://www.w3.org/2000/svg",c.svgWordElement);if(d.setAttribute("class","BRwordElement"),d.setAttribute("x",l.toString()),d.setAttribute("y",f.toString()),d.setAttribute("textLength",(p-l).toString()),d.setAttribute("lengthAdjust","spacingAndGlyphs"),d.textContent=u.textContent,r.appendChild(d),i<n.length-1){var g=n[i+1],y=v($(g).attr("coords").split(",").map(parseFloat),4),m=y[0],b=(y[1],y[2],y[3],document.createElementNS("http://www.w3.org/2000/svg",c.svgWordElement));b.setAttribute("class","BRwordElement"),b.setAttribute("x",p.toString()),b.setAttribute("y",f.toString()),m-p>0&&b.setAttribute("textLength",(m-p).toString()),b.setAttribute("lengthAdjust","spacingAndGlyphs"),b.textContent=" ",r.appendChild(b)}i==n.length-1&&c.insertNewlines&&r.appendChild(document.createTextNode("\n"))}o.sort();var w=o[Math.floor(.85*o.length)];r.setAttribute("font-size",w.toString()),a.appendChild(r)}})),this.stopPageFlip(n);case 19:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})}]),t}(),P=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(o,t);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=p(e);if(n){var o=p(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return f(this,t)});function o(){return y(this,o),r.apply(this,arguments)}return b(o,[{key:"init",value:function(){var t=Object.assign({},x,this.options.plugins.textSelection);t.enabled&&(this.textSelectionPlugin=new S(t,this.options.vars),this.options.plugins.textSelection=t,this.textSelectionPlugin.init()),s(p(o.prototype),"init",this).call(this)}},{key:"_createPageContainer",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=s(p(o.prototype),"_createPageContainer",this).call(this,t,n);return this.mode!=this.constModeThumb&&(null===(e=this.textSelectionPlugin)||void 0===e||e.createTextLayer(t,r)),r}}]),o}(w);window.BookReader=P},7775:function(t,e,n){"use strict";function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:navigator.vendor;return/chrome/i.test(t)&&/google inc/i.test(e)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/firefox/i.test(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/safari/i.test(t)&&!/chrome|chromium/i.test(t)}n.d(e,{i7:function(){return r},vU:function(){return o},G6:function(){return i}})},6833:function(t,e,n){var r=n(8113);t.exports=/(iphone|ipod|ipad).*applewebkit/i.test(r)},7065:function(t,e,n){"use strict";var r=n(3099),o=n(111),i=[].slice,a={},c=function(t,e,n){if(!(e in a)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";a[e]=Function("C,a","return new C("+r.join(",")+")")}return a[e](t,n)};t.exports=Function.bind||function(t){var e=r(this),n=i.call(arguments,1),a=function(){var r=n.concat(i.call(arguments));return this instanceof a?c(e,r.length,r):e.apply(t,r)};return o(e.prototype)&&(a.prototype=e.prototype),a}},842:function(t,e,n){var r=n(7854);t.exports=function(t,e){var n=r.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}},408:function(t,e,n){var r=n(9670),o=n(7659),i=n(7466),a=n(9974),c=n(1246),u=n(3411),s=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,e,n,l,f){var p,v,h,d,g,y,m,b=a(e,n,l?2:1);if(f)p=t;else{if("function"!=typeof(v=c(t)))throw TypeError("Target is not iterable");if(o(v)){for(h=0,d=i(t.length);d>h;h++)if((g=l?b(r(m=t[h])[0],m[1]):b(t[h]))&&g instanceof s)return g;return new s(!1)}p=v.call(t)}for(y=p.next;!(m=y.call(p)).done;)if("object"==typeof(g=u(p,b,m.value,l))&&g&&g instanceof s)return g;return new s(!1)}).stop=function(t){return new s(!0,t)}},5948:function(t,e,n){var r,o,i,a,c,u,s,l,f=n(7854),p=n(1236).f,v=n(4326),h=n(261).set,d=n(6833),g=f.MutationObserver||f.WebKitMutationObserver,y=f.process,m=f.Promise,b="process"==v(y),w=p(f,"queueMicrotask"),x=w&&w.value;x||(r=function(){var t,e;for(b&&(t=y.domain)&&t.exit();o;){e=o.fn,o=o.next;try{e()}catch(t){throw o?a():i=void 0,t}}i=void 0,t&&t.enter()},b?a=function(){y.nextTick(r)}:g&&!d?(c=!0,u=document.createTextNode(""),new g(r).observe(u,{characterData:!0}),a=function(){u.data=c=!c}):m&&m.resolve?(s=m.resolve(void 0),l=s.then,a=function(){l.call(s,r)}):a=function(){h.call(f,r)}),t.exports=x||function(t){var e={fn:t,next:void 0};i&&(i.next=e),o||(o=e,a()),i=e}},3366:function(t,e,n){var r=n(7854);t.exports=r.Promise},8523:function(t,e,n){"use strict";var r=n(3099),o=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)};t.exports.f=function(t){return new o(t)}},2534:function(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},9478:function(t,e,n){var r=n(9670),o=n(111),i=n(8523);t.exports=function(t,e){if(r(t),o(e)&&e.constructor===t)return e;var n=i.f(t);return(0,n.resolve)(e),n.promise}},6340:function(t,e,n){"use strict";var r=n(5005),o=n(3070),i=n(5112),a=n(9781),c=i("species");t.exports=function(t){var e=r(t),n=o.f;a&&e&&!e[c]&&n(e,c,{configurable:!0,get:function(){return this}})}},6091:function(t,e,n){var r=n(7293),o=n(1361);t.exports=function(t){return r((function(){return!!o[t]()||" "!=" "[t]()||o[t].name!==t}))}},3111:function(t,e,n){var r=n(4488),o="["+n(1361)+"]",i=RegExp("^"+o+o+"*"),a=RegExp(o+o+"*$"),c=function(t){return function(e){var n=String(r(e));return 1&t&&(n=n.replace(i,"")),2&t&&(n=n.replace(a,"")),n}};t.exports={start:c(1),end:c(2),trim:c(3)}},261:function(t,e,n){var r,o,i,a=n(7854),c=n(7293),u=n(4326),s=n(9974),l=n(490),f=n(317),p=n(6833),v=a.location,h=a.setImmediate,d=a.clearImmediate,g=a.process,y=a.MessageChannel,m=a.Dispatch,b=0,w={},x=function(t){if(w.hasOwnProperty(t)){var e=w[t];delete w[t],e()}},S=function(t){return function(){x(t)}},P=function(t){x(t.data)},j=function(t){a.postMessage(t+"",v.protocol+"//"+v.host)};h&&d||(h=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return w[++b]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},r(b),b},d=function(t){delete w[t]},"process"==u(g)?r=function(t){g.nextTick(S(t))}:m&&m.now?r=function(t){m.now(S(t))}:y&&!p?(i=(o=new y).port2,o.port1.onmessage=P,r=s(i.postMessage,i,1)):!a.addEventListener||"function"!=typeof postMessage||a.importScripts||c(j)||"file:"===v.protocol?r="onreadystatechange"in f("script")?function(t){l.appendChild(f("script")).onreadystatechange=function(){l.removeChild(this),x(t)}}:function(t){setTimeout(S(t),0)}:(r=j,a.addEventListener("message",P,!1))),t.exports={set:h,clear:d}},1361:function(t){t.exports="\t\n\v\f\r \u2028\u2029\ufeff"},5003:function(t,e,n){var r=n(2109),o=n(7293),i=n(5656),a=n(1236).f,c=n(9781),u=o((function(){a(1)}));r({target:"Object",stat:!0,forced:!c||u,sham:!c},{getOwnPropertyDescriptor:function(t,e){return a(i(t),e)}})},489:function(t,e,n){var r=n(2109),o=n(7293),i=n(7908),a=n(9518),c=n(8544);r({target:"Object",stat:!0,forced:o((function(){a(1)})),sham:!c},{getPrototypeOf:function(t){return a(i(t))}})},8674:function(t,e,n){"use strict";var r,o,i,a,c=n(2109),u=n(1913),s=n(7854),l=n(5005),f=n(3366),p=n(1320),v=n(2248),h=n(8003),d=n(6340),g=n(111),y=n(3099),m=n(5787),b=n(4326),w=n(2788),x=n(408),S=n(7072),P=n(6707),j=n(261).set,E=n(5948),A=n(9478),O=n(842),R=n(8523),k=n(2534),C=n(9909),T=n(4705),$=n(5112),D=n(7392),M=$("species"),_="Promise",G=C.get,U=C.set,B=C.getterFor(_),I=f,L=s.TypeError,F=s.document,V=s.process,H=l("fetch"),N=R.f,W=N,X="process"==b(V),J=!!(F&&F.createEvent&&s.dispatchEvent),q="unhandledrejection",z=T(_,(function(){if(w(I)===String(I)){if(66===D)return!0;if(!X&&"function"!=typeof PromiseRejectionEvent)return!0}if(u&&!I.prototype.finally)return!0;if(D>=51&&/native code/.test(I))return!1;var t=I.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[M]=e,!(t.then((function(){}))instanceof e)})),K=z||!S((function(t){I.all(t).catch((function(){}))})),Q=function(t){var e;return!(!g(t)||"function"!=typeof(e=t.then))&&e},Y=function(t,e,n){if(!e.notified){e.notified=!0;var r=e.reactions;E((function(){for(var o=e.value,i=1==e.state,a=0;r.length>a;){var c,u,s,l=r[a++],f=i?l.ok:l.fail,p=l.resolve,v=l.reject,h=l.domain;try{f?(i||(2===e.rejection&&nt(t,e),e.rejection=1),!0===f?c=o:(h&&h.enter(),c=f(o),h&&(h.exit(),s=!0)),c===l.promise?v(L("Promise-chain cycle")):(u=Q(c))?u.call(c,p,v):p(c)):v(o)}catch(t){h&&!s&&h.exit(),v(t)}}e.reactions=[],e.notified=!1,n&&!e.rejection&&tt(t,e)}))}},Z=function(t,e,n){var r,o;J?((r=F.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),s.dispatchEvent(r)):r={promise:e,reason:n},(o=s["on"+t])?o(r):t===q&&O("Unhandled promise rejection",n)},tt=function(t,e){j.call(s,(function(){var n,r=e.value;if(et(e)&&(n=k((function(){X?V.emit("unhandledRejection",r,t):Z(q,t,r)})),e.rejection=X||et(e)?2:1,n.error))throw n.value}))},et=function(t){return 1!==t.rejection&&!t.parent},nt=function(t,e){j.call(s,(function(){X?V.emit("rejectionHandled",t):Z("rejectionhandled",t,e.value)}))},rt=function(t,e,n,r){return function(o){t(e,n,o,r)}},ot=function(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,Y(t,e,!0))},it=function(t,e,n,r){if(!e.done){e.done=!0,r&&(e=r);try{if(t===n)throw L("Promise can't be resolved itself");var o=Q(n);o?E((function(){var r={done:!1};try{o.call(n,rt(it,t,r,e),rt(ot,t,r,e))}catch(n){ot(t,r,n,e)}})):(e.value=n,e.state=1,Y(t,e,!1))}catch(n){ot(t,{done:!1},n,e)}}};z&&(I=function(t){m(this,I,_),y(t),r.call(this);var e=G(this);try{t(rt(it,this,e),rt(ot,this,e))}catch(t){ot(this,e,t)}},(r=function(t){U(this,{type:_,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=v(I.prototype,{then:function(t,e){var n=B(this),r=N(P(this,I));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=X?V.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Y(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),o=function(){var t=new r,e=G(t);this.promise=t,this.resolve=rt(it,t,e),this.reject=rt(ot,t,e)},R.f=N=function(t){return t===I||t===i?new o(t):W(t)},u||"function"!=typeof f||(a=f.prototype.then,p(f.prototype,"then",(function(t,e){var n=this;return new I((function(t,e){a.call(n,t,e)})).then(t,e)}),{unsafe:!0}),"function"==typeof H&&c({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return A(I,H.apply(s,arguments))}}))),c({global:!0,wrap:!0,forced:z},{Promise:I}),h(I,_,!1,!0),d(_),i=l(_),c({target:_,stat:!0,forced:z},{reject:function(t){var e=N(this);return e.reject.call(void 0,t),e.promise}}),c({target:_,stat:!0,forced:u||z},{resolve:function(t){return A(u&&this===i?I:this,t)}}),c({target:_,stat:!0,forced:K},{all:function(t){var e=this,n=N(e),r=n.resolve,o=n.reject,i=k((function(){var n=y(e.resolve),i=[],a=0,c=1;x(t,(function(t){var u=a++,s=!1;i.push(void 0),c++,n.call(e,t).then((function(t){s||(s=!0,i[u]=t,--c||r(i))}),o)})),--c||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=N(e),r=n.reject,o=k((function(){var o=y(e.resolve);x(t,(function(t){o.call(e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}})},2419:function(t,e,n){var r=n(2109),o=n(5005),i=n(3099),a=n(9670),c=n(111),u=n(30),s=n(7065),l=n(7293),f=o("Reflect","construct"),p=l((function(){function t(){}return!(f((function(){}),[],t)instanceof t)})),v=!l((function(){f((function(){}))})),h=p||v;r({target:"Reflect",stat:!0,forced:h,sham:h},{construct:function(t,e){i(t),a(e);var n=arguments.length<3?t:i(arguments[2]);if(v&&!p)return f(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(s.apply(t,r))}var o=n.prototype,l=u(c(o)?o:Object.prototype),h=Function.apply.call(t,l,e);return c(h)?h:l}})},4819:function(t,e,n){var r=n(2109),o=n(111),i=n(9670),a=n(6656),c=n(1236),u=n(9518);r({target:"Reflect",stat:!0},{get:function t(e,n){var r,s,l=arguments.length<3?e:arguments[2];return i(e)===l?e[n]:(r=c.f(e,n))?a(r,"value")?r.value:void 0===r.get?void 0:r.get.call(l):o(s=u(e))?t(s,n,l):void 0}})},3210:function(t,e,n){"use strict";var r=n(2109),o=n(3111).trim;r({target:"String",proto:!0,forced:n(6091)("trim")},{trim:function(){return o(this)}})}},0,[[4529,898]]]); | ||
//# sourceMappingURL=plugin.text_selection.js.map |
@@ -0,1 +1,7 @@ | ||
# 4.18.0 | ||
- Dev: Add eslint for `space-after-keywords`, `space-before-blocks`, `only-multiline` @Yashs911 | ||
- Dev: Update eslint, sinon, @types/jest, testcafe, sass, webpack @dependabot-preview + @cdrini | ||
- Dev: Add 3 more files to eslint @Yashs911 | ||
- Feature: New options for text selection plugin: single page DJVU XML url @cdrini | ||
# 4.17.0 | ||
@@ -2,0 +8,0 @@ - Fix: text selection on Safari @cdrini |
{ | ||
"name": "@internetarchive/bookreader", | ||
"version": "4.17.0", | ||
"version": "4.18.0", | ||
"description": "The Internet Archive BookReader.", | ||
@@ -32,3 +32,3 @@ "repository": { | ||
"@babel/preset-env": "7.11.5", | ||
"@types/jest": "26.0.13", | ||
"@types/jest": "26.0.14", | ||
"babel-loader": "8.1.0", | ||
@@ -38,3 +38,3 @@ "codecov": "3.7.2", | ||
"core-js": "3.6.5", | ||
"eslint": "7.8.1", | ||
"eslint": "7.10.0", | ||
"eslint-plugin-testcafe": "^0.2.1", | ||
@@ -47,6 +47,6 @@ "http-server": "0.12.3", | ||
"regenerator-runtime": "0.13.7", | ||
"sass": "1.26.10", | ||
"sinon": "9.0.3", | ||
"testcafe": "1.9.2", | ||
"webpack": "5.0.0-beta.29", | ||
"sass": "1.26.11", | ||
"sinon": "9.1.0", | ||
"testcafe": "1.9.3", | ||
"webpack": "5.0.0-rc.3", | ||
"webpack-cli": "3.3.12" | ||
@@ -53,0 +53,0 @@ }, |
@@ -105,3 +105,3 @@ // @ts-check | ||
return indices; | ||
} catch(err) { | ||
} catch (err) { | ||
// Do nothing... will run through page names and see if one matches | ||
@@ -108,0 +108,0 @@ } |
@@ -672,4 +672,3 @@ // @ts-check | ||
if(this.br.enableTextSelection) this.br.textSelectionPlugin.stopPageFlip(this.br.refs.$brContainer); | ||
this.br.textSelectionPlugin?.stopPageFlip(this.br.refs.$brContainer); | ||
this.br.trigger('pageChanged'); | ||
@@ -811,4 +810,3 @@ }); | ||
if(this.br.enableTextSelection) this.br.textSelectionPlugin.stopPageFlip(this.br.refs.$brContainer); | ||
this.br.textSelectionPlugin?.stopPageFlip(this.br.refs.$brContainer); | ||
this.br.trigger('pageChanged'); | ||
@@ -815,0 +813,0 @@ }); |
@@ -126,6 +126,21 @@ /** @typedef {import('./BookModel.js').PageNumString} PageNumString */ | ||
/** Enables text selection layer */ | ||
enableTextSelection: false, | ||
/** | ||
* Settings for individual plugins. Note they have to be imported first. | ||
* WIP: Most plugins just put their options anywhere in this global options file, | ||
* but going forward we'll keep them here. | ||
**/ | ||
plugins: { | ||
/** @type {import('../plugins/plugin.text_selection.js').TextSelectionPluginOptions} */ | ||
textSelection: null, | ||
}, | ||
/** | ||
* Any variables you want to define. If an option has a StringWithVars type, or | ||
* has something like `{{server}}/foo.com` in its value, these variables replace | ||
* the `{{foo}}`. | ||
* @type { {[var_name: string]: any } } | ||
*/ | ||
vars: {}, | ||
/** | ||
* @type {Array<[PageData, PageData]|[PageData]>} | ||
@@ -132,0 +147,0 @@ * Data is a simple way to populate the bookreader |
@@ -32,3 +32,3 @@ | ||
*/ | ||
var holdOffOnToggle = false; | ||
let holdOffOnToggle = false; | ||
@@ -44,3 +44,3 @@ /** | ||
} | ||
var $menuTab = br.refs.$BRnav.children('.BRnavCntl'); | ||
const $menuTab = br.refs.$BRnav.children('.BRnavCntl'); | ||
$menuTab.css('display', 'none'); | ||
@@ -76,3 +76,3 @@ } | ||
*/ | ||
var removeClickHandlers = function removeClickHandlers(br) { | ||
const removeClickHandlers = function removeClickHandlers(br) { | ||
if (br.refs.$brPageViewEl) { | ||
@@ -93,4 +93,4 @@ br.refs.$brPageViewEl[0].removeEventListener('click', onBookClick, true); | ||
*/ | ||
var togglingNav = false; /* flag to make sure animations only fire once */ | ||
var toggleNav = function toggleNav(br) { | ||
let togglingNav = false; /* flag to make sure animations only fire once */ | ||
const toggleNav = function toggleNav(br) { | ||
if (togglingNav) { | ||
@@ -101,3 +101,3 @@ return; | ||
togglingNav = true; | ||
var navToggled = function navToggled() { | ||
const navToggled = function navToggled() { | ||
togglingNav = false; | ||
@@ -108,3 +108,3 @@ window.removeEventListener('BookReader:navToggled', navToggled); | ||
var menuIsShowing = br.navigationIsVisible(); | ||
const menuIsShowing = br.navigationIsVisible(); | ||
if (menuIsShowing) { | ||
@@ -122,6 +122,6 @@ br.hideNavigation(); | ||
*/ | ||
var isBRcontainerScrollable = function isBRcontainerScrollable() { | ||
var brContainer = document.querySelector('.BRcontainer'); | ||
var scrollWidth = brContainer.scrollWidth; | ||
var offsetWidth = brContainer.offsetWidth; | ||
const isBRcontainerScrollable = function isBRcontainerScrollable() { | ||
const brContainer = document.querySelector('.BRcontainer'); | ||
const scrollWidth = brContainer.scrollWidth; | ||
const offsetWidth = brContainer.offsetWidth; | ||
@@ -137,12 +137,12 @@ return scrollWidth > offsetWidth; | ||
*/ | ||
var isCenterClick = function isCenterClick(event, book) { | ||
var clickPosition = event.clientX; | ||
var bookWidth = book.offsetWidth; | ||
var leftOffset = book.offsetLeft | ||
var bookEndPageFlipArea = Math.round(bookWidth / 3); | ||
var leftThreshold = Math.round(bookEndPageFlipArea + leftOffset); // without it, the click area is small | ||
var rightThreshold = Math.round(bookWidth - bookEndPageFlipArea + leftOffset); | ||
var isOkOnRight = clickPosition > leftThreshold; | ||
var isOkOnLeft = clickPosition < rightThreshold; | ||
var isCenterClick = isOkOnRight && isOkOnLeft; | ||
const isCenterClick = function isCenterClick(event, book) { | ||
const clickPosition = event.clientX; | ||
const bookWidth = book.offsetWidth; | ||
const leftOffset = book.offsetLeft | ||
const bookEndPageFlipArea = Math.round(bookWidth / 3); | ||
const leftThreshold = Math.round(bookEndPageFlipArea + leftOffset); // without it, the click area is small | ||
const rightThreshold = Math.round(bookWidth - bookEndPageFlipArea + leftOffset); | ||
const isOkOnRight = clickPosition > leftThreshold; | ||
const isOkOnLeft = clickPosition < rightThreshold; | ||
const isCenterClick = isOkOnRight && isOkOnLeft; | ||
@@ -157,4 +157,4 @@ return isCenterClick; | ||
*/ | ||
var isBackground = function isBackground(element) { | ||
var isBackgroundClick = $(element).hasClass('BookReader') | ||
const isBackground = function isBackground(element) { | ||
const isBackgroundClick = $(element).hasClass('BookReader') | ||
|| $(element).hasClass('BRcontainer') /* main black theatre */ | ||
@@ -175,3 +175,3 @@ || $(element).hasClass('BRemptypage') /* empty page placeholder */ | ||
*/ | ||
var toggleRouter = function toggleRouter (br, e, atBookCenter) { | ||
const toggleRouter = function toggleRouter (br, e, atBookCenter) { | ||
if (holdOffOnToggle) { | ||
@@ -181,6 +181,6 @@ return; | ||
var book = isBRcontainerScrollable() ? br.refs.$brContainer[0] : e.currentTarget; | ||
var is1UpMode = br.constMode1up === br.mode; | ||
var validBookClick = is1UpMode || isCenterClick(e, book); | ||
var isValidClickArea = atBookCenter ? validBookClick : isBackground(e.target); | ||
const book = isBRcontainerScrollable() ? br.refs.$brContainer[0] : e.currentTarget; | ||
const is1UpMode = br.constMode1up === br.mode; | ||
const validBookClick = is1UpMode || isCenterClick(e, book); | ||
const isValidClickArea = atBookCenter ? validBookClick : isBackground(e.target); | ||
if (isValidClickArea) { | ||
@@ -212,8 +212,8 @@ toggleNav(br, atBookCenter); | ||
var atBookCenter = true; | ||
const atBookCenter = true; | ||
toggleRouter(br, e, atBookCenter); | ||
} | ||
var initialX; | ||
var initialY; | ||
let initialX; | ||
let initialY; | ||
/** | ||
@@ -224,3 +224,3 @@ * attaches mouseup & mousedown event handlers to assess if user is dragging | ||
function registerDragHandlers() { | ||
var background = document.querySelector('.BookReader'); | ||
const background = document.querySelector('.BookReader'); | ||
if (!background) { | ||
@@ -237,3 +237,3 @@ return; | ||
background.addEventListener('mouseup', function (e) { | ||
var isDrag = (Math.abs(initialX - e.screenX) > 5 || Math.abs(initialY - e.screenY) > 5); | ||
const isDrag = (Math.abs(initialX - e.screenX) > 5 || Math.abs(initialY - e.screenY) > 5); | ||
@@ -253,3 +253,3 @@ if (!isDrag) { | ||
function registerClickHandlers(br) { | ||
var background = document.querySelector('.BookReader'); | ||
const background = document.querySelector('.BookReader'); | ||
if (!background) { | ||
@@ -261,4 +261,4 @@ return; | ||
var desk = document.querySelector('.BRcontainer') || {}; | ||
var book = desk.firstChild; | ||
const desk = document.querySelector('.BRcontainer') || {}; | ||
const book = desk.firstChild; | ||
@@ -275,8 +275,8 @@ if (book) { | ||
*/ | ||
var installMenuToggle = function installMenuToggle(br) { | ||
var hasNav = false; | ||
const installMenuToggle = function installMenuToggle(br) { | ||
let hasNav = false; | ||
try { | ||
hasNav = br.navigationIsVisible(); | ||
} catch(error) { | ||
} catch (error) { | ||
hasNav = false; | ||
@@ -289,15 +289,15 @@ } | ||
var menuToggleEventRegister = function menuToggleEventRegister(e) { | ||
const menuToggleEventRegister = function menuToggleEventRegister(e) { | ||
registerClickHandlers(br); | ||
}; | ||
var setupDOMandHandlers = function setupDOMandHandlers(e) { | ||
const setupDOMandHandlers = function setupDOMandHandlers(e) { | ||
setupNavForToggle(br); | ||
}; | ||
var persistNav = function persistNav(e) { | ||
const persistNav = function persistNav(e) { | ||
alwaysShowNav(br); | ||
}; | ||
var whenToToggleNav = [ | ||
const whenToToggleNav = [ | ||
'BookReader:1PageViewSelected', | ||
@@ -310,3 +310,3 @@ 'BookReader:2PageViewSelected', | ||
var whenTolwaysShowNavWhen = [ | ||
const whenTolwaysShowNavWhen = [ | ||
'BookReader:3PageViewSelected' | ||
@@ -313,0 +313,0 @@ ]; |
@@ -27,9 +27,9 @@ /* global BookReader, archive_analytics */ | ||
var prevFragment = this.archiveAnalyticsSendFragmentChange.prevFragment; | ||
const prevFragment = this.archiveAnalyticsSendFragmentChange.prevFragment; | ||
var params = this.paramsFromCurrent(); | ||
var newFragment = this.fragmentFromParams(params); | ||
const params = this.paramsFromCurrent(); | ||
const newFragment = this.fragmentFromParams(params); | ||
if (prevFragment != newFragment) { | ||
var values = { | ||
const values = { | ||
bookreader: "user_changed_view", | ||
@@ -57,3 +57,3 @@ itemid: this.bookId, | ||
// Also send tracking event ping | ||
var additionalEventParams = this.options.lendingInfo && this.options.lendingInfo.loanId | ||
const additionalEventParams = this.options.lendingInfo && this.options.lendingInfo.loanId | ||
? { loanId: this.options.lendingInfo.loanId } | ||
@@ -60,0 +60,0 @@ : {}; |
@@ -35,3 +35,3 @@ /* global BookReader */ | ||
this.updateTOCState(this.firstIndex, this._tocEntries); | ||
if($('table-contents-list').parent().hasClass('mm-opened')){ | ||
if ($('table-contents-list').parent().hasClass('mm-opened')) { | ||
this.updateTOCState(this.firstIndex, this._tocEntries); | ||
@@ -76,3 +76,3 @@ } | ||
//adds .BRchapters to the slider only if pageIndex exists | ||
if(pageIndex != undefined){ | ||
if (pageIndex != undefined) { | ||
$(`<div></div>`) | ||
@@ -122,3 +122,3 @@ .append($('<div />').text(title + pageStr)) | ||
this.removeChapters(); | ||
if(this.enableMobileNav && tocEntries.length > 0){ | ||
if (this.enableMobileNav && tocEntries.length > 0) { | ||
this.$(".BRmobileMenu__tableContents").show(); | ||
@@ -246,3 +246,3 @@ } | ||
//this function won't have any effects if called before OpenLibrary request is finished | ||
if(!tocEntries){return} | ||
if (!tocEntries) {return} | ||
$('.current-chapter').removeClass('current-chapter'); | ||
@@ -252,5 +252,5 @@ const tocEntriesIndexed = tocEntries.filter((el) => el.pageIndex != undefined).reverse(); | ||
(el) => el.pageIndex <= currIndex)]; | ||
if(currChapter != undefined){ | ||
if (currChapter != undefined) { | ||
$(currChapter.mobileHTML).addClass('current-chapter'); | ||
} | ||
} |
@@ -279,3 +279,3 @@ /* global BookReader */ | ||
br.refs.$br.removeClass("filter-applied"); | ||
if($(el).is(':checked')){ | ||
if ($(el).is(':checked')) { | ||
br.refs.$br.addClass($(el).attr("filter-applied")); | ||
@@ -282,0 +282,0 @@ filterStr = filterStr + FILTERLIST[i].filter; |
//@ts-check | ||
import { isFirefox, isSafari } from '../../util/browserSniffing.js'; | ||
import { applyVariables } from '../../util/strings.js'; | ||
/** @typedef {import('../../util/strings.js').StringWithVars} StringWithVars */ | ||
const BookReader = /** @type {typeof import('../BookReader').default} */(window.BookReader); | ||
export const DEFAULT_OPTIONS = { | ||
enabled: true, | ||
/** @type {StringWithVars} The URL to fetch the entire DJVU xml. Supports options.vars */ | ||
fullDjvuXmlUrl: null, | ||
/** @type {StringWithVars} The URL to fetch a single page of the DJVU xml. Supports options.vars. Also has {{pageIndex}} */ | ||
singlePageDjvuXmlUrl: null, | ||
}; | ||
/** @typedef {typeof DEFAULT_OPTIONS} TextSelectionPluginOptions */ | ||
export class TextSelectionPlugin { | ||
constructor(avoidTspans = isFirefox(), pointerEventsOnParagraph = isSafari()) { | ||
constructor(options = DEFAULT_OPTIONS, optionVariables, avoidTspans = isFirefox(), pointerEventsOnParagraph = isSafari()) { | ||
this.options = options; | ||
this.optionVariables = optionVariables; | ||
/**@type {PromiseLike<JQuery<HTMLElement>|undefined>} */ | ||
@@ -20,3 +33,3 @@ this.djvuPagesPromise = null; | ||
this.pointerEventsOnParagraph = pointerEventsOnParagraph; | ||
if(avoidTspans) { | ||
if (avoidTspans) { | ||
this.svgParagraphElement = "g"; | ||
@@ -27,9 +40,8 @@ this.svgWordElement = "text"; | ||
/** | ||
* @param {string} ocaid | ||
*/ | ||
init(ocaid) { | ||
init() { | ||
// Only fetch the full djvu xml if the single page url isn't there | ||
if (this.options.singlePageDjvuXmlUrl) return; | ||
this.djvuPagesPromise = $.ajax({ | ||
type: "GET", | ||
url: `https://cors.archive.org/cors/${ocaid}/${ocaid}_djvu.xml`, | ||
url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables), | ||
dataType: "xml", | ||
@@ -48,4 +60,13 @@ | ||
async getPageText(index) { | ||
const XMLpagesArr = await this.djvuPagesPromise; | ||
if (XMLpagesArr) return XMLpagesArr[index]; | ||
if (this.options.fullDjvuXmlUrl) { | ||
const XMLpagesArr = await this.djvuPagesPromise; | ||
if (XMLpagesArr) return XMLpagesArr[index]; | ||
} else { | ||
return $.ajax({ | ||
type: "GET", | ||
url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }), | ||
dataType: "xml", | ||
error: (e) => undefined, | ||
}).then(xmlDoc => xmlDoc && $(xmlDoc).find("OBJECT")[0]); | ||
} | ||
} | ||
@@ -93,3 +114,3 @@ | ||
if (!$(event.target).is(".BRwordElement")) { | ||
if(window.getSelection().toString() != "") window.getSelection().removeAllRanges(); | ||
if (window.getSelection().toString() != "") window.getSelection().removeAllRanges(); | ||
} | ||
@@ -100,3 +121,3 @@ event.stopPropagation(); | ||
event.stopPropagation(); | ||
if(window.getSelection().toString() == "") { | ||
if (window.getSelection().toString() == "") { | ||
$(svg).off(".textSelectPluginHandler"); | ||
@@ -114,3 +135,3 @@ this.defaultMode(svg); } | ||
const $svg = $container.find('svg.textSelectionSVG'); | ||
if(!$svg.length) return; | ||
if (!$svg.length) return; | ||
$svg.each((i, s) => this.defaultMode(s)) | ||
@@ -128,3 +149,3 @@ this.interceptCopy($container); | ||
const XMLpage = await this.getPageText(pageIndex); | ||
if(!XMLpage) return; | ||
if (!XMLpage) return; | ||
const XMLwidth = $(XMLpage).attr("width"); | ||
@@ -159,3 +180,3 @@ const XMLheight = $(XMLpage).attr("height"); | ||
for(let i = 0; i < words.length; i++) { | ||
for (let i = 0; i < words.length; i++) { | ||
// Adding tspan for each word in paragraph | ||
@@ -179,3 +200,3 @@ const currWord = words[i]; | ||
// TODO: assumes left-to-right text | ||
if(i < words.length - 1){ | ||
if (i < words.length - 1) { | ||
const nextWord = words[i + 1]; | ||
@@ -188,3 +209,3 @@ // eslint-disable-next-line no-unused-vars | ||
spaceTspan.setAttribute("y", bottom.toString()); | ||
if((leftNext - right) > 0) spaceTspan.setAttribute("textLength", (leftNext - right).toString()); | ||
if ((leftNext - right) > 0) spaceTspan.setAttribute("textLength", (leftNext - right).toString()); | ||
spaceTspan.setAttribute("lengthAdjust", "spacingAndGlyphs"); | ||
@@ -196,3 +217,3 @@ spaceTspan.textContent = " "; | ||
// Adds newline at the end of paragraph on Firefox | ||
if((i == words.length - 1 && (this.insertNewlines))) { | ||
if ((i == words.length - 1 && (this.insertNewlines))) { | ||
paragSvg.appendChild(document.createTextNode("\n")); | ||
@@ -213,5 +234,9 @@ } | ||
init() { | ||
if(this.enableTextSelection){ | ||
this.textSelectionPlugin = new TextSelectionPlugin(); | ||
this.textSelectionPlugin.init(this.bookId); | ||
const options = Object.assign({}, DEFAULT_OPTIONS, this.options.plugins.textSelection); | ||
if (options.enabled) { | ||
this.textSelectionPlugin = new TextSelectionPlugin(options, this.options.vars); | ||
// Write this back; this way the plugin is the source of truth, and BR just | ||
// contains a reference to it. | ||
this.options.plugins.textSelection = options; | ||
this.textSelectionPlugin.init(); | ||
} | ||
@@ -227,4 +252,4 @@ super.init(); | ||
// Disable if thumb mode; it's too janky | ||
if(this.enableTextSelection && this.mode != this.constModeThumb){ | ||
this.textSelectionPlugin.createTextLayer(index, $container); | ||
if (this.mode != this.constModeThumb) { | ||
this.textSelectionPlugin?.createTextLayer(index, $container); | ||
} | ||
@@ -231,0 +256,0 @@ return $container; |
@@ -97,3 +97,3 @@ /* global BookReader, soundManager */ | ||
return function () { | ||
var $el = super_.call(this); | ||
const $el = super_.call(this); | ||
if (this.options.enableTtsPlugin && this.ttsEngine) { | ||
@@ -120,3 +120,3 @@ $el.find('.BRmobileMenu__moreInfoRow').after($(` | ||
return function () { | ||
var $el = super_.call(this); | ||
const $el = super_.call(this); | ||
if (this.options.enableTtsPlugin && this.ttsEngine) { | ||
@@ -260,5 +260,5 @@ this.refs.$BRReadAloudToolbar = $(` | ||
BookReader.prototype.ttsMaybeFlipToIndex = function (leafIndex) { | ||
var in2PageMode = this.constMode2up == this.mode; | ||
var resolve = null; | ||
var promise = new Promise(res => resolve = res); | ||
const in2PageMode = this.constMode2up == this.mode; | ||
let resolve = null; | ||
const promise = new Promise(res => resolve = res); | ||
@@ -269,3 +269,3 @@ if (!in2PageMode) { | ||
} else { | ||
var leafVisible = leafIndex == this.twoPage.currentIndexR || leafIndex == this.twoPage.currentIndexL; | ||
const leafVisible = leafIndex == this.twoPage.currentIndexR || leafIndex == this.twoPage.currentIndexL; | ||
if (leafVisible) { | ||
@@ -304,5 +304,5 @@ resolve(); | ||
var leafTop = 0; | ||
var h; | ||
var i; | ||
let leafTop = 0; | ||
let h; | ||
let i; | ||
for (i = 0; i < chunk.leafIndex; i++) { | ||
@@ -313,12 +313,12 @@ h = parseInt(this._getPageHeight(i) / this.reduce); | ||
var chunkTop = chunk.lineRects[0][3]; //coords are in l,b,r,t order | ||
var chunkBot = chunk.lineRects[chunk.lineRects.length - 1][1]; | ||
const chunkTop = chunk.lineRects[0][3]; //coords are in l,b,r,t order | ||
const chunkBot = chunk.lineRects[chunk.lineRects.length - 1][1]; | ||
var topOfFirstChunk = leafTop + chunkTop / this.reduce; | ||
var botOfLastChunk = leafTop + chunkBot / this.reduce; | ||
const topOfFirstChunk = leafTop + chunkTop / this.reduce; | ||
const botOfLastChunk = leafTop + chunkBot / this.reduce; | ||
if (soundManager.debugMode) console.log('leafTop = ' + leafTop + ' topOfFirstChunk = ' + topOfFirstChunk + ' botOfLastChunk = ' + botOfLastChunk); | ||
var containerTop = this.refs.$brContainer.prop('scrollTop'); | ||
var containerBot = containerTop + this.refs.$brContainer.height(); | ||
const containerTop = this.refs.$brContainer.prop('scrollTop'); | ||
const containerBot = containerTop + this.refs.$brContainer.height(); | ||
if (soundManager.debugMode) console.log('containerTop = ' + containerTop + ' containerBot = ' + containerBot); | ||
@@ -335,10 +335,10 @@ | ||
BookReader.prototype.ttsHilite1UP = function(chunk) { | ||
for (var i = 0; i < chunk.lineRects.length; i++) { | ||
for (let i = 0; i < chunk.lineRects.length; i++) { | ||
//each rect is an array of l,b,r,t coords (djvu.xml ordering...) | ||
var l = chunk.lineRects[i][0]; | ||
var b = chunk.lineRects[i][1]; | ||
var r = chunk.lineRects[i][2]; | ||
var t = chunk.lineRects[i][3]; | ||
const l = chunk.lineRects[i][0]; | ||
const b = chunk.lineRects[i][1]; | ||
const r = chunk.lineRects[i][2]; | ||
const t = chunk.lineRects[i][3]; | ||
var div = document.createElement('div'); | ||
const div = document.createElement('div'); | ||
this.ttsHilites.push(div); | ||
@@ -363,10 +363,10 @@ $(div).prop('className', 'BookReaderSearchHilite').appendTo( | ||
BookReader.prototype.ttsHilite2UP = function (chunk) { | ||
for (var i = 0; i < chunk.lineRects.length; i++) { | ||
for (let i = 0; i < chunk.lineRects.length; i++) { | ||
//each rect is an array of l,b,r,t coords (djvu.xml ordering...) | ||
var l = chunk.lineRects[i][0]; | ||
var b = chunk.lineRects[i][1]; | ||
var r = chunk.lineRects[i][2]; | ||
var t = chunk.lineRects[i][3]; | ||
const l = chunk.lineRects[i][0]; | ||
const b = chunk.lineRects[i][1]; | ||
const r = chunk.lineRects[i][2]; | ||
const t = chunk.lineRects[i][3]; | ||
var div = document.createElement('div'); | ||
const div = document.createElement('div'); | ||
this.ttsHilites.push(div); | ||
@@ -373,0 +373,0 @@ $(div) |
@@ -315,3 +315,3 @@ /* global br */ | ||
} | ||
switch(result) { | ||
switch (result) { | ||
case 'ended': | ||
@@ -318,0 +318,0 @@ // audio was stopped/finished; nothing to do |
@@ -56,3 +56,3 @@ import sinon from 'sinon'; | ||
// Call it several times with 500ms between each call | ||
for(let i = 0; i < 10; i++) { | ||
for (let i = 0; i < 10; i++) { | ||
clock.tick(500); | ||
@@ -59,0 +59,0 @@ debouncedFunc(); |
@@ -9,3 +9,3 @@ export const TEST_TEXT_FOUND = 'theory'; | ||
/** Mock response for a matching search term. */ | ||
export function mockResponseFound(req, res){ | ||
export function mockResponseFound(req, res) { | ||
const requestUrl = new URL(req.url); | ||
@@ -18,3 +18,3 @@ const jqueryUrl = requestUrl.searchParams.get("callback"); | ||
/** Mock response for a matching search term. */ | ||
export function mockResponseNotFound(req, res){ | ||
export function mockResponseNotFound(req, res) { | ||
const requestUrl = new URL(req.url); | ||
@@ -21,0 +21,0 @@ const jqueryUrl = requestUrl.searchParams.get("callback"); |
@@ -112,3 +112,3 @@ import sinon from 'sinon'; | ||
test("textSelectionPlugin constructor with firefox browser", () => { | ||
const tsp = new TextSelectionPlugin(true) | ||
const tsp = new TextSelectionPlugin({}, {}, true) | ||
expect(tsp.djvuPagesPromise).toBe(null); | ||
@@ -120,3 +120,3 @@ expect(tsp.svgParagraphElement).toBe("g"); | ||
test("textSelectionPlugin constructor not on firefox browser", () => { | ||
const tsp = new TextSelectionPlugin(false) | ||
const tsp = new TextSelectionPlugin({}, {}, false) | ||
expect(tsp.djvuPagesPromise).toBe(null); | ||
@@ -123,0 +123,0 @@ expect(tsp.svgParagraphElement).toBe("text"); |
@@ -37,5 +37,6 @@ // @ts-check | ||
path: path.resolve(__dirname, 'BookReader'), | ||
ecmaVersion: 5 | ||
}, | ||
target: ['web', 'es5'], | ||
// Accurate source maps at the expense of build time. | ||
@@ -42,0 +43,0 @@ // The source map is intentionally exposed |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
5821409
307
50589