3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00
dbot/views/imgur/imgurr.jade
Douglas Gardner 9b191bc89a Add new "details" box to random imgur page
This commit adds a new box to the imgur page, separating the
"Loading..." box with a new "details" box, which contains the
information found via the API.

The loading box appears on the left, and disappears when an image is
loaded, to be replaced with a box on the right.

API operations, such as a "report" or "submit to gallery" option, could
appear below the current right-aligned box, in a smaller font.

I'm undecided as to whether this commit is an improvement or not.
2013-04-16 17:47:01 +00:00

33 lines
1.1 KiB
Plaintext

!!! 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")
link(rel="stylesheet", href="/imgurr.css")
title random imgur
script
var count = 0;
function getNewImage() {
count += 1;
$('#details').hide();
$('#loading').text('Loading image ' + count + '...');
$('#loading').css('font-size', ((count * 0.03) + 12));
$('#loading').show();
$('#image').load(function(){});
$.get("/api/imgur/getRandomImage", function(d) {
$('#image').attr('src', d.data[0]);
$.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) {
$("#details").text(count + ': ' + info.data[0]);
$('#details').show();
$('#loading').hide();
}, "json");
}, "json");
}
$(getNewImage());
$(document).on('keydown', function(e){(e.which==32)&&(getNewImage()) });
body
div#loading Loading Image
div#details Press [SPACE] to load a new image
div#container
img#image