Spaces:
Sleeping
Sleeping
Commit ·
adc9a35
1
Parent(s): 6b63775
Change all the templates
Browse files- src/lists/templates/base.html +8 -34
- src/lists/templates/edit_text.html +0 -37
- src/lists/templates/home.html +56 -2
- src/lists/templates/list.html +0 -46
src/lists/templates/base.html
CHANGED
|
@@ -2,9 +2,10 @@
|
|
| 2 |
<html lang="en" data-bs-theme="dark">
|
| 3 |
|
| 4 |
<head>
|
| 5 |
-
<title>
|
| 6 |
<meta charset="utf-8">
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
| 8 |
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
| 9 |
</head>
|
| 10 |
|
|
@@ -13,43 +14,16 @@
|
|
| 13 |
|
| 14 |
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
|
| 15 |
<div class="col-lg-6 text-center">
|
| 16 |
-
<h1 class="display-1 mb-4">
|
| 17 |
-
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
name="item_text"
|
| 22 |
-
id="id_new_item"
|
| 23 |
-
placeholder="Enter a to-do item"
|
| 24 |
-
/>
|
| 25 |
-
|
| 26 |
-
<div class="mt-3">
|
| 27 |
-
<label for="id_new_priority" class="form-label"><h3>Priority :</h3></label>
|
| 28 |
-
<input
|
| 29 |
-
name="priority_text"
|
| 30 |
-
id="id_new_priority"
|
| 31 |
-
class="form-control"
|
| 32 |
-
placeholder="Enter a to-do priority"
|
| 33 |
-
/>
|
| 34 |
-
</div>
|
| 35 |
-
|
| 36 |
-
<p class="mt-3">
|
| 37 |
-
<input type="submit" value="Submit" class="btn btn-primary">
|
| 38 |
-
</p>
|
| 39 |
-
|
| 40 |
-
{% csrf_token %}
|
| 41 |
-
</form>
|
| 42 |
-
</div>
|
| 43 |
-
</div>
|
| 44 |
-
|
| 45 |
-
<div class="row justify-content-center">
|
| 46 |
-
<div class="col-lg-6">
|
| 47 |
-
{% block table %}
|
| 48 |
{% endblock %}
|
|
|
|
| 49 |
</div>
|
| 50 |
</div>
|
| 51 |
|
| 52 |
</div>
|
| 53 |
</body>
|
| 54 |
-
|
| 55 |
</html>
|
|
|
|
| 2 |
<html lang="en" data-bs-theme="dark">
|
| 3 |
|
| 4 |
<head>
|
| 5 |
+
<title>Calculator</title>
|
| 6 |
<meta charset="utf-8">
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 8 |
+
<!-- Keeping your local bootstrap reference -->
|
| 9 |
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
| 10 |
</head>
|
| 11 |
|
|
|
|
| 14 |
|
| 15 |
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
|
| 16 |
<div class="col-lg-6 text-center">
|
| 17 |
+
<h1 class="display-1 mb-4">Calculator</h1>
|
| 18 |
+
|
| 19 |
+
<!-- We removed the hardcoded form.
|
| 20 |
+
Now we just define a block where other pages can put their own content. -->
|
| 21 |
+
{% block content %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
{% endblock %}
|
| 23 |
+
|
| 24 |
</div>
|
| 25 |
</div>
|
| 26 |
|
| 27 |
</div>
|
| 28 |
</body>
|
|
|
|
| 29 |
</html>
|
src/lists/templates/edit_text.html
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<title>Edit Item</title>
|
| 5 |
-
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
| 6 |
-
</head>
|
| 7 |
-
<body class="bg-light">
|
| 8 |
-
<div class="container mt-5">
|
| 9 |
-
<div class="row justify-content-center">
|
| 10 |
-
<div class="col-md-6">
|
| 11 |
-
<div class="card shadow-sm">
|
| 12 |
-
<div class="card-header bg-white text-center py-3">
|
| 13 |
-
<h3 class="mb-0">แก้ไขรายการ (Edit Item)</h3>
|
| 14 |
-
</div>
|
| 15 |
-
<div class="card-body p-4">
|
| 16 |
-
<form method="POST">
|
| 17 |
-
{% csrf_token %}
|
| 18 |
-
<div class="mb-3">
|
| 19 |
-
<label class="form-label fw-bold">สิ่งที่จะแก้:</label>
|
| 20 |
-
<input type="text" name="item_text" value="{{ item.text }}" class="form-control form-control-lg" required>
|
| 21 |
-
</div>
|
| 22 |
-
<div class="mb-4">
|
| 23 |
-
<label class="form-label fw-bold">ความสำคัญ (Priority):</label>
|
| 24 |
-
<input type="text" name="priority" value="{{ item.priority }}" class="form-control" placeholder="เช่น High, Medium, Low">
|
| 25 |
-
</div>
|
| 26 |
-
<div class="d-grid gap-2">
|
| 27 |
-
<button type="submit" class="btn btn-primary btn-lg">บันทึก (Save Changes)</button>
|
| 28 |
-
<a href="/lists/{{ item.list.id }}/" class="btn btn-outline-secondary">ยกเลิก (Cancel)</a>
|
| 29 |
-
</div>
|
| 30 |
-
</form>
|
| 31 |
-
</div>
|
| 32 |
-
</div>
|
| 33 |
-
</div>
|
| 34 |
-
</div>
|
| 35 |
-
</div>
|
| 36 |
-
</body>
|
| 37 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/lists/templates/home.html
CHANGED
|
@@ -1,5 +1,59 @@
|
|
| 1 |
{% extends 'base.html' %}
|
| 2 |
|
| 3 |
-
{% block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{% extends 'base.html' %}
|
| 2 |
|
| 3 |
+
{% block content %}
|
| 4 |
+
<div class="card shadow-sm text-start">
|
| 5 |
+
<div class="card-body">
|
| 6 |
+
|
| 7 |
+
<!-- Input 1 -->
|
| 8 |
+
<div class="mb-3">
|
| 9 |
+
<input type="number" id="id_number_1" class="form-control form-control-lg" placeholder="Enter first number">
|
| 10 |
+
</div>
|
| 11 |
+
|
| 12 |
+
<!-- Input 2 -->
|
| 13 |
+
<div class="mb-3">
|
| 14 |
+
<input type="number" id="id_number_2" class="form-control form-control-lg" placeholder="Enter second number">
|
| 15 |
+
</div>
|
| 16 |
|
| 17 |
+
<!-- Buttons (type="button" ensures the browser doesn't try to submit a form) -->
|
| 18 |
+
<div class="d-grid gap-2 d-md-block mt-4 text-center">
|
| 19 |
+
<button type="button" id="id_btn_sum" class="btn btn-primary btn-lg" onclick="calculate('sum')">Sum</button>
|
| 20 |
+
<button type="button" id="id_btn_subtract" class="btn btn-danger btn-lg" onclick="calculate('subtract')">Subtract</button>
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
<!-- Result Display (Hidden by default) -->
|
| 24 |
+
<div class="mt-4 p-3 bg-light rounded border text-center" id="result_container" style="display:none;">
|
| 25 |
+
<h2 id="id_result" class="mb-0 text-dark"></h2>
|
| 26 |
+
</div>
|
| 27 |
+
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<script>
|
| 32 |
+
function calculate(action) {
|
| 33 |
+
// 1. Get values from inputs
|
| 34 |
+
const num1 = parseFloat(document.getElementById('id_number_1').value);
|
| 35 |
+
const num2 = parseFloat(document.getElementById('id_number_2').value);
|
| 36 |
+
let result = 0;
|
| 37 |
+
|
| 38 |
+
// 2. Validate input (Optional but good practice)
|
| 39 |
+
if (isNaN(num1) || isNaN(num2)) {
|
| 40 |
+
alert("Please enter valid numbers");
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// 3. Perform calculation
|
| 45 |
+
if (action === 'sum') {
|
| 46 |
+
result = num1 + num2;
|
| 47 |
+
} else if (action === 'subtract') {
|
| 48 |
+
result = num1 - num2;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// 4. Display the result
|
| 52 |
+
const resultElement = document.getElementById('id_result');
|
| 53 |
+
const container = document.getElementById('result_container');
|
| 54 |
+
|
| 55 |
+
resultElement.innerText = "Result: " + result;
|
| 56 |
+
container.style.display = 'block';
|
| 57 |
+
}
|
| 58 |
+
</script>
|
| 59 |
+
{% endblock %}
|
src/lists/templates/list.html
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
{% extends 'base.html' %}
|
| 2 |
-
|
| 3 |
-
{% block header_text %}Your To-Do list{% endblock %}
|
| 4 |
-
|
| 5 |
-
{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %}
|
| 6 |
-
|
| 7 |
-
{% block table %}
|
| 8 |
-
<table class="table table-hover mt-3" id="id_list_table">
|
| 9 |
-
<thead class="table-light">
|
| 10 |
-
<tr>
|
| 11 |
-
<th>No.</th>
|
| 12 |
-
<th>Item</th>
|
| 13 |
-
<th>Priority</th>
|
| 14 |
-
<th>Action</th>
|
| 15 |
-
</tr>
|
| 16 |
-
</thead>
|
| 17 |
-
<tbody>
|
| 18 |
-
{% for item in list.item_set.all %}
|
| 19 |
-
<tr>
|
| 20 |
-
<td>{{ forloop.counter }}</td>
|
| 21 |
-
|
| 22 |
-
<td>{{ item.text }}</td>
|
| 23 |
-
|
| 24 |
-
<td>
|
| 25 |
-
<span class="badge rounded-pill fw-normal fs-6
|
| 26 |
-
{% if item.priority == 'High' %}
|
| 27 |
-
bg-danger text-white
|
| 28 |
-
{% elif item.priority == 'Medium' %}
|
| 29 |
-
bg-warning text-dark
|
| 30 |
-
{% else %}
|
| 31 |
-
bg-secondary text-white
|
| 32 |
-
{% endif %}">
|
| 33 |
-
{{ item.priority }}
|
| 34 |
-
</span>
|
| 35 |
-
</td>
|
| 36 |
-
|
| 37 |
-
<td>
|
| 38 |
-
<a href="{% url 'edit_item' item.id %}" class="btn btn-outline-secondary btn-sm">
|
| 39 |
-
Edit
|
| 40 |
-
</a>
|
| 41 |
-
</td>
|
| 42 |
-
</tr>
|
| 43 |
-
{% endfor %}
|
| 44 |
-
</tbody>
|
| 45 |
-
</table>
|
| 46 |
-
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|