Commit 7c051b94 authored by Martin Lees's avatar Martin Lees
Browse files

Avatar size is now fixed to 55*55 px and comments are sorted by payout

parent 1219ea6a
......@@ -8,7 +8,7 @@
text-align: right;
}
steempress_sp_cmmnt img { border: 0; max-width: 100%; }
steempress_sp_cmmnt img { border: 0; max-width: 100%; height: 55px;}
/* page layout structure */
......
......@@ -2,33 +2,13 @@
(function( $ ) {
'use strict';
/**
* All of the code for your admin-facing JavaScript source
* should reside in this file.
*
* Note: It has been assumed you will write jQuery code here, so the
* $ function reference has been prepared for usage within the scope
* of this function.
*
* This enables you to define handlers, for when the DOM is ready:
*
* $(function() {
*
* });
*
* When the window is loaded:
*
* $( window ).load(function() {
*
* });
*
* ...and/or other possibilities.
*
* Ideally, it is not considered best practise to attach more than a
* single DOM-ready or window-load handler for a particular page.
* Although scripts in the WordPress core, Plugins and Themes may be
* practising this, we should strive to set a better example in our own work.
*/
function compare_posts(a,b) {
if (a.payout < b.payout)
return 1;
if (a.payout > b.payout)
return -1;
return 0;
}
function get_whole_values(base_value, time_fractions) {
var time_data = [base_value];
......@@ -120,6 +100,8 @@
comments_ordered.push(get_replies(comment, comment_list, author_list));
}
return callback(comments_ordered);
});
}
......@@ -137,10 +119,12 @@
reply.payout = reply.pending_payout_value.replace("SBD", "");
reply.payout = (Math.floor(parseFloat(reply.payout)*100)/100);
reply.payout = reply.payout.toString()+" $";
comment.replies[i] = get_replies(reply, comment_list, author_list);
}
comment.replies.sort(compare_posts);
return comment;
}
......@@ -152,10 +136,10 @@
for (var i = 0; i < comments.length; i++)
{
str += "<li class=\"steempress_sp_cmmnt\">\n" +
" <div class=\"avatar\"><img src=\"https://steemitimages.com/u/"+comments[i].author+"/avatar\" width=\"55\" height=\"55\" alt=\""+comments[i].author+"'s avatar\"></div>\n" +
" <div class=\"avatar\"><img src=\"https://steemitimages.com/u/"+comments[i].author+"/avatar\" style='height: 55px; width: 55px' alt=\""+comments[i].author+"'s avatar\"></div>\n" +
" <div class=\"steempress_sp_cmmnt-content\">\n" +
" <header><a href=\"https://steemit.com/@"+comments[i].author+"\" class=\"userlink\">"+comments[i].author+"</a> - <span class=\"pubdate\">posted "+comments[i].date+"</span> </header>\n" +
" <p class=\"steempress_sp_comment_text\">"+comments[i].body+"</p>\n" + comments[i].payout.toString()+
" <header><a href=\"https://steemit.com/@"+comments[i].author+"\" class=\"userlink\">"+comments[i].author+"</a> - <span class=\"pubdate\">"+comments[i].date+"</span> </header>\n" +
" <p class=\"steempress_sp_comment_text\">"+comments[i].body+"</p>\n" + comments[i].payout.toString()+" $"+
" </div>\n"
if (comments[i].replies.length !== 0) {
......@@ -171,15 +155,18 @@
}
$(window).load(function () {
function load_steem_capabilities() {
const username = $("#steempress_sp_username")[0].innerText;
const permlink = $("#steempress_sp_permlink")[0].innerText;
const tag = $("#steempress_sp_tag")[0].innerText;
get_all_comments(username, permlink, tag, function (result) {
// TODO : Test this correctly
if (result.error)
return load_steem_capabilities();
var payout = "";
if (result[0].total_payout_value !== "0.000 SBD")
......@@ -187,19 +174,21 @@
else
payout = result[0].pending_payout_value.replace("SBD", "");
payout = (Math.floor(parseFloat(payout)*100)/100);
payout = payout.toString()+" $";
payout = (Math.floor(parseFloat(payout) * 100) / 100);
payout = payout.toString() + " $";
$("#steempress_sp_price")[0].innerHTML = payout;
var comment_str = "<h4>Steem Comments : </h4><div id=\"steempress_sp_comment_container\"><ul id=\"steempress_sp_comments\">";
var comment_str = "<p>Steem comments <a href=\"https://wordpress.org/plugins/steempress/\">powered by SteemPress</a> : </p> <div id=\"steempress_sp_comment_container\"><ul id=\"steempress_sp_comments\">";
comment_str += generate_comment_string(result[0].replies);
comment_str += "</ul></div>";
$("#steempress_sp_comments")[0].innerHTML = comment_str;
});
})
}
$(window).load(load_steem_capabilities)
})( jQuery );
......
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