Skip to content

Commit 6ee9caa

Browse files
authored
Update sitemaplinks.html
1 parent 68d1dc9 commit 6ee9caa

File tree

1 file changed

+1
-94
lines changed

1 file changed

+1
-94
lines changed

src/Wiki/sitemaplinks.html

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -107,60 +107,11 @@
107107
color: #ff4d4d;
108108
}
109109

110-
li p {
111-
font-size: 1.1rem;
112-
color: #333;
113-
}
114-
115110
li small {
116111
font-size: 0.9rem;
117112
color: #777;
118113
}
119114

120-
/* Flexbox for Edit and Delete buttons */
121-
.button-container {
122-
display: flex;
123-
gap: 10px;
124-
position: absolute;
125-
top: 10px;
126-
right: 10px;
127-
}
128-
129-
.edit, .delete {
130-
padding: 8px 15px;
131-
border-radius: 5px;
132-
font-size: 1rem;
133-
cursor: pointer;
134-
transition: transform 0.2s ease;
135-
}
136-
137-
.edit {
138-
background-color: #ffcc00;
139-
color: white;
140-
}
141-
142-
.edit:hover {
143-
transform: scale(1.1);
144-
}
145-
146-
.delete {
147-
background-color: #ff4d4d;
148-
color: white;
149-
}
150-
151-
.report {
152-
background-color: #FFC0CB;
153-
color: white;
154-
}
155-
156-
.report:hover {
157-
transform: scale(1.1);
158-
}
159-
160-
.delete:hover {
161-
transform: scale(1.1);
162-
}
163-
164115
/* Mobile Responsive Styling */
165116
@media (max-width: 768px) {
166117
.form-container {
@@ -226,25 +177,12 @@ <h2>Wiki Posts</h2>
226177
wikis.forEach(wiki => {
227178
const li = document.createElement('li');
228179
li.innerHTML = `
229-
<h3>${wiki.title}</h3>
230-
<p>${wiki.content}</p>
231-
<small>Owner: ${wiki.owner}</small>
232-
<div class="button-container">
233-
${username && isOwnerOrAdmin(wiki.owner) ? `<button class="edit" onclick="editWiki('${wiki.title}')">Edit</button>` : ''}
234-
${username && isOwnerOrAdmin(wiki.owner) ? `<button class="delete" onclick="deleteWiki(${wiki.id})">Delete</button>` : ''}
235-
<a href="report.html">
236-
<button>Report</button>
237-
</div>
180+
<h3><a href="https://thejsurlback.onrender.com/wiki/${encodeURIComponent(wiki.title)}">${wiki.title}</a></h3>
238181
`;
239182
wikiList.appendChild(li);
240183
});
241184
};
242185

243-
// Check if user is the owner or admin
244-
const isOwnerOrAdmin = (owner) => {
245-
return owner === username || username === "kRxZy_kRxZy" || username === "MyScratchedAccount" || username === "mcgdj";
246-
};
247-
248186
// Create a new wiki
249187
createWikiForm.addEventListener('submit', async (e) => {
250188
e.preventDefault();
@@ -262,37 +200,6 @@ <h3>${wiki.title}</h3>
262200
createWikiForm.reset();
263201
});
264202

265-
// Delete a wiki
266-
window.deleteWiki = async (id) => {
267-
if (!username) {
268-
alert('You must be logged in to delete a wiki.');
269-
return;
270-
}
271-
272-
const response = await fetch(`${backendUrl}/wikis/${id}`, {
273-
method: 'DELETE',
274-
headers: { 'Content-Type': 'application/json' },
275-
body: JSON.stringify({ owner: username }), // Send username from localStorage
276-
});
277-
278-
if (response.ok) {
279-
fetchWikis(); // Refresh wiki list
280-
} else {
281-
alert('Not authorized to delete this wiki or wiki not found');
282-
}
283-
};
284-
285-
// Redirect to edit page
286-
window.editWiki = (title) => {
287-
if (!username) {
288-
alert('You must be logged in to edit a wiki. Go to https://scratch-coding-hut.netlify.app/account to log in.');
289-
return;
290-
}
291-
292-
// Redirect to the edit page with the 'edit' parameter
293-
window.location.href = `edit.html?edit=${encodeURIComponent(title)}`;
294-
};
295-
296203
// Initial fetch of wikis
297204
fetchWikis();
298205
});

0 commit comments

Comments
 (0)