From a6b096c7591dd284b8abb36f54117a6c011b3ded Mon Sep 17 00:00:00 2001 From: sudokode Date: Thu, 21 Jan 2016 01:02:17 -0500 Subject: [PATCH] Initial implementation --- js/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 803250c..213a2b4 100644 --- a/js/index.js +++ b/js/index.js @@ -215,7 +215,7 @@ var WWW = (function(undefined) { $('#uuid').val(uuid); } - function set_content(data, xhr) { + function set_content(data, xhr, id) { if (xhr.getResponseHeader('etag') == null) { try { @@ -229,6 +229,18 @@ var WWW = (function(undefined) { if (ct.startsWith("text/")) { $('#content').val(data); return; + } else if (ct.startsWith("image/")) { + var link = $('') + .attr('href', 'https://ptpb.pw/' + id) + .attr('target', '_blank') + .attr('title', 'Opens in a new window'); + + var img = $('') + .attr('src', 'https://ptpb.pw/' + id) + .attr('height', '10%') + .attr('width', '30%'); + + alert_new().append(alert_title('image loaded', $(link).append(img))); } else { alert_new().append(alert_title('status', 'cowardly refusing to display C-T: ' + ct)); } @@ -354,7 +366,7 @@ $(function() { spinner.removeClass('hidden'); api.paste.get(id).done(function(data, status, xhr) { - app.set_content(data, xhr); + app.set_content(data, xhr, id); spinner.addClass('hidden'); });