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 13:14:36 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210023-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753622075.963693,VS0,VE1217
vary: Accept-Encoding
x-fastly-request-id: 163a8a9c73bd1c685cba2b05e418621c00b40534
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 13:14:36 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210061-BOM
x-cache: HIT
x-cache-hits: 0
x-timer: S1753622076.235457,VS0,VE232
vary: Authorization,Accept-Encoding
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: 012e6480af3d2201868369a040e11bdc17934677
expires: Sun, 27 Jul 2025 13:19:36 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;
};
}]);