Repository navigation
Javascript 3 project branch #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
spiropoulos94
wants to merge
23
commits into
SocialHackerCreteClass:Nikos-Spiropoulos
Choose a base branch
from
spiropoulos94:javascript-3-project-branch
base: Nikos-Spiropoulos
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c2cb9b8
Create test.txt.txt
spiropoulos94 a086173
Create testReadme.txt
spiropoulos94 91cb85c
Create whoDoWeHaveHere.js
spiropoulos94 42f644b
exercise1 finished
spiropoulos94 dc3f122
programming humour added
spiropoulos94 727f9cc
exercise 3
spiropoulos94 8f5e955
Update index.html
spiropoulos94 06906b8
first comment work
spiropoulos94 da96f3d
little update on week1 of project
spiropoulos94 95da064
Update index.js
spiropoulos94 2768963
Update index.js
spiropoulos94 2c606d3
Update index.js
spiropoulos94 0db052f
Update index.js
spiropoulos94 81da1d6
Update index.js
spiropoulos94 1ce0036
update
spiropoulos94 0c3527f
week one part of project finished
spiropoulos94 c918bba
Update index.js
spiropoulos94 0cd011b
i love commiting
spiropoulos94 b33bffa
update
spiropoulos94 8fd4613
up to date
spiropoulos94 07f25bc
trying to implement repo replacing(progress from week 2)
spiropoulos94 c448476
added repo List, making of contributors list
spiropoulos94 2b95515
added some eye-hurting functionality for contributors banner
spiropoulos94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Parcel Sandbox</title> | ||
| <meta charset="UTF-8" /> | ||
| <script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="app"></div> | ||
|
|
||
| <script src="script.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //function using XMLHttp Request | ||
|
|
||
| let xhrObject = new XMLHttpRequest(); | ||
|
|
||
| xhrObject.addEventListener('error', xhrObjectErrorHandler); | ||
|
|
||
| function xhrObjectErrorHandler(event) { | ||
| console.log('Error'); | ||
| } | ||
| xhrObject.onreadystatechange = function() { | ||
| if (this.readyState == 4 && this.status == 200) { | ||
|
|
||
|
|
||
| let xhrObjectJason = JSON.parse(xhrObject.responseText); | ||
|
|
||
|
|
||
| let name = `${xhrObjectJason.results[0].name.first} ${xhrObjectJason.results[0].name.last}`; | ||
| document.body.innerHTML = `<h1> Hello ${name}, you were called using XmlHttpRequest.</h1>`; | ||
| } | ||
| }; | ||
|
|
||
| xhrObject.open('GET', 'https://www.randomuser.me/api'); | ||
| xhrObject.send(); | ||
|
|
||
| //function using axios | ||
|
|
||
| axios | ||
| .get('https://www.randomuser.me/api') | ||
| .then(function(response) { | ||
| let nameAxios = `${response.data.results[0].name.first} ${response.data.results[0].name.last}`; | ||
| document.body.innerHTML += `<h1> Hello ${nameAxios}, you were called using Axios.</h1>`; | ||
| }) | ||
| .catch(function(error) { | ||
| //console.log(error); | ||
| }); |
41 changes: 41 additions & 0 deletions
41
Week1/js-exercises-week1/exercise2 Programming Humour/app.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| let header = document.createElement('H1'); | ||
| header.innerHTML = `In this webpage you will see the latest post from xkcd.com <br> | ||
| First one is displayed with an XMLHttpRequest and second one is displayed with axios library `; | ||
| document.body.appendChild(header); | ||
| //document.body.appendChild | ||
|
|
||
| //function using XMLHttpRequest-------- | ||
|
|
||
| let xhrObject = new XMLHttpRequest(); | ||
|
|
||
| xhrObject.onreadystatechange = () => { | ||
| if (xhrObject.readyState == 4 && xhrObject.status == 200) { | ||
| let xhrObjectJason = JSON.parse(xhrObject.responseText); | ||
| let image = document.createElement('img'); | ||
| image.src = xhrObjectJason.img; | ||
| document.body.appendChild(image); | ||
| } | ||
| }; | ||
|
|
||
| xhrObject.open('GET', 'https://xkcd.now.sh/?comic=latest'); | ||
| xhrObject.onerror = err => { | ||
| console.log(err); | ||
| }; | ||
| xhrObject.send(); | ||
|
|
||
| //function using axios-------- | ||
|
|
||
| axios | ||
| .get('https://xkcd.now.sh/?comic=latest') | ||
| .then(function(response) { | ||
| // handle success | ||
| let axiosImage = document.createElement('img'); | ||
| axiosImage.src = response.data.img; | ||
| document.body.appendChild(axiosImage); | ||
|
|
||
| console.log(axiosImage); | ||
| }) | ||
| .catch(function(error) { | ||
| // handle error | ||
| console.log(error); | ||
| }); |
12 changes: 12 additions & 0 deletions
12
Week1/js-exercises-week1/exercise2 Programming Humour/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Parcel Sandbox</title> | ||
| <meta charset="UTF-8" /> | ||
| <script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <script src="app.js"></script> | ||
| </body> | ||
| </html> |
58 changes: 58 additions & 0 deletions
58
Week1/js-exercises-week1/exercise3 dog photo gallery/app.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| //made using xmlhttp request | ||
|
|
||
| let xmlObject = new XMLHttpRequest(); | ||
|
|
||
| function randomDogPhotoXml() { | ||
| xmlObject.onreadystatechange = function() { | ||
| if (this.readyState === 4 && this.status === 200) { | ||
| // Typical action to be performed when the document is ready: | ||
| let jsonObject = JSON.parse(xmlObject.responseText); | ||
| let button = document.querySelector('button'); | ||
|
|
||
| let image = document.createElement('img'); | ||
| image.setAttribute('width', '150px'); | ||
| image.setAttribute('height', '150px'); | ||
| image.src = jsonObject.message; | ||
|
|
||
| document.body.appendChild(image); | ||
|
|
||
| console.log(image); | ||
| } | ||
| }; | ||
|
|
||
| xmlObject.open('GET', 'https://dog.ceo/api/breeds/image/random'); | ||
| xmlObject.onerror = err => { | ||
| console.log(err); | ||
| }; | ||
| xmlObject.send(); | ||
| } | ||
|
|
||
| let buttonOne = document.getElementById('buttonOne'); | ||
| buttonOne.addEventListener('click', () => { | ||
| randomDogPhotoXml(); | ||
| }); | ||
|
|
||
| //made using axios | ||
|
|
||
| function randomDogPhotoAxios() { | ||
| axios | ||
| .get('https://dog.ceo/api/breeds/image/random') | ||
| .then(function(response) { | ||
| // handle success | ||
| let imageAxios = document.createElement('img'); | ||
| imageAxios.src = response.data.message; | ||
| imageAxios.setAttribute('width', '300px'); | ||
| imageAxios.setAttribute('height', '300px'); | ||
| console.log(imageAxios); | ||
| document.body.appendChild(imageAxios); | ||
| }) | ||
| .catch(function(error) { | ||
| // handle error | ||
| console.log(error); | ||
| }); | ||
| } | ||
|
|
||
| let buttonTwo = document.getElementById('buttonTwo'); | ||
| buttonTwo.addEventListener('click', () => { | ||
| randomDogPhotoAxios(); | ||
| }); |
19 changes: 19 additions & 0 deletions
19
Week1/js-exercises-week1/exercise3 dog photo gallery/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Random Dog Photo Gallery</title> | ||
| <meta charset="UTF-8" /> | ||
| <script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <button id="buttonOne"> | ||
| click me to add a random dog photo with XMLHttpRequest | ||
| </button> | ||
| <button id="buttonTwo"> | ||
| click me to add a random dog photo with Axios | ||
| </button> | ||
|
|
||
| <script src="app.js"></script> | ||
| </body> | ||
| </html> |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,29 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" | ||
| /> | ||
| <meta name="theme-color" content="#000000" /> | ||
| <meta name="apple-mobile-web-app-capable" content="yes" /> | ||
| <meta name="mobile-web-app-capable" content="yes" /> | ||
| <meta name="format-detection" content="telephone=no" /> | ||
| <link rel="apple-touch-icon" href="./hyf.png" /> | ||
| <link rel="shortcut icon" type="image/png" href="./hyf.png" /> | ||
| <title>HYF-GITHUB</title> | ||
| <link | ||
| href="https://fonts.googleapis.com/css?family=Roboto:400,700" | ||
| rel="stylesheet" | ||
| /> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
| </head> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
| <meta name="theme-color" content="#000000"> | ||
| <meta name="apple-mobile-web-app-capable" content="yes"> | ||
| <meta name="mobile-web-app-capable" content="yes"> | ||
| <meta name="format-detection" content="telephone=no"> | ||
| <link rel="apple-touch-icon" href="./hyf.png"> | ||
| <link rel="shortcut icon" type="image/png" href="./hyf.png" /> | ||
| <title>HYF-GITHUB</title> | ||
| <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"> | ||
| <link rel="stylesheet" href="./style.css"> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="root"></div> | ||
| <script src="./index.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
| <body> | ||
| <div id="root"> | ||
| <!-- here will be appended the javascript generated elements--> | ||
| </div> | ||
| <script src="./index.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,11 +30,24 @@ | |
| } | ||
|
|
||
| function renderRepoDetails(repo, ul) { | ||
| createAndAppend('li', ul, { text: repo.name }); | ||
| createAndAppend('li', ul, { text: ` Repository : ${repo.name}` }); | ||
| let a = createAndAppend('a', ul, { text: repo.name }); | ||
| a.setAttribute('href', repo.html_url); | ||
| a.setAttribute('target', '_blank'); | ||
| createAndAppend('p', ul, { text: `Description : ${repo.description}` }); | ||
| createAndAppend('p', ul, { text: `Forks : ${repo.forks}` }); | ||
| createAndAppend('p', ul, { text: `Update at : ${repo.updated_at}` }); | ||
| } | ||
|
|
||
| let reposBanner = document.createElement('H1'); | ||
| reposBanner.innerHTML = 'HYF REPOSITORIES'; | ||
| document.getElementById('root').appendChild(reposBanner); | ||
| reposBanner.className += 'banner'; | ||
|
|
||
| function main(url) { | ||
| fetchJSON(url, (err, repos) => { | ||
| //to repos anaferetai sto xhr.response | ||
| //olo ayto einai meros ths cb(callback function) | ||
|
spiropoulos94 marked this conversation as resolved.
Outdated
|
||
| const root = document.getElementById('root'); | ||
| if (err) { | ||
| createAndAppend('div', root, { | ||
|
|
@@ -44,6 +57,23 @@ | |
| return; | ||
| } | ||
| const ul = createAndAppend('ul', root); | ||
|
|
||
| repos.sort(function(a, b) { | ||
| return a['name'].toUpperCase() > b['name'].toUpperCase() | ||
|
spiropoulos94 marked this conversation as resolved.
Outdated
|
||
| ? 1 | ||
| : b['name'].toUpperCase() > a['name'].toUpperCase() | ||
| ? -1 | ||
| : 0; | ||
| }); | ||
|
|
||
| let reposIndices = []; | ||
| for (let x = 0; x < 10; x++) { | ||
| reposIndices.push(repos[x]); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a classic case of a map function |
||
|
|
||
| repos = reposIndices; | ||
| console.log(repos); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try not to use console.log in your final code |
||
|
|
||
| repos.forEach(repo => renderRepoDetails(repo, ul)); | ||
| }); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,26 @@ | ||
| .alert-error { | ||
| color: red; | ||
| background-color: pink; | ||
| padding: 2vh; | ||
| } | ||
|
|
||
| .banner { | ||
| background-color: blue; | ||
| color: white; | ||
| padding: 3%; | ||
| } | ||
|
|
||
| ul { | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| li { | ||
| font-weight: bolder; | ||
| border-style: groove; | ||
| list-style-type: none; | ||
| display: inline-block; | ||
| margin: auto; | ||
| padding: 1.5vw; | ||
| margin-left: 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be as little code as possible that leaves outside of a function. It is better to place this code inside a init() function of example and just call init at the beginning of your code