Commit a5801f57 by christian

non-essential

parent 867854de
function db() {
var x = arguments;
var p = 'DEBUG from ' + (new Error).stack.split("\n")[2];
console.log.apply(console, [p].concat(Array.prototype.slice.call(x)));
}
function cl() {
var x = arguments;
var p = 'LOG: ';
console.log.apply(console, [p].concat(Array.prototype.slice.call(x)));
}
function CityGuess(el, lvl) {
'use strict';
this.element = el;
this.level = lvl;
this.terms = 'world_skylines';
this.apiKey = '4a4db211fadccefa706aeb033fdb64dd';
this.flickUrl = 'https://api.flickr.com/services/rest/?format=json&jsoncallback=?&api_key=' + this.apiKey;
this.imgUrl = this.flickUrl + '&sort=random&method=flickr.photos.search&text=' + this.terms + '&per_page=250&page=' + Math.ceil(Math.floor(Math.random() * 100)) + '&tag_mode=all&media=photos&accuracy=11&has_geo=1';
this.map = {
39: 1,
37: 2,
32: 3
};
this.setup(this.element, this.level);
//&per_page=10
}
CityGuess.prototype.setup = function (slides, size) {
// For the sake of simplicity, some jobs are going to jquery..
var tileSizes = {
'small': 12,
'medium': 8,
'big': 4
},
winW = $(window).width(),
winH = $(window).height(),
$slideContent = slides,
$slideUl = $('<ul class="ul"/>');
this.tagArr = [];
$($slideContent).css({
width: '100%',
height: winH,
background: '#eee'
});
//$slideUl.css({
// margin: 0,
// padding: 0,
// width: '100%',
// height: winH,
// listStyle: 'none'
//});
// start Ajax action
this.getAjax($slideContent, $slideUl, this.tagArr);
} // end setup
CityGuess.prototype.getAjax = function ($slideContent, $slideUl, tagArr) {
var self = this;
var flickURL = this.flickUrl;
$.getJSON(this.imgUrl, function (data) {
var j = Math.floor(Math.random() * 251);
var i = Math.floor(Math.random() * 100);
i = Math.ceil(i), j = Math.ceil(j);
var z = data.photos.photo[j];
var $slideBox = $('<div />'), $slideLi = $('<li class="li" />');
var imgSRC = 'http://farm' + z.farm + '.static.flickr.com/' + z.server + '/' + z.id + '_' + z.secret + '_m.jpg',
imgID = z.id,
tagUrl = flickURL + '&method=flickr.photos.getInfo&photo_id=' + imgID,
geoUrl = flickURL + '&method=flickr.photos.geo.getLocation&accuracy=11&has_geo=1&photo_id=' + imgID,
sizeUrl = flickURL + '&method=flickr.photos.getSizes&photo_id=' + imgID + '&extras=url_o';
$.getJSON(tagUrl, function (data) {
if (data.stat != 'fail') {
data.photo.tags.tag.forEach(function (i) {
self.tagArr.push(i.raw)
});
}
cl(self.tagArr)
$.getJSON(geoUrl, function (data) {
if (data.stat != 'fail') {
cl('geo', data.photo.location.locality._content)
cl('geo2', data.photo.location)
if (data.photo.location.accuracy == 11) {
$.getJSON(geoUrl, function (data) {
cl('bloorb')
}());
}
else {
$.getJSON(sizeUrl, function (data) {
if (data.stat != 'fail') {
var src = data.sizes.size.pop().source;
render(src)
}
});
}
}
});
});
function render(src) {
$slideBox.css({
backgroundImage: 'url(' + src + ')'
});
}
$slideBox.addClass('slidebox');
$slideBox.css({
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
width: '100%',
height: $(window).height(),
maxHeight: $(window).height()
});
//$slideLi.css({
// display: 'block',
// float: 'left',
// margin: 0,
// padding: 0,
// width: '100%',
// height: $(window).height()
//});
$('#slider').append($slideBox);
//$slideUl.append($slideLi);
//$('#slider').append($slideUl);
}); // end ajax
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment