A Steem.js tutorial on making a vote weight slider for minnows

in utopian-io •  6 years ago  (edited)

What Will I Learn?

The Steemit interface gives a vote slider for minnows only when they are over 500SP.

This is also valid for the downvotes.

There are many other interfaces that provide you this ability but if you are interested how to make one for yourself, this is the correct tutorial.

  • Using steem.js API to broadcast upvote or downvote with the desired percentage.
  • Make a slider to decide the percentage of the vote.
  • Take out the author and permlink from a given steemit post or comment URL in javascript.

Requirements

No requirement, just a text editor ( notepad is fine ) and any internet browser
Basic javascript knowledge and basic HTML knowledge would help.

Difficulty

  • Basic

Tutorial Contents

We need four HTML elements for the vote slider
1- A slider that can take a value between -100 and +100

image.png

2- An input box where we will paste the URL of the post or comment that we will upvote or downvote

image.png

3- A button to complete the action

image.png

4- A message to inform us when the operation is performed

image.png

Complete code

Complete code can be found at GitHub : https://github.com/firedreamgames/upvote_and_downvote_slider/blob/master/upvote_slider.html

image.png

Step-by-step instructions

  • Making the input box

image.png

An HTML element where we paste the URL we copied from SteemIt.

  • Making the slider

image.png

When the slider value is changed, we send this value to a function ShowValue to display the value selected.

The slider ranges between -100 to +100 allowing downvotes(flags) also.

  • Making the button

image.png

The button, when presses calls the send_vote() function

  • Making the Elements Function with JavaScript

Include steem.js API in the project

image.png

Make a function to show value of slider

image.png

Build the vote sending fuction

image.png
Write your Steemit Name without @ and your posting key in the code.

Read the voting weight and URL from HTML

image.png

Find author and permlink from URL

image.png

Use steem.js API to broadcast the vote and inform user

image.png

Contact

@FireDream - Steemit

@firedream#3528 - Discord

Links

GitHub for tutorial : https://github.com/firedreamgames/upvote_and_downvote_slider

Proof of Work

image.png



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Excellent tutorial for those learning about Steem api . . . and useful!

Thank you @tibra, learning by doing is the best way.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

@redart,
I wasn't sure of it whether to use steem-js repo or my repo.
Thank you for correcting it and your approval.
For code blocks, I will sure consider it for next contributions.

FD.

Hey @firedream I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you @utopian-io