Commit 66260d90 authored by Kannan V M's avatar Kannan V M
Browse files

Merge branch 'devel' of fsci:community/knowledge-tree into devel

parents a4e7ea6d 90a4ecf3
......@@ -474,11 +474,19 @@
var socket = io();
//following should be there when the leaf text is added/changed
socket.on('leaves data', (leavesdata) => {
//set up the tree with the data of all leaves
let i = 0;
for(leaf in leavesdata) {
leafdata = leavesdata[leaf];
growLeaves(i, leafdata);
i++;
}
function growLeaves(i, leafdata) {
setTimeout(function() {
growLeaf(leafdata);
}, 300 * i);
}
});
function addKnowledgeItem() {
......@@ -488,6 +496,10 @@
}
socket.on('leaf data', (leafdata) => {
growLeaf(leafdata);
});
function growLeaf(leafdata) {
leafID = leafdata.leafid;
activeLeaf = document.getElementById(leafID);
activeLeaf.classList.add("leaf-active");
......@@ -498,13 +510,14 @@
knowledgeItem.setAttribute("class", "knowledge-item");
let knowledgeId = activeLeaf.id.replace("path", "knowledge");
leafData = document.getElementById(knowledgeId);
if(!leafData) {
if(leafData) {
leafData.innerHTML = leafdata.leaftext;
} else {
knowledgeItem.setAttribute("id", knowledgeId);
knowledgeItem.innerHTML = leafdata.leaftext;
document.getElementById("knowledge").appendChild(knowledgeItem);
}
leafData.innerHTML = leafdata.leaftext;
});
}
function popupLeaf() {
let knowledgeId = this.id.replace("path", "knowledge");
......
......@@ -37,7 +37,7 @@ var socketids = [];
user.on('connection', (socket) => {
let id = socket.id;
io.to(id).emit('leaves data', leavesdata);
socket.emit('leaves data', leavesdata);
socket.on('leaf text', (leafdata) => {
if(!socketids.includes(id)) { //checks if socketid is already assigned with leafid
......
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