/* * 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 ../common/Binding requireClass ../common/Weinre requireClass ./ConnectorList requireClass ./DOMTemplates as dt //----------------------------------------------------------------------------- class RemotePanel < WebInspector.Panel super("remote") this.initialize() //----------------------------------------------------------------------------- method initialize() // main div var div = dt.DIV() div.style.position = "absolute" div.style.top = "1em" div.style.right = "1em" div.style.left = "1em" div.style.bottom = "1em" div.style.overflow = "auto" // create icon var icon = dt.IMG({ src: "../images/weinre-icon-128x128.png" }) icon.style.float = "right" div.appendChild(icon) // create target and client lists this.targetList = new TargetList() this.clientList = new ClientList() div.appendChild(this.targetList.getElement()) div.appendChild(this.clientList.getElement()) // create server properties this.serverProperties = dt.DIV({ $className: "weinreServerProperties" }) div.appendChild(dt.H1("Server Properties")) div.appendChild(this.serverProperties) // add main div to page this.element.appendChild(div) this.reset(); //----------------------------------------------------------------------------- method addClient(client) this.clientList.add(client) method addTarget(target) this.targetList.add(target) method getTarget(channel) return this.targetList.get(channel) method removeClient(channel) this.clientList.remove(channel) method removeTarget(channel) this.targetList.remove(channel) method setCurrentClient(channel) this.clientList.setCurrent(channel) method setCurrentTarget(channel) this.targetList.setCurrent(channel) method setClientState(channel, state) this.clientList.setState(channel, state) method setTargetState(channel, state) this.targetList.setState(channel, state) //----------------------------------------------------------------------------- method getNewestTargetChannel(ignoring) return this.targetList.getNewestConnectorChannel(ignoring) //----------------------------------------------------------------------------- method afterInitialConnection this.clientList.afterInitialConnection() //----------------------------------------------------------------------------- method reset this.clientList.removeAll() this.targetList.removeAll() Weinre.WeinreClientCommands.getTargets(Binding(this, "cb_getTargets")) Weinre.WeinreClientCommands.getClients(Binding(this, "cb_getClients")) //----------------------------------------------------------------------------- method connectionClosed this.clientList.removeAll() this.targetList.removeAll() //----------------------------------------------------------------------------- method cb_getTargets(targets) targets.forEach(function(target) { this.addTarget(target) }, this) if (!Weinre.client.autoConnect()) return var newestTargetChannel = this.getNewestTargetChannel() if (!newestTargetChannel) return if (!Weinre.messageDispatcher) return Weinre.WeinreClientCommands.connectTarget(Weinre.messageDispatcher.channel, newestTargetChannel) //----------------------------------------------------------------------------- method cb_getClients(clients) clients.forEach(function(client) { this.addClient(client) }, this) //----------------------------------------------------------------------------- getter toolbarItemClass return "remote" //----------------------------------------------------------------------------- getter toolbarItemLabel return "Remote" //----------------------------------------------------------------------------- getter statusBarItems return [] //----------------------------------------------------------------------------- getter defaultFocusedElement return this.contentElement //----------------------------------------------------------------------------- method show super() //----------------------------------------------------------------------------- method hide() super() //----------------------------------------------------------------------------- method setServerProperties(properties) var table = "
" + key.escapeHTML() + ": | " + val }) table += " |