Hedgehog
11 years ago
5 changed files with 47 additions and 52 deletions
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
(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); |
||||
} |
||||
})(); |
Loading…
Reference in new issue