Skip to content

Commit 6bcdc39

Browse files
authored
Update Wiki.html
1 parent 9d62957 commit 6bcdc39

File tree

1 file changed

+109
-14
lines changed

1 file changed

+109
-14
lines changed

Wiki/Wiki.html

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,29 @@
99

1010
async function fetchPages() {
1111
const response = await fetch(apiUrl);
12-
const pages = await response.json();
12+
const data = await response.json();
13+
14+
console.log('Fetched data:', data); // Log the response to check its structure
15+
16+
// Check if data has a record property or handle the structure appropriately
17+
const pages = data.record || []; // Adjust based on actual response structure
1318
renderPages(pages);
1419
}
1520

1621
async function createPage() {
17-
const title = prompt('Enter title:');
18-
const content = prompt('Enter content:');
22+
const title = document.getElementById('createTitle').value;
23+
const content = document.getElementById('createContent').value;
1924
if (!title || !content) return;
25+
2026
await fetch(apiUrl, {
2127
method: 'POST',
2228
headers: { 'Content-Type': 'application/json' },
2329
body: JSON.stringify({ title, body: content })
2430
});
31+
32+
// Clear the input fields and refresh the list of pages
33+
document.getElementById('createTitle').value = '';
34+
document.getElementById('createContent').value = '';
2535
fetchPages();
2636
}
2737

@@ -46,6 +56,7 @@
4656
function renderPages(pages) {
4757
const pagesDiv = document.getElementById('pages');
4858
pagesDiv.innerHTML = '';
59+
4960
pages.forEach(page => {
5061
pagesDiv.innerHTML += `
5162
<div class="card">
@@ -64,21 +75,105 @@
6475
window.onload = fetchPages;
6576
</script>
6677
<style>
67-
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #0f172a; color: #f8fafc; margin: 0; padding: 0; }
68-
.container { max-width: 800px; margin: 50px auto; padding: 20px; }
69-
.card { background: #1e293b; padding: 20px; border-radius: 16px; margin-bottom: 15px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5); transition: transform 0.2s, box-shadow 0.2s; }
70-
.card:hover { transform: scale(1.02); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7); }
71-
.card-content { margin-bottom: 10px; }
72-
.card-content strong { font-size: 1.5em; color: #38bdf8; }
73-
.actions { display: flex; gap: 10px; }
74-
button { padding: 10px 15px; border-radius: 12px; border: none; background: #38bdf8; color: #0f172a; font-weight: bold; cursor: pointer; transition: background 0.3s ease-in-out; }
75-
button:hover { background: #7dd3fc; }
78+
body {
79+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
80+
background: #0f172a;
81+
color: #f8fafc;
82+
margin: 0;
83+
padding: 0;
84+
}
85+
86+
.container {
87+
max-width: 800px;
88+
margin: 50px auto;
89+
padding: 20px;
90+
}
91+
92+
.card {
93+
background: #1e293b;
94+
padding: 20px;
95+
border-radius: 16px;
96+
margin-bottom: 15px;
97+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
98+
transition: transform 0.2s, box-shadow 0.2s;
99+
}
100+
101+
.card:hover {
102+
transform: scale(1.02);
103+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
104+
}
105+
106+
.card-content {
107+
margin-bottom: 10px;
108+
}
109+
110+
.card-content strong {
111+
font-size: 1.5em;
112+
color: #38bdf8;
113+
}
114+
115+
.actions {
116+
display: flex;
117+
gap: 10px;
118+
}
119+
120+
button {
121+
padding: 10px 15px;
122+
border-radius: 12px;
123+
border: none;
124+
background: #38bdf8;
125+
color: #0f172a;
126+
font-weight: bold;
127+
cursor: pointer;
128+
transition: background 0.3s ease-in-out;
129+
}
130+
131+
button:hover {
132+
background: #7dd3fc;
133+
}
134+
135+
.form-container {
136+
margin-bottom: 20px;
137+
background: #1e293b;
138+
padding: 20px;
139+
border-radius: 8px;
140+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
141+
}
142+
143+
.form-container input,
144+
.form-container textarea {
145+
width: 100%;
146+
padding: 10px;
147+
margin-bottom: 10px;
148+
border-radius: 8px;
149+
border: 1px solid #38bdf8;
150+
background: #0f172a;
151+
color: #f8fafc;
152+
font-size: 1em;
153+
}
154+
155+
.form-container button {
156+
width: 100%;
157+
}
158+
159+
h2 {
160+
font-size: 1.8em;
161+
color: #38bdf8;
162+
}
76163
</style>
77164
</head>
78165
<body>
79166
<div class="container">
80-
<button onclick="createPage()">➕ Create New Wiki</button>
81-
<div id="pages"></div>
167+
<h2>Create New Wiki</h2>
168+
<div class="form-container">
169+
<input type="text" id="createTitle" placeholder="Enter title" />
170+
<textarea id="createContent" placeholder="Enter content"></textarea>
171+
<button onclick="createPage()">➕ Create Wiki</button>
172+
</div>
173+
174+
<div id="pages">
175+
<!-- List of pages will appear here -->
176+
</div>
82177
</div>
83178
</body>
84179
</html>

0 commit comments

Comments
 (0)