summaryrefslogtreecommitdiff
path: root/day9
diff options
context:
space:
mode:
Diffstat (limited to 'day9')
-rw-r--r--day9/task5/server.py2
-rw-r--r--day9/task5/static/css/ContentBoxStyle.css2
-rw-r--r--day9/task5/static/css/TableStyle.css11
-rw-r--r--day9/task5/static/js/main.js22
4 files changed, 18 insertions, 19 deletions
diff --git a/day9/task5/server.py b/day9/task5/server.py
index c5178bd..8ee52a2 100644
--- a/day9/task5/server.py
+++ b/day9/task5/server.py
@@ -43,7 +43,7 @@ class MyHTTPRequestHandler(BaseHTTPRequestHandler):
'query': {'files': files}
}))
- elif content_type.split(';')[0] == 'text/plain':
+ elif content_type.split(';')[0] in ['text/plain', 'application/x-www-form-urlencoded']:
post_data = parse_qs(post_data.decode('utf-8'))
for key in post_data:
post_data[key] = post_data[key][0]
diff --git a/day9/task5/static/css/ContentBoxStyle.css b/day9/task5/static/css/ContentBoxStyle.css
index 5b7782d..abe9ee1 100644
--- a/day9/task5/static/css/ContentBoxStyle.css
+++ b/day9/task5/static/css/ContentBoxStyle.css
@@ -1,7 +1,7 @@
.contentBox {
padding: 20px;
width: 500px;
- height: 700px;
+ height: 695px;
background-color: #f0f0f0;
border-radius: 10px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3);
diff --git a/day9/task5/static/css/TableStyle.css b/day9/task5/static/css/TableStyle.css
index e4160fa..0631fbe 100644
--- a/day9/task5/static/css/TableStyle.css
+++ b/day9/task5/static/css/TableStyle.css
@@ -7,17 +7,16 @@ table {
thead > tr > th {
padding: 6px;
font-size: 24px;
- background-color: #6f6f6f;
+ background-color: #d5d5d5;
+ border: 1px black solid;
}
td {
- padding: 3px;
+ padding: 8px;
font-size: 21px;
+ border: 1px black solid;
}
-.odd { background-color: #dedede; }
-.even { background-color: #c5c5c5; }
-
.editableField:hover {
- background-color: rgba(0, 0, 0, 0.3);
+ background-color: rgba(0, 0, 0, 0.1);
}
diff --git a/day9/task5/static/js/main.js b/day9/task5/static/js/main.js
index 39c8c9b..2ac3958 100644
--- a/day9/task5/static/js/main.js
+++ b/day9/task5/static/js/main.js
@@ -46,7 +46,7 @@ const defaultColumnInputs = {
'notified_about_expiration': `<input type="text">`
};
-const baseFormFields = `<form id="tableForm" action="/update">
+const baseFormFields = `<form id="tableForm" action="/api/update" method="post">
<div class="formRow">
<div class="formRow-label">service_id</div>
<div class="formRow-input"><input type="text" name="service_id" class="formInput" id="formServiceId" disabled></div>
@@ -123,14 +123,14 @@ const baseFormFields = `<form id="tableForm" action="/update">
</form>`;
const formCreateButtons = `<div class="formButtons">
- <button type="button" onclick="hideForm()">Cancel</button>
- <button type="submit">Create</button>
- </div>`;
+ <button type="button" onclick="hideForm()">Cancel</button>
+ <button type="submit">Create</button>
+</div>`;
const formEditButtons = `<div class="formButtons">
- <button type="button" onclick="hideForm()">Cancel</button>
- <button type="submit">Update</button>
- </div>`;
+ <button type="button" onclick="hideForm()">Cancel</button>
+ <button type="submit">Update</button>
+</div>`;
const uploadFileHtml = '<img src="/static/images/upload_icon.png" alt="" style="width: 70%;height: 70%;">';
@@ -209,7 +209,6 @@ function renderTable(text) {
contentRow.setAttribute('id', `row_${row[0]}`);
row.forEach((column, colIndex) => {
- let color = (colIndex % 2 + rowIndex % 2) % 2 === 0 ? 'odd' : 'even';
let columnNode = document.createElement('td');
if (colIndex !== 0 && colIndex < data['headers'].length) {
@@ -219,7 +218,6 @@ function renderTable(text) {
columnNode.setAttribute('id', fieldId);
}
- columnNode.classList.add(color);
columnNode.innerHTML = column;
contentRow.appendChild(columnNode);
});
@@ -294,12 +292,14 @@ function showForm() {
showEditForm = () => {
let contentBox = showForm();
- contentBox.appendChild(elementFromHTML(formEditButtons));
+ contentBox.firstChild.appendChild(elementFromHTML(formEditButtons));
+ contentBox.firstChild.action = '/api/update';
};
showCreateForm = () => {
let contentBox = showForm();
- contentBox.appendChild(elementFromHTML(formCreateButtons));
+ contentBox.firstChild.appendChild(elementFromHTML(formCreateButtons));
+ contentBox.firstChild.action = '/api/add';
document.getElementById('formServiceId').disabled = false;
};