dbot/views/imgur/imgurr.jade

41 lines
1.4 KiB
Plaintext
Raw Normal View History

2013-04-15 03:10:29 +02:00
!!! 5
html(lang='en')
head
meta(charset='utf-8')
script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js")
2013-04-15 03:50:50 +02:00
link(rel="stylesheet", href="/imgurr.css")
2013-04-15 03:10:29 +02:00
title random imgur
script
2013-04-15 23:55:50 +02:00
var count = 0;
function getNewImage() {
2013-04-15 23:55:50 +02:00
count += 1;
2013-04-17 22:02:36 +02:00
$('#loading').fadeIn();
$('#loading').text('Loading image ' + count + '...');
document.title = 'random imgur (' + count + ')';
$('#loading').fadeIn();
$('#image').load(function(){});
$.get("/api/imgur/getRandomImage", function(d) {
$('#image').attr('src', d.data[0]);
$('#details').text("Fetching info...");
2013-04-17 22:02:36 +02:00
$('<a href="' + d.data[0] + '">' + d.data[0] + '</a>').prependTo('#history').hide().slideDown();
$.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) {
2013-04-17 22:02:36 +02:00
if(info.data[0].indexOf('undefined') == -1) {
$("#details").text(count + ': ' + info.data[0]);
$('#details').show();
} else {
$("#details").hide();
}
$('#loading').fadeOut();
}, "json");
}, "json");
}
$(getNewImage());
$(document).on('keydown', function(e){(e.which==32)&&(getNewImage()) });
2013-04-15 03:10:29 +02:00
body
div#loading Loading image 1...
div#details Press [SPACE] to load a new image
2013-04-17 22:02:36 +02:00
div#history
a Press [SPACE] for next
2013-04-15 03:10:29 +02:00
div#container
2013-04-15 03:50:50 +02:00
img#image