From 6fbce51f49502c5ff5f45cef9e58973fa0f3a90c Mon Sep 17 00:00:00 2001
From: tomsmeding <tom.smeding@gmail.com>
Date: Sun, 24 Dec 2017 17:19:24 +0100
Subject: Add 'save' module

---
 modules/save/index.html | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 modules/save/index.html

(limited to 'modules/save/index.html')

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>
-- 
cgit v1.2.3-70-g09d2