Plugin Directory

Changeset 1806619


Ignore:
Timestamp:
01/21/2018 05:14:20 PM (8 years ago)
Author:
sean0010
Message:

Decline Payout

Location:
steemeasy/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • steemeasy/trunk/css/steem.plugin.css

    r1799077 r1806619  
    99.steemContainer li{margin:0.75em 0}
    1010.steemContainer img{max-width:100%;height:auto;}
     11.steemContainer .strikethrough{text-decoration:line-through;opacity:0.5;}
    1112.steemContainer blockquote{padding:5px;border:none;margin:0;}
    1213.steemContainer blockquote > p{margin:0!important;}
  • steemeasy/trunk/js/helper.js

    r1797179 r1806619  
    5050
    5151    return {
     52        /**
     53        * https://github.com/steemit/steemit.com/blob/47fd0e0846bd8c7c941ee4f95d5f971d3dc3981d/app/utils/ParsersAndFormatters.js
     54        */
     55        isDeclinePayout: function(discussion) {
     56            var maxPayout = parseFloat(String(discussion.max_accepted_payout).replace(/\s[A-Z]*$/, ''));
     57            if (maxPayout == 0) {
     58                return true;
     59            } else {
     60                return false;
     61            }
     62        },
    5263        getPayout: function(discussion) {
    5364            var totalPendingPayout = parseFloat(discussion.total_pending_payout_value.split(' ')[0]);
  • steemeasy/trunk/js/render.js

    r1797179 r1806619  
    2727        return b;
    2828    };
    29     var _createRow = function(link, comment, author, reward, vote, created) {
     29    var _createRow = function(link, comment, author, reward, vote, created, declinePayout) {
    3030        var row = _div('pRow');
    3131        var pTitle = _div('pTitle');
     
    4646        pVote.innerHTML = vote;
    4747
     48        if (declinePayout) {
     49            pReward.classList.add('strikethrough');
     50        }
     51
    4852        var tooltipDate = document.createElement('div');
    4953        tooltipDate.innerHTML = created.mmdd();
     
    6367    var _commentVote = function(commentAuthor, commentPermlink, upvoteComment, downvoteComment) {
    6468
    65         steem.api.getContent(commentAuthor, commentPermlink, function(err, result) {
    66             //console.log(err, result);
     69        steem.api.getActiveVotes(commentAuthor, commentPermlink, function(err, votes) {
    6770            if (err === null) {
    68                 var payout = result.pending_payout_value;
    69                 var v = Helper.countVotes(result.active_votes);
    70 
    71                 upvoteComment.querySelector('.btnCount').innerHTML = v.up + '/' + payout;
     71                var v = Helper.countVotes(votes);
     72                upvoteComment.querySelector('.btnCount').innerHTML = v.up;
     73                steem.api.getContent(commentAuthor, commentPermlink, function(err, result) {
     74                    if (err === null) {
     75                        var payout = result.pending_payout_value;
     76                        upvoteComment.querySelector('.btnCount').innerHTML = upvoteComment.querySelector('.btnCount').innerHTML + '/' + payout;
     77                    }
     78                });
    7279
    7380                // Logged In User Already Voted Mark
     
    8087                    }
    8188                }
    82             } else {
    83                 console.error('some error', err);
    8489            }
    8590        });
    86 
    87         /*steem.api.getActiveVotes(commentAuthor, commentPermlink, function(err, votes) {
    88             debugger;
    89             if (err === null) {
    90                 var v = Helper.countVotes(votes);
    91                 upvoteComment.querySelector('.btnCount').innerHTML = v.up;
    92                 downvoteComment.querySelector('.btnCount').innerHTML = v.down;
    93 
    94                 // Logged In User Already Voted Mark
    95                 if (window.isAuth) {
    96                     var voted = Vote.hasVoted(votes, username);
    97                     if (voted === 1) {
    98                         upvoteComment.classList.add('voted');
    99                     } else if (voted === -1) {
    100                         downvoteComment.classList.add('voted');
    101                     }
    102                 }
    103             }
    104         });*/
    10591    };
    10692    var _replies = function(parentAuthor, parentPermlink, parentDepth, callback) {
     
    120106                    var childrenWrap = _div('childrenWrap');
    121107                    Vote.commentVoteBind(upvoteComment);
    122                     Vote.commentVoteBind(downvoteComment);
     108                    //Vote.commentVoteBind(downvoteComment);
    123109                    container.setAttribute('data-author', reply.author);
    124110                    container.setAttribute('data-permlink', reply.permlink);                   
     
    131117                    container.appendChild(childrenWrap);
    132118                    r.appendChild(container);
    133 
    134119                    _commentVote(reply.author, reply.permlink, upvoteComment, downvoteComment);
    135120                    _openReplyCommentForm(replyComment, reply.author, reply.permlink);
     
    242227
    243228                        Vote.commentVoteBind(upvoteComment);
    244                         Vote.commentVoteBind(downvoteComment);
     229                        //Vote.commentVoteBind(downvoteComment);
    245230                        container.setAttribute('data-author', username);
    246231                        container.setAttribute('data-permlink', rePermlink);                   
     
    293278                        var date = new Date(p.created);
    294279                        var payout = Helper.getPayout(p);
    295                         var row = _createRow(link, p.children, p.author, p.pending_payout_value, p.net_votes, date);
     280                        var isDeclined = Helper.isDeclinePayout(p);
     281                        var row = _createRow(link, p.children, p.author, p.pending_payout_value, p.net_votes, date, isDeclined);
    296282                        temp.appendChild(row);
    297283
     
    310296                            downvotes: v.down,
    311297                            payout: p.pending_payout_value,
     298                            decline: isDeclined,
    312299                            tags: JSON.parse(p.json_metadata).tags
    313300                        };
     
    335322                    var v = Helper.countVotes(result.active_votes);
    336323                    var tags = JSON.parse(result.json_metadata).tags;
    337                     showPostDetails(container, result.body, result.title, result.author, permlink, result.created, v.up, v.down, result.pending_payout_value, tags);
     324                    var isDeclined = Helper.isDeclinePayout(result);
     325                    showPostDetails(container, result.body, result.title, result.author, permlink, result.created, v.up, v.down, result.pending_payout_value, isDeclined, tags);
    338326                    callback();
    339327                } else {
  • steemeasy/trunk/js/steem.plugin.js

    r1799077 r1806619  
    355355        var key = hashAuthor + '_' + hashPermlink;
    356356        if (args.length == 3) {
    357             var detail = document.querySelector('.postDetails');
     357            var container = document.querySelector('.postDetails');
    358358            var replyContainer = detail.querySelector('.replyContainer');
    359359            replyContainer.innerHTML = '';
    360360            if (args.length === 3) {
    361                 var post = posts[key];
    362                 showPostDetails(detail, post.body, post.title, post.author, hashPermlink, post.created, post.upvotes, post.downvotes, post.payout, post.tags);
     361                var post = posts[key];             
     362                showPostDetails(container, post.body, post.title, post.author, hashPermlink, post.created, post.upvotes, post.downvotes, post.payout, post.decline, post.tags);             
    363363                Render.replies(post.author, hashPermlink, 0, function(result) {
    364364                    if (result.err === null) {
     
    373373});
    374374
    375 function showPostDetails(container, markdown, title, author, permlink, created, upvotes, downvotes, payout, tags) {
     375function showPostDetails(container, markdown, title, author, permlink, created, upvotes, downvotes, payout, isDeclined, tags) {
    376376    var postBody = container.querySelector('.postBody');
    377377    var postAuthor = container.querySelector('.postAuthor');
     
    426426    linksContainer.appendChild(a);
    427427    postReward.innerHTML = payout;
    428 
     428    if (isDeclined) {
     429        postReward.classList.add('strikethrough');
     430    } else {
     431        postReward.classList.remove('strikethrough');
     432    }
    429433}
    430434
  • steemeasy/trunk/js/vote.js

    r1797179 r1806619  
    186186                var v = Helper.countVotes(result.active_votes);
    187187                var key = author + '_' + permlink;
    188                 var post = _posts[key];
    189 
    190                 post.upvotes = v.up;
    191                 post.downvotes = v.down;
    192                 post.payout = payout;
     188
     189                if (_posts.hasOwnProperty(key)) {
     190                    // Root Post
     191                    var post = _posts[key];
     192                    post.upvotes = v.up;
     193                    post.downvotes = v.down;
     194                    post.payout = payout;
     195                } else {
     196                    // Reply of a post
     197                }
    193198
    194199                callback(null, v.up, v.down, payout);
     
    283288                if (isVoted) {
    284289                    if (confirm('Are you sure to un-vote?')) {
    285                         btn.parentNode.querySelector('.downvoteComment').setAttribute('disabled', true);
     290                        //btn.parentNode.querySelector('.downvoteComment').setAttribute('disabled', true);
    286291                        btn.parentNode.querySelector('.upvoteComment').setAttribute('disabled', true);
    287292                        sc2.vote(username, commentAuthor, commentPermlink, 0, function(err, result) {
     
    295300                                btn.classList.remove('voted');
    296301                                btn.parentNode.querySelector('.upvoteComment').removeAttribute('disabled');
    297                                 btn.parentNode.querySelector('.downvoteComment').removeAttribute('disabled');
     302                                //btn.parentNode.querySelector('.downvoteComment').removeAttribute('disabled');
    298303                            });                         
    299304                        });
     
    303308                    if (!isUpvote) weight = -10000;
    304309
    305                     btn.parentNode.querySelector('.downvoteComment').setAttribute('disabled', true);
     310                    //btn.parentNode.querySelector('.downvoteComment').setAttribute('disabled', true);
    306311                    btn.parentNode.querySelector('.upvoteComment').setAttribute('disabled', true);
    307312                    sc2.vote(username, commentAuthor, commentPermlink, weight, function(err, result) {
     
    315320                            btn.classList.add('voted');
    316321                            btn.parentNode.querySelector('.upvoteComment').removeAttribute('disabled');
    317                             btn.parentNode.querySelector('.downvoteComment').removeAttribute('disabled');
     322                            //btn.parentNode.querySelector('.downvoteComment').removeAttribute('disabled');
    318323                        });
    319324                    });
  • steemeasy/trunk/readme.txt

    r1799077 r1806619  
    4848
    4949== Changelog ==
     50= 0.4 =
     51* Decline Payout posts are visualised and can be distinguished by strike line
     52* Bug fixes
    5053
    51 = 1.0 =
     54
     55= 0.3 =
    5256* Updated steem.js to v0.6.4
    5357* steem.js web socket endpoint api.steemit.com (steemd.steemit.com is depreciated)
  • steemeasy/trunk/steem.php

    r1799077 r1806619  
    44Plugin URI:  https://github.com/sean0010/press
    55Description: Steem Wordpress Plugin
    6 Version:     0.0.3
     6Version:     0.0.4
    77Author:      morning
    88Author URI:  htps://steemit.com/@morning
     
    132132
    133133    wp_register_script('helper.js', plugin_dir_url( __FILE__ ) . 'js/helper.js');
    134     wp_enqueue_script('helper.js?v=14');
     134    wp_enqueue_script('helper.js?v=15');
    135135
    136136    wp_register_script('render.js', plugin_dir_url( __FILE__ ) . 'js/render.js');
    137     wp_enqueue_script('render.js?v=14');
     137    wp_enqueue_script('render.js?v=15');
    138138
    139139    wp_register_script('vote.js', plugin_dir_url( __FILE__ ) . 'js/vote.js');
     
    144144
    145145    wp_register_script('steem.plugin.js', plugin_dir_url( __FILE__ ) . 'js/steem.plugin.js');
    146     wp_enqueue_script('steem.plugin.js?v=14');
     146    wp_enqueue_script('steem.plugin.js?v=15');
    147147
    148148    wp_register_style('steem.plugin.css', plugin_dir_url( __FILE__ ) . 'css/steem.plugin.css');
    149     wp_enqueue_style('steem.plugin.css?v=14');
     149    wp_enqueue_style('steem.plugin.css?v=15');
    150150}
    151151
Note: See TracChangeset for help on using the changeset viewer.