forked from HackYourFuture/JavaScript3
-
Notifications
You must be signed in to change notification settings - Fork 2
Week1-AmirHossein-Exercises #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
89d60ef
Exe1 is added
amirhshad 0f3b67f
Ex1 error handling is added
amirhshad 6c49686
Ex2 is added
amirhshad baf3130
Exe3 is added
amirhshad 322895e
Ex3 finished
amirhshad ee86b14
Margin added to ex3
amirhshad 6dfc70c
Project html and css is added
amirhshad 54babac
Hackyourrep-app added
amirhshad c6caf84
Hackyourrep midifications
amirhshad 08d62cf
Folder name AmirHossein is added
amirhshad 49647bc
Ex1 as aded - some bugs need to be solved
amirhshad 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
8000
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,59 @@ | ||
| const XMLBtn = document.getElementById('btn1'); | ||
| const AxiosBtn = document.getElementById('btn2'); | ||
|
|
||
| function xhrMethod() { | ||
| const xhr = new XMLHttpRequest(); | ||
| const li = document.createElement('li'); | ||
| const image = document.createElement('img'); | ||
| const ul = document.getElementById('list'); | ||
| const url = 'https://dog.ceo/api/breeds/image/random' | ||
| xhr.open('GET', url); | ||
| xhr.send(); | ||
| xhr.onreadystatechange = processRequest; | ||
|
|
||
| ul.appendChild(li.appendChild(image)) | ||
|
|
||
| function processRequest(e) { | ||
| if(xhr.readyState == 4 && xhr.status == 200) { | ||
| let response = JSON.parse(xhr.responseText); | ||
| image.src = response.message; | ||
| image.style.width = '300px' | ||
| image.style.height = '300px' | ||
| image.style.margin = '5px' | ||
|
|
||
| }; | ||
| }; | ||
| xhr.onerror = function() { | ||
| if (xhr.status != 200) { | ||
| alert (`Error ${xhr.status}: ${xhr.statusText}`); | ||
| }; | ||
| }; | ||
|
|
||
| }; | ||
|
|
||
| XMLBtn.addEventListener('click', xhrMethod); | ||
|
|
||
|
|
||
|
|
||
| function axiosMethod() { | ||
| const li = document.createElement('li'); | ||
| const image = document.createElement('img'); | ||
| const ul = document.getElementById('list'); | ||
| ul.appendChild(li.appendChild(image)) | ||
| axios | ||
| .get('https://dog.ceo/api/breeds/image/random') | ||
| .then(function(response) { | ||
amirhshad marked this conversation as resolved.
10000
span>
Show resolved
Hide resolved
|
||
|
|
||
| image.src = response.data.message; | ||
| image.style.width = '300px' | ||
| image.style.height = '300px' | ||
| image.style.margin = '5px' | ||
|
|
||
| }) | ||
| .catch(function(error) { | ||
| console.log(error) | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| AxiosBtn.addEventListener('click', axiosMethod); | ||
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,40 @@ | ||
| function xhrMethod() { | ||
| const xhr = new XMLHttpRequest(); | ||
| const url = 'https://www.randomuser.me/api' | ||
|
|
||
| xhr.open('GET', url); | ||
| xhr.send(); | ||
|
|
||
| xhr.onreadystatechange = processRequest; | ||
|
|
||
| function processRequest(e) { | ||
| if(xhr.readyState == 4 && xhr.status == 200) { | ||
| let respons = JSON.parse(xhr.responseText); | ||
| console.log(respons) | ||
| } | ||
| } | ||
|
|
||
| xhr.onerror = function() { | ||
| if (xhr.status != 200) { | ||
| alert (`Error ${xhr.status}: ${xhr.statusText}`) | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| const axios = require('axios'); | ||
| function axiosMethod() { | ||
| axios | ||
| .get('https://www.randomuser.me/api') | ||
| .then(function(response) { | ||
| console.log(response.data); | ||
| }) | ||
| .catch(function(error) { | ||
| console.log(error) | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| axiosMethod(); | ||
| xhrMethod(); |
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,42 @@ | ||
|
|
||
|
|
||
| function xhrMethod() { | ||
| const xhr = new XMLHttpRequest(); | ||
| const url = 'https://xkcd.now.sh/?comic=latest' | ||
| xhr.open('GET', url); | ||
| xhr.send(); | ||
| xhr.onreadystatechange = processRequest; | ||
| function processRequest(e) { | ||
| if(xhr.readyState == 4 && xhr.status == 200) { | ||
| let response = JSON.parse(xhr.responseText); | ||
| document.getElementsByTagName('img').src = response.img; | ||
| console.log(response); | ||
| }; | ||
| }; | ||
| xhr.onerror = function() { | ||
| if (xhr.status != 200) { | ||
| alert (`Error ${xhr.status}: ${xhr.statusText}`); | ||
| 10BC0 | }; | |
| }; | ||
| }; | ||
|
|
||
| xhrMethod(); | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| function axiosMethod() { | ||
| axios | ||
| .get('https://xkcd.now.sh/?comic=latest') | ||
| .then(function(response) { | ||
| console.log(response.data); | ||
| document.getElementsByTagName('img').src = response.data.img; | ||
| }) | ||
| .catch(function(error) { | ||
| console.log(error) | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| axiosMethod(); |
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,20 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Dog Gallery</title> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <button id="btn1">XMLHttpRrquest</button> | ||
| <button id="btn2">Axios</button> | ||
| <ul id="list"></ul> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
| <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
| <script src="dogGallery.js"></script> | ||
| </body> | ||
| </html> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
0
Week2/assets/week2.png → Week2/AmirHossein/assets/week2.png
100755 → 100644
File renamed without changes
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,16 @@ | ||
| const getAnonName = (firstName) => { | ||
| return new Promise((resolve, reject) => { | ||
| const fullName = `${firstName} Doe` | ||
| resolve(fullName) | ||
| console.log(fullName) | ||
|
|
||
|
|
||
|
|
||
| reject(new Error("You didn't pass in a first name!")) | ||
|
|
||
| }) | ||
|
|
||
|
|
||
| }; | ||
|
|
||
| getAnonName() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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,96 @@ | ||
| /* | ||
| /* | ||
| Write here your CSS rules for HackYourRepo! | ||
| */ 4B72 | ||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| box-sizing: border-box; | ||
|
|
||
| } | ||
|
|
||
| #header { | ||
| color: white; | ||
| height: 50px; | ||
| background-color: #3f51b5; | ||
| display: flex; | ||
| align-items: center; | ||
| padding: 20px; | ||
|
|
||
| } | ||
| p { | ||
| margin-right: 30px; | ||
| } | ||
|
|
||
| .container { | ||
| width: 80%; | ||
| margin: 0 auto; | ||
|
|
||
|
|
||
| } | ||
|
|
||
| .bottom-box { | ||
|
|
||
| display: flex; | ||
| flex-direction: row; | ||
| height: auto; | ||
| } | ||
|
|
||
| #left-side { | ||
| margin-top: 10px; | ||
| width: 50%; | ||
|
|
||
| } | ||
| .card { | ||
| margin-left: 5px; | ||
| margin-top: 5px; | ||
| box-shadow: | ||
| 0px 20px 30px 0px rgba(0, 0, 0, 0.05), | ||
| 0px 4px 4px 0 rgba(0, 0, 0, .15), | ||
| 1px 2px 2px 0 rgba(0, 0, 0, .2); | ||
| font-size: 2vmin; | ||
| } | ||
| .card .col-right { | ||
| padding-left: 30px; | ||
| padding-right: 25px; | ||
|
|
||
| } | ||
| .col-left { | ||
|
|
||
| padding: 5px 0 0 5px; | ||
| } | ||
| #right-side { | ||
|
|
||
| width: 50%; | ||
| } | ||
|
|
||
| #contributor { | ||
| margin-top: 10px; | ||
| margin-left:0.4rem; | ||
| color: darkgray; | ||
| box-shadow: none; | ||
| padding-top: 1rem; | ||
| padding-left: 0.3rem; | ||
| border: 1px solid rgba(0, 0, 0, 0.12); | ||
| border-bottom: none; | ||
| height: 3em; | ||
| } | ||
| .small-card { | ||
| display: flex; | ||
| justify-content: flex-start; | ||
| align-items: center; | ||
| margin: 0.4rem; | ||
| } | ||
| img { | ||
| margin: 1rem; | ||
| } | ||
|
|
||
|
|
||
| .badge { | ||
| margin-left: auto; | ||
| background-color: #a9a9a9; | ||
| color: white; | ||
| border-radius: 4px; | ||
| margin-right: 1rem; | ||
| margin-top: 1.3rem; | ||
| padding: 0.1rem 0.8rem; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.