SteemConnect support for SRD and bug fix
SteemRandomDraw is application that automate the draw.
SteemConnect support
Сonnecting the app with steemconnect seemed like something beyond possibilities. But thanks to steem developer portal, steemconnect sdk and this example I wrote test version of connection to steemconnect that was finalized by @deadzy.
It is steemlogin.js where I wrote all that needed to connection.
+function getQueryVariable(variable)
+{
+ var query = window.location.search.substring(1);
+ var vars = query.split("&");
+ for (var i=0;i<vars.length;i++) {
+ var pair = vars[i].split("=");
+ if(pair[0] == variable){return pair[1];}
+ }
+ return(false);
+}
+
+sc2.init({
+ app:'delayed-upvotes',
+ callbackURL: 'https://deadz.github.io/SteemRandomDraw/',
+ accessToken: 'access_token',
+ scope: ['comment']
+})
+
+//authentication
+var link = sc2.getLoginURL();
+if (window.location.search == "")
+ window.location.replace(link);
+//
+
+sc2.setAccessToken(getQueryVariable('access_token'));
+
+function commentWinnerList(author, authorPermlink, winners)
+{
+ var permlink = steem.formatter.commentPermlink(author, authorPermlink);
+ console.log(permlink);
+ console.log(winners);
+ var message = "test";
+ sc2.comment(author, authorPermlink, author, permlink, '', message, '', function(err, result) {
+ console.log(err, result);
+ });
+}
Bug with the multiple contest links
Desription
This bug appeared when you enter two different links in one session like with different authors or/and different permlink. The winner from the first contest was keeped in the list as well as the winner from second contest was added to the same list.
Solution
I added two boolean variables flag1 and flag2 one for sessionStorage.author and other for sessionStorage.permlink.
var flag1 = true;
var flag2 = true;
In the function getAuthorPermlink I added this lines:
flag1 = (sessionStorage.author == link_split.split(regex_v2)[0]);
flag2 = (sessionStorage.permlink == link_split.split(regex_v2)[1]);
Here I check if previous value of sessionStorage.author and sessionStorage.permlink were the same as in new contest link.
And finally:
if (!(flag1 && flag2))
{
win_list = [];
number_of_draws="1";
}
Here I set variables to their init value.
Contact
if you have some suggestions write it here or contact me on discord CleverShovel#7855
- app: https://deadz.github.io/SteemRandomDraw
- original repo: https://github.com/Deadz/SteemRandomDraw
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for your contribution.
Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.
[utopian-moderator]
Congratulations @clevershovel! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
To support your work, I also upvoted your post!
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last announcement from @steemitboard!
Hey @clevershovel I am @utopian-io. I have just upvoted you!
Achievements
Utopian Witness!
Participate on Discord. Lets GROW TOGETHER!
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