From d48c3ccb5e273730d2643366ecd6aa0dcb22e6f4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 8 Jul 2019 13:29:53 +0400 Subject: =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D0=B3=20javascript=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day9/task5/static/js/editForm.js | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 day9/task5/static/js/editForm.js (limited to 'day9/task5/static/js/editForm.js') diff --git a/day9/task5/static/js/editForm.js b/day9/task5/static/js/editForm.js new file mode 100644 index 0000000..f3f2bd8 --- /dev/null +++ b/day9/task5/static/js/editForm.js @@ -0,0 +1,56 @@ +function showContentBox() { + let elem = document.getElementById('backgroundTint'); + elem.classList.remove('hidden'); + elem.classList.add('shown'); + + elem = document.getElementById('contentBox'); + elem.classList.remove('hidden'); + elem.classList.add('shown'); +} + +function hideContentBox() { + let elem = document.getElementById('backgroundTint'); + elem.classList.remove('shown'); + elem.classList.add('hidden'); + + elem = document.getElementById('contentBox'); + elem.classList.remove('shown'); + elem.classList.add('hidden'); +} + +function showForm() { + let newEntryBtn = document.getElementById('newEntryBtn'); + newEntryBtn.style.display = 'none'; + + showContentBox(); + let contentBox = document.getElementById('contentBox'); + while (contentBox.firstChild) + contentBox.removeChild(contentBox.firstChild); + + contentBox.appendChild(elementFromHTML(baseFormFields)); + return contentBox; +} + +function hideForm() { + let newEntryBtn = document.getElementById('newEntryBtn'); + newEntryBtn.style.display = 'inline'; + + let contentBox = document.getElementById('contentBox'); + while (contentBox.firstChild) + contentBox.removeChild(contentBox.firstChild); + + hideContentBox(); +} + +function showEditForm() { + let contentBox = showForm(); + contentBox.firstChild.appendChild(elementFromHTML(formEditButtons)); + contentBox.firstChild.action = '/api/update'; +} + +function showCreateForm() { + let contentBox = showForm(); + contentBox.firstChild.appendChild(elementFromHTML(formCreateButtons)); + contentBox.firstChild.action = '/api/add'; + document.getElementById('formServiceId').disabled = false; +} -- cgit v1.2.3