-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcreate.html
132 lines (118 loc) · 5.12 KB
/
create.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Note/Create</title>
<link rel="stylesheet" type="text/css" href="/restful/css/style.css"/>
<script type="text/javascript" src="/restful/js/restful.js"></script>
<script type="text/javascript">
// window.onload
window.onload = function() {
var endpoint = "/restful/api/user/profile";
ajaxCall('GET', endpoint, null, null, function(data) {
}, function(data) {
createSignin(data.response);
}
);
};
//create signin
function createSignin(str) {
var html = '<table>'
+ '<tr>'
+ '<td>userid</td>'
+ '<td><input type="text" name="userid" id="userid" tabindex="1" placeholder=" UserId"></td>'
+ '</tr>'
+ '<tr>'
+ '<td>password</td>'
+ '<td><input type="password" name="password" id="password" tabindex="1" placeholder=" Password"></td>'
+ '</tr>'
+ '<tr>'
+ '<td align="center" colspan="2"><input type="button" value="Sign In" onClick="signin()"></td>'
+ '</tr>'
+ '<tr>'
+ '<td align="right" colspan="2"><a href="/restful/user/signup.html">Sign Up</a></td>'
+ '</tr>'
+ '</table>';
var res = '<p>'+ str +'</p>';
document.getElementById('table').innerHTML = res + html;
}
// Sign In
function signin() {
var userid = document.getElementById('userid').value;
var password = document.getElementById('password').value;
if (!userid) {
alert('Please input your userid');
return;
} else if (!password) {
alert('Please insert your password');
return;
}
var params = {
'name' : userid,
'pwd' : password
};
var endpoint = "/restful/api/user/signin";
ajaxCall('POST', endpoint, null, params, function(data) {
var status = data.status;
if (status == 'OK') {
location.reload(true);
}
},
function(data) {
alert(data.response);
}
);
}
// Sign Up
function create() {
var subject = document.getElementById('subject').value;
var content = document.getElementById('content').value;
if (!subject) {
alert('Please input subject');
return;
} else if (!content) {
alert('Please insert content');
return;
}
var params = {
'subject': subject,
'content': content
};
var endpoint = "/restful/api/note";
ajaxCall('POST', endpoint, null, params, function(data) {
var status = data.status;
if (status == 'OK') {
location.replace("list.html");
}
},
function(data) {
alert(data.response);
}
);
}
</script>
</head>
<body>
<p>Create</p>
<div id='table'>
<table style="width: 200px;">
<tr>
<td>
<table>
<tr>
<td>subject</td>
<td><input type="text" name="subject" id="subject" tabindex="1" placeholder=" Subject"></td>
</tr>
<tr>
<td colspan="2"><textarea name="content" id="content" tabindex="1" placeholder=" Content" rows="5" cols="25"></textarea></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><input type="button" value="Create" onClick="create()"></td>
</tr>
</table>
</div>
</body>
</html>