summaryrefslogtreecommitdiff
path: root/modules/save/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'modules/save/index.html')
-rw-r--r--modules/save/index.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/save/index.html b/modules/save/index.html
new file mode 100644
index 0000000..d8c55ca
--- /dev/null
+++ b/modules/save/index.html
@@ -0,0 +1,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>