Skip to content

Commit

Permalink
v0.0.8 add tools and utopian posts tab
Browse files Browse the repository at this point in the history
  • Loading branch information
SteakOverCooked authored and SteakOverCooked committed Feb 5, 2018
1 parent 90f43b6 commit 56837bf
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function() {
(function($) {
let id;
let website;

Expand Down Expand Up @@ -28,4 +28,4 @@ $(function() {
}
}
});
})();
})(jQuery);
15 changes: 15 additions & 0 deletions js/steem.min.js

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions js/utopian.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,40 @@ function getTeamMembers(id, api, dom, div_of_chart) {
});
}

const getPosts = (id, dom, num = 10) => {
steem.api.setOptions({ url: 'https://api.steemit.com' });

var query = {
tag: id,
limit: num
};

steem.api.getDiscussionsByBlog(query, function (err, discussions) {
console.log(err, discussions);
if (!err) {
discussions.map(function (discussion) {
var li = document.createElement('li');
li.innerHTML = "<font color=gray><I>" + discussion.created + "</I></font>: <a target=_blank href='https://steemit.com/@" + discussion.author + "/" + discussion.permlink + "'>" + discussion.title + "</a>" + " @" + discussion.author;
dom.append(li);
});
}
});
}

const getData = (id, dom, item) => {
steem.api.setOptions({ url: 'https://api.steemit.com' });

steem.api.getAccounts([id], function(err, result) {
let s = "<ul>";
console.log(result);
$.each(item, function(index, value) {
s += "<li><i>" + value + "</i>: " + result[0][value] + "</li>";
});
s += "</ul>";
dom.html(s);
});
}

document.addEventListener('DOMContentLoaded', function() {
// init tabs
$(function() {
Expand Down Expand Up @@ -619,4 +653,23 @@ document.addEventListener('DOMContentLoaded', function() {
updateModeratorsById(id, "https://api.utopian.io/api/moderators", $("div#search_result_stats2"));
}
});
// get latest utopian posts
getPosts("utopian-io", $("ul#posts"), 20);
// get basic information
getData("utopian-io", $("div#info"), [
"name",
"balance",
"sbd_balance",
"last_vote_time",
"post_count",
"delegated_vesting_shares",
"voting_power",
"reputation"
]);
// rep calculator
$('button#btn_rep').click(function() {
let rep = parseInt($('input#steemit_reputation').val());
let reputation = steem.formatter.reputation(rep);
$('div#rep_result').html("Reputation of " + rep + " = <B>" + reputation + "</B>");
})
}, false);
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Utopian Moderator & Supervisor",
"short_name": "Utopian-IO",
"default_locale": "en",
"version": "0.0.7",
"version": "0.0.8",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Utopian Moderator & Supervisor",
Expand Down
19 changes: 17 additions & 2 deletions utopian-ext-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<link rel="stylesheet" href="css/export.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/jquery-ui.css" />
<script src="js/jquery-ui.js"></script>
<script src="js/steem.min.js"></script>
<style>
.ext-window {width: 750px;}
.ext-window {width: 770px;}
textarea {width: 100%;}
img {max-width: 100%;}
.chart {width: 100%; height: 570px;}
Expand All @@ -35,7 +36,9 @@
<li><a href="#tabs-moderators">Moderator</a></li>
<li><a href="#tabs-supervisor">Supervisor</a></li>
<li><a href="#tabs-chart">Chart</a></li>
<li><a href="#tabs-posts">Posts</a></li>
<li><a href="#tabs-setting">Setting</a></li>
<li><a href="#tabs-tools">Tools</a></li>
<li><a href="#tabs-log">Log</a></li>
</ul>
<div id="tabs-general">
Expand Down Expand Up @@ -84,7 +87,13 @@ <h4>Top Moderators by total_moderated</h4>
<div id='chartdiv_moderators_count' class="chart"> </div>
<h4>Top Moderators by total_paid_steem</h4>
<div id='chartdiv_moderators_total_paid' class="chart"> </div>
</div>
</div>
<div id="tabs-posts">
<h4>@utopian-io</h4>
<div id="info"> </div>
<h4>Latest Posts from @utopian-io</h4>
<ul id="posts"> </ul>
</div>
<div id="tabs-setting">
<p><h4>Your SteemId ID: </h4><input type='text' class='form-control' id='steemit_id' name='steemit_id' placeholder="Your Steem ID without @" value=''></p>
<p>
Expand All @@ -100,6 +109,12 @@ <h4>Additional ID's (Tab General)</h4>
</p>
<p><button class='form-control' style='width: 70px' id='save_id_btn'>Save</button></p>
</div>
<div id="tabs-tools">
<h4>Reputation Calculator</h4>
<p><input type='number' class='form-control' id='steemit_reputation' name='steemit_reputation' placeholder="Raw Reputation Value" value=''></p>
<p><button class='form-control' style='width: 110px' id='btn_rep'>Calculate</button></p>
<div id='rep_result'> </div>
</div>
<div id="tabs-log">
<h4>Proudly brought to you by <a target=_blank href="https://steemit.com/@justyy">@justyy</a></h4>
<textarea readonly class='form-control' rows=15 id='about'>
Expand Down

0 comments on commit 56837bf

Please sign in to comment.