pandorafms/pandora_console/include/javascript/tree/TreeController.js

840 lines
24 KiB
JavaScript
Raw Normal View History

// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2014-12-17 19:11:07 +01:00
var TreeController;
var TreeNodeDetailController;
TreeController = {
controllers: [],
getController: function () {
var controller = {
index: -1,
recipient: '',
tree: [],
emptyMessage: "Empty",
errorMessage: "Error",
baseURL: "",
ajaxURL: "ajax.php",
2014-12-17 19:45:09 +01:00
ajaxPage: "include/ajax/tree.ajax",
2014-12-17 19:11:07 +01:00
detailRecipient: '',
2014-12-17 19:46:33 +01:00
filter: {},
counterTitles: {},
reload: function () {
2014-12-17 19:11:07 +01:00
// Bad recipient
if (typeof this.recipient == 'undefined' || this.recipient.length == 0) {
return;
}
2014-12-17 19:46:33 +01:00
2014-12-17 19:11:07 +01:00
// Load branch
2014-12-17 20:12:21 +01:00
function _processGroup (container, elements, rootGroup) {
var $group = $("<ul></ul>");
2014-12-16 19:57:48 +01:00
2014-12-17 19:11:07 +01:00
// First group
2014-12-16 19:57:48 +01:00
if (typeof rootGroup != 'undefinded' && rootGroup == true) {
$group
.addClass("tree-root")
.hide()
2014-12-17 20:12:21 +01:00
.prepend('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')+'images/pandora.ico.gif" />');
2014-12-16 19:57:48 +01:00
}
2014-12-17 19:11:07 +01:00
// Normal group
2014-12-16 19:57:48 +01:00
else {
$group
.addClass("tree-group")
.hide();
}
2014-12-17 19:46:33 +01:00
container.append($group);
2014-12-17 19:46:33 +01:00
elements.forEach(function(element, index) {
2015-01-14 17:56:42 +01:00
element.jqObject = _processNode($group, element);
}, $group);
2015-01-02 09:09:56 +01:00
return $group;
}
// Load leaf counters
function _processNodeCounters (container, counters, type) {
if (typeof counters != 'undefined') {
function _processNodeCounterTitle (container, elementType, counterType) {
var defaultCounterTitles = {
total: {
agents: "Total agents",
modules: "Total modules",
none: "Total"
},
fired: {
2014-12-30 16:23:31 +01:00
agents: "Alert fired",
modules: "Alert fired",
none: "Alert fired"
},
critical: {
agents: "Critical agents",
modules: "Critical modules",
none: "Critical"
},
warning: {
agents: "Warning agents",
modules: "Warning modules",
none: "Warning"
},
unknown: {
agents: "Unknown agents",
modules: "Unknown modules",
none: "Unknown"
},
not_init: {
agents: "Not init agents",
modules: "Not init modules",
none: "Not init"
},
ok: {
agents: "Normal agents",
modules: "Normal modules",
none: "Normal"
}
}
try {
var title = '';
switch (elementType) {
case "group":
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].agents != 'undefined') {
title = controller.counterTitles[counterType].agents;
}
else {
title = defaultCounterTitles[counterType].agents;
}
break;
case "agent":
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].modules != 'undefined') {
title = controller.counterTitles[counterType].modules;
}
else {
title = defaultCounterTitles[counterType].modules;
}
break;
default:
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].none != 'undefined') {
title = controller.counterTitles[counterType].none;
}
else {
title = defaultCounterTitles[counterType].none;
}
break;
}
if (title.length > 0) {
container
.prop("title", title)
.addClass("forced_title")
.data("use_title_for_force_title", 1); // Trick to make easier the 'force title' output
}
}
catch (error) {
// console.log(error);
}
}
var $counters = $("<div></div>");
$counters.addClass('tree-node-counters');
if (typeof counters.total != 'undefined'
&& counters.total > 0) {
var $totalCounter = $("<div></div>");
$totalCounter
.addClass('tree-node-counter')
.addClass('total')
.html(counters.total);
_processNodeCounterTitle($totalCounter, type, "total");
// Open the parentheses
$counters.append(" (");
$counters.append($totalCounter);
if (typeof counters.fired != 'undefined'
&& counters.fired > 0) {
var $firedCounter = $("<div></div>");
$firedCounter
.addClass('tree-node-counter')
.addClass('fired')
.addClass('orange')
.html(counters.fired);
_processNodeCounterTitle($firedCounter, type, "fired");
$counters
.append(" : ")
.append($firedCounter);
}
if (typeof counters.critical != 'undefined'
&& counters.critical > 0) {
var $criticalCounter = $("<div></div>");
$criticalCounter
.addClass('tree-node-counter')
.addClass('critical')
.addClass('red')
.html(counters.critical);
_processNodeCounterTitle($criticalCounter, type, "critical");
$counters
.append(" : ")
.append($criticalCounter);
}
if (typeof counters.warning != 'undefined'
&& counters.warning > 0) {
var $warningCounter = $("<div></div>");
$warningCounter
.addClass('tree-node-counter')
.addClass('warning')
.addClass('yellow')
.html(counters.warning);
_processNodeCounterTitle($warningCounter, type, "warning");
$counters
.append(" : ")
.append($warningCounter);
}
if (typeof counters.unknown != 'undefined'
&& counters.unknown > 0) {
var $unknownCounter = $("<div></div>");
$unknownCounter
.addClass('tree-node-counter')
.addClass('unknown')
.addClass('grey')
.html(counters.unknown);
_processNodeCounterTitle($unknownCounter, type, "unknown");
$counters
.append(" : ")
.append($unknownCounter);
}
if (typeof counters.not_init != 'undefined'
&& counters.not_init > 0) {
var $notInitCounter = $("<div></div>");
$notInitCounter
.addClass('tree-node-counter')
.addClass('not_init')
.addClass('blue')
.html(counters.not_init);
_processNodeCounterTitle($notInitCounter, type, "not_init");
$counters
.append(" : ")
.append($notInitCounter);
}
if (typeof counters.ok != 'undefined'
&& counters.ok > 0) {
var $okCounter = $("<div></div>");
$okCounter
.addClass('tree-node-counter')
.addClass('ok')
.addClass('green')
.html(counters.ok);
_processNodeCounterTitle($okCounter, type, "ok");
$counters
.append(" : ")
.append($okCounter);
}
// Close the parentheses
$counters.append(")");
}
// Add the counters html to the container
container.append($counters);
}
// Load the counters asynchronously
// else if (typeof element.searchCounters != 'undefined' && element.searchCounters) {
// var $counters = $("<div></div>");
// $counters
// .addClass('tree-node-counters')
// .append(' (')
// .append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')+'images/spinner.gif" />')
// .append(')');
// $content.append($counters);
// }
}
2014-12-17 19:11:07 +01:00
// Load leaf
2015-01-14 17:56:42 +01:00
function _processNode (container, element) {
var $node = $("<li></li>");
var $leafIcon = $("<div></div>");
var $content = $("<div></div>");
2014-12-17 19:46:33 +01:00
// Leaf icon
$leafIcon.addClass("leaf-icon");
2014-12-17 19:46:33 +01:00
// Content
$content.addClass("node-content");
switch (element.type) {
case 'group':
2014-12-18 18:13:22 +01:00
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
2015-01-05 16:48:11 +01:00
+'images/groups_small/'+element.icon+'" /> ');
2014-12-18 18:13:22 +01:00
}
2015-01-14 17:56:42 +01:00
else if (typeof element.iconHTML != 'undefined' && element.iconHTML.length > 0) {
$content.append(element.iconHTML);
}
$content.append(element.name);
break;
case 'agent':
// Status image
if (typeof element.statusImageHTML != 'undefined'
&& element.statusImageHTML.length > 0) {
var $statusImage = $(element.statusImageHTML);
$statusImage.addClass("agent-status");
$content.append($statusImage);
}
// Alerts fired image
if (typeof element.alertImageHTML != 'undefined'
&& element.alertImageHTML.length > 0) {
var $alertImage = $(element.alertImageHTML);
$alertImage.addClass("agent-alerts-fired");
$content.append($alertImage);
}
$content.append(element.name);
2014-12-19 13:02:30 +01:00
break;
2014-12-18 18:13:22 +01:00
case 'module':
// Status image
if (typeof element.statusImageHTML != 'undefined'
&& element.statusImageHTML.length > 0) {
var $statusImage = $(element.statusImageHTML);
$statusImage.addClass("module-status");
$content.append($statusImage);
}
// Server type
if (typeof element.serverTypeHTML != 'undefined'
&& element.serverTypeHTML.length > 0
&& element.serverTypeHTML != '--') {
var $serverTypeImage = $(element.serverTypeHTML);
$serverTypeImage.addClass("module-server-type");
$content.append($serverTypeImage);
}
// Graph pop-up
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/chart_curve.png" /> ');
$graphImage
.addClass('module-graph')
.click(function (e) {
e.preventDefault();
try {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
console.log(error);
}
});
// Data pop-up
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/binary.png" /> ');
$dataImage
.addClass('module-data')
.click(function (e) {
e.preventDefault();
try {
if ($("#module_details_window").length > 0)
show_module_detail_dialog(element.id, '', '', 0, 86400);
}
catch (error) {
console.log(error);
}
});
$content
.append($graphImage)
.append($dataImage)
.append(element.name);
break;
2015-01-02 12:37:19 +01:00
case 'os':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
2015-01-05 16:48:11 +01:00
+'images/os_icons/'+element.icon+'" /> ');
}
$content.append(element.name);
break;
case 'tag':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/os_icons/'+element.icon+'" /> ');
}
else {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/tag_red.png" /> ');
2015-01-02 12:37:19 +01:00
}
$content.append(element.name);
break;
2014-12-17 19:11:07 +01:00
default:
$content.append(element.name);
break;
}
2014-12-18 18:13:22 +01:00
// Load the status counters
_processNodeCounters($content, element.counters, element.type);
2014-12-17 19:11:07 +01:00
// If exist the detail container, show the data
2014-12-17 20:12:21 +01:00
if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) {
2014-12-17 19:11:07 +01:00
$content.click(function (e) {
TreeNodeDetailController.getController().init({
recipient: controller.detailRecipient,
type: element.type,
id: element.id,
baseURL: controller.baseURL,
ajaxURL: controller.ajaxURL,
ajaxPage: controller.ajaxPage
});
});
}
2014-12-17 19:46:33 +01:00
$node
.addClass("tree-node")
.append($leafIcon)
.append($content);
2014-12-17 19:46:33 +01:00
container.append($node);
2014-12-17 19:46:33 +01:00
2015-01-14 17:56:42 +01:00
$node.addClass("leaf-empty");
2014-12-30 16:23:31 +01:00
if (typeof element.children != 'undefined' && element.children.length > 0) {
2015-01-14 17:56:42 +01:00
$node
.removeClass("leaf-empty")
.addClass("leaf-closed");
2014-12-17 19:46:33 +01:00
// Add children
2014-12-30 16:23:31 +01:00
var $children = _processGroup($node, element.children);
$node.data('children', $children);
2014-12-17 19:46:33 +01:00
2015-01-14 17:56:42 +01:00
if (typeof element.searchChildren == 'undefined' || !element.searchChildren) {
$leafIcon.click(function (e) {
e.preventDefault();
2014-12-18 18:13:22 +01:00
2015-01-14 17:56:42 +01:00
if ($node.hasClass("leaf-open")) {
$node
.removeClass("leaf-open")
.addClass("leaf-closed")
.data('children')
.slideUp();
}
else {
$node
.removeClass("leaf-closed")
.addClass("leaf-open")
.data('children')
.slideDown();
}
});
}
}
2015-01-14 17:56:42 +01:00
if (typeof element.searchChildren != 'undefined' && element.searchChildren) {
$node
.removeClass("leaf-empty")
.addClass("leaf-closed");
2014-12-17 19:46:33 +01:00
2014-12-17 19:45:09 +01:00
$leafIcon.click(function (e) {
e.preventDefault();
2015-01-14 17:56:42 +01:00
if (!$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) {
$node
.removeClass("leaf-closed")
.removeClass("leaf-error")
.addClass("leaf-loading");
2014-12-18 11:20:21 +01:00
$.ajax({
2014-12-17 19:45:09 +01:00
url: controller.ajaxURL,
type: 'POST',
dataType: 'json',
data: {
2014-12-17 19:45:09 +01:00
page: controller.ajaxPage,
getChildren: 1,
id: element.id,
2014-12-17 19:46:33 +01:00
type: element.type,
2014-12-30 16:23:31 +01:00
filter: controller.filter,
childrenMethod: 'live',
countModuleStatusMethod: 'live',
countAgentStatusMethod: 'live'
},
complete: function(xhr, textStatus) {
$node.removeClass("leaf-loading");
2014-12-18 18:13:22 +01:00
$node.addClass("children-loaded");
},
success: function(data, textStatus, xhr) {
if (data.success) {
2015-01-19 17:09:31 +01:00
var $group = $node.children("ul.tree-group");
2015-01-14 17:56:42 +01:00
2015-01-19 17:07:07 +01:00
if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) {
$node.addClass("leaf-open");
2015-01-14 17:56:42 +01:00
if ($group.length <= 0) {
$group = $("<ul></ul>");
$group
.addClass("tree-group")
.hide();
$node.append($group);
}
2014-12-18 11:20:21 +01:00
2015-01-14 17:56:42 +01:00
data.tree.forEach(function(element, index) {
element.jqObject = _processNode($group, element);
}, $group);
2014-12-18 09:55:54 +01:00
2015-01-14 17:56:42 +01:00
$group.slideDown();
$node.data('children', $group);
// Add again the hover event to the 'force_callback' elements
forced_title_callback();
2014-12-18 09:55:54 +01:00
}
else {
$node.addClass("leaf-empty");
}
}
else {
$node.addClass("leaf-error");
}
},
error: function(xhr, textStatus, errorThrown) {
$node.addClass("leaf-error");
}
});
}
2014-12-18 09:55:54 +01:00
else if (! $node.hasClass("leaf-empty")) {
if ($node.hasClass("leaf-open")) {
$node
.removeClass("leaf-open")
.addClass("leaf-closed")
.data('children')
.slideUp();
}
else {
$node
.removeClass("leaf-closed")
.addClass("leaf-open")
.data('children')
.slideDown();
}
}
});
}
2014-12-17 19:46:33 +01:00
return $node;
}
2014-12-17 19:46:33 +01:00
2014-12-17 20:12:21 +01:00
if (controller.recipient.length == 0) {
return;
}
2014-12-17 20:12:21 +01:00
else if (controller.tree.length == 0) {
controller.recipient.html("<div>" + controller.emptyMessage + "</div>");
return;
}
2014-12-17 19:46:33 +01:00
2014-12-17 20:12:21 +01:00
controller.recipient.empty();
2014-12-17 20:12:21 +01:00
var $children = _processGroup(this.recipient, this.tree, true);
$children.show();
2014-12-17 19:46:33 +01:00
2014-12-17 20:12:21 +01:00
controller.recipient.data('children', $children);
2015-01-02 09:09:56 +01:00
// Add again the hover event to the 'force_callback' elements
forced_title_callback();
},
load: function () {
this.reload();
},
changeTree: function (tree) {
this.tree = tree;
this.reload();
},
init: function (data) {
if (typeof data.recipient != 'undefined' && data.recipient.length > 0) {
this.recipient = data.recipient;
}
2014-12-17 19:11:07 +01:00
if (typeof data.detailRecipient != 'undefined' && data.detailRecipient.length > 0) {
this.detailRecipient = data.detailRecipient;
}
if (typeof data.tree != 'undefined' && data.tree.length > 0) {
this.tree = data.tree;
}
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
this.emptyMessage = data.emptyMessage;
}
if (typeof data.errorMessage != 'undefined' && data.errorMessage.length > 0) {
this.errorMessage = data.errorMessage;
}
if (typeof data.baseURL != 'undefined' && data.baseURL.length > 0) {
this.baseURL = data.baseURL;
}
if (typeof data.ajaxURL != 'undefined' && data.ajaxURL.length > 0) {
this.ajaxURL = data.ajaxURL;
}
if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) {
this.ajaxPage = data.ajaxPage;
}
2014-12-17 20:12:21 +01:00
if (typeof data.filter != 'undefined') {
2014-12-17 19:46:33 +01:00
this.filter = data.filter;
}
this.load();
},
remove: function () {
2014-12-17 19:11:07 +01:00
if (typeof this.recipient != 'undefined' && this.recipient.length > 0) {
this.recipient.empty();
}
if (this.index > -1) {
TreeController.controllers.splice(this.index, 1);
}
}
}
2014-12-18 11:20:21 +01:00
controller.index = TreeController.controllers.push(controller) - 1;
return controller;
}
2014-12-17 19:11:07 +01:00
}
// The controllers will be inside the 'controllers' object,
// ordered by ['type']['id']
TreeNodeDetailController = {
controllers: {},
controllerExist: function (type, id) {
if (typeof this.controllers[type][id] != 'undefined') {
return true;
}
else {
return false;
}
},
removeControllers: function () {
2014-12-18 14:41:21 +01:00
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
element.remove();
});
}
2014-12-17 19:11:07 +01:00
});
2014-12-18 14:41:21 +01:00
}
2014-12-17 19:11:07 +01:00
},
getController: function () {
var controller = {
recipient: '',
type: 'none',
id: -1,
emptyMessage: "Empty",
errorMessage: "Error",
baseURL: "",
ajaxURL: "ajax.php",
2014-12-17 19:45:09 +01:00
ajaxPage: "include/ajax/tree.ajax",
2014-12-17 19:11:07 +01:00
container: '',
reload: function () {
// Label
var $label = $("<div></div>");
$label
.addClass("tree-element-detail-label")
.click(function (e) {
if ($label.hasClass('tree-element-detail-loaded'))
controller.toggle();
});
// Content
var $content = $("<div></div>");
$content.addClass("tree-element-detail-content");
// Container
this.container = $("<div></div>");
this.container
.addClass("tree-element-detail")
.append($label)
.data('label', $label)
.append($content)
.data('content', $content)
.hide();
2014-12-17 19:11:07 +01:00
$label.addClass('tree-element-detail-loading');
$.ajax({
url: this.ajaxURL,
type: 'POST',
dataType: 'json',
data: {
2014-12-17 20:12:21 +01:00
page: this.ajaxPage,
2014-12-17 19:11:07 +01:00
getDetail: 1,
type: this.type,
id: this.id
},
complete: function(xhr, textStatus) {
$label.removeClass('tree-element-detail-loading');
},
success: function(data, textStatus, xhr) {
if (data.success) {
$label.addClass('tree-element-detail-loaded');
$content.html(data.html);
2014-12-17 19:11:07 +01:00
controller.open();
}
else {
$label.addClass('tree-element-detail-error');
$content.html(controller.errorMessage);
}
},
error: function(xhr, textStatus, errorThrown) {
$label.addClass('tree-element-detail-error');
$content.html(controller.errorMessage);
}
});
this.recipient.append(this.container);
this.open();
},
load: function () {
this.reload();
},
toggle: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (this.container.isClosed) {
this.open();
}
else {
this.close();
}
},
open: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (this.container.isClosed) {
this.container.data('content').slideLeft();
this.container.isClosed = false;
}
},
close: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (!this.container.isClosed) {
this.container.data('content').slideRight();
this.container.isClosed = true;
}
},
init: function (data) {
// Remove the other controllers
TreeNodeDetailController.removeControllers();
// Required
if (typeof data.recipient != 'undefined' && data.recipient.length > 0) {
this.recipient = data.recipient;
}
else {
return false;
}
// Required
if (typeof data.type != 'undefined' && data.type.length > 0) {
this.type = data.type;
}
else {
return false;
}
// Required
if (typeof data.id != 'undefined' && (data.id.length > 0 || !isNaN(data.id))) {
2014-12-17 19:11:07 +01:00
this.id = data.id;
}
else {
return false;
}
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
this.emptyMessage = data.emptyMessage;
}
if (typeof data.errorMessage != 'undefined' && data.errorMessage.length > 0) {
this.errorMessage = data.errorMessage;
}
if (typeof data.baseURL != 'undefined' && data.baseURL.length > 0) {
this.baseURL = data.baseURL;
}
if (typeof data.ajaxURL != 'undefined' && data.ajaxURL.length > 0) {
this.ajaxURL = data.ajaxURL;
}
if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) {
this.ajaxPage = data.ajaxPage;
}
if (typeof data.counterTitles != 'undefined') {
this.counterTitles = data.counterTitles;
}
2014-12-17 19:11:07 +01:00
2014-12-17 20:12:21 +01:00
if (typeof TreeNodeDetailController.controllers[this.type] == 'undefined')
TreeNodeDetailController.controllers[this.type] = {};
2014-12-17 19:11:07 +01:00
TreeNodeDetailController.controllers[this.type][this.id] = this;
this.load();
},
remove: function () {
if (typeof this.recipient != 'undefined' && this.recipient.length > 0) {
this.recipient.empty();
}
if (this.type != 'none' && this.id > -1) {
2014-12-18 14:41:21 +01:00
try {
delete TreeNodeDetailController.controllers[this.type][this.id];
}
catch (error) {
// console.log('Item not deleted');
}
2014-12-17 19:11:07 +01:00
}
},
closeOther: function () {
2014-12-18 14:41:21 +01:00
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
if (this.type != type && this.id != id)
element.close();
}, this);
}
2014-12-17 19:11:07 +01:00
}, this);
2014-12-18 14:41:21 +01:00
}
2014-12-17 19:11:07 +01:00
},
removeOther: function () {
2014-12-18 14:41:21 +01:00
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
if (this.type != type && this.id != id)
element.remove();
}, this);
}
2014-12-17 19:11:07 +01:00
}, this);
2014-12-18 14:41:21 +01:00
}
2014-12-17 19:11:07 +01:00
}
}
return controller;
}
}