+const API = "https://families.cworth.org/";
+
+function undisplay(element) {
+ element.style.display="none";
+}
+
+function add_message(severity, message) {
+ message = `<div class="message ${severity}" onclick="undisplay(this)">
+${message}
+<span class="hide-button" onclick="undisplay(this.parentElement)">×</span>
+</div>`;
+ message_area = document.getElementById('message-area');
+ message_area.insertAdjacentHTML('beforeend', message);
+}
+
+function register_loaded(name) {
+ add_message("success", name + " is now in the game!");
+}
+
+function register(form) {
+ var request = new XMLHttpRequest();
+ request.addEventListener("load", register_loaded(form.name.value));
+
+ request.open("POST", API + "register");
+ request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
+ var data = {
+ "name": form.name.value,
+ "character": form.character.value
+ };
+ request.send(JSON.stringify(data));
+
+ form.reset();
+}