Thanks for your help and for the great work guys, it's just amazing what one 
can achieve with Firebug within 2 days starting from zero knowledge.

My last step is to detect when someone clicks on an attribute (i need to build 
xpath for this too), i suppose there is something similar to udpateSelection 
around...


Here is my final code for the records : 


FBL.ns(function() { with (FBL) {

function firejettsPanel() {}

firejettsPanel.prototype = extend(Firebug.Panel,
{
    name: "firejetts",
    title: "jetts mapping",
        parentPanel: 'html',

        updateSelection: function(element)
    {
                xpath = this.getElementXPath(element);
                var domplate = Firebug.firejettsModel.xpathRep;
                domplate.myTag.append({xpath:xpath}, this.panelNode, domplate);
    },

        getElementXPath: function(element)
        {
            if (element && element.id)
                return '//'+element.localName+'[...@id="' + element.id + '"]';
            else
                return this.getElementTreeXPath(element);
        },

        getElementTreeXPath: function(element)
        {
                var isRelative = false;
            var paths = [];

            for (; element && element.nodeType == 1; element = 
element.parentNode)
            {
                        if(element.id) {
                                paths.splice(0, 0, 
this.getElementXPath(element));
                                isRelative = true;
                                break;
                        }else{
                       var index = 0;
                        for (var sibling = element.previousSibling; sibling; 
sibling = sibling.previousSibling)
                        {
                            if (sibling.localName == element.localName)
                                ++index;
                        }

                        var tagName = element.localName.toLowerCase();
                        var pathIndex = (index ? "[" + (index+1) + "]" : "");
                        paths.splice(0, 0, tagName + pathIndex);
                        }
            }

            return paths.length ? ((isRelative) ? "" : "/") + paths.join("/") : 
null;
        },

});

Firebug.firejettsModel = extend(Firebug.Module,
{
    initialize: function() {
        Firebug.Panel.initialize.apply(this, arguments);

                var htmlpanel = FirebugContext.getPanel('html');
                htmlpanel.addEventListener("click", function 
(){Firebug.Console.log('event')}, false);
    },
});

Firebug.firejettsModel.xpathRep = domplate(
{
    myTag:
        DIV({onclick: "$onClick"},
            SPAN({class: "cssProp editGroup"},"$xpath")
        ),
        onClick: function(event)
            {
                        event.target.parentNode.removeChild(event.target)
            }
});

Firebug.registerPanel(firejettsPanel);
Firebug.registerModule(Firebug.firejettsModel);

}});

Le 17 mars 2010 à 21:26, John J Barton a écrit :

> 
> 
> On Mar 17, 10:24 am, Duchesnes Grégory - Ilomedia
> <[email protected]> wrote:
>> tried the show method as well but it didn't work.
>> 
>> I think i'm missing something obvious but i don't see what.
>> My code is below, am i stupid?
> 
> Firebug is complex, sophisticated, and not well documented.
> 
>> 
>> FBL.ns(function() { with (FBL) {
>> 
>> function firejettsPanel() {}
>> 
>> firejettsPanel.prototype = extend(Firebug.Panel,
>> {
>>     name: "firejetts",
>>     title: "FireJetts",
>>         parentPanel: 'html',
>> 
>> });
>> 
>> Firebug.firejettsModel = extend(Firebug.Module,
>> {
>> 
>>     initialize: function() {
>>         Firebug.Panel.initialize.apply(this, arguments);
>>     },
>> 
> 
> showPanel means "Hey model, we are about to show panel". It should be
> reserved for model updates base on panel selection, that that should
> be very rare. We are often using in it incorrectly now in firebug
> now.  We should not be using it to set up the panel UI. You should
> move most of this code to panel.show() I think.
> 
>>     showPanel: function(browser, panel) {
>>         var isfirejettsPanel = panel && panel.name == "firejetts";
>>         var firejettsButtons = browser.chrome.$("fbfirejettsButtons");
>>         collapse(firejettsButtons, !isfirejettsPanel);
>> 
>>         if (!isfirejettsPanel) return;
>> 
>>         var doc = panel.document;
>>         var div = panel.panelNode;
>> 
>>         if (!this.initialized) {
>>             this.initialized = true;
>>         }
>> 
>>                 var htmlpanel = FirebugContext.getPanel('html');
>>                 if(typeof htmlpanel.selection != 'undefined' && 
>> htmlpanel.selection != null)
>>                 {
>>                         xpath = this.getElementXPath(htmlpanel.selection);
>>                         this.xpathRep.myTag.append({xpath:xpath}, div, 
>> this.xpathRep);
>>                 }
>>     },
>> 
>>         showSidePanel: function(browser, panel)
>>     {
> 
> Generally you should call showPanel, its a framework method.
> 
>>         this.showPanel(browser, panel);
>>     },
>> 
>>         show: function(state)
>>     {
>>                 // nothing pops up in console :(
> 
> Nothing comes out because this is a panel method, not a module method.
> 
>>         Firebug.Console.log('show');
> 
> I suggest using
>         if (FBTrace.DBG_JETT) and learning about FBTrace or learning
> chromebug our debugger.
> 
> Looks like you are close...
> 
> jjb
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Firebug" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/firebug?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.

Reply via email to