-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.html
More file actions
258 lines (234 loc) · 12.6 KB
/
edit.html
File metadata and controls
258 lines (234 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/edit.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel='stylesheet' href='https://cdn-uicons.flaticon.com/3.0.0/uicons-thin-rounded/css/uicons-thin-rounded.css'>
<title>Edit Listings - Zenith Zone Realty</title>
<meta property="og:title" content="Zenith Zone Realty – Edit Listing">
<meta property="og:description" content="A lightweight real estate platform powered by localStorage, helping users list and find properties without middlemen.">
<meta property="og:image" content="https://orjihenry.github.io/zenithzone/assets/screenshots/desktop-screenshot.png">
<meta property="og:url" content="https://orjihenry.github.io/zenithzone/">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Zenith Zone Realty – Edit Listing">
<meta name="twitter:description" content="List and explore properties easily. No middlemen, no inflated fees.">
<meta name="twitter:image" content="https://orjihenry.github.io/zenithzone/assets/screenshots/desktop-screenshot.png">
</head>
<body>
<header class="header">
<nav>
<div class="logo-div">
<a href="index.html" class="logo-div">
<!-- <img src="assets/GOT.png" alt="Logo"> -->
<p class="logo">
Z
<span class="inner-logo">enith</span>
<span class="inner-logo">one</span>
</p>
<p class="realty">R <span class="inner-realty">ealty</span></p>
</a>
</div>
<div class="nav-hero">
<input type="checkbox" id="checkbox">
<label class="btn" for="checkbox"><i class="fa fa-bars"></i> <span>Menu</span></label>
<div class="sidebar">
<ul>
<a href="index.html"><li><i class="fa fa-house-user"></i>Home</li></a>
<a href="about.html"><li><i class="fa fa-lightbulb"></i>About</li></a>
<a href="listings.html" class="active"><li><i class="fa fa-line-chart"></i>Listings</li></a>
<a href="contact.html"><li><i class="fa fa-television"></i>Contact</li></a>
<a href="blog.html"><li><i class="fa fa-square-rss"></i>Blog</li></a>
</ul>
<div class="nav-button nav-add-mobile">
<a href="create.html" class="btn-add def-btn">Add Listings</a>
</div>
</div>
</div>
<div class="nav-button nav-add">
<a href="create.html" class="btn-add def-btn">Add Listings</a>
</div>
</nav>
</header>
<main>
<section class="form">
<form method="POST" id="update-form" class="update-form">
<h1>Update Listings</h1>
<p class="required">Marked fields are required *</p>
<div class="form-group">
<label for="title">Property Title *</label>
<input type="text" id="title" name="title" required>
</div>
<div class="form-group-two">
<div class="form-group prop-type">
<label for="property-type">Property Type *</label>
<select id="property-type" name="property-type" required>
<option value="" disabled selected>Select Property Type</option>
<option value="house">House</option>
<option value="apartment">Apartment</option>
<option value="condo">Condo</option>
<option value="cottage">Cottage</option>
</select>
</div>
<div class="form-group">
<label for="price">Price *</label>
<input type="number" id="price" name="price" required>
</div>
</div>
<div class="form-group-three">
<div class="form-group">
<label for="apt-number">Apt. Number</label>
<input type="text" id="apt-number" name="apt-number" placeholder="If Applicable">
</div>
<div class="form-group">
<label for="street-number">Street Number *</label>
<input type="number" id="street-number" name="street-number" required>
</div>
<div class="form-group">
<label for="street-name">Street Name *</label>
<input type="text" id="street-name" name="street-name" required>
</div>
</div>
<div class="form-group-three">
<div class="form-group">
<label for="city">City *</label>
<select name="city" id="city">
<option value="" disabled selected>Select City</option>
<option value="Torbay">Torbay</option>
<option value="Gander">Gander</option>
<option value="Paradise">Paradise</option>
<option value="St. John's">St. John's</option>
<option value="Mount Pearl">Mount Pearl</option>
<option value="Conception Bay South">Conception Bay South</option>
</select>
</div>
<div class="form-group">
<label for="province">Province/State *</label>
<select name="province" id="province">
<option value="" disabled selected>Select Province</option>
<option value="Quebec">Quebec</option>
<option value="Ontario">Ontario</option>
<option value="Manitoba">Manitoba</option>
<option value="Nova Scotia">Nova Scotia</option>
<option value="New Brunswick">New Brunswick</option>
<option value="Newfoundland & Labrador">Newfoundland & Labrador</option>
</select>
</div>
<div class="form-group">
<label for="country">Country *</label>
<input type="text" id="country" name="country" disabled>
</div>
</div>
<div class="form-group-three">
<div class="form-group">
<label for="bedrooms">Bedrooms *</label>
<input type="number" id="bedrooms" name="bedrooms" required>
</div>
<div class="form-group">
<label for="bathrooms">Bathrooms *</label>
<input type="number" id="bathrooms" name="bathrooms" required>
</div>
<div class="form-group">
<label for="garage">Garage *</label>
<input type="number" id="garage" name="garage" required>
</div>
</div>
<div class="form-group-two">
<div class="form-group">
<label for="Build Year">Build Year *</label>
<input type="number" id="build-year" name="build-year" required>
</div>
<div class="form-group">
<label for="Lot Area">Lot Area *</label>
<input type="number" id="lot-area" name="lot-area" required>
</div>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" value="" name="description" rows="4" required></textarea>
</div>
<div class="form-group">
<label for="images">Upload Image</label>
<label class="input-div" for="images">
<p>Drag and drop or click to upload</p>
<input type="file" id="images" name="images" multiple accept="image/*" style="display: none;">
</label>
<output id="image-preview"></output>
</div>
<div class="form-group">
<label for="status">Status</label>
<select id="status" name="status" required>
<option value="" disabled selected>Select Status</option>
<option value="available">Available</option>
<option value="sold">Sold</option>
</select>
</div>
<div class="form-group">
<label for="contact">Contact Information</label>
<input type="text" value="" id="contact" name="contact" required>
</div>
<div class="form-group" style="display: flex; gap: 20px;">
<button type="button" class="def-btn" onclick="validateForm();">Submit</button>
<button type="button" onclick="window.location.href = 'listings.html';" class="def-btn cancel-btn">Cancel</button>
</div>
</form>
</section>
</main>
<footer class="footer">
<small>© 2025 Zenith Zone Realty. All rights reserved.</small>
</footer>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
<script>
document.addEventListener("DOMContentLoaded", () => {
const urlParams = new URLSearchParams(window.location.search);
const id = parseInt(urlParams.get("id"));
const listings = JSON.parse(localStorage.getItem("listings")) || [];
const listing = listings.find(l => l.id === id);
let output = document.querySelector("#image-preview");
if (!listing) {
alert("Listing not found");
window.location.href = "listings.html";
return;
}
if (listing && listing.images && listing.images.length > 0) {
listing.images.forEach(imageUrl => {
const div = document.createElement("div");
div.classList.add("thumbnail-wrapper");
div.innerHTML = `
<span class="remove">×</span>
<img class="thumbnail" src="${imageUrl}" title="${imageUrl}"/>
`;
div.querySelector(".remove").addEventListener("click", () => {
output.removeChild(div);
imageUrls = imageUrls.filter(url => url !== imageUrl);
});
output.appendChild(div);
});
}
document.getElementById("title").value = listing.title;
document.getElementById("property-type").value = listing.propertyType;
document.getElementById("description").value = listing.description;
document.getElementById("price").value = listing.price;
document.getElementById("bedrooms").value = listing.bedrooms;
document.getElementById("bathrooms").value = listing.bathrooms;
document.getElementById("garage").value = listing.garage;
document.getElementById("lot-area").value = listing.lotArea;
document.getElementById("build-year").value = listing.buildYear;
document.getElementById("status").value = listing.status;
document.getElementById("contact").value = listing.contact;
document.getElementById("city").value = listing.city;
document.getElementById("apt-number").value = listing.aptNumber;
document.getElementById("street-number").value = listing.streetNumber;
document.getElementById("street-name").value = listing.streetName;
document.getElementById("province").value = listing.province;
document.getElementById("country").value = listing.country;
})
</script>