diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-12-24 17:19:24 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-12-24 17:19:24 +0100 |
commit | 6fbce51f49502c5ff5f45cef9e58973fa0f3a90c (patch) | |
tree | 4753eac41ec161a118f329c5284dc4e3ecd2d3e2 /modules/save/index.html | |
parent | 77d73b37116c44a13962cd1676ea457c37d7cf96 (diff) |
Add 'save' module
Diffstat (limited to 'modules/save/index.html')
-rw-r--r-- | modules/save/index.html | 41 |
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> |