/* * weinre is available under *either* the terms of the modified BSD license *or* the * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * * Copyright (c) 2010, 2011 IBM Corporation */ requireClass ./DOMTemplates as dt //----------------------------------------------------------------------------- class ConnectorList(title) this.connectors = {} this.noneItem = dt.LI("none") this.ulConnectors = dt.UL(this.noneItem) this.div = dt.DIV(dt.H1(title), this.ulConnectors) this.noneItem.addStyleClass("weinre-connector-item") //----------------------------------------------------------------------------- method getElement return this.div //----------------------------------------------------------------------------- method add(connector) if (this.connectors[connector.channel]) return this.connectors[connector.channel] = connector var li = this.getListItem(connector) if (this.noneItem.style.display != "none") { this.noneItem.style.display = "none" } li.addStyleClass("weinre-fadeable") var insertionPoint = this.getConnectorInsertionPoint(connector) if (!insertionPoint) { this.ulConnectors.appendChild(li) } else { this.ulConnectors.insertBefore(li, insertionPoint) } //----------------------------------------------------------------------------- method get(channel) return this.connectors[channel] //----------------------------------------------------------------------------- method getNewestConnectorChannel(ignoring) var newest = 0 for (var connectorChannel in this.connectors) { if (connectorChannel == ignoring) continue if (connectorChannel > newest) newest = connectorChannel } if (newest == 0) return null return newest //----------------------------------------------------------------------------- method getConnectorInsertionPoint(connector) for (var i=0; i