mirror of
https://github.com/twisterarmy/twister-calm.git
synced 2025-01-13 16:37:52 +00:00
4ecabec04d
added preview from img.bi
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
(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);
|
|
}
|
|
})();
|