source: extensions/EStat/js/estatPM.js @ 17760

Last change on this file since 17760 was 17758, checked in by grum, 12 years ago

version 0.1.0b

. Fix install bugs
. Manage anonymous directories
. Manage CSV export options settings
. Fix IPadress<=>country association bug & improve join performances
. Fix bug on IP filter
. Improve performances for history consult

  • Property svn:executable set to *
File size: 93.7 KB
Line 
1/**
2 * -----------------------------------------------------------------------------
3 * file: estatPM.js
4 * file version: 1.0.0
5 * date: 2011-12-02
6 *
7 * Page Manager
8 */
9
10var themeColor={
11      border:'#666666',
12      background:'#222222'
13    }
14
15
16/**
17 * estatPM class
18 * used to manage the admin interface
19 *
20 * public functions :
21 *  - changePage(pageName)
22 */
23$.EStatManagePages = function (fct, values)
24{
25  var $this = this,
26      properties={
27        url:'',
28        urlExport:'',
29        token:'',
30        currentPage:'Stats_by_period',
31        initPhase:false,
32        graph:{
33            axis:{
34                color:'#666666',
35                ticksSize:{
36                    small:1,
37                    big:10
38                  },
39                minSpaceLast:5,
40                frequency:{
41                    small:2,
42                    big:5
43                  },
44                value:{
45                    rotateH:20,
46                    rotateV:0,
47                    fontName:'arial',
48                    fontSize:8
49                  }
50              },
51            colors:{
52                normal:[
53                    '#ffdd18',  //  0: yellow
54                    '#b73561',  //  1: red purple
55                    '#00a14b',  //  2: green
56                    '#fe4819',  //  3: red-orange
57                    '#21409a',  //  4: blue
58                    '#f99d28',  //  5: yellow-orange
59                    '#7f4098',  //  6: purple
60                    '#8cc63f',  //  7: yellow-green
61                    '#ed1c24',  //  8: red
62                    '#07707d',  //  9: blue-green
63                    '#f26522',  // 10: orange
64                    '#584099'   // 11: blue-purple
65                  ],
66                light:[
67                    '#ffe466',  //  0: yellow
68                    '#c5667a',  //  1: red purple
69                    '#6ab574',  //  2: green
70                    '#f58256',  //  3: red-orange
71                    '#5a64ac',  //  4: blue
72                    '#fcbe75',  //  5: yellow-orange
73                    '#996caf',  //  6: purple
74                    '#a8d171',  //  7: yellow-green
75                    '#f16045',  //  8: red
76                    '#548490',  //  9: blue-green
77                    '#f78f58',  // 10: orange
78                    '#7968ae'   // 11: blue-purple
79                  ],
80                dark:[
81                    '#bfa417',  //  0: yellow
82                    '#872146',  //  1: red purple
83                    '#057938',  //  2: green
84                    '#b23016',  //  3: red-orange
85                    '#142a75',  //  4: blue
86                    '#b8761f',  //  5: yellow-orange
87                    '#5f2974',  //  6: purple
88                    '#66952d',  //  7: yellow-green
89                    '#b11016',  //  8: red
90                    '#05535d',  //  9: blue-green
91                    '#b34b14',  // 10: orange
92                    '#422a74'   // 11: blue-purple
93                  ],
94                gray:[
95                    '#111111',  //  0:
96                    '#222222',  //  1:
97                    '#333333',  //  2:
98                    '#444444',  //  3:
99                    '#555555',  //  4:
100                    '#666666',  //  5:
101                    '#777777',  //  6:
102                    '#888888',  //  7:
103                    '#999999',  //  8:
104                    '#AAAAAA',  //  9:
105                    '#BBBBBB',  // 10:
106                    '#CCCCCC',  // 11:
107                    '#DDDDDD',  // 12:
108                    '#EEEEEE'   // 13:
109                  ]
110              }
111          },
112        history:{
113            graphAllPeriods:{
114                axis:null,
115                serieTotal:null,
116                serieComputer:null,
117                serieMobile:null,
118                serieCrawler:null,
119                serieOther:null
120              },
121            graphCurrentPeriod:{
122                axis:null,
123                serieTotal:null,
124                serieComputer:null,
125                serieMobile:null,
126                serieCrawler:null,
127                serieOther:null
128              }
129          },
130        period:{
131            graph:{
132                axis:null,
133                serieViewedAlbums:null,
134                serieViewedImages:null,
135                serieViewedPages:null,
136                serieUniqueIP:null
137              }
138          },
139        ip:{
140            graphType:{
141                axis:null,
142                serie:null
143              },
144            graphCountry:{
145                axis:null,
146                serie:null
147              }
148          }
149      }, // << properties={...}
150
151    /**
152     * -------------------------------------------------------------------------
153     * set the properties values
154     * -------------------------------------------------------------------------
155     */
156    setProperties = function (values)
157      {
158        if(values==null)
159          values=$(window).data('EStatMPProperties');
160
161        if(values==null) return(false);
162
163        if(values.url)
164          properties.url=values.url;
165
166        if(values.urlExport)
167          properties.urlExport=values.urlExport;
168
169        if(values.token)
170          properties.token=values.token;
171
172        if(values.currentPage)
173          properties.currentPage=values.currentPage;
174
175        if(values.history)
176          properties.history=values.history;
177
178        if(values.period)
179          properties.period=values.period;
180
181        if(values.ip)
182          properties.ip=values.ip;
183
184        $(window).data('EStatMPProperties', properties);
185        return(true);
186      }, // << setProperties()
187
188
189
190    /**
191     * -------------------------------------------------------------------------
192     *
193     *                      INITIALIZATION FUNCTIONS
194     *
195     *
196     * -------------------------------------------------------------------------
197     */
198
199    /**
200     * -------------------------------------------------------------------------
201     * this function initialize the page (jquery objects) and preload data page
202     * -------------------------------------------------------------------------
203     */
204    init=function ()
205      {
206        properties.initPhase=true;
207
208        initGlobalObjects();
209        //initPageSynthesis();
210        initPagePeriod();
211        initPageIP();
212        initPageCategory();
213        initPageImage();
214        initPageHistory();
215        //initPageConfig();
216        //initPageTools();
217
218        properties.initPhase=false;
219        changePage('Stats_by_period');
220      },
221
222    /**
223     * -------------------------------------------------------------------------
224     * initialise objects common to all pages
225     * -------------------------------------------------------------------------
226     */
227    initGlobalObjects = function()
228      {
229        $('#iFilterCatId').categorySelector(
230          {
231            listMaxWidth:600,
232            listMaxHeight:350,
233            displayStatus:true,
234            displayPath:true,
235            multiple:true,
236            levelIndent:20,
237            userMode:'public',
238            galleryRoot:false,
239            load: function (event)
240                    {
241                      $(this).categorySelector('expand', ':all+0');
242                      //$(this).categorySelector('value', ':first');
243                    },
244            change: function (event)
245                    {
246                      loadPage();
247                    }
248          }
249        );
250
251        $('#iFilterPeriodId').inputTreeList(
252          {
253            listMaxWidth:600,
254            listMaxHeight:350,
255            levelIndent:15,
256            iconWidthEC:10,
257            displayPath:true,
258            postUrl:properties.url,
259            displayNfo:false,
260            multiple:false,
261            postData:{
262              ajaxfct:"admin.stat.periodTreeList",
263              token:properties.token
264            },
265            load: function (event)
266                    {
267                      $(this).inputTreeList('collapse', ':all+0');
268                      $(this).inputTreeList('value', ':first');
269                    },
270            change: function (event)
271                    {
272                      loadPage();
273                    }
274          }
275        );
276      }, // << initGlobalObjects()
277
278    initPageSynthesis = function()
279      {
280
281      }, // << initPageSynthesis()
282
283    /**
284     * -------------------------------------------------------------------------
285     * initialise objects for period page
286     * -------------------------------------------------------------------------
287     */
288    initPagePeriod = function()
289      {
290        // create history dynamic table
291        $('#iPeriodTable').dynamicTable(
292          {
293            columns:
294              [
295                {
296                  id:'period',
297                  title:translateString.period,
298                  sortable:'no',
299                  width:'20%'
300                },
301                {
302                  id:'viewedPages',
303                  title:translateString.viewedPages,
304                  sortable:'no',
305                  width:'20%'
306                },
307
308                {
309                  id:'viewedAlbums',
310                  title:translateString.viewedAlbums,
311                  sortable:'no',
312                  width:'20%'
313                },
314
315                {
316                  id:'viewedImages',
317                  title:translateString.viewedImages,
318                  sortable:'no',
319                  width:'20%'
320                },
321
322                {
323                  id:'uniqueIP',
324                  title:translateString.uniqueIP,
325                  sortable:'no'
326                }
327              ],
328            showTotalRow:'visible',
329            showSaveButton:false,
330            autoLoad:false,
331            postUrl:properties.url,
332            postData:
333              {
334                ajaxfct:"admin.stat.period",
335                token:properties.token,
336                period:''
337              },
338            minHeight:350,
339            maxHeight:350,
340            footerString:
341              {
342                singular:'',
343                plural:''
344              },
345/*
346            pageChanged: function (event, value)
347              {
348              },
349*/
350            contentLoading: function (event, value)
351              {
352                $('#iPeriodTable').dynamicTable('click', 'clear');
353              },
354            contentLoaded: function (event, value)
355              {
356                switch($('#iPeriodPath').inputPath('level'))
357                {
358                  case 1:
359                  case 2:
360                    $('#iPeriodTable').dynamicTable('click', clickOnPeriodTable);
361                    break;
362                  case 3:
363                    $('#iPeriodTable').dynamicTable('click', 'clear');
364                    break;
365                }
366
367              },
368            click: clickOnPeriodTable
369          }
370        );
371
372
373        // create graph - stat for all period
374        properties.period.graph.axis=new CDAxis(
375          {
376            mode:'XY',
377            display:{
378              color:properties.graph.axis.color,
379              visible:
380                {
381                  XY:
382                  {
383                    H:true,
384                    V:true
385                  }
386                }
387            },
388            XY:{
389              ticks:{
390                  H:{
391                    size:{
392                      small:properties.graph.axis.ticksSize.small,
393                      big:properties.graph.axis.ticksSize.big
394                    },
395                    visible:{
396                      small:true,
397                      big:true
398                    },
399                    minSpaceLast:properties.graph.axis.minSpaceLast,
400                    frequency:{
401                      small:1, //properties.graph.axis.frequency.small,
402                      big:1 //properties.graph.axis.frequency.big
403                    },
404                    value:{
405                      rotate:properties.graph.axis.value.rotateH,
406                      visible:true,
407                      fontName:properties.graph.axis.value.fontName,
408                      fontSize:properties.graph.axis.value.fontSize
409                    },
410                    offset0:true
411                  },
412                  V:{
413                    unit:'',
414                    size:{
415                      small:properties.graph.axis.ticksSize.small,
416                      big:properties.graph.axis.ticksSize.big
417                    },
418                    visible:{
419                      small:true,
420                      big:true
421                    },
422                    minSpaceLast:properties.graph.axis.minSpaceLast,
423                    steps:10000,
424                    frequency:{
425                      small:250,
426                      big:1000
427                    },
428                    value:{
429                      rotate:properties.graph.axis.value.rotateV,
430                      visible:true,
431                      fontName:properties.graph.axis.value.fontName,
432                      fontSize:properties.graph.axis.value.fontSize
433                    }
434                  }
435                }
436              },
437            values:{H:[]}
438          }
439        );
440
441        properties.period.graph.serieViewedPages=new CDSerie(
442          {
443            name:'viewedPages',
444            order:10,
445            values:[],
446            options:new CDSerieOptionsBar(
447              {
448                backgroundColor:properties.graph.colors.gray[3],
449                borderColor:properties.graph.colors.gray[7],
450                borderWidth:0,
451                width:1,
452                offset:0
453              }
454            )
455          }
456        );
457
458        properties.period.graph.serieViewedAlbums=new CDSerie(
459          {
460            name:'viewedAlbums',
461            order:2,
462            values:[],
463            options:new CDSerieOptionsLine(
464              {
465                color:properties.graph.colors.normal[0],
466                width:1,
467                offset:0
468              }
469            )
470          }
471        );
472
473        properties.period.graph.serieViewedImages=new CDSerie(
474          {
475            name:'viewedImages',
476            order:3,
477            values:[],
478            options:new CDSerieOptionsLine(
479              {
480                color:properties.graph.colors.normal[1],
481                width:1,
482                offset:0
483              }
484            )
485          }
486        );
487
488        properties.period.graph.serieUniqueIP=new CDSerie(
489          {
490            name:'uniqueIP',
491            order:4,
492            values:[],
493            options:new CDSerieOptionsLine(
494              {
495                color:properties.graph.colors.normal[2],
496                width:1,
497                offset:0
498              }
499            )
500          }
501        );
502
503        properties.period.graph.axis.serieAdd(properties.period.graph.serieViewedAlbums);
504        properties.period.graph.axis.serieAdd(properties.period.graph.serieViewedImages);
505        properties.period.graph.axis.serieAdd(properties.period.graph.serieViewedPages);
506        properties.period.graph.axis.serieAdd(properties.period.graph.serieUniqueIP);
507
508
509        $('#iPeriodGraph').drawingGraph(
510          {
511            display:
512              {
513                width:450,
514                height:150
515              },
516            cursor:
517              {
518                verticalType:'line'
519              },
520            margins:new CDMargins({top:5,bottom:45, left:50, right:1}),
521            legend:new CDLegend({
522                          width:0,
523                          visible:false,
524                          position:'right',  // left or right
525                          backgroundColor:themeColor.background,
526                          borderColor:themeColor.border,
527                          borderWidth:0,
528                          fontName:'arial',
529                          fontSize:10
530                        }),
531            axis:{front:properties.period.graph.axis, back:null},
532            events:{
533              mouseEnter:function (event)
534                          {
535                            var geometry={
536                                  x:0,
537                                  y:0,
538                                  w:250,
539                                  h:75
540                                };
541
542                            geometry.x=$('#iPeriodGraph').offset().left+($('#iPeriodGraph').width()-geometry.w)/2;
543                            geometry.y=$('#iPeriodGraph').offset().top-geometry.h-10;
544                            displayPopupInfo(true, geometry, getPeriodPopupContent());
545                          },
546              mouseLeave:function (event)
547                          {
548                            displayPopupInfo(false);
549                          },
550              mousePositionChange:function (event, data)
551                          {
552                            var list=['viewedAlbums', 'viewedImages', 'uniqueIP', 'viewedPages'];
553                            for(i=0;i<list.length;i++)
554                            {
555                              $('#iPI_'+list[i]).html(data.values[i].value);
556                            }
557                          }
558            }
559          }
560        );
561
562        $('#iPeriodPath')
563          .inputPath(
564            {
565              separator:'&gt;',
566              autoSetLevel:true,
567              click: function (event, value)
568                {
569                   loadPageStatByPeriod();
570                }
571            }
572          )
573          .inputPath('push', {id:'allYear', label:translateString.allYear});
574
575      }, // << initPagePeriod()
576
577
578
579    /**
580     * -------------------------------------------------------------------------
581     * initialise objects for IP page
582     * -------------------------------------------------------------------------
583     */
584    initPageIP = function()
585      {
586        // create IP dynamic table
587        $('#iIPTable').dynamicTable(
588          {
589            columns:
590              [
591                {
592                  id:'IPadress',
593                  title:translateString.ipAdress,
594                  sortable:'asc',
595                  filter:
596                    {
597                      title:translateString.ipAdress,
598                      dataType:'string',
599                      data:{
600                          regexp:'\d{1,3}(?:\.\d{1,3}){0,3}'
601                        },
602                      defaultOperator:'like',
603                      filterOperators:['like', 'not like', 'between', 'not between']
604                    },
605                  group:true,
606                  width:'100px'
607                },
608
609                {
610                  id:'country',
611                  title:translateString.filter.country,
612                  sortable:'asc',
613                  group:true,
614                  filter:
615                    {
616                      title:translateString.filter.country,
617                      dataType:'dataset-url',
618                      data:{
619                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=country&token='+properties.token
620                        },
621                      defaultOperator:'in',
622                      filterOperators:['in']
623                    }
624                },
625
626                {
627                  id:'uaType',
628                  title:translateString.type,
629                  filter:
630                    {
631                      title:translateString.filter.type,
632                      dataType:'dataset-url',
633                      data:{
634                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaType&token='+properties.token
635                        },
636                      defaultOperator:'in',
637                      filterOperators:['in']
638                    },
639                  group:true,
640                  sortable:'asc',
641                  width:'125px'
642                },
643
644                {
645                  id:'nbVisits',
646                  title:translateString.visits,
647                  sortable:'asc',
648                  width:'90px'
649                }
650
651              ],
652            showTotalRow:'visible',
653            showSaveButton:true,
654            autoLoad:false,
655            postUrl:properties.url,
656            postData:
657              {
658                ajaxfct:"admin.stat.ip",
659                token:properties.token,
660                period:''
661              },
662            minHeight:350,
663            maxHeight:350,
664            sortBoxTitle:translateString.sortBy,
665            footerString:
666              {
667                singular:translateString.item_nb,
668                plural:translateString.items_nb,
669                waitForDownload:translateString.waitForDownload
670              },
671            dialogsButtons:{
672                ok:translateString.ok,
673                cancel:translateString.cancel,
674                erase:translateString.eraseFilter
675              },
676            saveButtonClick: function (event, data)
677              {
678                $.dialogExport(
679                  {
680                    title:translateString.dataExport,
681                    buttons:
682                      {
683                        ok:translateString.ok,
684                        cancel:translateString.cancel
685                      },
686                    name:'ipAdress',
687                    format:'csv',
688                    compression:'gz',
689                    formatList:
690                      [
691                        {id:'csv', text:translateString.fileFormatCSV, infos:'(.csv)'},
692                        {id:'ods', text:translateString.fileFormatODS, infos:'(.ods)'},
693                        {id:'sqlite', text:translateString.fileFormatSQLite, infos:'(.db)'}
694                      ],
695                    compressionList:
696                      [
697                        {id:'none', text:translateString.fileCompressionNone, infos:''},
698                        {id:'zip', text:translateString.fileCompressionZIP, infos:'(.zip)'},
699                        {id:'gz', text:translateString.fileCompressionGZ, infos:'(.gz)'},
700                        {id:'bz2', text:translateString.fileCompressionBZ2, infos:'(.bz2)'}
701                      ],
702                    validExport: function (event, values)
703                      {
704                       $('#iIPTable').dynamicTable('waitForDownload', true);
705                        $.ajax(
706                          {
707                            type: "POST",
708                            url: properties.urlExport,
709                            data:
710                              {
711                                ajaxfct:'admin.export.ip',
712                                name:values.name,
713                                format:values.format,
714                                compression:values.compression,
715                                token:properties.token,
716                                period:$('#iFilterPeriodId').inputTreeList('value'),
717                                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')},
718                                sort:data.sort,
719                                filter:data.filter,
720                                group:data.group
721                              },
722                            async: true,
723                            success: function(msg)
724                              {
725                                $('#iIPTable').dynamicTable('waitForDownload', false);
726                                if(msg.substr(0,3)=='OK:')
727                                {
728                                  $.download(msg.substr(3));
729                                }
730                                else
731                                {
732                                  alert(translateString.downloadError);
733                                }
734                              },
735                            error: function(msg)
736                              {
737                                $('#iIPTable').dynamicTable('waitForDownload', false);
738                              }
739                          }
740                        );
741                      }
742                  }
743                );
744              },
745              /*
746            pageChanged: function (event, value)
747              {
748              },
749            contentLoading: function (event, value)
750              {
751              },
752            contentLoaded: function (event, value)
753              {
754              },
755            click: function (event, value)
756              {
757              }
758*/
759          }
760        );
761
762
763        // create graph - stat for type of browser
764        properties.ip.graphType.axis=new CDAxis(
765          {
766            mode:'pie',
767            display:{visible:{pie:false}}
768          }
769        );
770        properties.ip.graphType.serie=new CDSerie(
771          {
772            name:translateString.type,
773            order:1,
774            values:[],
775            valuesLabels:[],
776            options:new CDSerieOptionsPie(
777              {
778                outerRadius:85,
779                innerRadius:20,
780                offset:0,
781                borderWidth:1,
782                backgroundColors:properties.graph.colors.light
783              }
784            )
785          }
786        );
787        properties.ip.graphType.axis.serieAdd(properties.ip.graphType.serie);
788
789        $('#iIPGraphType').drawingGraph(
790          {
791            display:
792              {
793                width:225,
794                height:150
795              },
796            margins:new CDMargins({top:0,bottom:0, left:0, right:0}),
797            legend:new CDLegend({
798                          width:20,
799                          visible:true,
800                          position:'left',  // left or right
801                          backgroundColor:themeColor.background,
802                          borderColor:themeColor.border,
803                          borderWidth:0,
804                          fontName:'arial',
805                          fontSize:10
806                        }),
807            axis:{front:properties.ip.graphType.axis, back:null}
808/*
809            events:{
810              mouseEnter:function (event)
811                          {
812                          },
813              mouseLeave:function (event)
814                          {
815                          },
816              mousePositionChange:function (event, data)
817                          {
818                          }
819            }
820*/
821          }
822        );
823
824
825        // create graph - stat for countries
826        properties.ip.graphCountry.axis=new CDAxis(
827          {
828            mode:'pie',
829            display:{visible:{pie:false}}
830          }
831        );
832        properties.ip.graphCountry.serie=new CDSerie(
833          {
834            name:translateString.country,
835            order:1,
836            values:[],
837            valuesLabels:[],
838            options:new CDSerieOptionsPie(
839              {
840                outerRadius:85,
841                innerRadius:20,
842                offset:0,
843                borderWidth:1,
844                backgroundColors:properties.graph.colors.light
845              }
846            )
847          }
848        );
849        properties.ip.graphCountry.axis.serieAdd(properties.ip.graphCountry.serie);
850
851        $('#iIPGraphCountry').drawingGraph(
852          {
853            display:
854              {
855                width:225,
856                height:150
857              },
858            margins:new CDMargins({top:0,bottom:0, left:0, right:0}),
859            legend:new CDLegend({
860                          width:20,
861                          visible:true,
862                          position:'left',  // left or right
863                          backgroundColor:themeColor.background,
864                          borderColor:themeColor.border,
865                          borderWidth:0,
866                          fontName:'arial',
867                          fontSize:10
868                        }),
869            axis:{front:properties.ip.graphCountry.axis, back:null}
870/*
871            events:{
872              mouseEnter:function (event)
873                          {
874                          },
875              mouseLeave:function (event)
876                          {
877                          },
878              mousePositionChange:function (event, data)
879                          {
880                          }
881            }
882*/
883          }
884        );
885
886      }, // << initPageIP()
887
888    initPageCategory = function()
889      {
890        // create albums/categories dynamic table
891        $('#iCategoryTable').dynamicTable(
892          {
893            columns:
894              [
895                {
896                  id:'catId',
897                  title:translateString.album,
898                  sortable:'asc'
899                },
900
901                {
902                  id:'uaType',
903                  title:translateString.type,
904                  filter:
905                    {
906                      title:translateString.filter.type,
907                      dataType:'dataset-url',
908                      data:{
909                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaType&token='+properties.token
910                        },
911                      defaultOperator:'in',
912                      filterOperators:['in']
913                    },
914                  group:true,
915                  sortable:'asc',
916                  width:'125px'
917                },
918
919                {
920                  id:'nbVisits',
921                  title:translateString.visits,
922                  sortable:'asc',
923                  width:'125px'
924                }
925              ],
926            showTotalRow:'visible',
927            showSaveButton:true,
928            autoLoad:false,
929            postUrl:properties.url,
930            postData:
931              {
932                ajaxfct:"admin.stat.category",
933                token:properties.token,
934                period:''
935              },
936            minHeight:350,
937            maxHeight:350,
938            sortBoxTitle:translateString.sortBy,
939            footerString:
940              {
941                singular:translateString.item_nb,
942                plural:translateString.items_nb,
943                waitForDownload:translateString.waitForDownload
944              },
945            dialogsButtons:{
946                ok:translateString.ok,
947                cancel:translateString.cancel,
948                erase:translateString.eraseFilter
949              },
950/*
951            pageChanged: function (event, value)
952              {
953              },
954            contentLoaded: function (event, value)
955              {
956              },
957            click: function (event, value)
958              {
959              },
960*/
961            saveButtonClick: function (event, data)
962              {
963                $.dialogExport(
964                  {
965                    title:translateString.dataExport,
966                    buttons:
967                      {
968                        ok:translateString.ok,
969                        cancel:translateString.cancel
970                      },
971                    name:'album',
972                    format:'csv',
973                    compression:'gz',
974                    formatList:
975                      [
976                        {id:'csv', text:translateString.fileFormatCSV, infos:'(.csv)'},
977                        {id:'ods', text:translateString.fileFormatODS, infos:'(.ods)'},
978                        {id:'sqlite', text:translateString.fileFormatSQLite, infos:'(.db)'}
979                      ],
980                    compressionList:
981                      [
982                        {id:'none', text:translateString.fileCompressionNone, infos:''},
983                        {id:'zip', text:translateString.fileCompressionZIP, infos:'(.zip)'},
984                        {id:'gz', text:translateString.fileCompressionGZ, infos:'(.gz)'},
985                        {id:'bz2', text:translateString.fileCompressionBZ2, infos:'(.bz2)'}
986                      ],
987                    validExport: function (event, values)
988                      {
989                        $('#iCategoryTable').dynamicTable('waitForDownload', true);
990                        $.ajax(
991                          {
992                            type: "POST",
993                            url: properties.urlExport,
994                            data:
995                              {
996                                ajaxfct:'admin.export.category',
997                                name:values.name,
998                                format:values.format,
999                                compression:values.compression,
1000                                token:properties.token,
1001                                period:$('#iFilterPeriodId').inputTreeList('value'),
1002                                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')},
1003                                sort:data.sort,
1004                                filter:data.filter,
1005                                group:data.group
1006                              },
1007                            async: true,
1008                            success: function(msg)
1009                              {
1010                                $('#iCategoryTable').dynamicTable('waitForDownload', false);
1011                                if(msg.substr(0,3)=='OK:')
1012                                {
1013                                  $.download(msg.substr(3));
1014                                }
1015                                else
1016                                {
1017                                  alert(translateString.downloadError);
1018                                }
1019                              },
1020                            error: function(msg)
1021                              {
1022                                $('#iCategoryTable').dynamicTable('waitForDownload', false);
1023                              }
1024                          }
1025                        );
1026                      }
1027                  }
1028                );
1029              },
1030            contentLoading: function (event, value)
1031              {
1032                $(this).find('tr[oid]').unbind('mouseenter mouseleave');
1033              },
1034            contentDisplayed: function (event, value)
1035              {
1036                for(var i=0;i<value.rows.length;i++)
1037                {
1038                  if(value.rows[i][3]!='')
1039                  {
1040                    $(this).find('tr[oid='+i+']')
1041                      .bind('mouseenter', {v:value.rows[i][3]}, function (e)
1042                                {
1043                                  displayPopupThumb(true, {x:e.pageX, y:$(this).offset().top}, e.data.v);
1044                                }
1045                            )
1046                      .bind('mouseleave', function (e)
1047                                {
1048                                  displayPopupThumb(false);
1049
1050                                }
1051                            );
1052                  }
1053                }
1054              }
1055          }
1056        );
1057      }, // << initPageCategory()
1058
1059    initPageImage = function()
1060      {
1061        // create albums/categories dynamic table
1062        $('#iImageTable').dynamicTable(
1063          {
1064            columns:
1065              [
1066                {
1067                  id:'imageId',
1068                  title:translateString.image,
1069                  sortable:'asc'
1070                },
1071
1072                {
1073                  id:'uaType',
1074                  title:translateString.type,
1075                  filter:
1076                    {
1077                      title:translateString.filter.type,
1078                      dataType:'dataset-url',
1079                      data:{
1080                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaType&token='+properties.token
1081                        },
1082                      defaultOperator:'in',
1083                      filterOperators:['in']
1084                    },
1085                  group:true,
1086                  sortable:'asc',
1087                  width:'125px'
1088                },
1089
1090                {
1091                  id:'nbVisits',
1092                  title:translateString.visits,
1093                  sortable:'asc',
1094                  width:'125px'
1095                }
1096              ],
1097            showTotalRow:'visible',
1098            showSaveButton:true,
1099            autoLoad:false,
1100            postUrl:properties.url,
1101            postData:
1102              {
1103                ajaxfct:"admin.stat.image",
1104                token:properties.token,
1105                period:''
1106              },
1107            minHeight:350,
1108            maxHeight:350,
1109            sortBoxTitle:translateString.sortBy,
1110            footerString:
1111              {
1112                singular:translateString.item_nb,
1113                plural:translateString.items_nb,
1114                waitForDownload:translateString.waitForDownload
1115              },
1116            dialogsButtons:{
1117                ok:translateString.ok,
1118                cancel:translateString.cancel,
1119                erase:translateString.eraseFilter
1120              },
1121/*
1122            pageChanged: function (event, value)
1123              {
1124              },
1125            contentLoaded: function (event, value)
1126              {
1127              },
1128            click: function (event, value)
1129              {
1130              }
1131*/
1132            saveButtonClick: function (event, data)
1133              {
1134                $.dialogExport(
1135                  {
1136                    title:translateString.dataExport,
1137                    buttons:
1138                      {
1139                        ok:translateString.ok,
1140                        cancel:translateString.cancel
1141                      },
1142                    name:'images',
1143                    format:'csv',
1144                    compression:'gz',
1145                    formatList:
1146                      [
1147                        {id:'csv', text:translateString.fileFormatCSV, infos:'(.csv)'},
1148                        {id:'ods', text:translateString.fileFormatODS, infos:'(.ods)'},
1149                        {id:'sqlite', text:translateString.fileFormatSQLite, infos:'(.db)'}
1150                      ],
1151                    compressionList:
1152                      [
1153                        {id:'none', text:translateString.fileCompressionNone, infos:''},
1154                        {id:'zip', text:translateString.fileCompressionZIP, infos:'(.zip)'},
1155                        {id:'gz', text:translateString.fileCompressionGZ, infos:'(.gz)'},
1156                        {id:'bz2', text:translateString.fileCompressionBZ2, infos:'(.bz2)'}
1157                      ],
1158                    validExport: function (event, values)
1159                      {
1160                        $('#iImageTable').dynamicTable('waitForDownload', true);
1161                        $.ajax(
1162                          {
1163                            type: "POST",
1164                            url: properties.urlExport,
1165                            data:
1166                              {
1167                                ajaxfct:'admin.export.image',
1168                                name:values.name,
1169                                format:values.format,
1170                                compression:values.compression,
1171                                token:properties.token,
1172                                period:$('#iFilterPeriodId').inputTreeList('value'),
1173                                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')},
1174                                sort:data.sort,
1175                                filter:data.filter,
1176                                group:data.group
1177                              },
1178                            async: true,
1179                            success: function(msg)
1180                              {
1181                                $('#iImageTable').dynamicTable('waitForDownload', false);
1182                                if(msg.substr(0,3)=='OK:')
1183                                {
1184                                  $.download(msg.substr(3));
1185                                }
1186                                else
1187                                {
1188                                  alert(translateString.downloadError);
1189                                }
1190                              },
1191                            error: function(msg)
1192                              {
1193                                $('#iImageTable').dynamicTable('waitForDownload', false);
1194                              }
1195                          }
1196                        );
1197                      }
1198                  }
1199                );
1200              },
1201            contentLoading: function (event, value)
1202              {
1203                $(this).find('tr[oid]').unbind('mouseenter mouseleave');
1204              },
1205            contentDisplayed: function (event, value)
1206              {
1207                for(var i=0;i<value.rows.length;i++)
1208                {
1209                  if(value.rows[i][3]!='')
1210                  {
1211                    $(this).find('tr[oid='+i+']')
1212                      .bind('mouseenter', {v:value.rows[i][3]}, function (e)
1213                                {
1214                                  displayPopupThumb(true, {x:e.pageX, y:$(this).offset().top}, e.data.v);
1215                                }
1216                            )
1217                      .bind('mouseleave', function (e)
1218                                {
1219                                  displayPopupThumb(false);
1220
1221                                }
1222                            );
1223                  }
1224                }
1225              }
1226          }
1227        );
1228      }, // << initPageImage()
1229
1230
1231    /**
1232     * -------------------------------------------------------------------------
1233     * initialise objects for history page
1234     * -------------------------------------------------------------------------
1235     */
1236    initPageHistory = function()
1237      {
1238        // create history dynamic table
1239        $('#iHistoryTable').dynamicTable(
1240          {
1241            columns:
1242              [
1243                {
1244                  id:'date',
1245                  title:translateString.dateTime,
1246                  filter:
1247                    {
1248                      title:translateString.filter.dateTime,
1249                      dataType:'datetime',
1250                      data:{
1251                          timeFormat:'hh:mm'
1252                        },
1253                      defaultOperator:'between',
1254                      filterOperators:['>', '<', '>=', '<=', '=', '!=', 'between', 'not between']
1255                    },
1256                  sortable:'asc',
1257                  width:'125px'
1258                },
1259                {
1260                  id:'IPadress',
1261                  title:translateString.ip_user,
1262                  filter:
1263                    {
1264                      title:translateString.filter.ipAdress,
1265                      dataType:'string',
1266                      data:{
1267                          regexp:'\d{1,3}(?:\.\d{1,3}){0,3}'
1268                        },
1269                      defaultOperator:'like',
1270                      filterOperators:['like', 'not like', 'between', 'not between']
1271                    },
1272                  sortable:'asc',
1273                  width:'125px'
1274                },
1275
1276                {
1277                  id:'catId',
1278                  title:translateString.album,
1279                  sortable:'no',
1280                  width:'225px'
1281                },
1282
1283                {
1284                  id:'imageId',
1285                  title:translateString.image,
1286                  sortable:'no',
1287                  width:'200px'
1288                },
1289
1290                {
1291                  id:'tags',
1292                  title:translateString.tags,
1293                  sortable:'no'
1294                },
1295
1296                {
1297                  id:'section',
1298                  title:translateString.section,
1299                  filter:
1300                    {
1301                      title:translateString.filter.section,
1302                      dataType:'dataset',
1303                      data:{
1304                          serverUrl:''
1305                        },
1306                      defaultOperator:'in',
1307                      filterOperators:['in']
1308                    },
1309                  sortable:'asc',
1310                  width:'100px'
1311                },
1312
1313                {
1314                  id:'uaBrowser',
1315                  title:translateString.browser,
1316                  filter:
1317                    {
1318                      title:translateString.filter.browser,
1319                      dataType:'dataset-url',
1320                      data:{
1321                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaBrowser&token='+properties.token
1322                        },
1323                      defaultOperator:'in',
1324                      filterOperators:['in']
1325                    },
1326                  sortable:'asc',
1327                  width:'165px'
1328                },
1329
1330                {
1331                  id:'uaEngine',
1332                  title:translateString.engine,
1333                  filter:
1334                    {
1335                      title:translateString.filter.engine,
1336                      dataType:'dataset-url',
1337                      data:{
1338                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaEngine&token='+properties.token
1339                        },
1340                      defaultOperator:'in',
1341                      filterOperators:['in']
1342                    },
1343                  sortable:'asc',
1344                  width:'125px'
1345                },
1346
1347                {
1348                  id:'uaOS',
1349                  title:translateString.os,
1350                  filter:
1351                    {
1352                      title:translateString.filter.os,
1353                      dataType:'dataset-url',
1354                      data:{
1355                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaOS&token='+properties.token
1356                        },
1357                      defaultOperator:'in',
1358                      filterOperators:['in']
1359                    },
1360                  sortable:'asc',
1361                  width:'125px'
1362                },
1363
1364                {
1365                  id:'uaType',
1366                  title:translateString.type,
1367                  filter:
1368                    {
1369                      title:translateString.filter.type,
1370                      dataType:'dataset-url',
1371                      data:{
1372                          serverUrl:properties.url+'?ajaxfct=admin.fct.validValues&domain=uaType&token='+properties.token
1373                        },
1374                      defaultOperator:'in',
1375                      filterOperators:['in']
1376                    },
1377                  sortable:'asc',
1378                  width:'125px'
1379                }
1380              ],
1381            showSaveButton:true,
1382            autoLoad:false,
1383            postUrl:properties.url,
1384            postData:
1385              {
1386                ajaxfct:"admin.stat.history",
1387                token:properties.token,
1388                period:''
1389              },
1390            minHeight:150,
1391            maxHeight:350,
1392            sortBoxTitle:translateString.sortBy,
1393            footerString:
1394              {
1395                singular:translateString.item_nb,
1396                plural:translateString.items_nb,
1397                waitForDownload:translateString.waitForDownload
1398              },
1399            dialogsButtons:{
1400                ok:translateString.ok,
1401                cancel:translateString.cancel,
1402                erase:translateString.eraseFilter
1403              },
1404/*
1405            pageChanged: function (event, value)
1406              {
1407              },
1408            contentLoading: function (event, value)
1409              {
1410              },
1411*/
1412            saveButtonClick: function (event, data)
1413              {
1414                $.dialogExport(
1415                  {
1416                    title:translateString.dataExport,
1417                    buttons:
1418                      {
1419                        ok:translateString.ok,
1420                        cancel:translateString.cancel
1421                      },
1422                    name:'history',
1423                    format:'csv',
1424                    compression:'gz',
1425                    formatList:
1426                      [
1427                        {id:'csv', text:translateString.fileFormatCSV, infos:'(.csv)'},
1428                        {id:'ods', text:translateString.fileFormatODS, infos:'(.ods)'},
1429                        {id:'sqlite', text:translateString.fileFormatSQLite, infos:'(.db)'}
1430                      ],
1431                    compressionList:
1432                      [
1433                        {id:'none', text:translateString.fileCompressionNone, infos:''},
1434                        {id:'zip', text:translateString.fileCompressionZIP, infos:'(.zip)'},
1435                        {id:'gz', text:translateString.fileCompressionGZ, infos:'(.gz)'},
1436                        {id:'bz2', text:translateString.fileCompressionBZ2, infos:'(.bz2)'}
1437                      ],
1438                    validExport: function (event, values)
1439                      {
1440                        $('#iHistoryTable').dynamicTable('waitForDownload', true);
1441                        $.ajax(
1442                          {
1443                            type: "POST",
1444                            url: properties.urlExport,
1445                            data:
1446                              {
1447                                ajaxfct:'admin.export.history',
1448                                name:values.name,
1449                                format:values.format,
1450                                compression:values.compression,
1451                                token:properties.token,
1452                                period:$('#iHistoryFilterPeriod').inputList('value'),
1453                                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')},
1454                                sort:data.sort,
1455                                filter:data.filter,
1456                                group:data.group
1457                              },
1458                            async: true,
1459                            success: function(msg)
1460                              {
1461                                $('#iHistoryTable').dynamicTable('waitForDownload', false);
1462                                if(msg.substr(0,3)=='OK:')
1463                                {
1464                                  $.download(msg.substr(3));
1465                                }
1466                                else
1467                                {
1468                                  alert(translateString.downloadError);
1469                                }
1470                              },
1471                            error: function(msg)
1472                              {
1473                                $('#iHistoryTable').dynamicTable('waitForDownload', false);
1474                              }
1475                          }
1476                        );
1477                      }
1478                  }
1479                );
1480              },
1481            contentLoading: function (event, value)
1482              {
1483                $(this).find('tr[oid]').unbind('mouseenter mouseleave');
1484              },
1485            contentDisplayed: function (event, value)
1486              {
1487                for(var i=0;i<value.rows.length;i++)
1488                {
1489                  if(value.rows[i][11]!='')
1490                  {
1491                    $(this).find('tr[oid='+i+']')
1492                      .bind('mouseenter', {v:value.rows[i][11]}, function (e)
1493                                {
1494                                  displayPopupThumb(true, {x:e.pageX, y:$(this).offset().top}, e.data.v);
1495                                }
1496                            )
1497                      .bind('mouseleave', function (e)
1498                                {
1499                                  displayPopupThumb(false);
1500
1501                                }
1502                            );
1503                  }
1504                }
1505              }
1506/*
1507            click: function (event)
1508              {
1509                var oId=$(this).attr('oId'),
1510                    data=$('#table1').dynamicTable('loadedData', oId);
1511              }
1512*/
1513          }
1514        );
1515
1516
1517        // create graph - stat for all period
1518        properties.history.graphAllPeriods.axis=new CDAxis(
1519          {
1520            mode:'XY',
1521            display:{
1522              color:properties.graph.axis.color,
1523              visible:
1524                {
1525                  XY:
1526                  {
1527                    H:true,
1528                    V:true
1529                  }
1530                }
1531            },
1532            XY:{
1533              ticks:{
1534                  H:{
1535                    size:{
1536                      small:properties.graph.axis.ticksSize.small,
1537                      big:properties.graph.axis.ticksSize.big
1538                    },
1539                    visible:{
1540                      small:true,
1541                      big:true
1542                    },
1543                    minSpaceLast:properties.graph.axis.minSpaceLast,
1544                    frequency:{
1545                      small:1, //properties.graph.axis.frequency.small,
1546                      big:1 //properties.graph.axis.frequency.big
1547                    },
1548                    value:{
1549                      rotate:properties.graph.axis.value.rotateH,
1550                      visible:true,
1551                      fontName:properties.graph.axis.value.fontName,
1552                      fontSize:properties.graph.axis.value.fontSize
1553                    },
1554                    offset0:true
1555                  },
1556                  V:{
1557                    unit:'',
1558                    size:{
1559                      small:properties.graph.axis.ticksSize.small,
1560                      big:properties.graph.axis.ticksSize.big
1561                    },
1562                    visible:{
1563                      small:true,
1564                      big:true
1565                    },
1566                    minSpaceLast:properties.graph.axis.minSpaceLast,
1567                    steps:10000,
1568                    frequency:{
1569                      small:250,
1570                      big:1000
1571                    },
1572                    value:{
1573                      rotate:properties.graph.axis.value.rotateV,
1574                      visible:true,
1575                      fontName:properties.graph.axis.value.fontName,
1576                      fontSize:properties.graph.axis.value.fontSize
1577                    }
1578                  }
1579                }
1580              },
1581            values:{H:[]}
1582          }
1583        );
1584
1585        properties.history.graphAllPeriods.serieTotal=new CDSerie(
1586          {
1587            name:'total',
1588            order:10,
1589            values:[],
1590            options:new CDSerieOptionsBar(
1591              {
1592                backgroundColor:properties.graph.colors.gray[3],
1593                borderColor:properties.graph.colors.gray[7],
1594                borderWidth:0,
1595                width:1,
1596                offset:0
1597              }
1598            )
1599          }
1600        );
1601
1602        properties.history.graphAllPeriods.serieComputer=new CDSerie(
1603          {
1604            name:'computer',
1605            order:1,
1606            values:[],
1607            options:new CDSerieOptionsLine(
1608              {
1609                color:properties.graph.colors.normal[0],
1610                width:1,
1611                offset:0
1612              }
1613            )
1614          }
1615        );
1616
1617        properties.history.graphAllPeriods.serieMobile=new CDSerie(
1618          {
1619            name:'mobile',
1620            order:2,
1621            values:[],
1622            options:new CDSerieOptionsLine(
1623              {
1624                color:properties.graph.colors.normal[1],
1625                width:1,
1626                offset:0
1627              }
1628            )
1629          }
1630        );
1631
1632        properties.history.graphAllPeriods.serieCrawler=new CDSerie(
1633          {
1634            name:'crawler',
1635            order:3,
1636            values:[],
1637            options:new CDSerieOptionsLine(
1638              {
1639                color:properties.graph.colors.normal[2],
1640                width:1,
1641                offset:0
1642              }
1643            )
1644          }
1645        );
1646
1647        properties.history.graphAllPeriods.serieOther=new CDSerie(
1648          {
1649            name:'other',
1650            order:4,
1651            values:[],
1652            options:new CDSerieOptionsLine(
1653              {
1654                color:properties.graph.colors.normal[3],
1655                width:1,
1656                offset:0
1657              }
1658            )
1659          }
1660        );
1661
1662        properties.history.graphAllPeriods.axis.serieAdd(properties.history.graphAllPeriods.serieTotal);
1663        properties.history.graphAllPeriods.axis.serieAdd(properties.history.graphAllPeriods.serieComputer);
1664        properties.history.graphAllPeriods.axis.serieAdd(properties.history.graphAllPeriods.serieMobile);
1665        properties.history.graphAllPeriods.axis.serieAdd(properties.history.graphAllPeriods.serieCrawler);
1666        properties.history.graphAllPeriods.axis.serieAdd(properties.history.graphAllPeriods.serieOther);
1667
1668
1669        $('#iHistoryGraphAll').drawingGraph(
1670          {
1671            display:
1672              {
1673                width:450,
1674                height:150
1675              },
1676            cursor:
1677              {
1678                verticalType:'line'
1679              },
1680            margins:new CDMargins({top:5,bottom:45, left:50, right:1}),
1681            legend:new CDLegend({
1682                          width:0,
1683                          visible:false,
1684                          position:'right',  // left or right
1685                          backgroundColor:themeColor.background,
1686                          borderColor:themeColor.border,
1687                          borderWidth:0,
1688                          fontName:'arial',
1689                          fontSize:10
1690                        }),
1691            axis:{front:properties.history.graphAllPeriods.axis, back:null},
1692            events:{
1693              mouseEnter:function (event)
1694                          {
1695                            var geometry={
1696                                  x:0,
1697                                  y:0,
1698                                  w:250,
1699                                  h:90
1700                                };
1701
1702                            geometry.x=$('#iHistoryGraphAll').offset().left+($('#iHistoryGraphAll').width()-geometry.w)/2;
1703                            geometry.y=$('#iHistoryGraphAll').offset().top+$('#iHistoryGraphAll').height();
1704                            displayPopupInfo(true, geometry, getHistoryPopupContent());
1705                          },
1706              mouseLeave:function (event)
1707                          {
1708                            displayPopupInfo(false);
1709                          },
1710              mousePositionChange:function (event, data)
1711                          {
1712                            var list=['computer', 'mobile', 'crawler', 'other', 'total'];
1713                            for(i=0;i<list.length;i++)
1714                            {
1715                              $('#iPI_'+list[i]).html(data.values[i].value);
1716                            }
1717                          }
1718            }
1719          }
1720        );
1721
1722
1723        // create graph - stat for the current period
1724        properties.history.graphCurrentPeriod.axis=new CDAxis(
1725          {
1726            mode:'XY',
1727            display:{
1728              color:properties.graph.axis.color,
1729              visible:
1730                {
1731                  XY:
1732                  {
1733                    H:true,
1734                    V:true
1735                  }
1736                }
1737            },
1738            XY:{
1739              ticks:{
1740                  H:{
1741                    size:{
1742                      small:properties.graph.axis.ticksSize.small,
1743                      big:properties.graph.axis.ticksSize.big
1744                    },
1745                    visible:{
1746                      small:true,
1747                      big:true
1748                    },
1749                    minSpaceLast:properties.graph.axis.minSpaceLast,
1750                    frequency:{
1751                      small:1, //properties.graph.axis.frequency.small,
1752                      big:1 //properties.graph.axis.frequency.big
1753                    },
1754                    value:{
1755                      rotate:60, //properties.graph.axis.value.rotateH,
1756                      visible:true,
1757                      fontName:properties.graph.axis.value.fontName,
1758                      fontSize:properties.graph.axis.value.fontSize
1759                    },
1760                    offset0:true
1761                  },
1762                  V:{
1763                    unit:'',
1764                    size:{
1765                      small:properties.graph.axis.ticksSize.small,
1766                      big:properties.graph.axis.ticksSize.big
1767                    },
1768                    visible:{
1769                      small:true,
1770                      big:true
1771                    },
1772                    minSpaceLast:properties.graph.axis.minSpaceLast,
1773                    steps:10000,
1774                    frequency:{
1775                      small:250,
1776                      big:1000
1777                    },
1778                    value:{
1779                      rotate:properties.graph.axis.value.rotateV,
1780                      visible:true,
1781                      fontName:properties.graph.axis.value.fontName,
1782                      fontSize:properties.graph.axis.value.fontSize
1783                    }
1784                  }
1785                }
1786              },
1787            values:{H:[]}
1788          }
1789        );
1790
1791        properties.history.graphCurrentPeriod.serieTotal=new CDSerie(
1792          {
1793            name:'total',
1794            order:10,
1795            values:[],
1796            options:new CDSerieOptionsBar(
1797              {
1798                backgroundColor:properties.graph.colors.gray[3],
1799                borderColor:properties.graph.colors.gray[7],
1800                borderWidth:0,
1801                width:1,
1802                offset:0
1803              }
1804            )
1805          }
1806        );
1807
1808        properties.history.graphCurrentPeriod.serieComputer=new CDSerie(
1809          {
1810            name:'computer',
1811            order:1,
1812            values:[],
1813            options:new CDSerieOptionsLine(
1814              {
1815                color:properties.graph.colors.normal[0],
1816                width:1,
1817                offset:0
1818              }
1819            )
1820          }
1821        );
1822
1823        properties.history.graphCurrentPeriod.serieMobile=new CDSerie(
1824          {
1825            name:'mobile',
1826            order:2,
1827            values:[],
1828            options:new CDSerieOptionsLine(
1829              {
1830                color:properties.graph.colors.normal[1],
1831                width:1,
1832                offset:0
1833              }
1834            )
1835          }
1836        );
1837
1838        properties.history.graphCurrentPeriod.serieCrawler=new CDSerie(
1839          {
1840            name:'crawler',
1841            order:3,
1842            values:[],
1843            options:new CDSerieOptionsLine(
1844              {
1845                color:properties.graph.colors.normal[2],
1846                width:1,
1847                offset:0
1848              }
1849            )
1850          }
1851        );
1852
1853        properties.history.graphCurrentPeriod.serieOther=new CDSerie(
1854          {
1855            name:'other',
1856            order:4,
1857            values:[],
1858            options:new CDSerieOptionsLine(
1859              {
1860                color:properties.graph.colors.normal[3],
1861                width:1,
1862                offset:0
1863              }
1864            )
1865          }
1866        );
1867
1868        properties.history.graphCurrentPeriod.axis.serieAdd(properties.history.graphCurrentPeriod.serieTotal);
1869        properties.history.graphCurrentPeriod.axis.serieAdd(properties.history.graphCurrentPeriod.serieComputer);
1870        properties.history.graphCurrentPeriod.axis.serieAdd(properties.history.graphCurrentPeriod.serieMobile);
1871        properties.history.graphCurrentPeriod.axis.serieAdd(properties.history.graphCurrentPeriod.serieCrawler);
1872        properties.history.graphCurrentPeriod.axis.serieAdd(properties.history.graphCurrentPeriod.serieOther);
1873
1874
1875        $('#iHistoryGraphCurrent').drawingGraph(
1876          {
1877            display:
1878              {
1879                width:500,
1880                height:150
1881              },
1882            cursor:
1883              {
1884                verticalType:'line'
1885              },
1886            margins:new CDMargins({top:5,bottom:45, left:50, right:1}),
1887            legend:new CDLegend({
1888                          width:0,
1889                          visible:true,
1890                          position:'right',  // left or right
1891                          backgroundColor:themeColor.background,
1892                          borderColor:themeColor.border,
1893                          borderWidth:0,
1894                          fontName:'arial',
1895                          fontSize:10
1896                        }),
1897            axis:{front:properties.history.graphCurrentPeriod.axis, back:null},
1898            events:{
1899              mouseEnter:function (event)
1900                          {
1901                            var geometry={
1902                                  x:0,
1903                                  y:0,
1904                                  w:250,
1905                                  h:90
1906                                };
1907
1908                            geometry.x=$('#iHistoryGraphCurrent').offset().left+($('#iHistoryGraphCurrent').width()-geometry.w)/2;
1909                            geometry.y=$('#iHistoryGraphCurrent').offset().top+$('#iHistoryGraphCurrent').height();
1910                            displayPopupInfo(true, geometry, getHistoryPopupContent());
1911                          },
1912              mouseLeave:function (event)
1913                          {
1914                            displayPopupInfo(false);
1915                          },
1916              mousePositionChange:function (event, data)
1917                          {
1918                            var list=['computer', 'mobile', 'crawler', 'other', 'total'];
1919                            for(i=0;i<list.length;i++)
1920                            {
1921                              $('#iPI_'+list[i]).html(data.values[i].value);
1922                            }
1923                          }
1924            }
1925          }
1926        );
1927
1928
1929        // load period list
1930        $('#iHistoryFilterPeriod').inputList(
1931          {
1932            serverUrl:properties.url,
1933            postData:
1934              {
1935                ajaxfct:'admin.stat.history.periodList',
1936                token:properties.token
1937              },
1938            listMaxWidth:650,
1939            listMaxHeight:300,
1940            multiple:false,
1941            colsWidth:[180],
1942            colsCss:['cPFilterDate','cPFilterNB'],
1943            colsDisplayed:[0,1],
1944            //popup: function (event, value) { },
1945            change: function (event, value)
1946                    {
1947                      loadPageHistory(value);
1948                    },
1949            load: function (event, value)
1950                    {
1951                      $('#iHistoryFilterPeriod').inputList('value', ':last');
1952                      loadPageHistory(value);
1953                    }
1954          }
1955        );
1956      }, // << initPageHistory()
1957
1958
1959    initPageConfig = function()
1960      {
1961
1962      }, // << initPageConfig()
1963
1964    initPageTools = function()
1965      {
1966
1967      }, // << initPageTools()
1968
1969    /**
1970     * -------------------------------------------------------------------------
1971     *
1972     *                      PAGE MANAGMENT FUNCTIONS
1973     *
1974     *
1975     * -------------------------------------------------------------------------
1976     */
1977
1978
1979    /**
1980     * -------------------------------------------------------------------------
1981     * this function is used to change a page : switch the page, call the data...
1982     *
1983     * @param String pageName : the name of page to display
1984     * @return Boolean : true if ok, otherwise false
1985     * -------------------------------------------------------------------------
1986     */
1987    changePage = function(pageName)
1988      {
1989        $('.cTabContent').css('display', 'none');
1990        $('#iTab'+pageName).css('display', 'inline-block');
1991        switch(pageName)
1992        {
1993          case 'Stats_by_period':
1994            $('#iTabFilter').css('display', 'block');
1995            $('#iFilterCategory').css('display', 'block');
1996            $('#iFilterPeriod').css('display', 'none');
1997            break;
1998          case 'Stats_by_ip':
1999          case 'Stats_by_category':
2000          case 'Stats_by_image':
2001            // display filter block
2002            $('#iTabFilter').css('display', 'block');
2003            $('#iFilterCategory').css('display', 'block');
2004            $('#iFilterPeriod').css('display', 'block');
2005            break;
2006          //case 'Synthesis':
2007          case 'History':
2008          //case 'Config':
2009          //case 'Tools':
2010            // hide filter block
2011            $('#iTabFilter').css('display', 'none');
2012            $('#iFilterCategory').css('display', 'none');
2013            $('#iFilterPeriod').css('display', 'none');
2014            break;
2015          default:
2016            return(false);
2017        }
2018        properties.currentPage=pageName;
2019        return(loadPage(properties.currentPage));
2020      }, // << changePage
2021
2022
2023    /**
2024     * -----------------------------------------------------------------------
2025     * this function manage the page content's loading
2026     *
2027     * @param String pageName : the name of page which content have to be loaded
2028     * @return Boolean : true if ok, otherwise false
2029     * -----------------------------------------------------------------------
2030     */
2031    loadPage = function(pageName)
2032      {
2033        setProperties();
2034        displayPopupInfo(false);
2035        displayPopupThumb(false);
2036
2037        if(pageName==null)
2038        {
2039          pageName=properties.currentPage;
2040        }
2041        else
2042        {
2043          setProperties({currentPage:pageName});
2044        }
2045
2046        switch(pageName)
2047        {
2048          case 'Stats_by_period':
2049            loadPageStatByPeriod();
2050            break;
2051          case 'Stats_by_ip':
2052            loadPageStatByIp();
2053            break;
2054          case 'Stats_by_category':
2055            loadPageStatByCategory();
2056            break;
2057          case 'Stats_by_image':
2058            loadPageStatByImage();
2059            break;
2060          case 'Synthesis':
2061            loadPageSynthesis();
2062            break;
2063          case 'History':
2064            loadPageHistory();
2065            break;
2066          case 'Config':
2067            loadPageConfig();
2068            break;
2069          case 'Tools':
2070            loadPageTools();
2071            break;
2072          default:
2073            return(false);
2074        }
2075        return(true);
2076      }, // << loadPage()
2077
2078
2079
2080    /**
2081     * -----------------------------------------------------------------------
2082     * load content for the "Period" page
2083     *
2084     *  - period table
2085     *  - period graph
2086     * -----------------------------------------------------------------------
2087     */
2088    loadPageStatByPeriod = function ()
2089      {
2090        $('#iPeriodTable').dynamicTable('resizeContent');
2091        $('#iPeriodGraph').drawingGraph('options',
2092                            {
2093                              display:{
2094                                  width:$('#iPeriodTable').width(),
2095                                  height:$('#iPeriodTable').height()
2096                                }
2097                            }
2098                          );
2099
2100        refreshGraphPeriod();
2101        refreshPagePeriodContent();
2102      }, // << loadPageStatByPeriod()
2103
2104    loadPageStatByIp = function ()
2105      {
2106        var width=$('#iTabStats_by_ip').width()*0.29,
2107            height=$('#iIPTable').height(),
2108            radius=Math.min(width, height)*0.35;
2109
2110        properties.ip.graphType.serie.get().options.set({outerRadius:radius});
2111        properties.ip.graphCountry.serie.get().options.set({outerRadius:radius});
2112
2113        $('#iIPTable').dynamicTable('resizeContent');
2114        $('#iIPGraphType').drawingGraph('options',
2115                            {
2116                              display:{
2117                                  width:width,
2118                                  height:height
2119                                }
2120                            }
2121                          );
2122        $('#iIPGraphCountry').drawingGraph('options',
2123                            {
2124                              display:{
2125                                  width:width,
2126                                  height:height
2127                                }
2128                            }
2129                          );
2130        refreshGraphIP();
2131        refreshPageIPContent();
2132      }, // << loadPageStatByIp()
2133
2134    loadPageStatByCategory = function ()
2135      {
2136        $('#iCategoryTable').dynamicTable('resizeContent');
2137        refreshPageCategoryContent();
2138      }, // << loadPageStatByCategory()
2139
2140    loadPageStatByImage = function ()
2141      {
2142        $('#iImageTable').dynamicTable('resizeContent');
2143        refreshPageImageContent();
2144      }, // << loadPageStatByImage()
2145
2146    loadPageSynthesis = function ()
2147      {
2148      }, // << loadPageSynthesis()
2149
2150
2151    /**
2152     * -----------------------------------------------------------------------
2153     * load content for the "History" page
2154     *
2155     *  - history table
2156     *  - history graph
2157     * -----------------------------------------------------------------------
2158     */
2159    loadPageHistory = function (period)
2160      {
2161        $('#iHistoryTable').dynamicTable('resizeContent');
2162        refreshGraphHistoryMonth(period);
2163        refreshPageHistoryContent(period, 1);
2164      }, // << loadPageHistory()
2165
2166    loadPageConfig = function ()
2167      {
2168      }, // << loadPageConfig()
2169
2170    loadPageTools = function ()
2171      {
2172      }, // << loadPageTools()
2173
2174
2175
2176    /**
2177     * -----------------------------------------------------------------------
2178     * load the content of period table
2179     *
2180     * @param integer period: period the load; if not set, load the current period
2181     * -----------------------------------------------------------------------
2182     */
2183    refreshPagePeriodContent = function (period)
2184      {
2185        if(period==null)
2186          period=$('#iPeriodPath').inputPath('itemLevel', $('#iPeriodPath').inputPath('level')).id;
2187
2188        // load the table content
2189        $('#iPeriodTable')
2190          .dynamicTable('postData',
2191              {
2192                ajaxfct:'admin.stat.period',
2193                token:properties.token,
2194                period:period,
2195                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2196              }
2197            )
2198          .dynamicTable('refreshContent', 1);
2199
2200      }, // << refreshPagePeriodContent()
2201
2202
2203
2204    /**
2205     * -----------------------------------------------------------------------
2206     * load graph data for a period
2207     *
2208     * @param String period: the period (YYYYMM) to load; if not set, load the current period
2209     * -----------------------------------------------------------------------
2210     */
2211    refreshGraphPeriod = function (period)
2212      {
2213        if(period==null)
2214          period=$('#iPeriodPath').inputPath('itemLevel', $('#iPeriodPath').inputPath('level')).id;
2215
2216        $.ajax(
2217          {
2218            type: "POST",
2219            url: properties.url,
2220            data:
2221              {
2222                ajaxfct:'admin.stat.period.graph',
2223                token:properties.token,
2224                period:period,
2225                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2226              },
2227            async: true,
2228            success: function(msg)
2229              {
2230                msg=$.parseJSON(msg);
2231                properties.period.graph.axis.set(
2232                  {
2233                    XY:{ticks:{V:{steps:roundValue(msg.maxValue)}}}
2234                  }
2235                );
2236                properties.period.graph.axis.set(
2237                  {
2238                    XY:{ticks:{V:{frequency:calculateTicks(properties.period.graph.axis)}}}
2239                  }
2240                );
2241                properties.period.graph.axis.setValues({H:msg.axis});
2242                properties.period.graph.serieViewedAlbums.set(
2243                  {
2244                    values:msg.series.viewedAlbums.nbVisits,
2245                    name:msg.series.viewedAlbums.name
2246                  }
2247                );
2248                properties.period.graph.serieViewedImages.set(
2249                  {
2250                    values:msg.series.viewedImages.nbVisits,
2251                    name:msg.series.viewedImages.name
2252                  }
2253                );
2254                properties.period.graph.serieViewedPages.set(
2255                  {
2256                    values:msg.series.viewedPages.nbVisits,
2257                    name:msg.series.viewedPages.name
2258                  }
2259                );
2260                properties.period.graph.serieUniqueIP.set(
2261                  {
2262                    values:msg.series.uniqueIP.nbVisits,
2263                    name:msg.series.uniqueIP.name
2264                  }
2265                );
2266                $('#iPeriodGraph').drawingGraph('refresh');
2267              },
2268            error: function(msg)
2269              {
2270              }
2271          }
2272        );
2273      }, // << refreshGraphPeriod()
2274
2275
2276
2277
2278
2279    /**
2280     * -----------------------------------------------------------------------
2281     * load the content of history table
2282     *
2283     * @param integer period: period the load; if not set, load the current period
2284     * @param integer pageNumber: page to load
2285     * -----------------------------------------------------------------------
2286     */
2287    refreshPageHistoryContent = function (period, pageNumber)
2288      {
2289        if(period==null) period=$('#iHistoryFilterPeriod').inputList('value');
2290
2291        if(pageNumber==null | pageNumber<=0) pageNumber=1;
2292
2293        // load the table content
2294        $('#iHistoryTable')
2295          .dynamicTable('postData',
2296              {
2297                ajaxfct:'admin.stat.history',
2298                token:properties.token,
2299                period:period
2300              }
2301            )
2302          .dynamicTable('refreshContent', pageNumber);
2303      }, // << refreshPageHistoryContent()
2304
2305    /**
2306     * -----------------------------------------------------------------------
2307     * load graph data for a period
2308     *
2309     * @param String priod: the period (YYYYMM) to load; if not set, load the current period
2310     * -----------------------------------------------------------------------
2311     */
2312    refreshGraphHistoryMonth = function (period)
2313      {
2314        if(period==null) period=$('#iHistoryFilterPeriod').inputList('value');
2315
2316        $.ajax(
2317          {
2318            type: "POST",
2319            url: properties.url,
2320            data:
2321              {
2322                ajaxfct:'admin.stat.history.graphAllPeriods',
2323                token:properties.token,
2324                period:period,
2325                nbMonth:12
2326              },
2327            async: true,
2328            success: function(msg)
2329              {
2330                msg=$.parseJSON(msg);
2331                properties.history.graphAllPeriods.axis.set(
2332                  {
2333                    XY:{ticks:{V:{steps:roundValue(msg.maxValue)}}}
2334                  }
2335                );
2336                properties.history.graphAllPeriods.axis.set(
2337                  {
2338                    XY:{ticks:{V:{frequency:calculateTicks(properties.history.graphAllPeriods.axis)}}}
2339                  }
2340                );
2341                properties.history.graphAllPeriods.axis.setValues({H:msg.axis});
2342                properties.history.graphAllPeriods.serieTotal.set(
2343                  {
2344                    values:msg.series.total.nbVisits,
2345                    name:msg.series.total.name
2346                  }
2347                );
2348                properties.history.graphAllPeriods.serieComputer.set(
2349                  {
2350                    values:msg.series.computer.nbVisits,
2351                    name:msg.series.computer.name
2352                  }
2353                );
2354                properties.history.graphAllPeriods.serieCrawler.set(
2355                  {
2356                    values:msg.series.crawler.nbVisits,
2357                    name:msg.series.crawler.name
2358                  }
2359                );
2360                properties.history.graphAllPeriods.serieMobile.set(
2361                  {
2362                    values:msg.series.mobile.nbVisits,
2363                    name:msg.series.mobile.name
2364                  }
2365                );
2366                properties.history.graphAllPeriods.serieOther.set(
2367                  {
2368                    values:msg.series.other.nbVisits,
2369                    name:msg.series.other.name
2370                  }
2371                );
2372                $('#iHistoryGraphAll').drawingGraph('refresh');
2373              },
2374            error: function(msg)
2375              {
2376              }
2377          }
2378        );
2379
2380        $.ajax(
2381          {
2382            type: "POST",
2383            url: properties.url,
2384            data:
2385              {
2386                ajaxfct:'admin.stat.history.graphCurrentPeriod',
2387                token:properties.token,
2388                period:period
2389              },
2390            async: true,
2391            success: function(msg)
2392              {
2393                msg=$.parseJSON(msg);
2394                properties.history.graphCurrentPeriod.axis.set(
2395                  {
2396                    XY:{ticks:{V:{steps:roundValue(msg.maxValue)}}}
2397                  }
2398                );
2399                properties.history.graphCurrentPeriod.axis.set(
2400                  {
2401                    XY:{ticks:{V:{frequency:calculateTicks(properties.history.graphCurrentPeriod.axis)}}}
2402                  }
2403                );
2404                properties.history.graphCurrentPeriod.axis.setValues({H:msg.axis});
2405                properties.history.graphCurrentPeriod.serieTotal.set(
2406                  {
2407                    values:msg.series.total.nbVisits,
2408                    name:msg.series.total.name
2409                  }
2410                );
2411                properties.history.graphCurrentPeriod.serieComputer.set(
2412                  {
2413                    values:msg.series.computer.nbVisits,
2414                    name:msg.series.computer.name
2415                  }
2416                );
2417                properties.history.graphCurrentPeriod.serieCrawler.set(
2418                  {
2419                    values:msg.series.crawler.nbVisits,
2420                    name:msg.series.crawler.name
2421                  }
2422                );
2423                properties.history.graphCurrentPeriod.serieMobile.set(
2424                  {
2425                    values:msg.series.mobile.nbVisits,
2426                    name:msg.series.mobile.name
2427                  }
2428                );
2429                properties.history.graphCurrentPeriod.serieOther.set(
2430                  {
2431                    values:msg.series.other.nbVisits,
2432                    name:msg.series.other.name
2433                  }
2434                );
2435                $('#iHistoryGraphCurrent').drawingGraph('refresh');
2436              },
2437            error: function(msg)
2438              {
2439              }
2440          }
2441        );
2442      }, // << refreshGraphHistoryMonth()
2443
2444
2445
2446
2447    /**
2448     * -----------------------------------------------------------------------
2449     * load the content of IP table
2450     *
2451     * @param integer period: period the load; if not set, load the current period
2452     *                          A           : all periods
2453     *                          Y-yyyy      : year
2454     *                          YM-yyyymm   : year/month
2455     * -----------------------------------------------------------------------
2456     */
2457    refreshPageIPContent = function (period)
2458      {
2459        if(period==null)
2460          period=$('#iFilterPeriodId').inputTreeList('value');
2461
2462        // load the table content
2463        $('#iIPTable')
2464          .dynamicTable('postData',
2465              {
2466                ajaxfct:"admin.stat.ip",
2467                token:properties.token,
2468                period:period,
2469                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2470              }
2471            )
2472          .dynamicTable('refreshContent', 1);
2473      }, // << refreshPagePeriodContent()
2474
2475
2476
2477    /**
2478     * -----------------------------------------------------------------------
2479     * load graph data for IP
2480     *
2481     * @param integer period: period the load; if not set, load the current period
2482     *                          A           : all periods
2483     *                          Y-yyyy      : year
2484     *                          YM-yyyymm   : year/month
2485     * -----------------------------------------------------------------------
2486     */
2487    refreshGraphIP = function (period)
2488      {
2489        if(period==null)
2490          period=$('#iFilterPeriodId').inputTreeList('value');
2491
2492        $.ajax(
2493          {
2494            type: "POST",
2495            url: properties.url,
2496            data:
2497              {
2498                ajaxfct:"admin.stat.ip.graphType",
2499                token:properties.token,
2500                period:period,
2501                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2502              },
2503            async: true,
2504            success: function(msg)
2505              {
2506                msg=$.parseJSON(msg);
2507
2508                properties.ip.graphType.serie.set(
2509                  {
2510                    values:msg.values,
2511                    valuesLabels:msg.valuesLabels
2512                  }
2513                );
2514
2515                $('#iIPGraphType').drawingGraph('refresh');
2516              },
2517            error: function(msg)
2518              {
2519              }
2520          }
2521        );
2522
2523        $.ajax(
2524          {
2525            type: "POST",
2526            url: properties.url,
2527            data:
2528              {
2529                ajaxfct:"admin.stat.ip.graphCountry",
2530                token:properties.token,
2531                period:period,
2532                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2533              },
2534            async: true,
2535            success: function(msg)
2536              {
2537                msg=$.parseJSON(msg);
2538
2539                properties.ip.graphCountry.serie.set(
2540                  {
2541                    values:msg.values,
2542                    valuesLabels:msg.valuesLabels
2543                  }
2544                );
2545
2546                $('#iIPGraphCountry').drawingGraph('refresh');
2547              },
2548            error: function(msg)
2549              {
2550              }
2551          }
2552        );
2553
2554      }, // << refreshGraphIP()
2555
2556
2557
2558
2559    /**
2560     * -----------------------------------------------------------------------
2561     * load the content of album/categories table
2562     *
2563     * @param integer period: period the load; if not set, load the current period
2564     * -----------------------------------------------------------------------
2565     */
2566    refreshPageCategoryContent = function (period)
2567      {
2568        if(period==null)
2569          period=$('#iFilterPeriodId').inputTreeList('value');
2570
2571        // load the table content
2572        $('#iCategoryTable')
2573          .dynamicTable('postData',
2574              {
2575                ajaxfct:"admin.stat.category",
2576                token:properties.token,
2577                period:period,
2578                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2579              }
2580            )
2581          .dynamicTable('refreshContent', 1);
2582      }, // << refreshPageCategoryContent()
2583
2584
2585
2586
2587
2588    /**
2589     * -----------------------------------------------------------------------
2590     * load the content of images table
2591     *
2592     * @param integer period: period the load; if not set, load the current period
2593     * -----------------------------------------------------------------------
2594     */
2595    refreshPageImageContent = function (period)
2596      {
2597        if(period==null)
2598          period=$('#iFilterPeriodId').inputTreeList('value');
2599
2600        // load the table content
2601        $('#iImageTable')
2602          .dynamicTable('postData',
2603              {
2604                ajaxfct:"admin.stat.image",
2605                token:properties.token,
2606                period:period,
2607                additionalFilter:{catId:$('#iFilterCatId').categorySelector('value')}
2608              }
2609            )
2610          .dynamicTable('refreshContent', 1);
2611      }, // << refreshPageCategoryContent()
2612
2613
2614
2615
2616    /**
2617     * -------------------------------------------------------------------------
2618     *
2619     *                      UTILITIES FUNCTIONS
2620     *
2621     *
2622     * -------------------------------------------------------------------------
2623     */
2624
2625    /**
2626      * -----------------------------------------------------------------------
2627      * generic function used to round a value to nearest number according to
2628      * to 'size' of the value
2629      *
2630      * example:
2631      *   157   => 160
2632      *   241   => 250
2633      *   1247  => 1250
2634      *   12478 => 12500
2635      *
2636      * @param Integer value: the value to be rounded
2637      * @return Integer: rounded value
2638      * -----------------------------------------------------------------------
2639      */
2640    roundValue = function (value)
2641      {
2642        var divider=1;
2643
2644        if(value<=1000)
2645        {
2646          divider=10;
2647        }
2648        else if(value<10000)
2649        {
2650          divider=100;
2651        }
2652        else
2653        {
2654          divider=1000;
2655        }
2656        return(Math.ceil(value/divider)*divider);
2657      },
2658
2659    /**
2660     * -----------------------------------------------------------------------
2661     * calculate ticks values according to the current axis properties
2662     * (height in pixel and max value)
2663     *
2664     * @param CDAxis axis: axis
2665     * @return object: {small:(Integer), big:(Integer)}
2666     * -----------------------------------------------------------------------
2667     */
2668    calculateTicks = function (axis)
2669      {
2670        var divider=1,
2671            maxValue=axis.get().properties.XY.ticks.V.steps,
2672            returned={
2673              small:0,
2674              big:0
2675            };
2676
2677        if(maxValue<=10)
2678        {
2679          divider=1;
2680        }
2681        else if(maxValue<=100)
2682        {
2683          divider=10;
2684        }
2685        else if(maxValue<=1000)
2686        {
2687          divider=100;
2688        }
2689        else if(maxValue<10000)
2690        {
2691          divider=1000;
2692        }
2693        else
2694        {
2695          divider=10000;
2696        }
2697        returned.small=Math.ceil(maxValue/divider)*divider/20;
2698        returned.big=5*returned.small;
2699        return(returned);
2700      },
2701
2702    /**
2703     * -----------------------------------------------------------------------
2704     * display the popup info box
2705     *
2706     * @param Boolean visible: display or hide the popup
2707     * @param object geometry: {x:(Integer), y:(Integer), w:(Integer), h:(Integer)} object to set the position
2708     * @param String content: content of the box
2709     * -----------------------------------------------------------------------
2710     */
2711    displayPopupInfo = function (visible, geometry, content)
2712      {
2713        if(content==null) content='';
2714        if(geometry==null) geometry={x:-1, y:-1, w:0, h:0};
2715        if(visible==null) visible=false;
2716
2717        $('#iPopupInfo')
2718          .html(content)
2719          .css(
2720            {
2721              'left':geometry.x+'px',
2722              'top':geometry.y+'px',
2723              'width':geometry.w+'px',
2724              'height':geometry.h+'px',
2725              'display':visible?'block':'none'
2726            }
2727          );
2728      },
2729
2730    /**
2731     * -----------------------------------------------------------------------
2732     * display the popup thumbnail image
2733     *
2734     * @param Boolean visible: display or hide the popup
2735     * @param object geometry: {x:(Integer), y:(Integer)} object to set the position
2736     * @param String url: url of the thumbnail
2737     * -----------------------------------------------------------------------
2738     */
2739    displayPopupThumb = function (visible, geometry, url)
2740      {
2741        if(geometry==null) geometry={x:-1, y:-1};
2742        if(visible==null) visible=false;
2743        if(url==null)
2744        {
2745          visible=false;
2746          url='';
2747        }
2748
2749        if(visible)
2750        {
2751          $('#iPopupThumb')
2752            .bind('load', {geometry:geometry}, function (e)
2753                    {
2754                      $(this).css(
2755                        {
2756                          'left':(e.data.geometry.x-e.target.width/2)+'px',
2757                          'top':(e.data.geometry.y-e.target.height-15)+'px',
2758                          'display':'block'
2759                        }
2760                      );
2761                    }
2762                  )
2763            .attr('src', url);
2764        }
2765        else
2766        {
2767          $('#iPopupThumb').css('display', 'none');
2768        }
2769      },
2770
2771    /**
2772     * -----------------------------------------------------------------------
2773     * return the html content for popup box on history graph
2774     * -----------------------------------------------------------------------
2775     */
2776    getHistoryPopupContent = function ()
2777      {
2778        return(
2779          "<span class='nfoC'>"+translateString.events+"</span><br>"+
2780          "<span style='color:"+properties.graph.colors.normal[0]+"'>"+translateString.ua_Computer+"</span>"+
2781          "<span class='nfoR' id='iPI_computer'>-</span><br>"+
2782          "<span style='color:"+properties.graph.colors.normal[1]+"'>"+translateString.ua_Mobile+"</span>"+
2783          "<span class='nfoR' id='iPI_mobile'>-</span><br>"+
2784          "<span style='color:"+properties.graph.colors.normal[2]+"'>"+translateString.ua_Crawler+"</span>"+
2785          "<span class='nfoR' id='iPI_crawler'>-</span><br>"+
2786          "<span style='color:"+properties.graph.colors.normal[3]+"'>"+translateString.ua_Other+"</span>"+
2787          "<span class='nfoR' id='iPI_other'>-</span><br>"+
2788          "<span style='color:"+properties.graph.colors.gray[3]+"'>"+translateString.total+"</span>"+
2789          "<span class='nfoR' id='iPI_total'>-</span>"
2790        );
2791      },
2792
2793    /**
2794     * -----------------------------------------------------------------------
2795     * return the html content for popup box on period graph
2796     * -----------------------------------------------------------------------
2797     */
2798    getPeriodPopupContent = function ()
2799      {
2800        return(
2801          "<span class='nfoC'>"+translateString.visits+"</span><br>"+
2802          "<span style='color:"+properties.graph.colors.gray[3]+"'>"+translateString.viewedPages+"</span>"+
2803          "<span class='nfoR' id='iPI_viewedPages'>-</span><br>"+
2804          "<span style='color:"+properties.graph.colors.normal[0]+"'>"+translateString.viewedAlbums+"</span>"+
2805          "<span class='nfoR' id='iPI_viewedAlbums'>-</span><br>"+
2806          "<span style='color:"+properties.graph.colors.normal[1]+"'>"+translateString.viewedImages+"</span>"+
2807          "<span class='nfoR' id='iPI_viewedImages'>-</span><br>"+
2808          "<span style='color:"+properties.graph.colors.normal[2]+"'>"+translateString.uniqueIP+"</span>"+
2809          "<span class='nfoR' id='iPI_uniqueIP'>-</span><br>"
2810        );
2811      }
2812
2813
2814    /**
2815     * -----------------------------------------------------------------------
2816     * action done when user click on the period table
2817     *
2818     * this function is set has an event on $('#iPeriodTable') object
2819     * -----------------------------------------------------------------------
2820     */
2821    clickOnPeriodTable = function (event)
2822      {
2823        var oId=$(this).attr('oId'),
2824            data=$('#iPeriodTable').dynamicTable('loadedData', oId),
2825            period='';
2826
2827        switch($('#iPeriodPath').inputPath('level'))
2828        {
2829          case 1:
2830            // all years => years
2831            $('#iPeriodPath').inputPath('push', {id:'y-'+data[5], label:data[0]} );
2832            break;
2833          case 2:
2834            // year => months
2835            period=$('#iPeriodPath').inputPath('itemLevel', $('#iPeriodPath').inputPath('level')).id.substr(2);
2836            $('#iPeriodPath').inputPath('push', {id:'ym-'+period+data[5], label:data[0]} );
2837            break;
2838          case 3:
2839            // month => days
2840            break;
2841        }
2842        refreshGraphPeriod();
2843        refreshPagePeriodContent();
2844      };
2845
2846/**
2847  * ----------------------------------------------------------------------------
2848  *
2849  *                             MAIN OBJECT FUNCTION
2850  *
2851  *
2852  * ----------------------------------------------------------------------------
2853  */
2854
2855
2856  switch(fct)
2857  {
2858    case 'init':
2859      setProperties(values);
2860      init();
2861      break;
2862    case 'changePage':
2863      setProperties(null);
2864      changePage(values);
2865      break;
2866  }
2867}
Note: See TracBrowser for help on using the repository browser.