From 865db83c68f919d2ecf6fa5c0fed37f70541ba15 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 18 Apr 2017 15:53:07 +0200 Subject: [locationinfo] Use Location helper for getRoomTree, check backend validity in getCalendar --- modules-available/locationinfo/frontend/panel.html | 64 ++-------------------- 1 file changed, 6 insertions(+), 58 deletions(-) (limited to 'modules-available/locationinfo/frontend/panel.html') diff --git a/modules-available/locationinfo/frontend/panel.html b/modules-available/locationinfo/frontend/panel.html index 89d1c144..cd4db81f 100644 --- a/modules-available/locationinfo/frontend/panel.html +++ b/modules-available/locationinfo/frontend/panel.html @@ -259,7 +259,7 @@ for (var t = 0; t < ids.length; t++) { for (var i = 0; i < json.length; i++) { - if (ids[t] == json[i].id) { + if (ids[t] == json[i].locationid) { var el = generateObject(json[i], ($("#main")), true); } @@ -277,70 +277,18 @@ */ function generateObject(json, myParent, outermost) { var obj; - if (json.childs.length == 0) { - obj = generateChild(myParent, json.id, json.name, outermost); + if (!json.children || json.children.length == 0) { + obj = generateChild(myParent, json.locationid, json.locationname, outermost); } else { - obj = generateParent(myParent, json.id, json.name, outermost); - for (var i = 0; i < json.childs.length; i++) { - - generateObject(json.childs[i], $("#parent_" + json.id)); + obj = generateParent(myParent, json.locationid, json.locationname, outermost); + for (var i = 0; i < json.children.length; i++) { + generateObject(json.children[i], $("#parent_" + json.locationid)); } } return obj; } - /** - * Retruns the number of childs of the current node (inklusive childs of childs) - * @param json Json of the room tree - * @returns number of childs of the current node - */ - function getAllchildsRekusivly(json) { - var childs = 0; - for (var i = 0; i < json.childs.length; i++) { - childs++; - if (json.childs[i].childs.length != 0) { - childs = getAllchildsRekusivly(json.childs[i]); - } - } - return childs; - } - - /** - * Retruns the number of leaveschilds of the current node (inklusive leaves childs of childs) - * @param json Json of the room tree - * @returns number of leaveschilds of the current node - */ - function getChildsRekusivly(json) { - var childs = 0; - for (var i = 0; i < json.childs.length; i++) { - if (json.childs[i].childs.length == 0) { - childs++; - } else { - childs = getChildsRekusivly(json.childs[i]); - } - - } - return childs; - } - - /** - * Retruns the number of leaves childs of the current node - * @param json Json of the room tree - * @returns number of leaveschilds of the current node - */ - function getChilds(json) { - - var childs = 0; - for (var i = 0; i < json.childs.length; i++) { - if (json.childs[i].childs.length == 0) { - childs++; - } - } - return childs; - } - - /** * Helper function to generate id string used in query functions * @param list A string, wicht contains ids or not(for now) -- cgit v1.2.3-55-g7522