Ignore:
Timestamp:
11/15/12 11:01:02 (12 years ago)
Author:
vmipsl
Message:

account BD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_statistics/web/project/statistics-script.jsp

    r663 r667  
    99        /** *********** CONTAINERS *********** **/ 
    1010        this.parent = $( "#containerMiddle" ); 
    11         this.containerMenu = $( "#menuCircle" ); 
     11        this.containerMenu = $( "#menuLogo" ); 
    1212        this.containerErrors = $( "#errors" ); 
    1313 
     
    1515        this.language = '<spring:message code="language"/>'; 
    1616        this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>"; 
    17         this.projectsPath = "resources/images/"; 
     17        this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false; 
     18        this.logoSizeSmall = 30; 
     19        this.logoSizeBig = 50; 
     20 
    1821        this.projectsArray = [ 
    1922            {id:"ETHER", img:"logo_Ether_50.jpg", top:"-16px", left:"125px"}, 
     
    3437            {id:"ARLETTY", img:"logo_arletty_50.jpg", top:"-79px", left:"161.667px"} 
    3538        ]; 
    36         this.widthInitLogin = $( "#login_bg" ).width(); 
    3739        this.widthInitMentionsOrCredits = $( "#mentions" ).width(); 
    3840 
     
    4042        this.yArray = [0, 10, 30, 50, 100]; 
    4143 
    42  
    4344        this.bindButtons(); 
    44         this.createDraggableSlides(); 
    45         this.createMenuCircle(); 
     45        this.createMenuLogo(); 
    4646 
    4747        $( document ).ready( jQuery.proxy( function() 
     
    4949            $( ".containerToDrag" ).draggable(); 
    5050            // Menu 
    51             this.animateMenuCircle(); 
    52             this.bindMenuCircle(); 
    53             // Slides 
    54 //            this.onClickHelp(); 
    55             this.selectedLogo = $( "#ETHER" )[0]; 
    56             this.isSelectedLogoEther = true; 
    57             this.onClickLogo(); 
    58  
    59             this.changeRightSlide(); 
     51            this.animateMenuLogos(); 
     52            this.bindMenuLogos(); 
     53            this.createRightSlide(); 
     54 
     55            if( !this.jSONUser ) 
     56                this.onClickHelp(); 
     57            else 
     58                this.handleLogin(); 
    6059        }, this ) ); 
    6160    }, 
     
    6766        $( "#home_button" ).bind( "dblclick", this.onClickHome ); 
    6867        $( "#language_button" ).bind( "dblclick", jQuery.proxy( this.onClickLanguage, this ) ); 
    69         $( "#mail_button" ).bind( "dblclick", this.onClickMail ); 
    70         $( "#login_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogin, this ) ); 
     68        $( "#mail_button" ).bind( "dblclick", jQuery.proxy( this.onClickMail, this ) ); 
    7169        $( "#help" ).bind( "click", jQuery.proxy( this.onClickHelp, this ) ); 
    7270        $( "#credits" ).bind( "dblclick", jQuery.proxy( this.onClickCredits, this ) ); 
    7371        $( "#mentions" ).bind( "dblclick", jQuery.proxy( this.onClickMentions, this ) ); 
    74     }, 
    75  
    76     createMenuCircle: function() 
    77     { 
    78         var menuSize = this.containerMenu.width(); 
    79         var nbLogosForSize = (this.projectsArray.length / 2) + 1; 
    80         var divLogoSize = menuSize / nbLogosForSize; 
    81         this.logoSize = divLogoSize - 5; 
    82  
     72        $( "#login_button" ).bind( "click", jQuery.proxy( this.onClickLogin, this ) ); 
     73        $( "#logout_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogout, this ) ); 
     74    }, 
     75 
     76    createMenuLogo: function() 
     77    { 
    8378        var initTop = this.projectsArray[0].top; 
    8479        var initLeft = this.projectsArray[0].left; 
     
    8984            divLogo.addClass( "divLogo containerToDrag" ); 
    9085            divLogo.attr( {id:logo.id, style:"position:absolute; top:" + initTop + "; left:" + initLeft} ); 
    91             divLogo.html( '<img id="img_' + logo.id + '"src="' + this.projectsPath + '' + logo.img + '" width="' + this.logoSize + 'px" height="' + this.logoSize + 'px"/>' ); 
    92             $( "#menuCircle" ).append( divLogo ); 
     86            divLogo.html( '<img id="img_' + logo.id + '"src="resources/images/' + logo.img + '" width="' + this.logoSizeSmall + 'px" height="' + this.logoSizeSmall + 'px"/>' ); 
     87            this.containerMenu.append( divLogo ); 
    9388        }, this ) ); 
    9489    }, 
    9590 
    96     createDraggableSlides: function() 
     91    createAllSlides: function() 
    9792    { 
    9893        this.leftTopSlide = new DragSlide( {id:"leftTop", parent:this.parent, width:"170", height:"200", top:"140px", left:"53px", 
     
    110105            specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 
    111106 
    112         this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"300", top:"180px", left:"698px", 
     107        this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"270", top:"210px", left:"698px", 
     108            specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 
     109 
     110        this.rightLoginSlide = new DragSlide( {id:"loginRight", parent:this.parent, width:"200", height:"25", top:"170px", left:"697px", 
     111            specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 
     112    }, 
     113 
     114    createRightSlide: function() 
     115    { 
     116        this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"270", top:"210px", left:"698px", 
    113117            specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 
    114118    }, 
     
    122126            { 
    123127                location.reload(); 
    124             } 
     128            }, 
     129            error: jQuery.proxy( this.showErrors, [this] ) 
     130        } ); 
     131    }, 
     132 
     133    requestLogin: function() 
     134    { 
     135        var login = $( "#loginValue" ).val(); 
     136        var pwd = $( "#pwdValue" ).val(); 
     137        $.ajax( { 
     138            url: "project?methodName=login&login=" + login + "&pwd=" + pwd, 
     139            dataType: 'json', // Info needed since jquery.1.7 !! 
     140            success:jQuery.proxy( this.handleLogin, this ), 
     141            error: jQuery.proxy( this.showErrors, [this, "489px", "566px"] ) 
     142        } ); 
     143    }, 
     144 
     145    requestLogout: function() 
     146    { 
     147        $.ajax( { 
     148            url: "project?methodName=logout", 
     149            dataType: 'json', // Info needed since jquery.1.7 !! 
     150            success:jQuery.proxy( this.handleLogout, this ), 
     151            error: jQuery.proxy( this.showErrors, [this] ) 
    125152        } ); 
    126153    }, 
     
    134161            url: "statistic?methodName=searchMainStatisticsByProject&name=" + this.selectedLogo.id, 
    135162            success:jQuery.proxy( this.handleDataByLogo, this ), 
    136             error: jQuery.proxy( this.showErrors, [this] ) 
    137         } ); 
    138     }, 
    139  
    140     // HANDLES ******************************************************** = retours ajax 
     163            error: jQuery.proxy( this.showLoginError, this ) 
     164        } ); 
     165    }, 
     166 
     167    // HANDLES ******************************************************** 
    141168    handleDataByLogo: function( result ) 
    142169    { 
     
    147174    }, 
    148175 
     176    handleLogin: function( result ) 
     177    { 
     178        this.containerErrors.empty(); 
     179        this.containerErrors.css( "visibility", "hidden" ); 
     180 
     181        if( result ) 
     182            this.jSONUser = result.jSONUser; 
     183 
     184        $( "#loginValue" ).empty(); 
     185        $( "#pwdValue" ).empty(); 
     186        $( "#login_text" ).css( "visibility", "hidden" ); 
     187        $( "#login" ).animate( { 
     188            top:'47px', 
     189            left:'126px' 
     190        }, 2000, function() 
     191        { 
     192        } ); 
     193 
     194        $( "#login_bg" ).animate( { 
     195            opacity: 1, 
     196            height:'60px', 
     197            width:'67px' 
     198        }, 2000, function() 
     199        { 
     200        } ); 
     201 
     202        $( "#login_img" ).animate( { 
     203            top:'25px', 
     204            left: '16px', 
     205            width: '0', 
     206            height: '0' 
     207        }, 2000, jQuery.proxy( function() 
     208        { 
     209            // Slides 
     210            this.parent.empty(); 
     211            this.createAllSlides(); 
     212            this.changeRightSlide(); 
     213 
     214            // User 
     215            if( this.jSONUser.name ) 
     216                this.rightLoginSlide.setTitle( this.jSONUser.name ); 
     217            else 
     218                this.rightLoginSlide.setTitle( '<spring:message code="label.unknown"/>' ); 
     219            $( "#logout_button" ).css( "visibility", "visible" ); 
     220 
     221            // Logo 
     222            this.selectedLogo = $( "#ETHER" )[0]; 
     223            this.isSelectedLogoEther = true; 
     224            this.onClickLogo(); 
     225        }, this ) ); 
     226    }, 
     227 
     228    handleLogout: function() 
     229    { 
     230        this.jSONUser = false; 
     231        this.parent.empty(); 
     232        this.createRightSlide(); 
     233        this.onClickHelp(); 
     234 
     235        $( "#logout_button" ).css( "visibility", "hidden" ); 
     236        $( "#login" ).css( { zIndex:1 } ).animate( { 
     237            top:'79px', 
     238            left:'88px' 
     239        }, 2000, function() 
     240        { 
     241        } ); 
     242 
     243        $( "#login_bg" ).animate( { 
     244            opacity: 0.85, 
     245            height:'500px', 
     246            width:'500px' 
     247        }, 2000, function() 
     248        { 
     249            $( "#login_text" ).css( "visibility", "visible" ); 
     250        } ); 
     251 
     252        $( "#login_img" ).animate( { 
     253            top:'103px', 
     254            left: '148px', 
     255            width: '30px', 
     256            height: '30px' 
     257        }, 2000, function() 
     258        { 
     259        } ); 
     260    }, 
     261 
    149262    // EVENTS ******************************************************** 
    150263    onClickHome: function() 
     
    161274    { 
    162275        document.location.href = "mailto:" + this.webmaster + "?subject=[STATISTICS]"; 
    163     }, 
    164  
    165     onClickLogin: function() 
    166     { 
    167         if( this.widthInitLogin == $( "#login_bg" ).width() ) 
    168             this.enlargeLogin(); 
    169         else 
    170             this.reduceLogin(); 
    171276    }, 
    172277 
     
    191296        this.rightSlide.setTitle( '<spring:message code="label.help"/>' ); 
    192297        this.rightSlide.setContent( "<spring:message code='label.help.content'/>" ); 
    193         var backHelpButton = new Button( {value:"<spring:message code="label.display.actions"/>", parent:this.rightSlide.getDivContent(), className: "small positive back_button", onClick:jQuery.proxy( this.changeRightSlide, this )} ); 
    194     }, 
    195  
    196     onClickButtonLogin: function() 
    197     { 
    198         // TODO reduce cloud 
    199  
     298        if( this.jSONUser ) 
     299            var backHelpButton = new Button( {value:"<spring:message code="label.display.actions"/>", parent:this.rightSlide.getDivContent(), className: "small positive back_button", onClick:jQuery.proxy( this.changeRightSlide, this )} ); 
     300    }, 
     301 
     302    onClickLogin: function() 
     303    { 
     304        this.containerErrors.empty(); 
     305        this.containerErrors.css( "visibility", "hidden" ); 
     306        this.requestLogin(); 
     307    }, 
     308 
     309    onClickLogout: function() 
     310    { 
     311        this.requestLogout(); 
    200312    }, 
    201313 
     
    203315    { 
    204316        this.isSelectedLogoEther = (this.selectedLogo == $( "#ETHER" )[0]); 
    205         this.requestDataByLogo(); 
     317 
     318        if( this.jSONUser ) 
     319            this.requestDataByLogo(); 
     320        else 
     321        { 
     322            this.showErrors( "<spring:message code="error.connection.need"/>" ); 
     323            this.containerErrors.css( {top:"489px", left:"566px"} ); 
     324            this.containerErrors.css( "visibility", "visible" ); 
     325        } 
    206326    }, 
    207327 
     
    221341    { 
    222342        var context = this[0] ? this[0] : this; 
    223         var text = this[1]; 
     343        var topValue = this[1] ? this[1] : false; 
     344        var leftValue = this[2] ? this[2] : false; 
    224345        context.containerErrors.show(); 
    225 //        if( text ) 
    226 //            context.containerErrors.html( interfaceTexts[result.responseText] + " " + text ); 
    227 //        else if( interfaceTexts[result.responseText] ) 
    228 //            context.containerErrors.html( interfaceTexts[result.responseText] ); 
    229         if( result.responseText ) 
     346        if( result.responseText && interfaceTexts[result.responseText] ) 
     347            context.containerErrors.html( interfaceTexts[result.responseText] ); 
     348        else if( result.responseText ) 
    230349            context.containerErrors.html( result.responseText ); 
    231350        else 
    232351            context.containerErrors.html( result ); 
    233     }, 
    234  
    235     reduceLogin: function() 
    236     { 
    237         $( "#login" ).css( { zIndex:0 } ); 
    238         $( "#login_text" ).css( "visibility", "hidden" ); 
    239         $( "#login_bg" ).animate( { 
    240             opacity: 1, 
    241             height:'60px', 
    242             width:'78px', 
    243             zIndex:'0' 
    244         }, 2000, function() 
    245         { 
    246         } ); 
    247  
    248         $( "#login_button" ).animate( { 
    249             top:'16px', 
    250             left: '20px' 
    251         }, 2000, function() 
    252         { 
    253         } ); 
    254     }, 
    255  
    256     enlargeLogin: function() 
    257     { 
    258         $( "#login" ).css( { zIndex:1 } ); 
    259         $( "#login_bg" ).animate( { 
    260             opacity: 0.45, 
    261             height:'500px', 
    262             width:'500px' 
    263         }, 2000, function() 
    264         { 
    265             $( "#login_text" ).css( "visibility", "visible" ); 
    266         } ); 
    267  
    268         $( "#login_button" ).animate( { 
    269             top:'82px', 
    270             left: '155px' 
    271         }, 2000, function() 
    272         { 
    273         } ); 
     352        if( topValue && leftValue ) 
     353            context.containerErrors.css( {top: topValue, left: leftValue} ); 
     354        context.containerErrors.css( "visibility", "visible" ); 
     355    }, 
     356 
     357    showLoginError: function( result ) 
     358    { 
     359        this.onClickLogout(); 
     360        this.onClickLogo(); 
    274361    }, 
    275362 
     
    287374            opacity: 1, 
    288375            height:'42px', 
    289             width:'59px', 
     376            width:this.widthInitMentionsOrCredits + 'px', 
    290377            zIndex:'0' 
    291378        }, 2000, function() 
     
    317404    }, 
    318405 
    319     animateMenuCircle: function() 
     406    animateMenuLogos: function() 
    320407    { 
    321408        jQuery.each( this.projectsArray, jQuery.proxy( function( i, logo ) 
     
    330417    }, 
    331418 
    332     bindMenuCircle: function() 
    333     { 
     419    bindMenuLogos: function() 
     420    { 
     421        var gap = (this.logoSizeBig - this.logoSizeSmall) / 2; 
     422        var logoSizeBig = this.logoSizeBig + "px"; 
     423        var logoSizeSmall = this.logoSizeSmall + "px"; 
    334424        var gridimage; 
    335         $( '.divLogo' ).mouseover( 
    336                 function() 
    337                 { 
    338                     gridimage = $( this ).find( 'img' ); //Define target as a variable 
    339                     gridimage.stop().animate( {width: 50, height:50}, 150 ); 
    340                 } ).mouseout( 
    341                 jQuery.proxy( function( element ) 
    342                 { 
    343                     this.selectedLogo = element.currentTarget; 
    344                     gridimage.stop().animate( {width: this.logoSize, height:this.logoSize}, 150 ); 
    345                 }, this ) ).dblclick( 
    346                 jQuery.proxy( function() 
    347                 { 
    348                     this.onClickLogo(); 
    349                 }, this ) ); 
     425 
     426        $( '.divLogo' ).mouseover( function( element ) 
     427        { 
     428            gridimage = $( this ).find( 'img' ); //Define target as a variable 
     429            gridimage.stop().animate( { 
     430                width: logoSizeBig, 
     431                height: logoSizeBig 
     432            }, 150 ); 
     433            $( this ).animate( { 
     434                top: "-=10px", 
     435                left: "-=10px" 
     436            }, 150 ); 
     437        } ); 
     438 
     439        $( '.divLogo' ).mouseout( function( element ) 
     440        { 
     441            $( this ).animate( { 
     442                top: "+=10px", 
     443                left: "+=10px" 
     444            }, 150 ); 
     445            gridimage.stop().animate( { 
     446                width: logoSizeSmall, 
     447                height:logoSizeSmall 
     448            }, 150 ); 
     449        } ); 
     450 
     451        $( '.divLogo' ).dblclick( jQuery.proxy( function( element ) 
     452        { 
     453            this.selectedLogo = element.currentTarget; 
     454            this.onClickLogo(); 
     455        }, this ) ); 
    350456    }, 
    351457 
     
    379485        new Button( {value:"<spring:message code="statistics.data.download"/>", parent:this.rightSlide.getDivContent(), className: "positive action_button", onClick:jQuery.proxy( this.displayDownloadEvolution, this )} ); 
    380486        new Button( {value:"<spring:message code="statistics.map.distribution"/>", parent:this.rightSlide.getDivContent(), className: "positive action_button", onClick:jQuery.proxy( this.displayMapDistribution, this )} ); 
    381         new Button( {value:"<spring:message code="label.export"/>", parent:this.rightSlide.getDivContent(), className: "blue export_button print-preview", onClick:jQuery.proxy( this.onClickPrint, this )} ); 
     487        new Button( {value:"<spring:message code="label.print"/>", parent:this.rightSlide.getDivContent(), className: "blue export_button print-preview", onClick:jQuery.proxy( this.onClickPrint, this )} ); 
    382488    }, 
    383489 
     
    547653        this.changeMiddleSlideForMap(); 
    548654    } 
     655 
    549656} ); 
    550657 
Note: See TracChangeset for help on using the changeset viewer.