diff --git a/Call Book/add-user.html b/Call Book/add-user.html deleted file mode 100644 index 951c548..0000000 --- a/Call Book/add-user.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Edit contact - - - - - - -
- -
- - - - - diff --git a/Call Book/edit-contact.html b/Call Book/edit-contact.html deleted file mode 100644 index 81f4cb5..0000000 --- a/Call Book/edit-contact.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - Edit contact - - - - - - -
- -
- - - - - - diff --git a/Call Book/index.html b/Call Book/index.html index 403428b..cb55167 100644 --- a/Call Book/index.html +++ b/Call Book/index.html @@ -1,4 +1,4 @@ - + @@ -13,14 +13,21 @@
+
+ - + + + + + + diff --git a/Call Book/js/add-user.js b/Call Book/js/add-user.js index 300776a..bee2bbe 100644 --- a/Call Book/js/add-user.js +++ b/Call Book/js/add-user.js @@ -1,72 +1,10 @@ -class addUser{ +class AddUser{ constructor(options){ - +// this.context = new Context() } - contentEditable(){ - - let name = document.getElementById("Name") - let surname = document.getElementById("Surname") - - let doneBtn = document.querySelector('.done-btn') - let phone = document.querySelectorAll('.edit-info > .edit-field > input')[0] - let email = document.querySelectorAll('.edit-info > .edit-field > input')[2] - - const url = "http://easycode-js.herokuapp.com/GeogreTsendra13" - const serverAddUser = () =>{ - let user = { - fullName: `${name.value} ${surname.value} `, - email: email.value, - phone: phone.value - }; - const xhr = new XMLHttpRequest() - xhr.onreadystatechange = () =>{ - }; - xhr.open("POST", url + '/users', false); - xhr.setRequestHeader("Content-type","application/json") - xhr.send(JSON.stringify(user)) - xhr.timeout = 30000; - xhr.ontimeout = function() { - alert("Hi, you lose") - } - } - - doneBtn.addEventListener("click", e=>{ - if (name.value == " " - || surname.value == " " - || phone.value == " " - || email.value == " " - || typeof phone.value != "number" - || typeof name.value != "string" - || typeof surname.value != "string" - ){ - alert("Некорректно заполненая форма") - }else { - serverAddUser() - - } - }) - - window.addEventListener("keydown", e=>{ - if (e.keyCode == 13 ) { - if (name.value == " " - || surname.value == " " - || phone.value == " " - || email.value == " " - || typeof phone.value != "number" - || typeof name.value != "string" - || typeof surname.value != "string" - ){ - alert("Некорректно заполненая форма") - }else { - serverAddUser() - - } - } - }) - } @@ -104,7 +42,7 @@ constructor(options){ let main = document.getElementById('app') - main.innerHTML += `
+ main.innerHTML = `