JavaScript hacks
/*--------------------------------------*/
var loadjQuery = function(cb){
var scr = document.createElement('script');
scr.setAttribute('type', 'text/javascript');
scr.setAttribute('src', 'https://code.jquery.com/jquery-3.3.1.min.js');
if(scr.readyState){
scr.onreadystatechange = function(){
if(scr.readyState === 'complete' || scr.readyState === 'loaded'){
scr.onreadystatechange = null;
if(cb === 'function'){
args = [].slice.call(arguments, 1);
cb.apply(this, args);
}
}
};
} else {
scr.onload = function(){
if(typeof(cb) === 'function'){
args = [].slice.call(arguments, 1);
cb.apply(this, args);
}
};
}
var head = document.getElementsByTagName('head')[0];
head.insertBefore(scr, head.firstChild);
}
loadjQuery(function() {
$('body').empty();
let getRandomInt = function (max) {
return Math.floor(Math.random() * Math.floor(max));
};
let curr=getRandomInt(5000);
let addNewAvatar=function() {
$('body').append(
$('<img />').attr(
'src', 'https://avatars.githubusercontent.com/u/'+curr
).css({
'max-width': '50px',
'display': 'inline-block',
'float': 'left',
'margin': '0',
'padding': '0'
})
);
curr += (1+getRandomInt(3));
setTimeout(addNewAvatar, 100);
};
setTimeout(addNewAvatar, 100);
});
/*--------------------------------------*/
var loadjQuery = function(cb){
var scr = document.createElement('script');
scr.setAttribute('type', 'text/javascript');
scr.setAttribute('src', 'https://code.jquery.com/jquery-3.3.1.min.js');
if(scr.readyState){
scr.onreadystatechange = function(){
if(scr.readyState === 'complete' || scr.readyState === 'loaded'){
scr.onreadystatechange = null;
if(cb === 'function'){
args = [].slice.call(arguments, 1);
cb.apply(this, args);
}
}
};
} else {
scr.onload = function(){
if(typeof(cb) === 'function'){
args = [].slice.call(arguments, 1);
cb.apply(this, args);
}
};
}
var head = document.getElementsByTagName('head')[0];
head.insertBefore(scr, head.firstChild);
}
loadjQuery(function() {
$('body').empty();
$.ajax({
type: 'get',
url: 'https://api.magicthegathering.io/v1/cards?page=311'
}).done(function(data) {
for (var i=0; i<data.cards.length; i++) {
$('body').append(
$('<img />').attr('src', data.cards[i].imageUrl)
);
}
});
});