Tree patch

Discussion in 'Developers' Forum' started by djtremors, Feb 25, 2007.

  1. djtremors

    djtremors New Member

    Hi all,

    after being so frustrated with this 2.2.9->2.2.10 problem I decided to do something constructive and hence came up with this cookie routine patch for the tree view.

    Since I'm coding in the 2.2.9 release I didn't bother doing it in the SVN or anything so it's up to you to check it out and apply it or not.

    there's 3 sections to my patch.
    1. Add the extra functions for cookie reading/writing.
    2. Force the tree loop to check for saved settings and apply them
    3. Write settings to the cookie.

    Here is my patch

    These 3 were done in the web/isp_manager/inhalt_tree.php and seem to work fine.
    PHP:
    <!-- patch_startAdded cookie functions -->
    function 
    createCookie(name,value,days) {
        if (
    days) {
            var 
    date = new Date();
            
    date.setTime(date.getTime()+(days*24*60*60*1000));
            var 
    expires "; expires="+date.toGMTString();
        }
        else var 
    expires "";
        
    document.cookie name+"="+value+expires+"; path=/";
    }

    function 
    readCookie(name) {
        var 
    nameEQ name "=";
        var 
    ca document.cookie.split(';');
        for(var 
    i=0;ca.length;i++) {
            var 
    ca[i];
            while (
    c.charAt(0)==' 'c.substring(1,c.length);
            if (
    c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return 
    null;
    }
    <!-- 
    patch_endAdded cookie functions -->
    PHP:
    function maleVerz(startEintrag,zweigEintrag) {
            VerzAuf = '<? echo htmlspecialchars($go_api->lng("Verzeichnis �ffnen"))?>'
            VerzZu = '<? echo htmlspecialchars($go_api->lng("Verzeichnis schliessen"))?>'
            var nachfolger = sucheNachfolgerVon(startEintrag);
            var aktuellerIndex = 1;
            while (aktuellerIndex <= nachfolger.laenge) {
                    ausgabeFrame.write(zweigEintrag);
     <!--patched_start: Apply the cookie to the tree -->
                    checkval = readCookie("mgr_"+nachfolger[aktuellerIndex].name);
                    nachfolger[aktuellerIndex].offen = checkval;
    <!--patched_end: Apply the cookie to the tree -->
    PHP:
    <!-- patch_startstatus change added cookie writing -->
    function 
    aufzuVerz(name,status) {
            var 
    eintragsIndex indexVonEintrag(name);
            
    menuDaten[eintragsIndex].offen status;
            
    timeOutname setTimeout("maleMenu()",100);
            
    createCookie("mgr_"+name,status);
            if ((
    status == 1) && (menuDaten[eintragsIndex].url != '')) {frames["seiteFrame"].location.href=menuDaten[eintragsIndex].url}}
    <!-- 
    patch_endstatus change added cookie writing -->
     
    Last edited: Feb 28, 2007
  2. djtremors

    djtremors New Member

    Just noticed, it renderes the top level expand/collapse links useless unless someone can add something to loop through and reset them.
     

Share This Page