Commit 2c885746 authored by Bady's avatar Bady
Browse files

Send data to server when user enters data

parent 4b9e3f75
......@@ -460,7 +460,7 @@
<form id="knowledge-form">
<input type="text" id="knowledge-input">
<input type="submit" value="Submit" onclick="event.preventDefault(); growLeaf();">
<input type="submit" value="Submit" onclick="event.preventDefault(); addKnowledgeItem();">
</form>
<div id="knowledge"></div>
......@@ -475,9 +475,7 @@
var socket = io();
//following should be there when the leaf text is added/changed
var leafdata = { "leaftext": leaftext } //leaftext should be the text inside the leaf
socket.emit('leaf text', leafdata);
socket.on('leaves data', (leavesdata) => {
//set up the tree with the data of all leaves
......@@ -487,6 +485,12 @@
//update the tree with the new leaf data
});
function addKnowledgeItem() {
leaftext = document.getElementById('knowledge-input').value;
var leafdata = { "leaftext": leaftext }
socket.emit("leaf text", leafdata);
}
function growLeaf() {
let inactiveLeaves = document.getElementsByClassName("leaf-inactive");
let currentLeaf = inactiveLeaves[0];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment