yasershomaf / homeworks Goto Github PK
View Code? Open in Web Editor NEWThis repository contains all the required assignments by "Hack your future" team
This repository contains all the required assignments by "Hack your future" team
You prob only need your datastructure to be global. If not, youre doing something wrong. Look at other students hw to see how they solved this.
var reposList, repoItems, followers, publicRepos, intervalId;
var userInfo = [];
var oldRequest = "";
If I understand it correctly, what you're doing now is this:
userInfo[0] has the users profile info.
userInfo[1] has the users repo
userInfo[2] has the follower info
You could also follow this structure:
userInfo.profile = { name: resultJson.login, etc }
userInfo.repos = [repos]
userInfo.followers = [followers]
It will make the code more readable.
You could also add a list of features. Take a look at some other repos to see what I mean.
There is a lot of information coming through the API. Why not include at least the dates so it has some more info? Without context the events (besides the commits that have some) they have no or very little meaning.
You probably dont have to ask the user to update this info but ti's still a cool pattern.
var intervalId = setInterval(checkForUpdate, 60000);
function checkForUpdate() {
makeRequest(requestedURL).then(function(json) {
if (json.updated_at != userInfo[0].updatedAt) {
clearInterval(intervalId);
if (confirm("The data on user's page was updated on GitHub. It's probably better to include these updates. do you want that?")) {
//code here
}
}
});
}
There's really no need to do this since you load your js at the bottom of the body element.
If it's about protecting the scope, there are better ways to do that. Please ask me about this in class.
Now it's ugly and it makes your code indent unnecessarily.
userinput should only get userinput and then make a request. the result of that request should be sent to a function like storeProfileInfo, then you could make another request and call storeReposInfo, etc.
As a general rule you dont want to write css directly in js.
You could put this in the Week6 folder (and maybe rename the folder to have a more descriptive name)
I cannot use enter to search, however, when I press enter it does show the github info of the owner again. Could not find out why so fast
Functions should do just one thing. They should be short and self descriptive. Your getinputfield function does waaay to much. If you want to clear innerhtml for instance, you could do that in a separate function. Or even create a function called clearInnerHtml(element) that you pass html elements to.
It's just pasting linebreaks to every field and setting the innerHTML. Also you are using inline-css. This doesn't happen in the rest of the code either and you should've learned by now that this is a no-no ;)
Since this is a complex URL to construct it would be good to do it in parts (assign login to a var, name to a var, then concatenate the whole URL.
It would also make sense to have api.github.com
in a variable so you don't have to retype it the whole time (this can be global, for that it is very useful :))
Great, even better would be to make the first argument err
contain the actuall error or error message. So every function that needs a response can handle the error in it's own way.
Note that XmlHTTPRequest also has the onload
and onerror
events which might be even more useful since you don't have to check for the property message
.
Overal, very good work!
If you use if (/else) statements always use accolades, even though you only write one line and use indenting.
Look at some other students' work to get an idea of a better structure, or check this codepen:
https://codepen.io/Razpudding/pen/VbgKpd
This is due to:
It's confusing. Try calling it userName.
followers.style.color = "#000000";
publicRepos.style.color = "#ffffff";
IT's better to add and remoce CSS classes to achieve this effect. Take a look at my codepen examples to see how that's done.
It is now time to start loading your scripts like that. This makes it so you can place the content of your script anywhere and just bind to the event that is fired when the page is loaded and you can execute your initial function.
This also makes sure that you have no code execution on the global level (outisde of functions)
followerUListItem.innerHTML = userInfo[2][i][1][j];
These were both new assignments. Try to still complete them (link)
file.js is not(!) a good name. Why not name it after the functionality it holds? (Something with Github)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.