@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
3 lines (2 loc) • 13.2 kB
JavaScript
var d=function(){function r(){}return r.waitFor=function(t,i,n,a,c,o){a||(a=200),c||(c=100),o||(o=0),o+=1,o>c?n&&n():t()?i():setTimeout(function(){r.waitFor(t,i,n,a,c,o)},a)},r}();var S=function(){function r(){}return r.getBool=function(t,i){return t===null||typeof t=="undefined"?i:t},r}();var E=function(){function r(){}return r.supportsCopy=function(){return document.queryCommandSupported&&document.queryCommandSupported("copy")},r.copy=function(t){t=r.convertBrToNewLine(t);var i=document.createElement("textarea");i.value=t,r.hideButKeepEnabled(i),document.body.appendChild(i),i.focus(),i.select(),document.execCommand("copy"),document.body.removeChild(i)},r.hideButKeepEnabled=function(t){t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent"},r.convertBrToNewLine=function(t){var i=/<br\s*[\/]?>/gi;return t=t.replace(i,`
`),t},r}();var h=function(){function r(){}return r.float32ColorToARGB=function(t){var i=(t&4278190080)>>>24,n=(t&16711680)>>>16,a=(t&65280)>>>8,c=t&255,o=[i,n,a,c];return o},r._componentToHex=function(t){var i=t.toString(16);return i.length==1?"0"+i:i},r.rgbToHexString=function(t){return r.coalesce(t),"#"+r._componentToHex(t[0])+r._componentToHex(t[1])+r._componentToHex(t[2])},r.argbToHexString=function(t){return"#"+r._componentToHex(t[0])+r._componentToHex(t[1])+r._componentToHex(t[2])+r._componentToHex(t[3])},r.coalesce=function(t){for(var i=1;i<t.length;i++)typeof t[i]=="undefined"&&(t[i]=t[i-1])},r}();var O=function(){function r(){}return r.getTimeStamp=function(){return new Date().getTime()},r}();var L=function(){function r(){}return r.getPixelRatio=function(t){var i=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return i/n},r.isTouch=function(){return"ontouchstart"in window||window.navigator.msMaxTouchPoints>0},r}();var A=function(){function r(){}return r.isInIFrame=function(){try{return window.self!==window.top}catch{return!0}},r.supportsFullscreen=function(){var t=document.documentElement,i=t.requestFullscreen||t.mozRequestFullScreen||t.webkitRequestFullScreen||t.msRequestFullscreen;return i!==void 0},r.isHidden=function(){var t=r.getHiddenProp();return!!t},r.getHiddenProp=function(){var t=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var i=0;i<t.length;i++)if(t[i]+"Hidden"in document)return t[i]+"Hidden";return null},r}();var m=function(){function r(){}return r.debounce=function(t,i){return i=i||100,function(){if(!t.debouncing){var n=Array.prototype.slice.apply(arguments);t.lastReturnVal=t.apply(window,n),t.debouncing=!0}return clearTimeout(t.debounceTimeout),t.debounceTimeout=setTimeout(function(){t.debouncing=!1},i),t.lastReturnVal}},r}();var p=function(){function r(){}return r.simplifyMimeType=function(t){switch(t){case"text/plain":return"txt";case"image/jpeg":return"jpg";case"application/msword":return"doc";case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return"docx";default:var i=t.split("/");return i[i.length-1]}},r}();var N=function(){function r(){}return r.getCharCode=function(t){var i=typeof t.which=="number"?t.which:t.keyCode;return i},r}();var T=function(){function r(){}return r.normalise=function(t,i,n){return(t-i)/(n-i)},r.median=function(t){t.sort(function(n,a){return n-a});var i=Math.floor(t.length/2);return t.length%2?t[i]:(t[i-1]+t[i])/2},r.clamp=function(t,i,n){return Math.min(Math.max(t,i),n)},r}();var f=function(){function r(t,i){this.width=t,this.height=i}return r}();var D=function(){function r(){}return r.fitRect=function(t,i,n,a){var c=i/t,o=a/n,l=0,g=0,u;return c<o?(u=n/t,l=t*u,g=i*u):(u=a/i,l=t*u,g=i*u),new f(Math.floor(l),Math.floor(g))},r.hitRect=function(t,i,n,a,c,o){return c>t&&c<t+n&&o>i&&o<i+a},r}();var R=function(){function r(){}return r.numericalInput=function(t){return t.keyCode==46||t.keyCode==8||t.keyCode==9||t.keyCode==27||t.keyCode==65&&t.ctrlKey===!0||t.keyCode>=35&&t.keyCode<=39?!0:t.shiftKey||(t.keyCode<48||t.keyCode>57)&&(t.keyCode<96||t.keyCode>105)?(t.preventDefault(),!1):!0},r}();var C=function(){function r(){}return r.toPlainObject=function(t){t=Object(t);var i={};for(var n in t)i[n]=t[n];return i},r}();var H=function(){function r(){}return r.clear=function(t){switch(t===void 0&&(t=s.MEMORY),t){case s.MEMORY:this._memoryStorage={};break;case s.SESSION:sessionStorage.clear();break;case s.LOCAL:localStorage.clear();break}},r.clearExpired=function(t){t===void 0&&(t=s.MEMORY);for(var i=this.getItems(t),n=0;n<i.length;n++){var a=i[n];this._isExpired(a)&&this.remove(a.key)}},r.get=function(t,i){i===void 0&&(i=s.MEMORY);var n=null;switch(i){case s.MEMORY:n=this._memoryStorage[t];break;case s.SESSION:n=sessionStorage.getItem(t);break;case s.LOCAL:n=localStorage.getItem(t);break}if(!n)return null;var a=null;try{a=JSON.parse(n)}catch{return null}return!a||this._isExpired(a)?null:(a.key=t,a)},r._isExpired=function(t){return!(new Date().getTime()<t.expiresAt)},r.getItems=function(t){t===void 0&&(t=s.MEMORY);var i=[];switch(t){case s.MEMORY:for(var n=Object.keys(this._memoryStorage),a=0;a<n.length;a++){var c=this.get(n[a],s.MEMORY);c&&i.push(c)}break;case s.SESSION:for(var a=0;a<sessionStorage.length;a++){var o=sessionStorage.key(a);if(o){var c=this.get(o,s.SESSION);c&&i.push(c)}}break;case s.LOCAL:for(var a=0;a<localStorage.length;a++){var o=localStorage.key(a);if(o){var c=this.get(o,s.LOCAL);c&&i.push(c)}}break}return i},r.remove=function(t,i){switch(i===void 0&&(i=s.MEMORY),i){case s.MEMORY:delete this._memoryStorage[t];break;case s.SESSION:sessionStorage.removeItem(t);break;case s.LOCAL:localStorage.removeItem(t);break}},r.set=function(t,i,n,a){a===void 0&&(a=s.MEMORY);var c=n*1e3,o=new _;switch(o.value=i,o.expiresAt=new Date().getTime()+c,a){case s.MEMORY:this._memoryStorage[t]=JSON.stringify(o);break;case s.SESSION:sessionStorage.setItem(t,JSON.stringify(o));break;case s.LOCAL:localStorage.setItem(t,JSON.stringify(o));break}return o},r._memoryStorage={},r}();var _=function(){function r(){}return r}();var s;(function(r){r.MEMORY="memory",r.SESSION="session",r.LOCAL="local"})(s||(s={}));var P=function(){function r(){}return r.ellipsis=function(t,i){if(t.length<=i)return t;var n=t.substr(0,i),a=n.lastIndexOf(" ");return a!=-1&&(n=n.substr(0,Math.min(n.length,a))),n+"…"},r.htmlDecode=function(t){var i=document.createElement("div");return i.innerHTML=t,i.firstChild.nodeValue},r.format=function(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];for(var a=0;a<i.length;a++){var c=new RegExp("\\{"+a+"\\}","gm");t=t.replace(c,i[a])}return t},r.isAlphanumeric=function(t){return/^[a-zA-Z0-9]*$/.test(t)},r.toCssClass=function(t){return t.replace(/[^a-z0-9]/g,function(i){var n=i.charCodeAt(0);return n==32?"-":n>=65&&n<=90?"_"+i.toLowerCase():"__"+("000"+n.toString(16)).slice(-4)})},r.toFileName=function(t){return t.replace(/[^a-z0-9]/gi,"_").toLowerCase()},r.utf8_to_b64=function(t){return window.btoa(unescape(encodeURIComponent(t)))},r}();var U=function(){function r(){}return r.getHashParameter=function(t,i){return i||(i=window.document),i&&i.location?this.getHashParameterFromString(t,i.location.hash):null},r.getHashParameterFromString=function(t,i){var n=new RegExp("#.*[?&]"+t+"=([^&]+)(&|$)"),a=n.exec(i);return a?decodeURIComponent(a[1].replace(/\+/g," ")):null},r.setHashParameter=function(t,i,n){if(n||(n=window.document),n&&n.location){var a=this.updateURIKeyValuePair(n.location.hash.replace("#?",""),t,i),c="#?"+a,o=n.URL,l=o.indexOf("#");l!=-1&&(o=o.substr(0,o.indexOf("#"))),n.location.replace(o+c)}},r.getQuerystringParameter=function(t,i){return i||(i=window),this.getQuerystringParameterFromString(t,i.location.search)},r.getQuerystringParameterFromString=function(t,i){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+t+"=([^&#]*)"),a=n.exec(i);return a?decodeURIComponent(a[1].replace(/\+/g," ")):null},r.setQuerystringParameter=function(t,i,n){if(n||(n=window.document),n&&n.location){var a=this.updateURIKeyValuePair(n.location.hash.replace("#?",""),t,i);window.location.search=a}},r.updateURIKeyValuePair=function(t,i,n){i=encodeURIComponent(i),n=encodeURIComponent(n);var a=t.split("&");a[0]==""&&a.shift();for(var c=a.length,o;c--;)if(o=a[c].split("="),o[0]==i){o[1]=n,a[c]=o.join("=");break}return c<0&&(a[a.length]=[i,n].join("=")),a.join("&")},r.getUrlParts=function(t){var i=document.createElement("a");return i.href=t,i},r.convertToRelativeUrl=function(t){var i=this.getUrlParts(t),n=i.pathname+i.searchWithin;return n.startsWith("/")||(n="/"+n),n},r}();var e=class{};e.ACCEPT_TERMS="acceptTerms",e.ANNOTATION_CANVAS_CHANGE="annotationCanvasChange",e.ANNOTATION_CHANGE="annotationChange",e.ANNOTATIONS_CLEARED="annotationsCleared",e.ANNOTATIONS_EMPTY="annotationsEmpty",e.ANNOTATIONS="annotations",e.BOOKMARK="bookmark",e.CANVAS_INDEX_CHANGE_FAILED="canvasIndexChangeFailed",e.CANVAS_INDEX_CHANGE="canvasIndexChange",e.CLEAR_ANNOTATIONS="clearAnnotations",e.CLICKTHROUGH="clickthrough",e.CLOSE_ACTIVE_DIALOGUE="closeActiveDialogue",e.CLOSE_LEFT_PANEL="closeLeftPanel",e.CLOSE_RIGHT_PANEL="closeRightPanel",e.COLLECTION_INDEX_CHANGE="collectionIndexChange",e.CREATE="create",e.CURRENT_TIME_CHANGE="currentTimeChanged",e.RANGE_TIME_CHANGE="rangeTimeChanged",e.DOWN_ARROW="downArrow",e.DOWNLOAD="download",e.END="end",e.ESCAPE="escape",e.EXTERNAL_LINK_CLICKED="externalLinkClicked",e.FEEDBACK="feedback",e.FIRST="first",e.FORBIDDEN="forbidden",e.GALLERY_DECREASE_SIZE="galleryDecreaseSize",e.GALLERY_INCREASE_SIZE="galleryIncreaseSize",e.GALLERY_THUMB_SELECTED="galleryThumbSelected",e.HIDE_AUTH_DIALOGUE="hideAuthDialogue",e.HIDE_CLICKTHROUGH_DIALOGUE="hideClickthroughDialogue",e.HIDE_DOWNLOAD_DIALOGUE="hideDownloadDialogue",e.HIDE_EMBED_DIALOGUE="hideEmbedDialogue",e.HIDE_EXTERNALCONTENT_DIALOGUE="hideExternalContentDialogue",e.HIDE_GENERIC_DIALOGUE="hideGenericDialogue",e.HIDE_HELP_DIALOGUE="hideHelpDialogue",e.HIDE_INFORMATION="hideInformation",e.HIDE_LOGIN_DIALOGUE="hideLoginDialogue",e.HIDE_MOREINFO_DIALOGUE="hideMoreInfoDialogue",e.HIDE_MULTISELECT_DIALOGUE="hideMultiSelectDialogue",e.HIDE_OVERLAY="hideOverlay",e.HIDE_RESTRICTED_DIALOGUE="hideRestrictedDialogue",e.HIDE_SETTINGS_DIALOGUE="hideSettingsDialogue",e.HIDE_SHARE_DIALOGUE="hideShareDialogue",e.HOME="home",e.LAST="last",e.LEFT_ARROW="leftArrow",e.LEFTPANEL_COLLAPSE_FULL_FINISH="leftPanelCollapseFullFinish",e.LEFTPANEL_COLLAPSE_FULL_START="leftPanelCollapseFullStart",e.LEFTPANEL_EXPAND_FULL_FINISH="leftPanelExpandFullFinish",e.LEFTPANEL_EXPAND_FULL_START="leftPanelExpandFullStart",e.LOGIN_FAILED="loginFailed",e.LOGIN="login",e.LOGOUT="logout",e.MANIFEST_INDEX_CHANGE="manifestIndexChange",e.METRIC_CHANGE="metricChange",e.MINUS="minus",e.MULTISELECT_CHANGE="multiSelectChange",e.MULTISELECTION_MADE="multiSelectionMade",e.NEXT="next",e.NOT_FOUND="notFound",e.OPEN_EXTERNAL_RESOURCE="openExternalResource",e.OPEN_LEFT_PANEL="openLeftPanel",e.OPEN_RIGHT_PANEL="openRightPanel",e.OPEN_THUMBS_VIEW="openThumbsView",e.OPEN_TREE_VIEW="openTreeView",e.OPEN="open",e.PAGE_DOWN="pageDown",e.PAGE_UP="pageUp",e.PAUSE="pause",e.PINPOINT_ANNOTATION_CLICKED="pinpointAnnotationClicked",e.PLUS="plus",e.PREV="prev",e.RANGE_CHANGE="rangeChange",e.REDIRECT="redirect",e.REFRESH="refresh",e.RESOURCE_DEGRADED="resourceDegraded",e.RETRY="retry",e.RETURN="return",e.RIGHT_ARROW="rightArrow",e.RIGHTPANEL_COLLAPSE_FULL_FINISH="rightPanelCollapseFullFinish",e.RIGHTPANEL_COLLAPSE_FULL_START="rightPanelCollapseFullStart",e.RIGHTPANEL_EXPAND_FULL_FINISH="rightPanelExpandFullFinish",e.RIGHTPANEL_EXPAND_FULL_START="rightPanelExpandFullStart",e.SET_ROTATION="setRotation",e.SET_TARGET="setTarget",e.SETTINGS_CHANGE="settingsChange",e.SHOW_AUTH_DIALOGUE="showAuthDialogue",e.SHOW_CLICKTHROUGH_DIALOGUE="showClickThroughDialogue",e.SHOW_DOWNLOAD_DIALOGUE="showDownloadDialogue",e.SHOW_EMBED_DIALOGUE="showEmbedDialogue",e.SHOW_EXTERNALCONTENT_DIALOGUE="showExternalContentDialogue",e.SHOW_GENERIC_DIALOGUE="showGenericDialogue",e.SHOW_HELP_DIALOGUE="showHelpDialogue",e.SHOW_INFORMATION="showInformation",e.SHOW_LOGIN_DIALOGUE="showLoginDialogue",e.SHOW_MESSAGE="showMessage",e.MESSAGE_DISPLAYED="messageDisplayed",e.SHOW_MOREINFO_DIALOGUE="showMoreInfoDialogue",e.SHOW_MULTISELECT_DIALOGUE="showMultiSelectDialogue",e.SHOW_OVERLAY="showOverlay",e.SHOW_RESTRICTED_DIALOGUE="showRestrictedDialogue",e.SHOW_SETTINGS_DIALOGUE="showSettingsDialogue",e.SHOW_SHARE_DIALOGUE="showShareDialogue",e.SHOW_TERMS_OF_USE="showTermsOfUse",e.TARGET_CHANGE="targetChange",e.THUMB_MULTISELECTED="thumbMultiSelected",e.THUMB_SELECTED="thumbSelected",e.TOGGLE_EXPAND_LEFT_PANEL="toggleExpandLeftPanel",e.TOGGLE_EXPAND_RIGHT_PANEL="toggleExpandRightPanel",e.TREE_NODE_MULTISELECTED="treeNodeMultiSelected",e.TREE_NODE_SELECTED="treeNodeSelected",e.UP_ARROW="upArrow",e.UPDATE_SETTINGS="updateSettings",e.VIEW_FULL_TERMS="viewFullTerms",e.WINDOW_UNLOAD="windowUnload";export{d as a,S as b,O as c,A as d,p as e,N as f,T as g,f as h,D as i,R as j,C as k,H as l,s as m,P as n,U as o,e as p};