@@ -61,3 +61,80 @@ if ($('main').hasClass('feed') ) {
6161
6262 } )
6363}
64+
65+ if ( $ ( 'main' ) . hasClass ( 'profile' ) ) {
66+ let username = $ ( '.profile' ) . data ( 'username' )
67+
68+ steem . api . setOptions ( { url : 'wss://rpc.buildteam.io' } ) ;
69+
70+ let totalVestingShares , totalVestingFundSteem ;
71+
72+ steem . api . getDynamicGlobalProperties ( ( err , result ) => {
73+ totalVestingShares = result . total_vesting_shares ;
74+ totalVestingFundSteem = result . total_vesting_fund_steem ;
75+ } )
76+
77+ steem . api . getAccounts ( [ username ] , ( err , result ) => {
78+
79+ let user = result [ 0 ]
80+
81+ // store meta Data
82+ let jsonData = user . json_metadata ? JSON . parse ( user . json_metadata ) . profile : { }
83+ // steem power calc
84+ let vestingShares = user . vesting_shares ;
85+ let delegatedVestingShares = user . delegated_vesting_shares ;
86+ let receivedVestingShares = user . received_vesting_shares ;
87+ let steemPower = steem . formatter . vestToSteem ( vestingShares , totalVestingShares , totalVestingFundSteem ) ;
88+ let delegatedSteemPower = steem . formatter . vestToSteem ( ( receivedVestingShares . split ( ' ' ) [ 0 ] ) + ' VESTS' , totalVestingShares , totalVestingFundSteem ) ;
89+ let outgoingSteemPower = steem . formatter . vestToSteem ( ( receivedVestingShares . split ( ' ' ) [ 0 ] - delegatedVestingShares . split ( ' ' ) [ 0 ] ) + ' VESTS' , totalVestingShares , totalVestingFundSteem ) - delegatedSteemPower ;
90+
91+ // vote power calc
92+ let lastVoteTime = ( new Date - new Date ( user . last_vote_time + "Z" ) ) / 1000 ;
93+ let votePower = user . voting_power += ( 10000 * lastVoteTime / 432000 ) ;
94+ votePower = Math . min ( votePower / 100 , 100 ) . toFixed ( 2 ) ;
95+
96+ let data = {
97+ name : user . name ,
98+ image : jsonData . profile_image ? 'https://steemitimages.com/2048x512/' + jsonData . profile_image : '' ,
99+ rep : steem . formatter . reputation ( user . reputation ) ,
100+ effectiveSp : parseInt ( steemPower + delegatedSteemPower - - outgoingSteemPower ) ,
101+ sp : parseInt ( steemPower ) . toLocaleString ( ) ,
102+ delegatedSpIn : parseInt ( delegatedSteemPower ) . toLocaleString ( ) ,
103+ delegatedSpOut : parseInt ( - outgoingSteemPower ) . toLocaleString ( ) ,
104+ vp : votePower ,
105+ steem : user . balance . substring ( 0 , user . balance . length - 5 ) ,
106+ sbd : user . sbd_balance . substring ( 0 , user . sbd_balance . length - 3 ) ,
107+ numOfPosts : user . post_count ,
108+ followerCount : '' ,
109+ followingCount : '' ,
110+ usdValue : '' ,
111+ createdDate : new Date ( user . created )
112+ }
113+
114+
115+ steem . api . getFollowCount ( user . name , function ( err , result ) {
116+ data . followerCount = result . follower_count
117+ data . followingCount = result . following_count
118+ } )
119+
120+
121+ data . usdValue = steem . formatter . estimateAccountValue ( user )
122+
123+
124+ console . log ( data )
125+
126+ let template =
127+ `
128+ <section class="profile">
129+ <h2>${ data . name } - ${ data . rep } </h2>
130+ <img src="${ data . image } ">
131+ </section>
132+ `
133+
134+ $ ( 'main' ) . append ( template )
135+
136+
137+
138+
139+ } )
140+ }
0 commit comments