3
0
mirror of https://github.com/reality/dbot.git synced 2025-02-02 15:44:33 +01:00
This commit is contained in:
reality 2013-04-16 21:19:11 +00:00
commit 2b2d256081
5 changed files with 59 additions and 23 deletions

View File

@ -1,4 +1,7 @@
{ {
"dbKeys": [ "imgur" ], "dbKeys": [ "imgur" ],
"dependencies": [ "web", "api" ] "dependencies": [ "web", "api" ]
"imagelength": 5,
"nsfwwarn": true,
"apikey": "86fd3a8da348b65"
} }

View File

@ -68,7 +68,7 @@ var imgur = function(dbot) {
'url': 'https://api.imgur.com/3/image/' + slug + '.json', 'url': 'https://api.imgur.com/3/image/' + slug + '.json',
'json': true, 'json': true,
'headers': { 'headers': {
'Authorization': 'Client-ID 86fd3a8da348b65' 'Authorization': 'Client-ID ' + dbot.config.imgur.apikey
} }
}, function(err, response, body) { }, function(err, response, body) {
this.db.totalApiRequests += 1; this.db.totalApiRequests += 1;

View File

@ -1,6 +1,6 @@
{ {
"webHost": "nourishedcloud.com", "webHost": "nourishedcloud.com",
"webPort": 8080, "webPort": 9001,
"externalPath": false, "externalPath": false,
"help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md" "help": "https://github.com/reality/depressionbot/blob/master/modules/web/README.md"
} }

View File

@ -8,17 +8,41 @@
padding:0; padding:0;
} }
#details {
display:none;
font-weight:700;
left:25px;
min-width:280px;
padding:20px;
text-align:center;
top:25px;
}
#link {
left:25px;
text-align:center;
width:168px;
}
#link,#loading {
font-family:monospace;
font-size:10px;
padding:10px;
top:95px;
}
#loading { #loading {
font-weight:500;
left:220px;
min-width:95px;
}
#loading,#details,#link {
background:rgba(43,43,43,0.8); background:rgba(43,43,43,0.8);
border-bottom-right-radius:5px; border-radius:5px;
border-top-right-radius:5px;
color:#85bf25; color:#85bf25;
font-family:sans-serif; font-family:sans-serif;
font-weight:700;
left:0;
padding:20px;
position:absolute; position:absolute;
top:50px;
} }
html,body { html,body {

View File

@ -11,21 +11,30 @@ html(lang='en')
count += 1; count += 1;
$('#loading').show(); $('#loading').show();
$('#loading').text('Loading image ' + count + '...'); $('#loading').text('Loading image ' + count + '...');
document.title = 'random imgur (' + count + ')';
$('#loading').fadeIn();
$('#image').load(function(){}); $('#image').load(function(){});
$.get("/api/imgur/getRandomImage", function(d) { $.get("/api/imgur/getRandomImage", function(d) {
$('#image').attr('src', d.data[0]); $('#image').attr('src', d.data[0]);
$('#details').text("Fetching info...");
$('#link').text(d.data[0]);
$('#link').attr('href',d.data[0]);
$.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) { $.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) {
if(info.data[0].indexOf('undefined') == -1) { if(info.data[0].indexOf('undefined') == -1) {
$("#loading").text(count + ': ' + info.data[0]); $("#details").text(count + ': ' + info.data[0]);
$('#details').show();
} else { } else {
$("#loading").hide(); $("#details").hide();
} }
$('#loading').fadeOut();
}, "json"); }, "json");
}, "json"); }, "json");
} }
$(getNewImage()); $(getNewImage());
$(document).on('keydown', function(e){(e.which==32)&&(getNewImage()) }); $(document).on('keydown', function(e){(e.which==32)&&(getNewImage()) });
body body
div#loading Loading Image div#loading Loading image 1...
div#details Press [SPACE] to load a new image
a#link [SPACE] for next
div#container div#container
img#image img#image