|
|
|
function getRandom(max) {
|
|
|
|
var o = Math.round((Math.random())*max);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function place_imgs(window_size){
|
|
|
|
$.ajax({
|
|
|
|
dataType: 'jsonp',
|
|
|
|
url : 'https://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&action=query&generator=categorymembers&gcmtype=file&gcmtitle=Category:Special%20Issue%205&prop=imageinfo&iiprop=url&iiurlheight=150',
|
|
|
|
success : function(json) {
|
|
|
|
var pages=json.query.pages;
|
|
|
|
for (key in pages){
|
|
|
|
var img_url = pages[key].imageinfo[0].thumburl;
|
|
|
|
var img_w = pages[key].imageinfo[0].thumbwidth;
|
|
|
|
var img_h = pages[key].imageinfo[0].thumbheight;
|
|
|
|
var img_max_left = window_size.w - img_w;
|
|
|
|
var img_max_top = window_size.h - img_h;
|
|
|
|
var img_pos_left = ( getRandom(img_max_left).toString() )+"px";
|
|
|
|
var img_pos_top = ( getRandom(img_max_top).toString() )+"px";
|
|
|
|
|
|
|
|
var img_el = jQuery('<img />',{ src: img_url, class:'background'} );
|
|
|
|
$('div.background').append(img_el[0]);
|
|
|
|
|
|
|
|
img_el.css('left',img_pos_left,'!important')
|
|
|
|
.css('top',img_pos_top,'!important')
|
|
|
|
.css('z-index', (getRandom(pages.length)).toString() ,'!important')
|
|
|
|
.css('display','block');
|
|
|
|
|
|
|
|
// console.log(img_el, pages.length);
|
|
|
|
// console.log(img, img_w, img_h);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
var wh = {w: ($(window).width()), h: ($(window).height())} ;
|
|
|
|
place_imgs(wh);
|
|
|
|
})
|