-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.html
109 lines (87 loc) · 2.4 KB
/
homepage.html
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
<html>
<head>
<title>"Homepage"</title>
<meta charset = "utf-8"/>
</head>
<body>
<h1>
Homepage
</h1>
<div>
<table id = "postlist" style="width:100%">
<tr>
<th>Title</th>
<th>Description</th>
<th>Time</th>
<th>Update</th>
<th style="display : none">Delete</th>
</tr>
</table>
</div>
<br/ >
<input onCLick="" type="button" id="newpost" name="newpost" value="New Post"/>
<div id="popup">
<label>Title<input type="text" id="title" name="tile" value=""/></label>
<br/ >
<label>Description<input type="text" id="desc" name="desc" value=""/></label>
<input onCLick="" type="button" id="post" name="post" value="Post"/>
</div>
<div></div>
<br/ >
<a href="login.html">Log Out</a>
</body>
<script>
window.onload = () => {
document.getElementById("newpost").onclick=(function(){
var popup = document.getElementById("popup");
popup.style.display = "block";
document.getElementById("post").onclick=(function(){
var postTitle;
var postDesc;
var curTime = new Date().toLocaleString();
postTitle = document.getElementById("title").value;
postDesc = document.getElementById("desc").value;
popup.style.display = "none";
tabBody=document.getElementsByTagName("TBODY").item(0);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
cell3 = document.createElement("TD");
cell4 = document.createElement("TD");
let delButton = document.createElement('button');
delButton.innerHTML = "Update";
textnode1=document.createTextNode(postTitle);
textnode2=document.createTextNode(postDesc);
textnode3=document.createTextNode(curTime);
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
cell3.appendChild(textnode3);
cell4.appendChild(delButton);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
tabBody.appendChild(row);
});
});
};
</script>
<style>
table, th, td {
border: 1px solid black;
}
#popup {
display:none;
position:fixed;
left:20%;
top:50%;
width:200px;
height:100px;
margin-top:-75px;
margin-left:-150px;
background:#FFFFFF;
border:2px solid #000;
z-index:100000;
}
</style>
</html>