summaryrefslogtreecommitdiff
path: root/modules/save/index.html
blob: d8c55caf1e0f41ec8486151ac90fc40dc10d3eee (plain)
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Save</title>
<script>
function doSave(){
	var text=document.getElementById("text").value.trim();
	if(text==""){
		alert("Please enter some text");
		return;
	}

	var xhr=new XMLHttpRequest();
	xhr.onreadystatechange=function(){
		if(xhr.readyState==4){
			if(xhr.status!=200){
				alert("Error saving text\n"+xhr.responseText);
			} else {
				alert("Successfully saved!")
				document.getElementById("text").value="";
			}
		}
	};
	xhr.open("POST","/save");
	xhr.send(text);
}
</script>
<style>
body {
	font-family: sans-serif;
}
</style>
</head>
<body>
<h2>Save some text for Tom</h2>
<textarea id="text" style="width:500px;height:100px"></textarea><br>
<br>
<input type="button" value="Save" onclick="doSave()">
</body>
</html>