This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
bike for refugee #4
Open
Yjohn
wants to merge
6
commits into
CodeYourFuture:master
Choose a base branch
from
Yjohn:master
base: master
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8e2edba
create a new class for validating the form
Yjohn 36b8ae6
create a restriction for the forms
Yjohn 892f80d
adjusted the validation for the forms
Yjohn 30abe6a
reduce complexity of the code
Yjohn c268202
change the email validation code
Yjohn b7b6dbe
made all box red when the fields empty
Yjohn 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
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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // post code in ajax | ||
|
|
||
| function postMessage() { | ||
| var mainArticles = document.querySelector('#mainArticles'); | ||
| var textBox = document.querySelector('.addArticle'); | ||
|
|
||
| var request = new XMLHttpRequest(); //creating a request object | ||
|
|
||
| request.onreadystatechange = function () { | ||
| if (request.readyState === 4) { // check if a response was sent back | ||
| if (request.status === 200) { // check if request was successful | ||
| mainArticles.innerHTML = request.responseText; | ||
| } else { | ||
| mainArticles.innerHTML = 'An error occurred during your request: ' + request.status + ' ' + request.statusText; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| var url = "http://ajax-cyf.eu-west-1.elasticbeanstalk.com/chatroom/?id=cyf"; //server location | ||
| var params = textBox.value; // content we want to send | ||
| textBox.value = ''; | ||
| request.open("POST", url, true); // adding them to the request | ||
|
|
||
| request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //header info | ||
| request.send(params); | ||
|
|
||
| } | ||
| var postLetter = document.querySelector('#postMessageBtn'); | ||
| postLetter.addEventListener('click', postMessage); | ||
|
|
||
|
|
||
|
|
||
| // get code from the server | ||
|
|
||
| /*var request = new XMLHttpRequest(); //creating a request object | ||
|
|
||
| request.onreadystatechange = function() { | ||
| if(request.readyState === 4) { // check if a response was sent back | ||
| if(request.status === 200) { // check if request was successful | ||
| textBox.innerHTML = request.responseText; | ||
| } else { | ||
| textBox.innerHTML = 'An error occurred during your request: ' + request.status + ' ' + request.statusText; | ||
| } | ||
| } | ||
| } | ||
| var url = "http://ajax-cyf.eu-west-1.elasticbeanstalk.com/chatroom/?id=cyf"; //server location | ||
| request.open("GET", url); // adding it to the request | ||
|
|
||
| request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //header info | ||
| request.send(); // sending the request | ||
| */ |
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,79 @@ | ||
| var bluChange = document.querySelector('#blueBtn');// select the button and assign to the bluChange variable | ||
| bluChange.addEventListener('click', changeBlueColor);// create an Event and call the function | ||
|
|
||
| var oraChange = document.querySelector('#orangeBtn'); | ||
| oraChange.addEventListener('click', changeOrangeColor); | ||
|
|
||
| var greenChange = document.querySelector('#greenBtn'); | ||
| greenChange.addEventListener('click', changeGreenColor); | ||
|
|
||
| var myJumbo = document.querySelector('.jumbotron'); | ||
| var myDonate = document.querySelector('.btn-primary') | ||
| var volnter = document.querySelector('.btn-secondary') | ||
|
|
||
| function changeBlueColor() { | ||
| myJumbo.style.backgroundColor = '#588fbd'; | ||
| myDonate.style.backgroundColor = '#ffa500'; | ||
| volnter.style.backgroundColor = 'black'; | ||
| volnter.style.color = 'white'; | ||
| } | ||
|
|
||
| function changeOrangeColor() { | ||
| myJumbo.style.backgroundColor = '#f0ad4e'; | ||
| myDonate.style.backgroundColor = '#5751fd'; | ||
| volnter.style.backgroundColor = '#31b0d5'; | ||
| volnter.style.color = 'white'; | ||
| } | ||
|
|
||
| function changeGreenColor() { | ||
| myJumbo.style.backgroundColor = '#87ca8a'; | ||
| myDonate.style.backgroundColor = 'black'; | ||
| volnter.style.backgroundColor = '#8c9c08'; | ||
| } | ||
|
|
||
|
|
||
| var register = document.querySelector('#summitValid'); | ||
| register.addEventListener('click', validatFormFild); | ||
|
|
||
|
|
||
| function validatFormFild() { | ||
| event.preventDefault(); | ||
| var userName = document.querySelector('#example-text-input'); | ||
| var emailAddress = document.querySelector('#exampleInputEmail1'); | ||
| var textArea = document.querySelector('#exampleTextarea'); | ||
| var isEmail = false; | ||
| if ((emailAddress.value==="") && (userName.value==="") && (textArea.value==="")) { | ||
| alert('please Enter all the boxes'); | ||
| emailAddress.style.backgroundColor = 'red'; | ||
| userName.style.backgroundColor = 'red'; | ||
| textArea.style.backgroundColor = 'red'; | ||
| } | ||
| for (i = 0; i < emailAddress.value.length; i++) { | ||
| if (emailAddress.value[i] === '@') { | ||
| isEmail = true; | ||
| } | ||
| } | ||
| if (!isEmail) { | ||
| alert('please Enter a valid Email Address'); | ||
| emailAddress.style.backgroundColor = 'red'; | ||
|
|
||
| } | ||
| else if (!userName.value) { | ||
| alert('please Enter your user name?'); | ||
| userName.style.backgroundColor = 'red'; | ||
| } | ||
| else if (!textArea.value) { | ||
| alert('please discribe about yourself?'); | ||
| textArea.style.backgroundColor = 'red'; | ||
| } else { | ||
| //clear all the input | ||
| alert('thank you for filling out the form'); | ||
| userName.value = ''; | ||
| emailAddress.value = ''; | ||
| textArea.value = ''; | ||
| userName.style.backgroundColor = ''; | ||
| emailAddress.style.backgroundColor = ''; | ||
| textArea.style.backgroundColor = ''; | ||
| } | ||
|
|
||
| } |
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,73 @@ | ||
| // var donate = document.querySelector('#donateBike'); | ||
| // donate.addEventListener('click', showTheAlert); | ||
|
|
||
| // function showTheAlert() { | ||
| // alert('Donate button clicked'); | ||
| // } | ||
| /*var change = document.querySelector('#changeButtons'); | ||
| change.addEventListener('click', changeAll); | ||
|
|
||
| function appendParagraph() { | ||
| var paragraph = document.createElement('p'); | ||
| paragraph.innerText = "How are you?"; | ||
| var main = document.querySelector('#mainArticles'); | ||
| main.appendChild(paragraph); | ||
| } | ||
| function changeAll() { | ||
| changeTheColor(); | ||
| appendParagraph(); | ||
| changeParagraphColor(); | ||
| } | ||
|
|
||
| function changeParagraphColor(){ | ||
| var paragraphs = document.querySelectorAll('p'); | ||
| for(var i=0; i<paragraphs.length; i++){ | ||
| paragraphs[i].style.backgroundColor = 'blue'; | ||
| } | ||
| } | ||
| changeParagraphColor(); | ||
|
|
||
| */ | ||
|
|
||
|
|
||
| var donate = document.querySelector('#donateBike'); | ||
| donate.addEventListener('click', changeTheColor); | ||
|
|
||
| function changeTheColor(event) { | ||
| event.preventDefault(); | ||
| var myJumbo = document.querySelector('.jumbotron'); | ||
| myJumbo.className += " highlites"; | ||
| } | ||
|
|
||
|
|
||
| var addArticle = document.querySelector('#addArticleBtn'); | ||
| addArticle.addEventListener('click', appendArticle); | ||
|
|
||
| function appendArticle() { | ||
| var articleTextBox = document.querySelector('.addArticle'); | ||
|
|
||
| if (!articleTextBox.value) { | ||
| alert('please Enter the values'); | ||
| } else { | ||
| // 1. Create element based on input | ||
| var element = createArticle(articleTextBox.value); | ||
|
|
||
| // 2. Append input to main articles | ||
| var mainArticles = document.querySelector('#mainArticles'); | ||
| mainArticles.appendChild(element); | ||
|
|
||
| // 3. clear input | ||
| articleTextBox.value = ' '; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function createArticle(textBoxValue) { | ||
| var article = document.createElement('article'); | ||
| var element = document.createElement('div'); | ||
| element.className = 'article-title'; | ||
| article.className = 'article'; | ||
| element.innerText = textBoxValue; | ||
| article.appendChild(element); | ||
| return article; | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -156,4 +156,7 @@ body { | |
| .navbar-brand > img { | ||
| max-height: 80px; | ||
| } | ||
| } | ||
| .highlites{ | ||
| background: red; | ||
| } | ||
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.
I assume all of this is an extra. I am not sure what is the full intention so will no code review further but do follow the same principles as before.