Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AroriaNetwork
GitHub Repository: AroriaNetwork/3kho-backup
Path: blob/main/projects/particle-clicker/js/external/retina.js
1834 views
1
/*!
2
* Retina.js v1.3.0
3
*
4
* Copyright 2014 Imulus, LLC
5
* Released under the MIT license
6
*
7
* Retina.js is an open source script that makes it easy to serve
8
* high-resolution images to devices with retina displays.
9
*/
10
!function(){var t="undefined"==typeof exports?window:exports,e={retinaImageSuffix:"@2x",check_mime_type:!0,force_original_dimensions:!0};function i(){}t.Retina=i,i.configure=function(t){for(var i in null===t&&(t={}),t)t.hasOwnProperty(i)&&(e[i]=t[i])},i.init=function(e){null===e&&(e=t);var i=e.onload||function(){};e.onload=function(){var t,e,a=document.getElementsByTagName("img"),n=[];for(t=0;t<a.length;t+=1)(e=a[t]).getAttributeNode("data-no-retina")||(e.setAttribute("data-at2x-loaded",!0),n.push(new o(e)));i()}},i.recheck=function(){var t,e,i=document.getElementsByTagName("img"),a=[];for(t=0;t<i.length;t+=1)(e=i[t]).getAttributeNode("data-no-retina")||e.getAttributeNode("data-at2x-loaded")||(e.setAttribute("data-at2x-loaded",!0),a.push(new o(e)))},i.isRetina=function(){return t.devicePixelRatio>1||!(!t.matchMedia||!t.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches)};var a=/\.\w+$/;function n(t){return e.retinaImageSuffix+t}function r(t,e){if(this.path=t||"",null!=e)this.at_2x_path=e,this.perform_check=!1;else{if(void 0!==document.createElement){var i=document.createElement("a");i.href=this.path,i.pathname=i.pathname.replace(a,n),this.at_2x_path=i.href}else{var r=this.path.split("?");r[0]=r[0].replace(a,n),this.at_2x_path=r.join("?")}this.perform_check=!0}}function o(t){this.el=t,this.path=new r(this.el.getAttribute("src"),this.el.getAttribute("data-at2x"));var e=this;this.path.check_2x_variant((function(t){t&&e.swap()}))}t.RetinaImagePath=r,r.confirmed_paths=[],r.prototype.is_external=function(){return!(!this.path.match(/^https?\:/i)||this.path.match("//"+document.domain))},r.prototype.check_2x_variant=function(t){var i,a=this;return this.is_external()?t(!1):this.perform_check||void 0===this.at_2x_path||null===this.at_2x_path?this.at_2x_path in r.confirmed_paths?t(!0):((i=new XMLHttpRequest).open("HEAD",this.at_2x_path),i.onreadystatechange=function(){if(4!==i.readyState)return t(!1);if(i.status>=200&&i.status<=399){if(e.check_mime_type){var n=i.getResponseHeader("Content-Type");if(null===n||!n.match(/^image/i))return t(!1)}return r.confirmed_paths.push(a.at_2x_path),t(!0)}return t(!1)},void i.send()):t(!0)},t.RetinaImage=o,o.prototype.swap=function(t){void 0===t&&(t=this.path.at_2x_path);var i=this;!function a(){i.el.complete?(e.force_original_dimensions&&(i.el.setAttribute("width",i.el.width),i.el.setAttribute("height",i.el.height)),i.el.setAttribute("src",t)):setTimeout(a,5)}()},i.isRetina()&&i.init(t)}();
11
12