diff --git a/homework.html b/homework.html index 926360a..07438cd 100644 --- a/homework.html +++ b/homework.html @@ -80,7 +80,7 @@

Bikes for Refugees

- +

Learn more

diff --git a/index.html b/index.html index 6ce4ab3..7343b80 100644 --- a/index.html +++ b/index.html @@ -60,12 +60,16 @@

Bikes for Refugees

Donate a bike today Add to "Learn more" All images + Change Buttons
-
+ +
+ +

Learn more

@@ -145,5 +149,6 @@

Upcoming events

+ \ No newline at end of file diff --git a/js/ajax.js b/js/ajax.js new file mode 100644 index 0000000..2253638 --- /dev/null +++ b/js/ajax.js @@ -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 +*/ \ No newline at end of file diff --git a/js/homework.js b/js/homework.js index e69de29..5382eda 100644 --- a/js/homework.js +++ b/js/homework.js @@ -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 = ''; + } + +} \ No newline at end of file diff --git a/js/main.js b/js/main.js index e69de29..535139c 100644 --- a/js/main.js +++ b/js/main.js @@ -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 img { max-height: 80px; } +} +.highlites{ + background: red; } \ No newline at end of file