PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/hudson-core/src/main/resources/hudson/model/BuildTimelineWidget/control.jelly

http://github.com/hudson/hudson
Unknown | 170 lines | 142 code | 28 blank | 0 comment | 0 complexity | 253c7e8a65321bb6f14417c6be5b9a97 MD5 | raw file
  1<!--
  2The MIT License
  3
  4Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Seiji Sogabe
  5
  6Permission is hereby granted, free of charge, to any person obtaining a copy
  7of this software and associated documentation files (the "Software"), to deal
  8in the Software without restriction, including without limitation the rights
  9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10copies of the Software, and to permit persons to whom the Software is
 11furnished to do so, subject to the following conditions:
 12
 13The above copyright notice and this permission notice shall be included in
 14all copies or substantial portions of the Software.
 15
 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22THE SOFTWARE.
 23-->
 24<?jelly escape-by-default='true'?>
 25<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
 26    <st:documentation>
 27    Show timeline trend image. It takes two builds
 28    </st:documentation>
 29    
 30    <script type="text/javascript">
 31        var SimileAjax = {
 32            Platform: {}
 33        }; 
 34    </script>          
 35
 36    <script type="text/javascript">
 37        var browserName=navigator.appName;
 38        if (browserName=="Microsoft Internet Explorer"){
 39           //load ie friendly stylesheet
 40           document.write('<link rel="stylesheet" type="text/css" href="${resURL}/scripts/timeline_2.3.2/timeline_ajax/styles/graphics-ie6.css" />)
 41        } else{
 42           document.write('<link rel="stylesheet" type="text/css" href="${resURL}/scripts/timeline_2.3.2/timeline_ajax/styles/graphics.css" />)
 43        }
 44     </script> 
 45
 46    <link rel="stylesheet" type="text/css" href="${resURL}/scripts/timeline_2.3.2/timeline_ajax/styles/graphics.css" />
 47    <link rel="stylesheet" type="text/css" href="${resURL}/scripts/timeline_2.3.2/timeline_js/timeline-bundle.css" />
 48    
 49    <script src="${resURL}/scripts/timeline_2.3.2/timeline_ajax/simile-ajax-bundle.js" type="text/javascript" /> 
 50    
 51     <script type="text/javascript">
 52        
 53            var Timeline = {};
 54            Timeline.DateTime = SimileAjax.DateTime;
 55            Timeline.urlPrefix ='${resURL}/scripts/timeline_2.3.2/timeline_js/';
 56            Timeline.serverLocale = '${h.serverLocale.language}';
 57            Timeline.clientLocale = '${h.clientLocale.language}';;
 58            
 59    </script>  
 60    
 61    <script src="${resURL}/scripts/timeline_2.3.2/timeline_js/timeline-bundle.js" type="text/javascript" />
 62    
 63    <script src="${resURL}/scripts/timeline_2.3.2/timeline_js/scripts/l10n/en/labellers.js" type="text/javascript" />   
 64    <script src="${resURL}/scripts/timeline_2.3.2/timeline_js/scripts/l10n/en/timeline.js" type="text/javascript" /> 
 65    
 66    
 67    <j:invokeStatic var="tz" className="java.util.TimeZone" method="getDefault"/>
 68    <div id="tl" style="height:250px; border:1px solid black;" />
 69    <div id="status" />
 70 
 71     <script type="text/javascript">
 72       
 73          <![CDATA[
 74            // Respect Daylight Saving Time on client side
 75            var tz = ${it.getTimeZoneOffset()};
 76           
 77             function onLoadEvent() {
 78                var tl_el = document.getElementById("tl");
 79                var eventSource1 = new Timeline.DefaultEventSource();
 80                eventSource1.loaded = {};
 81                var interval = 24*60*60*1000;
 82                eventSource1.ensureVisible = function(band) {
 83                  // make sure all data are loaded for the portion visible in the band
 84                  // $('status').innerHTML = "min="+band.getMinDate()+" max="+band.getMaxDate();
 85                  var min = Math.floor(band.getMinDate().getTime()/interval);
 86                  var max = Math.ceil(band.getMaxDate().getTime()/interval);
 87                  for (var i=min; i<=max; i++) {
 88                    if (!this.loaded[i]) {
 89                      this.loaded[i] = true;
 90                      new Ajax.Request("timeline/data",{
 91                          method:"POST",
 92                          parameters: {min: i*interval, max:(i+1)*interval},
 93                          onSuccess: function(t) {
 94                            try {
 95                              eventSource1.loadJSON(eval('('+t.responseText+')'),'.');
 96                            } catch (e) {
 97                              alert(e);
 98                            }
 99                          }
100                      });
101                    }
102                  }
103                };
104
105
106                var theme1 = Timeline.ClassicTheme.create();
107                 // theme1.autoWidth = true; // Set the Timeline's "width" automatically.
108                 // Set autoWidth on the Timeline's first band's theme,
109                 // will affect all bands.
110                theme1.timeline_start = new Date(${it.firstBuild.timeInMillis-24*60*60*1000});
111                theme1.timeline_stop  = new Date(${it.lastBuild.timeInMillis+24*60*60*1000});
112
113                var d = new Date(${it.lastBuild.timeInMillis});
114                var bandInfos = [
115                    // the bar that shows outline
116                    Timeline.createBandInfo({
117                        width:          "50px", // set to a minimum, autoWidth will then adjust
118                        intervalUnit:   Timeline.DateTime.DAY,
119                        intervalPixels: 200,
120                        eventSource:    eventSource1,
121                        timeZone:       tz,
122                        theme:          theme1,
123                        layout:         'overview'  // original, overview, detailed
124                    }),
125                    // the main area
126                    Timeline.createBandInfo({
127                        width:          "200px",
128                        eventSource:    eventSource1,
129                        timeZone:       tz,
130                        theme:          theme1,
131                        intervalUnit:   Timeline.DateTime.HOUR,
132                        intervalPixels: 200
133                    })
134                ];
135                bandInfos[0].highlight = true;
136                bandInfos[0].syncWith = 1;
137
138                // create the Timeline
139                var tl = Timeline.create(tl_el, bandInfos, Timeline.HORIZONTAL);
140
141                tl.getBand(0).addOnScrollListener(function(band) {
142                    eventSource1.ensureVisible(band);
143                });
144
145                tl.layout(); // display the Timeline
146
147                // if resized, redo layout
148                var resizeTimerID = null;
149                window.addEventListener('resize',function() {
150                    if (resizeTimerID == null) {
151                        resizeTimerID = window.setTimeout(function() {
152                            resizeTimerID = null;
153                            tl.layout();
154                        }, 500);
155                    }
156                },false);
157            }
158
159            if (window.attachEvent) {
160                window.attachEvent('onload', onLoadEvent);
161            }else if (window.addEventListener) {
162               window.addEventListener('load', onLoadEvent, false);
163            }else {
164               document.addEventListener('load', onLoadEvent, false);
165            }
166     ]]>
167    
168  </script>
169     
170</j:jelly>