twitst4tz

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4b37764326de5e9ea148c32685923f768ce26bef
parent 2d3d989f620d2d7d154c7eda874972914a1b320b
Author: underd0g1 <hide4@comcast.net>
Date:   Wed, 20 May 2020 01:16:29 -0400

created userstats page

Diffstat:
Mindex.js | 12++++++++----
Mviews/index.ejs | 19++++++++-----------
Aviews/userstats.ejs | 9+++++++++
3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/index.js b/index.js @@ -68,6 +68,7 @@ app.post('/userstatspage', function(req, res){ console.log('triggered the userstats page'); var username = req.body.username; + // console.log(username); var bearer = 'AAAAAAAAAAAAAAAAAAAAAGLfBQEAAAAAVeDxlZsqNtyYsN4qMmfrrKBDbUM%3DisXeBus50iY7LzBBJBiNXJpyllGkEaVnRNMdLJTvtdHX7MLxQ0'; async function userdata (username){ var url = 'https://api.twitter.com/1.1/users/show.json?screen_name='+ username; @@ -79,18 +80,20 @@ app.post('/userstatspage', function(req, res){ }); var response = await request.json() //test to make sure the data is coming in correctly - // console.log (response); + // console.log (response); //v ars var friends = response.friends_count; var followers = response.followers_count; - + console.log('friends ' + typeof friends ); + console.log('followers ' + followers); + var ratio = ( friends / followers); //console.log(response.screen_name); //console.log(response.followers_count); //console.log(response.friends_count) //calcs - var ratio = (response.friends_count / response.followers_count); - console.log(ratio); + //var ratio = (numeric(friends) / numeric(followers)); + //TODO: grab the actual data that we want to display to the end user //which would be : @@ -104,6 +107,7 @@ app.post('/userstatspage', function(req, res){ res.render('userstats', { username: username, + //pass the variables outside of the function. ratio: ratio, friends: friends, followers: followers diff --git a/views/index.ejs b/views/index.ejs @@ -55,27 +55,24 @@ <script> function openform(){ var userstatsform = document .getElementById('streamer'); - var twitterstream = document.getElementById('stream'); - var locationtrends = document.getElementById('location'); if (userstatsform.style.display === 'none'){ userstatsform.style.display= 'block'; }else { userstatsform.style.display== 'none'; } + } - - } </script> <div id = "options"> <span> - <button id ="userstats" onclick = 'openform();'>user stats</button> + <button id ="userstats" onclick = 'userlink();'>user stats</button> <button id = "stream" onclick = 'openform();'>tweet stream</button> - <button id ="location" onlclick = 'openform();'> location trends</button> + <button id ="location" onlclick = 'locationlink();'> location trends</button> </span> </div> -<div id = 'streamer' style = "display: none"> +<div id = 'streamer'> <form id = 'twitterstream' action = "/sendit" method = "post" > <div class="input-group mb-3"> <div class="input-group-append"> @@ -89,12 +86,12 @@ </form> </div> -<div id = 'streamer1' style ="display:none"> -<form id = 'userstatsform' action = "/userstatspage" method = "post" style = 'visibility:hidden'> +<div id = 'streamer1' > +<form id = 'userstatsform' action = "/userstatspage" method = "post"> <div class="input-group mb-3"> <div class="input-group-append"> <span> - <input type="text" name = 'tag' class="form-control" placeholder="@twitterdev" aria-label="Enter a username." aria-describedby="basic-addon2"></input> + <input type="text" name = 'username' class="form-control" placeholder="@twitterdev" aria-label="Enter a username." aria-describedby="basic-addon2"></input> <!-- <button id = 'submitbutton' class="btn btn-outline-secondary" type="button" value = "Submit">Submit</button> --> </span> @@ -103,7 +100,7 @@ </form> </div> -<div id = "locations" style = "visibility: hidden"> +<div id = "locations" > <form id = 'locationtrends' action = "/locationpage" method = "post"> <div class="input-group mb-3"> <div class="input-group-append"> diff --git a/views/userstats.ejs b/views/userstats.ejs @@ -0,0 +1,9 @@ +<html> + <head><title>hello</title></head> + <body> + <%=ratio %> + </body> + + + +</html>