Subversion Repositories eFlore/Archives.eflore-xul

Rev

Blame | Last modification | View Log | Download | RSS feed

var gBrowser = null;
var gTree = null;
var gTreeChildren = null;
var gTabWord = null;
var gTextBox = null;

function initTree()
{
        gTree = document.getElementById("tree");       
        gTreeChildren = document.getElementById("dicotreechildren");
        gBrowser = document.getElementById("browserdico");
        var tabTreeCell = gTreeChildren.getElementsByTagName("treecell");
        gTabWord=new Array(tabTreeCell.length);
        for(var i=0; i<tabTreeCell.length;i++)
        {      
                gTabWord[i] = tabTreeCell[i].getAttribute("label");    
        }
        gTextBox = document.getElementById("mot_tb");
       
        gTree.treeBoxObject.selection.clearSelection();
        gTree.treeBoxObject.selection.select(0);
}

function selectMot()
{
        var numrow = gTree.currentIndex;
        if (numrow== -1) { numrow=0; }
        var treeCell= gTreeChildren.childNodes[numrow].firstChild.firstChild;
        var text="<B>"+treeCell.getAttribute("label")+":</B> "+treeCell.getAttribute("def");
        if (treeCell.hasAttribute("img"))
        {
                text= "<table><tr><td><img src='chrome://lexique/content/images/"+
                       encodeURIComponent(treeCell.getAttribute("img"))+"'></td><td>"+text+"</td></tr></table>";
        }
        gBrowser.contentDocument.open();
        gBrowser.contentDocument.write(text);
        gBrowser.contentDocument.close();
}

function updateSelectedWord()
{
        var word= gTextBox.value;
        for(var i=gTabWord.length-1;i>=0;i--)
        {      
                if (gTabWord[i].localeCompare(word)>=0) { pos=i; }
        }

    gTree.treeBoxObject.selection.clearSelection();
        gTree.treeBoxObject.selection.select(pos);
        gTree.treeBoxObject.scrollToRow(pos);
        gTree.invalidate();
}