Theme for twister
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

(function () {
if (window.addEventListener) {
window.addEventListener('load', imgBiJS, false);
}
else if(window.attachEvent) {
window.attachEvent('onload', imgBiJS);
}
else {
document.addEventListener('load', imgBiJS, false);
}
function imgBiJS() {
var elems = document.querySelectorAll('[data-imgbi]');
i = elems.length;
while (i--) {
var params = elems[i].dataset.imgbi.split('!');
imgBiJSDownload(params[0].replace('#','') + 'download/' + params[1], params[2], elems[i], new XMLHttpRequest());
}
}
function imgBiJSDownload(url, pass, elem, request) {
request.open('GET', url);
request.onload = function() {
if (request.status == 200) {
var result = sjcl.decrypt(pass,request.responseText);
if (result) {
elem.src = result;
}
else {
console.log('Failed to decrypt image');
}
}
else {
console.log('Failed to load image');
}
};
request.send(null);
}
})();