|
| 1 | + |
| 2 | +exports.for = function (API) { |
| 3 | + |
| 4 | +API.console.log("init panel"); |
| 5 | + |
| 6 | + const Panel = API.CLASS( |
| 7 | + { |
| 8 | + extends: API.DEV_PANEL, |
| 9 | + |
| 10 | + label: "FirePHP", |
| 11 | + tooltip: "Log from PHP scripts to Console", |
| 12 | + icon: "./FirePHP_16.png", |
| 13 | + url: "./panel.html", |
| 14 | + |
| 15 | + /** |
| 16 | + * Executed by the framework when an instance of this panel is created. |
| 17 | + * There is one instance of this panel per {@Toolbox}. The panel is |
| 18 | + * instantiated when selected in the toolbox for the first time. |
| 19 | + */ |
| 20 | + initialize: function(options) { |
| 21 | + |
| 22 | +API.console.log("initialize()"); |
| 23 | +API.console.log("initialize() this", this); |
| 24 | +API.console.log("initialize() options", options); |
| 25 | + |
| 26 | + }, |
| 27 | + |
| 28 | + /** |
| 29 | + * Executed by the framework when the panel is destroyed. |
| 30 | + */ |
| 31 | + dispose: function() { |
| 32 | +API.console.log("dispose()"); |
| 33 | + }, |
| 34 | + |
| 35 | + /** |
| 36 | + * Executed by the framework when the panel content iframe is |
| 37 | + * constructed. Allows e.g to connect the backend through |
| 38 | + * `debuggee` object |
| 39 | + */ |
| 40 | + setup: function(options) { |
| 41 | + // TODO: connect to backend using options.debuggee |
| 42 | + |
| 43 | +API.console.log("setup()"); |
| 44 | +API.console.log("setup() options", options); |
| 45 | + |
| 46 | +/* |
| 47 | +options.frame.contentWindow.addEventListener("message", function (event) { |
| 48 | + API.console.log("GOT MESSAGE IN PANEL:", event.data); |
| 49 | +}, false); |
| 50 | +*/ |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + var panel = API.PANEL.Panel({ |
| 55 | + contentURL: "./viewer.html", |
| 56 | + contentScriptFile: API.SELF.data.url("viewer.js") |
| 57 | + }); |
| 58 | + |
| 59 | +panel.port.on("message", function(data) { |
| 60 | + |
| 61 | + API.console.log("GOT MESSAGE", data); |
| 62 | +}); |
| 63 | + |
| 64 | + panel.show(); |
| 65 | + |
| 66 | +API.TIMERS.setInterval(function () { |
| 67 | + |
| 68 | + panel.port.emit("message", "Message from extension!"); |
| 69 | + |
| 70 | +}, 2000); |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +API.console.log("setup() DONE"); |
| 78 | + |
| 79 | + } |
| 80 | + }); |
| 81 | + |
| 82 | +API.console.log("register panel"); |
| 83 | + |
| 84 | + const Tool = new API.DEV_TOOL({ |
| 85 | + name: "FirePHP", |
| 86 | + panels: { |
| 87 | + panel: Panel |
| 88 | + } |
| 89 | + }); |
| 90 | + |
| 91 | + return {}; |
| 92 | +} |
0 commit comments