source: ether_statistics/web/project/statistics-script.jsp @ 591

Last change on this file since 591 was 591, checked in by vmipsl, 12 years ago

clean

File size: 7.3 KB
Line 
1<%@ page import="com.ether.WebHelper" %>
2<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
3
4<script type="text/javascript">
5
6var InterfaceStatistics = Class.create( {
7    initialize: function()
8    {
9        /** *********** CONTAINERS *********** **/
10        this.parent = $( "#containerMiddle" );
11        this.containerMenu = $( "#menuCircle" );
12
13        /** *********** VARIABLES *********** **/
14        this.language = '<spring:message code="language"/>';
15        this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>";
16        this.projectsArray = ["logo_Ether_50.jpg", "logo_Ndacc_50.jpg", "logo_ECCAD_50.gif", "logo_iasi_50.jpg", "logo_gosat_50.jpg", "logo_Iagos_50.jpg", "logo_tropico_50.jpg", "logo_Megapoli_50.png", "logo_mimosa_50.png", "logo_reprobus_50.png", "logo_geisa_50.jpg", "logo_tapas_50.png", "logo_acomida_50.jpg", "logo_omer7A_50.jpg", "logo_girafe_50.JPG", "logo_arletty_50.jpg"];
17        this.projectsPath = "resources/images/";
18
19        this.bindButtons();
20        this.createDivs();
21        this.createCircleMenu();
22        $( ".containerToDrag" ).draggable();
23    },
24
25
26    // CREATES AND BINDS ********************************************************
27    bindButtons: function()
28    {
29        $( "#home_button" ).bind( "dblclick", this.onClickHome );
30        $( "#language_button" ).bind( "dblclick", jQuery.proxy( this.onClickLanguage, this ) );
31        $( "#mail_button" ).bind( "dblclick", this.onClickMail );
32        $( "#login_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogin, this ) );
33    },
34
35    createDivs: function()
36    {
37        var div1 = this.createDiv( "div1", "150", "200", "200", "100", "Main statistics", "content" );
38        this.parent.append( div1 );
39        var div2 = this.createDiv( "div2", "250", "200", "150", "300", "MEGAPOLI Statistics", "content" );
40        this.parent.append( div2 );
41        var div3 = this.createDiv( "div3", "150", "200", "300", "600", "TAPAS Statistics", "content" );
42        this.parent.append( div3 );
43    },
44
45    createDiv: function( id, width, height, top, left, title, content )
46    {
47        var divContainer = $( document.createElement( "div" ) );
48        divContainer.addClass( "containerStatistics containerToDrag" );
49        divContainer.attr( {id:id, style:"width:" + width + "px; height:" + height + "px; top:" + top + "px; left:" + left + "px"} );
50        var divTitle = $( document.createElement( "div" ) );
51        divTitle.addClass( "containerStatisticsTitle" );
52        divTitle.html( title );
53        divTitle.attr( {style:"width:" + (width - 7) + "px"} );
54        divContainer.append( divTitle );
55        var divContent = $( document.createElement( "div" ) );
56        divContent.addClass( "containerStatisticsContent" );
57        divContent.html( content );
58        divContainer.append( divContent );
59        return divContainer;
60    },
61
62    createCircleMenu: function()
63    {
64        var menuSize = this.containerMenu.width();
65        var nbLogosForSize = (this.projectsArray.length / 2) + 1;
66        var divLogoSize = menuSize / nbLogosForSize;
67        var logoSize = divLogoSize - 5;
68        var stepLeft = 0;
69        var stepTop = this.createTopLevels( nbLogosForSize - 1 );
70        for( var i = 0; i < this.projectsArray.length; i++ )
71        {
72            var left = stepLeft * divLogoSize;
73            var top = menuSize / 2 - stepTop[stepLeft] * divLogoSize;
74            var divLogo = $( document.createElement( "div" ) );
75            divLogo.html( '<img id="img_' + this.projectsArray[i] + '"src="' + this.projectsPath + '' + this.projectsArray[i] + '" width="' + logoSize + 'px" height="' + logoSize + 'px"/>' );
76            divLogo.addClass( "divLogo" );
77            divLogo.attr( {id:this.projectsArray[i], style:"position:absolute; top:" + top + "px; left:" + left + "px"} );
78            this.containerMenu.append( divLogo );
79
80            if( 0 != i && (this.projectsArray.length - 1) != i )
81            {
82                top = menuSize / 2 + stepTop[stepLeft] * divLogoSize;
83                i++;
84                var divLogo2 = $( document.createElement( "div" ) );
85                divLogo2.html( '<img id="img_' + this.projectsArray[i] + '"src="' + this.projectsPath + '' + this.projectsArray[i] + '" width="' + logoSize + 'px" height="' + logoSize + 'px"/>' );
86                divLogo2.addClass( "divLogo" );
87                divLogo2.attr( {id:this.projectsArray[i], style:"position:absolute; top:" + top + "px; left:" + left + "px"} );
88                this.containerMenu.append( divLogo2 );
89            }
90            stepLeft++;
91        }
92
93//        $( ".divLogo" ).hover( function()
94//        {
95//            $( this )[0].firstChild.width = "50px";
96//            $( "#img_logo_mimosa_50.png" ).animate( {
97//                opacity: 1,
98//                width:'50px'
99//            }, 5000, function()
100//            {
101//            } );
102
103//            $("#img_logo_mimosa_50.png").stop(false, false).animate({width:'50px'}, 600);
104//            $( "#img_" + $( this )[0].id ).width( "50px" );
105//        } );
106    },
107
108    createTopLevels: function( nb )
109    {
110        var topLevels = [];
111        var level = 0;
112        for( var i = 0; i <= (nb / 2); i++ )
113        {
114            topLevels[i] = level;
115            topLevels[nb - i] = level;
116            level++;
117        }
118        return topLevels;
119    },
120
121    // REQUESTS ********************************************************
122    requestChangeLocale: function()
123    {
124        $.ajax( {
125            url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>",
126            success:function()
127            {
128                location.reload();
129            }
130        } );
131    },
132
133    // HANDLES ******************************************************** = retours ajax
134    handleCreateXML: function( result )
135    {
136        this.loadingRequest.hide();
137        //this.loadingRequest.display();
138
139        var res = jQuery.parseJSON( result ).result;
140        alert( res );
141    },
142
143
144    // EVENTS ********************************************************
145    onClickHome: function()
146    {
147        location.reload();
148    },
149
150    onClickLanguage: function()
151    {
152        this.requestChangeLocale();
153    },
154
155    onClickMail: function()
156    {
157        document.location.href = "mailto:" + this.webmaster + "?subject=[STATISTICS]";
158    },
159
160    onClickLogin: function()
161    {
162        if( 88 == $( "#login_bg" ).width() )
163            this.enlargeLogin();
164        else
165            this.reduceLogin();
166    },
167
168    onClickButtonLogin: function()
169    {
170        // TODO reduce cloud
171
172    },
173
174    // OTHERS ********************************************************
175    reduceLogin: function()
176    {
177        $( "#login_text" ).css( "visibility", "hidden" );
178        $( "#login_bg" ).animate( {
179            opacity: 1,
180            height:'60px',
181            width:'78px'
182        }, 5000, function()
183        {
184        } );
185
186        $( "#login_button" ).animate( {
187            top:'16px',
188            left: '20px'
189        }, 5000, function()
190        {
191        } );
192    },
193
194    enlargeLogin: function()
195    {
196        $( "#login_bg" ).animate( {
197            opacity: 0.45,
198            height:'500px',
199            width:'500px'
200        }, 5000, function()
201        {
202            $( "#login_text" ).css( "visibility", "visible" );
203        } );
204
205        $( "#login_button" ).animate( {
206            top:'82px',
207            left: '155px'
208        }, 5000, function()
209        {
210        } );
211    }
212
213} );
214
215</script>
Note: See TracBrowser for help on using the repository browser.