function getSrc(e) {
copyToClipboard($(e.target).attr('src'));
}
function pressAlt(e){
if (e.keyCode == 18) {
$(document).off('keydown', pressAlt);
$('img').on('click', getSrc);
$(document).on('keyup', function () {
if (e.keyCode == 18) {
$('img').off('click', getSrc);
$(document).on('keydown', pressAlt);
}
});
}
}
function copyToClipboard(text) {
window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
}
$(document).on('keydown', pressAlt);
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://code.jquery.com/jquery-2.1.0.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.addEventListener('load', function(){
$(document).ready(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://cdn.rawgit.com/zeroclipboard/zeroclipboard/master/dist/ZeroClipboard.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.addEventListener('load', function(){
$(document).ready(function() {
ZeroClipboard.config({
forceHandCursor: true
});
var client = new ZeroClipboard($("img"));
client.on("ready", function(e) {
function once(e){
client.setText(e.target.src);
}
function altDwn(e){
if (e.keyCode == 18){
client.on("copy", once);
e.preventDefault();
$(document).off('keydown', altDwn);
}
}
$(document).on('keydown', altDwn);
$(document).on('keyup', function(e){
if (e.keyCode == 18){
$(document).on('keydown', altDwn);
client.off("copy", once);
}
});
});
});
}, false);
});
}, false);