CARVIEW |
Select Language
HTTP/2 301
location: https://raw.githubusercontent.com/urish/angular-load/master/angular-load.js
accept-ranges: bytes
age: 0
date: Sun, 27 Jul 2025 11:52:04 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210025-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753617124.767358,VS0,VE1199
vary: Accept-Encoding
x-fastly-request-id: 1e04940d3f5d500bdc7e5cc993b1d7ef92b95835
content-length: 0
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: W/"8857f633835625ba4b735604695d66e7da8cabe004c7a0d5ec1b0bb96f7cb826"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: B772:243198:1F1535:50F289:688612E4
content-encoding: gzip
accept-ranges: bytes
date: Sun, 27 Jul 2025 11:52:05 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210044-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753617125.021718,VS0,VE247
vary: Authorization,Accept-Encoding
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: 2f0313e805bf153d02db904237d79d55088e27ea
expires: Sun, 27 Jul 2025 11:57:05 GMT
source-age: 0
content-length: 817
/* angular-load.js / v0.4.2 / (c) 2014, 2015, 2016 Uri Shaked / MIT Licence */
angular.module('angularLoad', [])
.service('angularLoad', ['$document', '$q', '$timeout', function ($document, $q, $timeout) {
var document = $document[0];
var promises = {};
function loader(createElement) {
return function(url) {
if (typeof promises[url] === 'undefined') {
var deferred = $q.defer();
var element = createElement(url);
element.onload = element.onreadystatechange = function (e) {
if (element.readyState && element.readyState !== 'complete' && element.readyState !== 'loaded') {
return;
}
$timeout(function () {
deferred.resolve(e);
});
};
element.onerror = function (e) {
$timeout(function () {
deferred.reject(e);
});
};
promises[url] = deferred.promise;
}
return promises[url];
};
}
/**
* Dynamically loads the given script
* @param src The url of the script to load dynamically
* @returns {*} Promise that will be resolved once the script has been loaded.
*/
this.loadScript = loader(function (src) {
var script = document.createElement('script');
script.src = src;
document.body.appendChild(script);
return script;
});
/**
* Dynamically loads the given CSS file
* @param href The url of the CSS to load dynamically
* @returns {*} Promise that will be resolved once the CSS file has been loaded.
*/
this.loadCSS = loader(function (href) {
var style = document.createElement('link');
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = href;
document.head.appendChild(style);
return style;
});
/**
* Dynamically unloads the given CSS file
* @param href The url of the CSS to unload dynamically
* @returns boolean that will be true once the CSS file has been unloaded successfully or otherwise false.
*/
this.unloadCSS = function (href) {
delete promises[href];
var docHead = document.head;
if(docHead) {
var targetCss = docHead.querySelector('[href="' + href + '"]');
if(targetCss) {
targetCss.remove();
return true;
}
}
return false;
};
}]);