Merge lp:~lucio.torre/graphite/add-flot into lp:~graphite-dev/graphite/main

Proposed by Lucio Torre
Status: Merged
Merge reported by: chrismd
Merged at revision: not available
Proposed branch: lp:~lucio.torre/graphite/add-flot
Merge into: lp:~graphite-dev/graphite/main
Diff against target: 4383 lines
To merge this branch: bzr merge lp:~lucio.torre/graphite/add-flot
Reviewer Review Type Date Requested Status
chrismd Approve
Review via email: mp+39768@code.launchpad.net

Description of the change

Adds a new interface for rendering graphs with the following features:
- rendering is done client side
- you can mouse-over data points to see their value and to which series they belong
- you can zoom into portions of the data
- you have an overview of the plot
- you can move the series between any of the two axis
- autocomplete for metric input
- faster manipulation of graph series

We are currently working with this live to see how well it copes with lots of data. So far it seems to work ok. I find it very useful to have two axis and an easy way to tell which series is the one that i am pointing with the mouse (with many series colors become very similar)

Please let me know what you think.

To post a comment you must log in.
Revision history for this message
chrismd (chrismd) wrote :

Sorry for the extremely long delay. I've finally reviewed your branch and I must say it is a pretty cool UI. I fixed a few merge issues (I think you forgot to bzr add a delete.png file you were replacing delete.gif with). And it is now in trunk, thanks and again sorry this took so long.

Revision history for this message
chrismd (chrismd) :
review: Approve
Revision history for this message
jeromy (fuji246) wrote :

Hi, is there any update on this? I've made an improved version, and added autoupdate and timezone suppport, and do some enhancement for the ui.

Revision history for this message
Amos Shapira (amos-shapira) wrote :

I'm not a member of the core team but from following them I understand that they moved the code repository to Github: https://github.com/graphite-project.

Maybe it could help if you submitted the new update there.

Thanks for all your work!

Revision history for this message
Lucio Torre (lucio.torre) wrote :

This has been merged and can be found on the "flot (experimental)" link in the main page.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'webapp/content/css/jquery.autocomplete.css'
--- webapp/content/css/jquery.autocomplete.css 1970-01-01 00:00:00 +0000
+++ webapp/content/css/jquery.autocomplete.css 2010-11-01 18:48:50 +0000
@@ -0,0 +1,48 @@
1.ac_results {
2 padding: 0px;
3 border: 1px solid black;
4 background-color: white;
5 overflow: hidden;
6 z-index: 99999;
7}
8
9.ac_results ul {
10 width: 100%;
11 list-style-position: outside;
12 list-style: none;
13 padding: 0;
14 margin: 0;
15}
16
17.ac_results li {
18 margin: 0px;
19 padding: 2px 5px;
20 cursor: default;
21 display: block;
22 /*
23 if width will be 100% horizontal scrollbar will apear
24 when scroll mode will be used
25 */
26 /*width: 100%;*/
27 font: menu;
28 font-size: 12px;
29 /*
30 it is very important, if line-height not setted or setted
31 in relative units scroll will be broken in firefox
32 */
33 line-height: 16px;
34 overflow: hidden;
35}
36
37.ac_loading {
38 background: white url('../img/indicator.png') right center no-repeat;
39}
40
41.ac_odd {
42 background-color: #eee;
43}
44
45.ac_over {
46 background-color: #0A246A;
47 color: white;
48}
049
=== added file 'webapp/content/css/table.css'
--- webapp/content/css/table.css 1970-01-01 00:00:00 +0000
+++ webapp/content/css/table.css 2010-11-01 18:48:50 +0000
@@ -0,0 +1,1 @@
1body {
0 color: #4f6b72;2 color: #4f6b72;
1 background: #E6EAE9;3 background: #E6EAE9;
2}4}
35
4a {6a {
5 color: #c75f3e;7 color: #c75f3e;
6}8}
79
#canvas {
8 border-right: 1px solid #C1DAD7;10 border-right: 1px solid #C1DAD7;
9 border-bottom: 1px solid #C1DAD7;11 border-bottom: 1px solid #C1DAD7;
10 background: #fff;12 background: #fff;
11 13
12 color: #4f6b72;14 color: #4f6b72;
13}15}
1416
#title {
15 font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;17 font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
16 color: #4f6b72;18 color: #4f6b72;
17 border-right: 1px solid #C1DAD7;19 border-right: 1px solid #C1DAD7;
18 border-bottom: 1px solid #C1DAD7;20 border-bottom: 1px solid #C1DAD7;
19 border-top: 1px solid #C1DAD7;21 border-top: 1px solid #C1DAD7;
20 letter-spacing: 2px;22 letter-spacing: 2px;
21 text-transform: uppercase;23 text-transform: uppercase;
22 text-align: left;24 text-align: left;
23 padding: 6px 6px 6px 12px;25 padding: 6px 6px 6px 12px;
24 background: #CAE8EA;26 background: #CAE8EA;
25}27}
2628
27.styledtable th {29.styledtable th {
28 font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;30 font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
29 color: #4f6b72;31 color: #4f6b72;
30 border-right: 1px solid #C1DAD7;32 border-right: 1px solid #C1DAD7;
31 border-bottom: 1px solid #C1DAD7;33 border-bottom: 1px solid #C1DAD7;
32 border-top: 1px solid #C1DAD7;34 border-top: 1px solid #C1DAD7;
33 letter-spacing: 2px;35 letter-spacing: 2px;
34 text-transform: uppercase;36 text-transform: uppercase;
35 text-align: left;37 text-align: left;
36 padding: 6px 6px 6px 12px;38 padding: 6px 6px 6px 12px;
37 background: #CAE8EA;39 background: #CAE8EA;
38}40}
3941
4042
4143
42.styledtable td {44.styledtable td {
43 border-right: 1px solid #C1DAD7;45 border-right: 1px solid #C1DAD7;
44 border-bottom: 1px solid #C1DAD7;46 border-bottom: 1px solid #C1DAD7;
45 background: #fff;47 background: #fff;
46 padding: 6px 6px 6px 12px;48 padding: 6px 6px 6px 12px;
47 color: #4f6b72;49 color: #4f6b72;
48}50}
4951
50\ No newline at end of file52\ No newline at end of file
5153
=== removed file 'webapp/content/img/delete.gif'
52Binary files webapp/content/img/delete.gif 2010-02-26 16:15:44 +0000 and webapp/content/img/delete.gif 1970-01-01 00:00:00 +0000 differ54Binary files webapp/content/img/delete.gif 2010-02-26 16:15:44 +0000 and webapp/content/img/delete.gif 1970-01-01 00:00:00 +0000 differ
=== added file 'webapp/content/img/delete.png'
53Binary files webapp/content/img/delete.png 1970-01-01 00:00:00 +0000 and webapp/content/img/delete.png 2010-11-01 18:48:50 +0000 differ55Binary files webapp/content/img/delete.png 1970-01-01 00:00:00 +0000 and webapp/content/img/delete.png 2010-11-01 18:48:50 +0000 differ
=== added file 'webapp/content/img/indicator.png'
54Binary files webapp/content/img/indicator.png 1970-01-01 00:00:00 +0000 and webapp/content/img/indicator.png 2010-11-01 18:48:50 +0000 differ56Binary files webapp/content/img/indicator.png 1970-01-01 00:00:00 +0000 and webapp/content/img/indicator.png 2010-11-01 18:48:50 +0000 differ
=== added file 'webapp/content/js/jquery.autocomplete.js'
--- webapp/content/js/jquery.autocomplete.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.autocomplete.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,762 @@
1/*
2 * Autocomplete - jQuery plugin 1.1pre
3 *
4 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
5 *
6 * Dual licensed under the MIT and GPL licenses:
7 * http://www.opensource.org/licenses/mit-license.php
8 * http://www.gnu.org/licenses/gpl.html
9 *
10 * Revision: $Id: jquery.autocomplete.js 5785 2008-07-12 10:37:33Z joern.zaefferer $
11 *
12 */
13
14;(function($) {
15
16$.fn.extend({
17 autocomplete: function(urlOrData, options) {
18 var isUrl = typeof urlOrData == "string";
19 options = $.extend({}, $.Autocompleter.defaults, {
20 url: isUrl ? urlOrData : null,
21 data: isUrl ? null : urlOrData,
22 delay: isUrl ? $.Autocompleter.defaults.delay : 10,
23 max: options && !options.scroll ? 10 : 150
24 }, options);
25
26 // if highlight is set to false, replace it with a do-nothing function
27 options.highlight = options.highlight || function(value) { return value; };
28
29 // if the formatMatch option is not specified, then use formatItem for backwards compatibility
30 options.formatMatch = options.formatMatch || options.formatItem;
31
32 return this.each(function() {
33 new $.Autocompleter(this, options);
34 });
35 },
36 result: function(handler) {
37 return this.bind("result", handler);
38 },
39 search: function(handler) {
40 return this.trigger("search", [handler]);
41 },
42 flushCache: function() {
43 return this.trigger("flushCache");
44 },
45 setOptions: function(options){
46 return this.trigger("setOptions", [options]);
47 },
48 unautocomplete: function() {
49 return this.trigger("unautocomplete");
50 }
51});
52
53$.Autocompleter = function(input, options) {
54
55 var KEY = {
56 UP: 38,
57 DOWN: 40,
58 DEL: 46,
59 TAB: 9,
60 RETURN: 13,
61 ESC: 27,
62 COMMA: 188,
63 PAGEUP: 33,
64 PAGEDOWN: 34,
65 BACKSPACE: 8
66 };
67
68 // Create $ object for input element
69 var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
70
71 var timeout;
72 var previousValue = "";
73 var cache = $.Autocompleter.Cache(options);
74 var hasFocus = 0;
75 var lastKeyPressCode;
76 var config = {
77 mouseDownOnSelect: false
78 };
79 var select = $.Autocompleter.Select(options, input, selectCurrent, config);
80
81 var blockSubmit;
82
83 // prevent form submit in opera when selecting with return key
84 $.browser.opera && $(input.form).bind("submit.autocomplete", function() {
85 if (blockSubmit) {
86 blockSubmit = false;
87 return false;
88 }
89 });
90
91 // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
92 $input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
93 // track last key pressed
94 lastKeyPressCode = event.keyCode;
95 switch(event.keyCode) {
96
97 case KEY.UP:
98 event.preventDefault();
99 if ( select.visible() ) {
100 select.prev();
101 } else {
102 onChange(0, true);
103 }
104 break;
105
106 case KEY.DOWN:
107 event.preventDefault();
108 if ( select.visible() ) {
109 select.next();
110 } else {
111 onChange(0, true);
112 }
113 break;
114
115 case KEY.PAGEUP:
116 event.preventDefault();
117 if ( select.visible() ) {
118 select.pageUp();
119 } else {
120 onChange(0, true);
121 }
122 break;
123
124 case KEY.PAGEDOWN:
125 event.preventDefault();
126 if ( select.visible() ) {
127 select.pageDown();
128 } else {
129 onChange(0, true);
130 }
131 break;
132
133 // matches also semicolon
134 case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
135 case KEY.TAB:
136 case KEY.RETURN:
137 if( selectCurrent() ) {
138 // stop default to prevent a form submit, Opera needs special handling
139 event.preventDefault();
140 blockSubmit = true;
141 return false;
142 }
143 break;
144
145 case KEY.ESC:
146 select.hide();
147 break;
148
149 default:
150 clearTimeout(timeout);
151 timeout = setTimeout(onChange, options.delay);
152 break;
153 }
154 }).focus(function(){
155 // track whether the field has focus, we shouldn't process any
156 // results if the field no longer has focus
157 hasFocus++;
158 }).blur(function() {
159 hasFocus = 0;
160 if (!config.mouseDownOnSelect) {
161 hideResults();
162 }
163 }).click(function() {
164 // show select when clicking in a focused field
165 if ( hasFocus++ > 1 && !select.visible() ) {
166 onChange(0, true);
167 }
168 }).bind("search", function() {
169 // TODO why not just specifying both arguments?
170 var fn = (arguments.length > 1) ? arguments[1] : null;
171 function findValueCallback(q, data) {
172 var result;
173 if( data && data.length ) {
174 for (var i=0; i < data.length; i++) {
175 if( data[i].result.toLowerCase() == q.toLowerCase() ) {
176 result = data[i];
177 break;
178 }
179 }
180 }
181 if( typeof fn == "function" ) fn(result);
182 else $input.trigger("result", result && [result.data, result.value]);
183 }
184 $.each(trimWords($input.val()), function(i, value) {
185 request(value, findValueCallback, findValueCallback);
186 });
187 }).bind("flushCache", function() {
188 cache.flush();
189 }).bind("setOptions", function() {
190 $.extend(options, arguments[1]);
191 // if we've updated the data, repopulate
192 if ( "data" in arguments[1] )
193 cache.populate();
194 }).bind("unautocomplete", function() {
195 select.unbind();
196 $input.unbind();
197 $(input.form).unbind(".autocomplete");
198 });
199
200
201 function selectCurrent() {
202 var selected = select.selected();
203 if( !selected )
204 return false;
205
206 var v = selected.result;
207 previousValue = v;
208
209 if ( options.multiple ) {
210 var words = trimWords($input.val());
211 if ( words.length > 1 ) {
212 v = words.slice(0, words.length - 1).join( options.multipleSeparator ) + options.multipleSeparator + v;
213 }
214 v += options.multipleSeparator;
215 }
216
217 $input.val(v);
218 hideResultsNow();
219 $input.trigger("result", [selected.data, selected.value]);
220 return true;
221 }
222
223 function onChange(crap, skipPrevCheck) {
224 if( lastKeyPressCode == KEY.DEL ) {
225 select.hide();
226 return;
227 }
228
229 var currentValue = $input.val();
230
231 if ( !skipPrevCheck && currentValue == previousValue )
232 return;
233
234 previousValue = currentValue;
235
236 currentValue = lastWord(currentValue);
237 if ( currentValue.length >= options.minChars) {
238 $input.addClass(options.loadingClass);
239 if (!options.matchCase)
240 currentValue = currentValue.toLowerCase();
241 request(currentValue, receiveData, hideResultsNow);
242 } else {
243 stopLoading();
244 select.hide();
245 }
246 };
247
248 function trimWords(value) {
249 if ( !value ) {
250 return [""];
251 }
252 var words = value.split( options.multipleSeparator );
253 var result = [];
254 $.each(words, function(i, value) {
255 if ( $.trim(value) )
256 result[i] = $.trim(value);
257 });
258 return result;
259 }
260
261 function lastWord(value) {
262 if ( !options.multiple )
263 return value;
264 var words = trimWords(value);
265 return words[words.length - 1];
266 }
267
268 // fills in the input box w/the first match (assumed to be the best match)
269 // q: the term entered
270 // sValue: the first matching result
271 function autoFill(q, sValue){
272 // autofill in the complete box w/the first match as long as the user hasn't entered in more data
273 // if the last user key pressed was backspace, don't autofill
274 if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
275 // fill in the value (keep the case the user has typed)
276 $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
277 // select the portion of the value not typed by the user (so the next character will erase)
278 $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
279 }
280 };
281
282 function hideResults() {
283 clearTimeout(timeout);
284 timeout = setTimeout(hideResultsNow, 200);
285 };
286
287 function hideResultsNow() {
288 var wasVisible = select.visible();
289 select.hide();
290 clearTimeout(timeout);
291 stopLoading();
292 if (options.mustMatch) {
293 // call search and run callback
294 $input.search(
295 function (result){
296 // if no value found, clear the input box
297 if( !result ) {
298 if (options.multiple) {
299 var words = trimWords($input.val()).slice(0, -1);
300 $input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
301 }
302 else
303 $input.val( "" );
304 }
305 }
306 );
307 }
308 if (wasVisible)
309 // position cursor at end of input field
310 $.Autocompleter.Selection(input, input.value.length, input.value.length);
311 };
312
313 function receiveData(q, data) {
314 if ( data && data.length && hasFocus ) {
315 stopLoading();
316 select.display(data, q);
317 autoFill(q, data[0].value);
318 select.show();
319 } else {
320 hideResultsNow();
321 }
322 };
323
324 function request(term, success, failure) {
325 if (!options.matchCase)
326 term = term.toLowerCase();
327 var data = cache.load(term);
328 // recieve the cached data
329 if (data && data.length) {
330 success(term, data);
331 // if an AJAX url has been supplied, try loading the data now
332 } else if( (typeof options.url == "string") && (options.url.length > 0) ){
333
334 var extraParams = {
335 timestamp: +new Date()
336 };
337 $.each(options.extraParams, function(key, param) {
338 extraParams[key] = typeof param == "function" ? param() : param;
339 });
340
341 $.ajax({
342 // try to leverage ajaxQueue plugin to abort previous requests
343 mode: "abort",
344 // limit abortion to this input
345 port: "autocomplete" + input.name,
346 dataType: options.dataType,
347 url: options.url,
348 data: $.extend({
349 q: lastWord(term),
350 limit: options.max
351 }, extraParams),
352 success: function(data) {
353 var parsed = options.parse && options.parse(data) || parse(data);
354 cache.add(term, parsed);
355 success(term, parsed);
356 }
357 });
358 } else {
359 // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
360 select.emptyList();
361 failure(term);
362 }
363 };
364
365 function parse(data) {
366 var parsed = [];
367 var rows = data.split("\n");
368 for (var i=0; i < rows.length; i++) {
369 var row = $.trim(rows[i]);
370 if (row) {
371 row = row.split("|");
372 parsed[parsed.length] = {
373 data: row,
374 value: row[0],
375 result: options.formatResult && options.formatResult(row, row[0]) || row[0]
376 };
377 }
378 }
379 return parsed;
380 };
381
382 function stopLoading() {
383 $input.removeClass(options.loadingClass);
384 };
385
386};
387
388$.Autocompleter.defaults = {
389 inputClass: "ac_input",
390 resultsClass: "ac_results",
391 loadingClass: "ac_loading",
392 minChars: 1,
393 delay: 400,
394 matchCase: false,
395 matchSubset: true,
396 matchContains: false,
397 cacheLength: 10,
398 max: 100,
399 mustMatch: false,
400 extraParams: {},
401 selectFirst: true,
402 formatItem: function(row) { return row[0]; },
403 formatMatch: null,
404 autoFill: false,
405 width: 0,
406 multiple: false,
407 multipleSeparator: ", ",
408 highlight: function(value, term) {
409 return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
410 },
411 scroll: true,
412 scrollHeight: 180
413};
414
415$.Autocompleter.Cache = function(options) {
416
417 var data = {};
418 var length = 0;
419
420 function matchSubset(s, sub) {
421 if (!options.matchCase)
422 s = s.toLowerCase();
423 var i = s.indexOf(sub);
424 if (options.matchContains == "word"){
425 i = s.toLowerCase().search("\\b" + sub.toLowerCase());
426 }
427 if (i == -1) return false;
428 return i == 0 || options.matchContains;
429 };
430
431 function add(q, value) {
432 if (length > options.cacheLength){
433 flush();
434 }
435 if (!data[q]){
436 length++;
437 }
438 data[q] = value;
439 }
440
441 function populate(){
442 if( !options.data ) return false;
443 // track the matches
444 var stMatchSets = {},
445 nullData = 0;
446
447 // no url was specified, we need to adjust the cache length to make sure it fits the local data store
448 if( !options.url ) options.cacheLength = 1;
449
450 // track all options for minChars = 0
451 stMatchSets[""] = [];
452
453 // loop through the array and create a lookup structure
454 for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
455 var rawValue = options.data[i];
456 // if rawValue is a string, make an array otherwise just reference the array
457 rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
458
459 var value = options.formatMatch(rawValue, i+1, options.data.length);
460 if ( value === false )
461 continue;
462
463 var firstChar = value.charAt(0).toLowerCase();
464 // if no lookup array for this character exists, look it up now
465 if( !stMatchSets[firstChar] )
466 stMatchSets[firstChar] = [];
467
468 // if the match is a string
469 var row = {
470 value: value,
471 data: rawValue,
472 result: options.formatResult && options.formatResult(rawValue) || value
473 };
474
475 // push the current match into the set list
476 stMatchSets[firstChar].push(row);
477
478 // keep track of minChars zero items
479 if ( nullData++ < options.max ) {
480 stMatchSets[""].push(row);
481 }
482 };
483
484 // add the data items to the cache
485 $.each(stMatchSets, function(i, value) {
486 // increase the cache size
487 options.cacheLength++;
488 // add to the cache
489 add(i, value);
490 });
491 }
492
493 // populate any existing data
494 setTimeout(populate, 25);
495
496 function flush(){
497 data = {};
498 length = 0;
499 }
500
501 return {
502 flush: flush,
503 add: add,
504 populate: populate,
505 load: function(q) {
506 if (!options.cacheLength || !length)
507 return null;
508 /*
509 * if dealing w/local data and matchContains than we must make sure
510 * to loop through all the data collections looking for matches
511 */
512 if( !options.url && options.matchContains ){
513 // track all matches
514 var csub = [];
515 // loop through all the data grids for matches
516 for( var k in data ){
517 // don't search through the stMatchSets[""] (minChars: 0) cache
518 // this prevents duplicates
519 if( k.length > 0 ){
520 var c = data[k];
521 $.each(c, function(i, x) {
522 // if we've got a match, add it to the array
523 if (matchSubset(x.value, q)) {
524 csub.push(x);
525 }
526 });
527 }
528 }
529 return csub;
530 } else
531 // if the exact item exists, use it
532 if (data[q]){
533 return data[q];
534 } else
535 if (options.matchSubset) {
536 for (var i = q.length - 1; i >= options.minChars; i--) {
537 var c = data[q.substr(0, i)];
538 if (c) {
539 var csub = [];
540 $.each(c, function(i, x) {
541 if (matchSubset(x.value, q)) {
542 csub[csub.length] = x;
543 }
544 });
545 return csub;
546 }
547 }
548 }
549 return null;
550 }
551 };
552};
553
554$.Autocompleter.Select = function (options, input, select, config) {
555 var CLASSES = {
556 ACTIVE: "ac_over"
557 };
558
559 var listItems,
560 active = -1,
561 data,
562 term = "",
563 needsInit = true,
564 element,
565 list;
566
567 // Create results
568 function init() {
569 if (!needsInit)
570 return;
571 element = $("<div/>")
572 .hide()
573 .addClass(options.resultsClass)
574 .css("position", "absolute")
575 .appendTo(document.body);
576
577 list = $("<ul/>").appendTo(element).mouseover( function(event) {
578 if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
579 active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
580 $(target(event)).addClass(CLASSES.ACTIVE);
581 }
582 }).click(function(event) {
583 $(target(event)).addClass(CLASSES.ACTIVE);
584 select();
585 // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
586 input.focus();
587 return false;
588 }).mousedown(function() {
589 config.mouseDownOnSelect = true;
590 }).mouseup(function() {
591 config.mouseDownOnSelect = false;
592 });
593
594 if( options.width > 0 )
595 element.css("width", options.width);
596
597 needsInit = false;
598 }
599
600 function target(event) {
601 var element = event.target;
602 while(element && element.tagName != "LI")
603 element = element.parentNode;
604 // more fun with IE, sometimes event.target is empty, just ignore it then
605 if(!element)
606 return [];
607 return element;
608 }
609
610 function moveSelect(step) {
611 listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
612 movePosition(step);
613 var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
614 if(options.scroll) {
615 var offset = 0;
616 listItems.slice(0, active).each(function() {
617 offset += this.offsetHeight;
618 });
619 if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
620 list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
621 } else if(offset < list.scrollTop()) {
622 list.scrollTop(offset);
623 }
624 }
625 };
626
627 function movePosition(step) {
628 active += step;
629 if (active < 0) {
630 active = listItems.size() - 1;
631 } else if (active >= listItems.size()) {
632 active = 0;
633 }
634 }
635
636 function limitNumberOfItems(available) {
637 return options.max && options.max < available
638 ? options.max
639 : available;
640 }
641
642 function fillList() {
643 list.empty();
644 var max = limitNumberOfItems(data.length);
645 for (var i=0; i < max; i++) {
646 if (!data[i])
647 continue;
648 var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
649 if ( formatted === false )
650 continue;
651 var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
652 $.data(li, "ac_data", data[i]);
653 }
654 listItems = list.find("li");
655 if ( options.selectFirst ) {
656 listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
657 active = 0;
658 }
659 // apply bgiframe if available
660 if ( $.fn.bgiframe )
661 list.bgiframe();
662 }
663
664 return {
665 display: function(d, q) {
666 init();
667 data = d;
668 term = q;
669 fillList();
670 },
671 next: function() {
672 moveSelect(1);
673 },
674 prev: function() {
675 moveSelect(-1);
676 },
677 pageUp: function() {
678 if (active != 0 && active - 8 < 0) {
679 moveSelect( -active );
680 } else {
681 moveSelect(-8);
682 }
683 },
684 pageDown: function() {
685 if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
686 moveSelect( listItems.size() - 1 - active );
687 } else {
688 moveSelect(8);
689 }
690 },
691 hide: function() {
692 element && element.hide();
693 listItems && listItems.removeClass(CLASSES.ACTIVE);
694 active = -1;
695 },
696 visible : function() {
697 return element && element.is(":visible");
698 },
699 current: function() {
700 return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
701 },
702 show: function() {
703 var offset = $(input).offset();
704 element.css({
705 width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
706 top: offset.top + input.offsetHeight,
707 left: offset.left
708 }).show();
709 if(options.scroll) {
710 list.scrollTop(0);
711 list.css({
712 maxHeight: options.scrollHeight,
713 overflow: 'auto'
714 });
715
716 if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
717 var listHeight = 0;
718 listItems.each(function() {
719 listHeight += this.offsetHeight;
720 });
721 var scrollbarsVisible = listHeight > options.scrollHeight;
722 list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
723 if (!scrollbarsVisible) {
724 // IE doesn't recalculate width when scrollbar disappears
725 listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
726 }
727 }
728
729 }
730 },
731 selected: function() {
732 var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
733 return selected && selected.length && $.data(selected[0], "ac_data");
734 },
735 emptyList: function (){
736 list && list.empty();
737 },
738 unbind: function() {
739 element && element.remove();
740 }
741 };
742};
743
744$.Autocompleter.Selection = function(field, start, end) {
745 if( field.createTextRange ){
746 var selRange = field.createTextRange();
747 selRange.collapse(true);
748 selRange.moveStart("character", start);
749 selRange.moveEnd("character", end);
750 selRange.select();
751 } else if( field.setSelectionRange ){
752 field.setSelectionRange(start, end);
753 } else {
754 if( field.selectionStart ){
755 field.selectionStart = start;
756 field.selectionEnd = end;
757 }
758 }
759 field.focus();
760};
761
762})(jQuery);
0\ No newline at end of file763\ No newline at end of file
1764
=== added file 'webapp/content/js/jquery.flot.crosshair.js'
--- webapp/content/js/jquery.flot.crosshair.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.flot.crosshair.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,156 @@
1/*
2Flot plugin for showing a crosshair, thin lines, when the mouse hovers
3over the plot.
4
5 crosshair: {
6 mode: null or "x" or "y" or "xy"
7 color: color
8 lineWidth: number
9 }
10
11Set the mode to one of "x", "y" or "xy". The "x" mode enables a
12vertical crosshair that lets you trace the values on the x axis, "y"
13enables a horizontal crosshair and "xy" enables them both. "color" is
14the color of the crosshair (default is "rgba(170, 0, 0, 0.80)"),
15"lineWidth" is the width of the drawn lines (default is 1).
16
17The plugin also adds four public methods:
18
19 - setCrosshair(pos)
20
21 Set the position of the crosshair. Note that this is cleared if
22 the user moves the mouse. "pos" should be on the form { x: xpos,
23 y: ypos } (or x2 and y2 if you're using the secondary axes), which
24 is coincidentally the same format as what you get from a "plothover"
25 event. If "pos" is null, the crosshair is cleared.
26
27 - clearCrosshair()
28
29 Clear the crosshair.
30
31 - lockCrosshair(pos)
32
33 Cause the crosshair to lock to the current location, no longer
34 updating if the user moves the mouse. Optionally supply a position
35 (passed on to setCrosshair()) to move it to.
36
37 Example usage:
38 var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
39 $("#graph").bind("plothover", function (evt, position, item) {
40 if (item) {
41 // Lock the crosshair to the data point being hovered
42 myFlot.lockCrosshair({ x: item.datapoint[0], y: item.datapoint[1] });
43 }
44 else {
45 // Return normal crosshair operation
46 myFlot.unlockCrosshair();
47 }
48 });
49
50 - unlockCrosshair()
51
52 Free the crosshair to move again after locking it.
53*/
54
55(function ($) {
56 var options = {
57 crosshair: {
58 mode: null, // one of null, "x", "y" or "xy",
59 color: "rgba(170, 0, 0, 0.80)",
60 lineWidth: 1
61 }
62 };
63
64 function init(plot) {
65 // position of crosshair in pixels
66 var crosshair = { x: -1, y: -1, locked: false };
67
68 plot.setCrosshair = function setCrosshair(pos) {
69 if (!pos)
70 crosshair.x = -1;
71 else {
72 var axes = plot.getAxes();
73
74 crosshair.x = Math.max(0, Math.min(pos.x != null ? axes.xaxis.p2c(pos.x) : axes.x2axis.p2c(pos.x2), plot.width()));
75 crosshair.y = Math.max(0, Math.min(pos.y != null ? axes.yaxis.p2c(pos.y) : axes.y2axis.p2c(pos.y2), plot.height()));
76 }
77
78 plot.triggerRedrawOverlay();
79 };
80
81 plot.clearCrosshair = plot.setCrosshair; // passes null for pos
82
83 plot.lockCrosshair = function lockCrosshair(pos) {
84 if (pos)
85 plot.setCrosshair(pos);
86 crosshair.locked = true;
87 }
88
89 plot.unlockCrosshair = function unlockCrosshair() {
90 crosshair.locked = false;
91 }
92
93 plot.hooks.bindEvents.push(function (plot, eventHolder) {
94 if (!plot.getOptions().crosshair.mode)
95 return;
96
97 eventHolder.mouseout(function () {
98 if (crosshair.x != -1) {
99 crosshair.x = -1;
100 plot.triggerRedrawOverlay();
101 }
102 });
103
104 eventHolder.mousemove(function (e) {
105 if (plot.getSelection && plot.getSelection()) {
106 crosshair.x = -1; // hide the crosshair while selecting
107 return;
108 }
109
110 if (crosshair.locked)
111 return;
112
113 var offset = plot.offset();
114 crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
115 crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
116 plot.triggerRedrawOverlay();
117 });
118 });
119
120 plot.hooks.drawOverlay.push(function (plot, ctx) {
121 var c = plot.getOptions().crosshair;
122 if (!c.mode)
123 return;
124
125 var plotOffset = plot.getPlotOffset();
126
127 ctx.save();
128 ctx.translate(plotOffset.left, plotOffset.top);
129
130 if (crosshair.x != -1) {
131 ctx.strokeStyle = c.color;
132 ctx.lineWidth = c.lineWidth;
133 ctx.lineJoin = "round";
134
135 ctx.beginPath();
136 if (c.mode.indexOf("x") != -1) {
137 ctx.moveTo(crosshair.x, 0);
138 ctx.lineTo(crosshair.x, plot.height());
139 }
140 if (c.mode.indexOf("y") != -1) {
141 ctx.moveTo(0, crosshair.y);
142 ctx.lineTo(plot.width(), crosshair.y);
143 }
144 ctx.stroke();
145 }
146 ctx.restore();
147 });
148 }
149
150 $.plot.plugins.push({
151 init: init,
152 options: options,
153 name: 'crosshair',
154 version: '1.0'
155 });
156})(jQuery);
0157
=== added file 'webapp/content/js/jquery.flot.js'
--- webapp/content/js/jquery.flot.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.flot.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,2119 @@
1/* Javascript plotting library for jQuery, v. 0.6.
2 *
3 * Released under the MIT license by IOLA, December 2007.
4 *
5 */
6
7// first an inline dependency, jquery.colorhelpers.js, we inline it here
8// for convenience
9
10/* Plugin for jQuery for working with colors.
11 *
12 * Version 1.0.
13 *
14 * Inspiration from jQuery color animation plugin by John Resig.
15 *
16 * Released under the MIT license by Ole Laursen, October 2009.
17 *
18 * Examples:
19 *
20 * $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
21 * var c = $.color.extract($("#mydiv"), 'background-color');
22 * console.log(c.r, c.g, c.b, c.a);
23 * $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
24 *
25 * Note that .scale() and .add() work in-place instead of returning
26 * new objects.
27 */
28(function(){jQuery.color={};jQuery.color.make=function(E,D,B,C){var F={};F.r=E||0;F.g=D||0;F.b=B||0;F.a=C!=null?C:1;F.add=function(I,H){for(var G=0;G<I.length;++G){F[I.charAt(G)]+=H}return F.normalize()};F.scale=function(I,H){for(var G=0;G<I.length;++G){F[I.charAt(G)]*=H}return F.normalize()};F.toString=function(){if(F.a>=1){return"rgb("+[F.r,F.g,F.b].join(",")+")"}else{return"rgba("+[F.r,F.g,F.b,F.a].join(",")+")"}};F.normalize=function(){function G(I,J,H){return J<I?I:(J>H?H:J)}F.r=G(0,parseInt(F.r),255);F.g=G(0,parseInt(F.g),255);F.b=G(0,parseInt(F.b),255);F.a=G(0,F.a,1);return F};F.clone=function(){return jQuery.color.make(F.r,F.b,F.g,F.a)};return F.normalize()};jQuery.color.extract=function(C,B){var D;do{D=C.css(B).toLowerCase();if(D!=""&&D!="transparent"){break}C=C.parent()}while(!jQuery.nodeName(C.get(0),"body"));if(D=="rgba(0, 0, 0, 0)"){D="transparent"}return jQuery.color.parse(D)};jQuery.color.parse=function(E){var D,B=jQuery.color.make;if(D=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(E)){return B(parseInt(D[1],10),parseInt(D[2],10),parseInt(D[3],10))}if(D=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E)){return B(parseInt(D[1],10),parseInt(D[2],10),parseInt(D[3],10),parseFloat(D[4]))}if(D=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(E)){return B(parseFloat(D[1])*2.55,parseFloat(D[2])*2.55,parseFloat(D[3])*2.55)}if(D=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E)){return B(parseFloat(D[1])*2.55,parseFloat(D[2])*2.55,parseFloat(D[3])*2.55,parseFloat(D[4]))}if(D=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(E)){return B(parseInt(D[1],16),parseInt(D[2],16),parseInt(D[3],16))}if(D=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(E)){return B(parseInt(D[1]+D[1],16),parseInt(D[2]+D[2],16),parseInt(D[3]+D[3],16))}var C=jQuery.trim(E).toLowerCase();if(C=="transparent"){return B(255,255,255,0)}else{D=A[C];return B(D[0],D[1],D[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})();
29
30// the actual Flot code
31(function($) {
32 function Plot(placeholder, data_, options_, plugins) {
33 // data is on the form:
34 // [ series1, series2 ... ]
35 // where series is either just the data as [ [x1, y1], [x2, y2], ... ]
36 // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
37
38 var series = [],
39 options = {
40 // the color theme used for graphs
41 colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
42 legend: {
43 show: true,
44 noColumns: 1, // number of colums in legend table
45 labelFormatter: null, // fn: string -> string
46 labelBoxBorderColor: "#ccc", // border color for the little label boxes
47 container: null, // container (as jQuery object) to put legend in, null means default on top of graph
48 position: "ne", // position of default legend container within plot
49 margin: 5, // distance from grid edge to default legend container within plot
50 backgroundColor: null, // null means auto-detect
51 backgroundOpacity: 0.85 // set to 0 to avoid background
52 },
53 xaxis: {
54 mode: null, // null or "time"
55 transform: null, // null or f: number -> number to transform axis
56 inverseTransform: null, // if transform is set, this should be the inverse function
57 min: null, // min. value to show, null means set automatically
58 max: null, // max. value to show, null means set automatically
59 autoscaleMargin: null, // margin in % to add if auto-setting min/max
60 ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
61 tickFormatter: null, // fn: number -> string
62 labelWidth: null, // size of tick labels in pixels
63 labelHeight: null,
64
65 // mode specific options
66 tickDecimals: null, // no. of decimals, null means auto
67 tickSize: null, // number or [number, "unit"]
68 minTickSize: null, // number or [number, "unit"]
69 monthNames: null, // list of names of months
70 timeformat: null, // format string to use
71 twelveHourClock: false // 12 or 24 time in time mode
72 },
73 yaxis: {
74 autoscaleMargin: 0.02
75 },
76 x2axis: {
77 autoscaleMargin: null
78 },
79 y2axis: {
80 autoscaleMargin: 0.02
81 },
82 series: {
83 points: {
84 show: false,
85 radius: 3,
86 lineWidth: 2, // in pixels
87 fill: true,
88 fillColor: "#ffffff"
89 },
90 lines: {
91 // we don't put in show: false so we can see
92 // whether lines were actively disabled
93 lineWidth: 2, // in pixels
94 fill: false,
95 fillColor: null,
96 steps: false
97 },
98 bars: {
99 show: false,
100 lineWidth: 2, // in pixels
101 barWidth: 1, // in units of the x axis
102 fill: true,
103 fillColor: null,
104 align: "left", // or "center"
105 horizontal: false // when horizontal, left is now top
106 },
107 shadowSize: 3
108 },
109 grid: {
110 show: true,
111 aboveData: false,
112 color: "#545454", // primary color used for outline and labels
113 backgroundColor: null, // null for transparent, else color
114 tickColor: "rgba(0,0,0,0.15)", // color used for the ticks
115 labelMargin: 5, // in pixels
116 borderWidth: 2, // in pixels
117 borderColor: null, // set if different from the grid color
118 markings: null, // array of ranges or fn: axes -> array of ranges
119 markingsColor: "#f4f4f4",
120 markingsLineWidth: 2,
121 // interactive stuff
122 clickable: false,
123 hoverable: false,
124 autoHighlight: true, // highlight in case mouse is near
125 mouseActiveRadius: 10 // how far the mouse can be away to activate an item
126 },
127 hooks: {}
128 },
129 canvas = null, // the canvas for the plot itself
130 overlay = null, // canvas for interactive stuff on top of plot
131 eventHolder = null, // jQuery object that events should be bound to
132 ctx = null, octx = null,
133 axes = { xaxis: {}, yaxis: {}, x2axis: {}, y2axis: {} },
134 plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
135 canvasWidth = 0, canvasHeight = 0,
136 plotWidth = 0, plotHeight = 0,
137 hooks = {
138 processOptions: [],
139 processRawData: [],
140 processDatapoints: [],
141 draw: [],
142 bindEvents: [],
143 drawOverlay: []
144 },
145 plot = this;
146
147 // public functions
148 plot.setData = setData;
149 plot.setupGrid = setupGrid;
150 plot.draw = draw;
151 plot.getPlaceholder = function() { return placeholder; };
152 plot.getCanvas = function() { return canvas; };
153 plot.getPlotOffset = function() { return plotOffset; };
154 plot.width = function () { return plotWidth; };
155 plot.height = function () { return plotHeight; };
156 plot.offset = function () {
157 var o = eventHolder.offset();
158 o.left += plotOffset.left;
159 o.top += plotOffset.top;
160 return o;
161 };
162 plot.getData = function() { return series; };
163 plot.getAxes = function() { return axes; };
164 plot.getOptions = function() { return options; };
165 plot.highlight = highlight;
166 plot.unhighlight = unhighlight;
167 plot.triggerRedrawOverlay = triggerRedrawOverlay;
168 plot.pointOffset = function(point) {
169 return { left: parseInt(axisSpecToRealAxis(point, "xaxis").p2c(+point.x) + plotOffset.left),
170 top: parseInt(axisSpecToRealAxis(point, "yaxis").p2c(+point.y) + plotOffset.top) };
171 };
172
173
174 // public attributes
175 plot.hooks = hooks;
176
177 // initialize
178 initPlugins(plot);
179 parseOptions(options_);
180 constructCanvas();
181 setData(data_);
182 setupGrid();
183 draw();
184 bindEvents();
185
186
187 function executeHooks(hook, args) {
188 args = [plot].concat(args);
189 for (var i = 0; i < hook.length; ++i)
190 hook[i].apply(this, args);
191 }
192
193 function initPlugins() {
194 for (var i = 0; i < plugins.length; ++i) {
195 var p = plugins[i];
196 p.init(plot);
197 if (p.options)
198 $.extend(true, options, p.options);
199 }
200 }
201
202 function parseOptions(opts) {
203 $.extend(true, options, opts);
204 if (options.grid.borderColor == null)
205 options.grid.borderColor = options.grid.color;
206 // backwards compatibility, to be removed in future
207 if (options.xaxis.noTicks && options.xaxis.ticks == null)
208 options.xaxis.ticks = options.xaxis.noTicks;
209 if (options.yaxis.noTicks && options.yaxis.ticks == null)
210 options.yaxis.ticks = options.yaxis.noTicks;
211 if (options.grid.coloredAreas)
212 options.grid.markings = options.grid.coloredAreas;
213 if (options.grid.coloredAreasColor)
214 options.grid.markingsColor = options.grid.coloredAreasColor;
215 if (options.lines)
216 $.extend(true, options.series.lines, options.lines);
217 if (options.points)
218 $.extend(true, options.series.points, options.points);
219 if (options.bars)
220 $.extend(true, options.series.bars, options.bars);
221 if (options.shadowSize)
222 options.series.shadowSize = options.shadowSize;
223
224 for (var n in hooks)
225 if (options.hooks[n] && options.hooks[n].length)
226 hooks[n] = hooks[n].concat(options.hooks[n]);
227
228 executeHooks(hooks.processOptions, [options]);
229 }
230
231 function setData(d) {
232 series = parseData(d);
233 fillInSeriesOptions();
234 processData();
235 }
236
237 function parseData(d) {
238 var res = [];
239 for (var i = 0; i < d.length; ++i) {
240 var s = $.extend(true, {}, options.series);
241
242 if (d[i].data) {
243 s.data = d[i].data; // move the data instead of deep-copy
244 delete d[i].data;
245
246 $.extend(true, s, d[i]);
247
248 d[i].data = s.data;
249 }
250 else
251 s.data = d[i];
252 res.push(s);
253 }
254
255 return res;
256 }
257
258 function axisSpecToRealAxis(obj, attr) {
259 var a = obj[attr];
260 if (!a || a == 1)
261 return axes[attr];
262 if (typeof a == "number")
263 return axes[attr.charAt(0) + a + attr.slice(1)];
264 return a; // assume it's OK
265 }
266
267 function fillInSeriesOptions() {
268 var i;
269
270 // collect what we already got of colors
271 var neededColors = series.length,
272 usedColors = [],
273 assignedColors = [];
274 for (i = 0; i < series.length; ++i) {
275 var sc = series[i].color;
276 if (sc != null) {
277 --neededColors;
278 if (typeof sc == "number")
279 assignedColors.push(sc);
280 else
281 usedColors.push($.color.parse(series[i].color));
282 }
283 }
284
285 // we might need to generate more colors if higher indices
286 // are assigned
287 for (i = 0; i < assignedColors.length; ++i) {
288 neededColors = Math.max(neededColors, assignedColors[i] + 1);
289 }
290
291 // produce colors as needed
292 var colors = [], variation = 0;
293 i = 0;
294 while (colors.length < neededColors) {
295 var c;
296 if (options.colors.length == i) // check degenerate case
297 c = $.color.make(100, 100, 100);
298 else
299 c = $.color.parse(options.colors[i]);
300
301 // vary color if needed
302 var sign = variation % 2 == 1 ? -1 : 1;
303 c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2)
304
305 // FIXME: if we're getting to close to something else,
306 // we should probably skip this one
307 colors.push(c);
308
309 ++i;
310 if (i >= options.colors.length) {
311 i = 0;
312 ++variation;
313 }
314 }
315
316 // fill in the options
317 var colori = 0, s;
318 for (i = 0; i < series.length; ++i) {
319 s = series[i];
320
321 // assign colors
322 if (s.color == null) {
323 s.color = colors[colori].toString();
324 ++colori;
325 }
326 else if (typeof s.color == "number")
327 s.color = colors[s.color].toString();
328
329 // turn on lines automatically in case nothing is set
330 if (s.lines.show == null) {
331 var v, show = true;
332 for (v in s)
333 if (s[v].show) {
334 show = false;
335 break;
336 }
337 if (show)
338 s.lines.show = true;
339 }
340
341 // setup axes
342 s.xaxis = axisSpecToRealAxis(s, "xaxis");
343 s.yaxis = axisSpecToRealAxis(s, "yaxis");
344 }
345 }
346
347 function processData() {
348 var topSentry = Number.POSITIVE_INFINITY,
349 bottomSentry = Number.NEGATIVE_INFINITY,
350 i, j, k, m, length,
351 s, points, ps, x, y, axis, val, f, p;
352
353 for (axis in axes) {
354 axes[axis].datamin = topSentry;
355 axes[axis].datamax = bottomSentry;
356 axes[axis].used = false;
357 }
358
359 function updateAxis(axis, min, max) {
360 if (min < axis.datamin)
361 axis.datamin = min;
362 if (max > axis.datamax)
363 axis.datamax = max;
364 }
365
366 for (i = 0; i < series.length; ++i) {
367 s = series[i];
368 s.datapoints = { points: [] };
369
370 executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]);
371 }
372
373 // first pass: clean and copy data
374 for (i = 0; i < series.length; ++i) {
375 s = series[i];
376
377 var data = s.data, format = s.datapoints.format;
378
379 if (!format) {
380 format = [];
381 // find out how to copy
382 format.push({ x: true, number: true, required: true });
383 format.push({ y: true, number: true, required: true });
384
385 if (s.bars.show)
386 format.push({ y: true, number: true, required: false, defaultValue: 0 });
387
388 s.datapoints.format = format;
389 }
390
391 if (s.datapoints.pointsize != null)
392 continue; // already filled in
393
394 if (s.datapoints.pointsize == null)
395 s.datapoints.pointsize = format.length;
396
397 ps = s.datapoints.pointsize;
398 points = s.datapoints.points;
399
400 insertSteps = s.lines.show && s.lines.steps;
401 s.xaxis.used = s.yaxis.used = true;
402
403 for (j = k = 0; j < data.length; ++j, k += ps) {
404 p = data[j];
405
406 var nullify = p == null;
407 if (!nullify) {
408 for (m = 0; m < ps; ++m) {
409 val = p[m];
410 f = format[m];
411
412 if (f) {
413 if (f.number && val != null) {
414 val = +val; // convert to number
415 if (isNaN(val))
416 val = null;
417 }
418
419 if (val == null) {
420 if (f.required)
421 nullify = true;
422
423 if (f.defaultValue != null)
424 val = f.defaultValue;
425 }
426 }
427
428 points[k + m] = val;
429 }
430 }
431
432 if (nullify) {
433 for (m = 0; m < ps; ++m) {
434 val = points[k + m];
435 if (val != null) {
436 f = format[m];
437 // extract min/max info
438 if (f.x)
439 updateAxis(s.xaxis, val, val);
440 if (f.y)
441 updateAxis(s.yaxis, val, val);
442 }
443 points[k + m] = null;
444 }
445 }
446 else {
447 // a little bit of line specific stuff that
448 // perhaps shouldn't be here, but lacking
449 // better means...
450 if (insertSteps && k > 0
451 && points[k - ps] != null
452 && points[k - ps] != points[k]
453 && points[k - ps + 1] != points[k + 1]) {
454 // copy the point to make room for a middle point
455 for (m = 0; m < ps; ++m)
456 points[k + ps + m] = points[k + m];
457
458 // middle point has same y
459 points[k + 1] = points[k - ps + 1];
460
461 // we've added a point, better reflect that
462 k += ps;
463 }
464 }
465 }
466 }
467
468 // give the hooks a chance to run
469 for (i = 0; i < series.length; ++i) {
470 s = series[i];
471
472 executeHooks(hooks.processDatapoints, [ s, s.datapoints]);
473 }
474
475 // second pass: find datamax/datamin for auto-scaling
476 for (i = 0; i < series.length; ++i) {
477 s = series[i];
478 points = s.datapoints.points,
479 ps = s.datapoints.pointsize;
480
481 var xmin = topSentry, ymin = topSentry,
482 xmax = bottomSentry, ymax = bottomSentry;
483
484 for (j = 0; j < points.length; j += ps) {
485 if (points[j] == null)
486 continue;
487
488 for (m = 0; m < ps; ++m) {
489 val = points[j + m];
490 f = format[m];
491 if (!f)
492 continue;
493
494 if (f.x) {
495 if (val < xmin)
496 xmin = val;
497 if (val > xmax)
498 xmax = val;
499 }
500 if (f.y) {
501 if (val < ymin)
502 ymin = val;
503 if (val > ymax)
504 ymax = val;
505 }
506 }
507 }
508
509 if (s.bars.show) {
510 // make sure we got room for the bar on the dancing floor
511 var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
512 if (s.bars.horizontal) {
513 ymin += delta;
514 ymax += delta + s.bars.barWidth;
515 }
516 else {
517 xmin += delta;
518 xmax += delta + s.bars.barWidth;
519 }
520 }
521
522 updateAxis(s.xaxis, xmin, xmax);
523 updateAxis(s.yaxis, ymin, ymax);
524 }
525
526 for (axis in axes) {
527 if (axes[axis].datamin == topSentry)
528 axes[axis].datamin = null;
529 if (axes[axis].datamax == bottomSentry)
530 axes[axis].datamax = null;
531 }
532 }
533
534 function constructCanvas() {
535 function makeCanvas(width, height) {
536 var c = document.createElement('canvas');
537 c.width = width;
538 c.height = height;
539 if ($.browser.msie) // excanvas hack
540 c = window.G_vmlCanvasManager.initElement(c);
541 return c;
542 }
543
544 canvasWidth = placeholder.width();
545 canvasHeight = placeholder.height();
546 placeholder.html(""); // clear placeholder
547 if (placeholder.css("position") == 'static')
548 placeholder.css("position", "relative"); // for positioning labels and overlay
549
550 if (canvasWidth <= 0 || canvasHeight <= 0)
551 throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight;
552
553 if ($.browser.msie) // excanvas hack
554 window.G_vmlCanvasManager.init_(document); // make sure everything is setup
555
556 // the canvas
557 canvas = $(makeCanvas(canvasWidth, canvasHeight)).appendTo(placeholder).get(0);
558 ctx = canvas.getContext("2d");
559
560 // overlay canvas for interactive features
561 overlay = $(makeCanvas(canvasWidth, canvasHeight)).css({ position: 'absolute', left: 0, top: 0 }).appendTo(placeholder).get(0);
562 octx = overlay.getContext("2d");
563 octx.stroke();
564 }
565
566 function bindEvents() {
567 // we include the canvas in the event holder too, because IE 7
568 // sometimes has trouble with the stacking order
569 eventHolder = $([overlay, canvas]);
570
571 // bind events
572 if (options.grid.hoverable)
573 eventHolder.mousemove(onMouseMove);
574
575 if (options.grid.clickable)
576 eventHolder.click(onClick);
577
578 executeHooks(hooks.bindEvents, [eventHolder]);
579 }
580
581 function setupGrid() {
582 function setTransformationHelpers(axis, o) {
583 function identity(x) { return x; }
584
585 var s, m, t = o.transform || identity,
586 it = o.inverseTransform;
587
588 // add transformation helpers
589 if (axis == axes.xaxis || axis == axes.x2axis) {
590 // precompute how much the axis is scaling a point
591 // in canvas space
592 s = axis.scale = plotWidth / (t(axis.max) - t(axis.min));
593 m = t(axis.min);
594
595 // data point to canvas coordinate
596 if (t == identity) // slight optimization
597 axis.p2c = function (p) { return (p - m) * s; };
598 else
599 axis.p2c = function (p) { return (t(p) - m) * s; };
600 // canvas coordinate to data point
601 if (!it)
602 axis.c2p = function (c) { return m + c / s; };
603 else
604 axis.c2p = function (c) { return it(m + c / s); };
605 }
606 else {
607 s = axis.scale = plotHeight / (t(axis.max) - t(axis.min));
608 m = t(axis.max);
609
610 if (t == identity)
611 axis.p2c = function (p) { return (m - p) * s; };
612 else
613 axis.p2c = function (p) { return (m - t(p)) * s; };
614 if (!it)
615 axis.c2p = function (c) { return m - c / s; };
616 else
617 axis.c2p = function (c) { return it(m - c / s); };
618 }
619 }
620
621 function measureLabels(axis, axisOptions) {
622 var i, labels = [], l;
623
624 axis.labelWidth = axisOptions.labelWidth;
625 axis.labelHeight = axisOptions.labelHeight;
626
627 if (axis == axes.xaxis || axis == axes.x2axis) {
628 // to avoid measuring the widths of the labels, we
629 // construct fixed-size boxes and put the labels inside
630 // them, we don't need the exact figures and the
631 // fixed-size box content is easy to center
632 if (axis.labelWidth == null)
633 axis.labelWidth = canvasWidth / (axis.ticks.length > 0 ? axis.ticks.length : 1);
634
635 // measure x label heights
636 if (axis.labelHeight == null) {
637 labels = [];
638 for (i = 0; i < axis.ticks.length; ++i) {
639 l = axis.ticks[i].label;
640 if (l)
641 labels.push('<div class="tickLabel" style="float:left;width:' + axis.labelWidth + 'px">' + l + '</div>');
642 }
643
644 if (labels.length > 0) {
645 var dummyDiv = $('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">'
646 + labels.join("") + '<div style="clear:left"></div></div>').appendTo(placeholder);
647 axis.labelHeight = dummyDiv.height();
648 dummyDiv.remove();
649 }
650 }
651 }
652 else if (axis.labelWidth == null || axis.labelHeight == null) {
653 // calculate y label dimensions
654 for (i = 0; i < axis.ticks.length; ++i) {
655 l = axis.ticks[i].label;
656 if (l)
657 labels.push('<div class="tickLabel">' + l + '</div>');
658 }
659
660 if (labels.length > 0) {
661 var dummyDiv = $('<div style="position:absolute;top:-10000px;font-size:smaller">'
662 + labels.join("") + '</div>').appendTo(placeholder);
663 if (axis.labelWidth == null)
664 axis.labelWidth = dummyDiv.width();
665 if (axis.labelHeight == null)
666 axis.labelHeight = dummyDiv.find("div").height();
667 dummyDiv.remove();
668 }
669
670 }
671
672 if (axis.labelWidth == null)
673 axis.labelWidth = 0;
674 if (axis.labelHeight == null)
675 axis.labelHeight = 0;
676 }
677
678 function setGridSpacing() {
679 // get the most space needed around the grid for things
680 // that may stick out
681 var maxOutset = options.grid.borderWidth;
682 for (i = 0; i < series.length; ++i)
683 maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
684
685 plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = maxOutset;
686
687 var margin = options.grid.labelMargin + options.grid.borderWidth;
688
689 if (axes.xaxis.labelHeight > 0)
690 plotOffset.bottom = Math.max(maxOutset, axes.xaxis.labelHeight + margin);
691 if (axes.yaxis.labelWidth > 0)
692 plotOffset.left = Math.max(maxOutset, axes.yaxis.labelWidth + margin);
693 if (axes.x2axis.labelHeight > 0)
694 plotOffset.top = Math.max(maxOutset, axes.x2axis.labelHeight + margin);
695 if (axes.y2axis.labelWidth > 0)
696 plotOffset.right = Math.max(maxOutset, axes.y2axis.labelWidth + margin);
697
698 plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
699 plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
700 }
701
702 var axis;
703 for (axis in axes)
704 setRange(axes[axis], options[axis]);
705
706 if (options.grid.show) {
707 for (axis in axes) {
708 prepareTickGeneration(axes[axis], options[axis]);
709 setTicks(axes[axis], options[axis]);
710 measureLabels(axes[axis], options[axis]);
711 }
712
713 setGridSpacing();
714 }
715 else {
716 plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0;
717 plotWidth = canvasWidth;
718 plotHeight = canvasHeight;
719 }
720
721 for (axis in axes)
722 setTransformationHelpers(axes[axis], options[axis]);
723
724 if (options.grid.show)
725 insertLabels();
726
727 insertLegend();
728 }
729
730 function setRange(axis, axisOptions) {
731 var min = +(axisOptions.min != null ? axisOptions.min : axis.datamin),
732 max = +(axisOptions.max != null ? axisOptions.max : axis.datamax),
733 delta = max - min;
734
735 if (delta == 0.0) {
736 // degenerate case
737 var widen = max == 0 ? 1 : 0.01;
738
739 if (axisOptions.min == null)
740 min -= widen;
741 // alway widen max if we couldn't widen min to ensure we
742 // don't fall into min == max which doesn't work
743 if (axisOptions.max == null || axisOptions.min != null)
744 max += widen;
745 }
746 else {
747 // consider autoscaling
748 var margin = axisOptions.autoscaleMargin;
749 if (margin != null) {
750 if (axisOptions.min == null) {
751 min -= delta * margin;
752 // make sure we don't go below zero if all values
753 // are positive
754 if (min < 0 && axis.datamin != null && axis.datamin >= 0)
755 min = 0;
756 }
757 if (axisOptions.max == null) {
758 max += delta * margin;
759 if (max > 0 && axis.datamax != null && axis.datamax <= 0)
760 max = 0;
761 }
762 }
763 }
764 axis.min = min;
765 axis.max = max;
766 }
767
768 function prepareTickGeneration(axis, axisOptions) {
769 // estimate number of ticks
770 var noTicks;
771 if (typeof axisOptions.ticks == "number" && axisOptions.ticks > 0)
772 noTicks = axisOptions.ticks;
773 else if (axis == axes.xaxis || axis == axes.x2axis)
774 // heuristic based on the model a*sqrt(x) fitted to
775 // some reasonable data points
776 noTicks = 0.3 * Math.sqrt(canvasWidth);
777 else
778 noTicks = 0.3 * Math.sqrt(canvasHeight);
779
780 var delta = (axis.max - axis.min) / noTicks,
781 size, generator, unit, formatter, i, magn, norm;
782
783 if (axisOptions.mode == "time") {
784 // pretty handling of time
785
786 // map of app. size of time units in milliseconds
787 var timeUnitSize = {
788 "second": 1000,
789 "minute": 60 * 1000,
790 "hour": 60 * 60 * 1000,
791 "day": 24 * 60 * 60 * 1000,
792 "month": 30 * 24 * 60 * 60 * 1000,
793 "year": 365.2425 * 24 * 60 * 60 * 1000
794 };
795
796
797 // the allowed tick sizes, after 1 year we use
798 // an integer algorithm
799 var spec = [
800 [1, "second"], [2, "second"], [5, "second"], [10, "second"],
801 [30, "second"],
802 [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
803 [30, "minute"],
804 [1, "hour"], [2, "hour"], [4, "hour"],
805 [8, "hour"], [12, "hour"],
806 [1, "day"], [2, "day"], [3, "day"],
807 [0.25, "month"], [0.5, "month"], [1, "month"],
808 [2, "month"], [3, "month"], [6, "month"],
809 [1, "year"]
810 ];
811
812 var minSize = 0;
813 if (axisOptions.minTickSize != null) {
814 if (typeof axisOptions.tickSize == "number")
815 minSize = axisOptions.tickSize;
816 else
817 minSize = axisOptions.minTickSize[0] * timeUnitSize[axisOptions.minTickSize[1]];
818 }
819
820 for (i = 0; i < spec.length - 1; ++i)
821 if (delta < (spec[i][0] * timeUnitSize[spec[i][1]]
822 + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
823 && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize)
824 break;
825 size = spec[i][0];
826 unit = spec[i][1];
827
828 // special-case the possibility of several years
829 if (unit == "year") {
830 magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10));
831 norm = (delta / timeUnitSize.year) / magn;
832 if (norm < 1.5)
833 size = 1;
834 else if (norm < 3)
835 size = 2;
836 else if (norm < 7.5)
837 size = 5;
838 else
839 size = 10;
840
841 size *= magn;
842 }
843
844 if (axisOptions.tickSize) {
845 size = axisOptions.tickSize[0];
846 unit = axisOptions.tickSize[1];
847 }
848
849 generator = function(axis) {
850 var ticks = [],
851 tickSize = axis.tickSize[0], unit = axis.tickSize[1],
852 d = new Date(axis.min);
853
854 var step = tickSize * timeUnitSize[unit];
855
856 if (unit == "second")
857 d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize));
858 if (unit == "minute")
859 d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize));
860 if (unit == "hour")
861 d.setUTCHours(floorInBase(d.getUTCHours(), tickSize));
862 if (unit == "month")
863 d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize));
864 if (unit == "year")
865 d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize));
866
867 // reset smaller components
868 d.setUTCMilliseconds(0);
869 if (step >= timeUnitSize.minute)
870 d.setUTCSeconds(0);
871 if (step >= timeUnitSize.hour)
872 d.setUTCMinutes(0);
873 if (step >= timeUnitSize.day)
874 d.setUTCHours(0);
875 if (step >= timeUnitSize.day * 4)
876 d.setUTCDate(1);
877 if (step >= timeUnitSize.year)
878 d.setUTCMonth(0);
879
880
881 var carry = 0, v = Number.NaN, prev;
882 do {
883 prev = v;
884 v = d.getTime();
885 ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
886 if (unit == "month") {
887 if (tickSize < 1) {
888 // a bit complicated - we'll divide the month
889 // up but we need to take care of fractions
890 // so we don't end up in the middle of a day
891 d.setUTCDate(1);
892 var start = d.getTime();
893 d.setUTCMonth(d.getUTCMonth() + 1);
894 var end = d.getTime();
895 d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
896 carry = d.getUTCHours();
897 d.setUTCHours(0);
898 }
899 else
900 d.setUTCMonth(d.getUTCMonth() + tickSize);
901 }
902 else if (unit == "year") {
903 d.setUTCFullYear(d.getUTCFullYear() + tickSize);
904 }
905 else
906 d.setTime(v + step);
907 } while (v < axis.max && v != prev);
908
909 return ticks;
910 };
911
912 formatter = function (v, axis) {
913 var d = new Date(v);
914
915 // first check global format
916 if (axisOptions.timeformat != null)
917 return $.plot.formatDate(d, axisOptions.timeformat, axisOptions.monthNames);
918
919 var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
920 var span = axis.max - axis.min;
921 var suffix = (axisOptions.twelveHourClock) ? " %p" : "";
922
923 if (t < timeUnitSize.minute)
924 fmt = "%h:%M:%S" + suffix;
925 else if (t < timeUnitSize.day) {
926 if (span < 2 * timeUnitSize.day)
927 fmt = "%h:%M" + suffix;
928 else
929 fmt = "%b %d %h:%M" + suffix;
930 }
931 else if (t < timeUnitSize.month)
932 fmt = "%b %d";
933 else if (t < timeUnitSize.year) {
934 if (span < timeUnitSize.year)
935 fmt = "%b";
936 else
937 fmt = "%b %y";
938 }
939 else
940 fmt = "%y";
941
942 return $.plot.formatDate(d, fmt, axisOptions.monthNames);
943 };
944 }
945 else {
946 // pretty rounding of base-10 numbers
947 var maxDec = axisOptions.tickDecimals;
948 var dec = -Math.floor(Math.log(delta) / Math.LN10);
949 if (maxDec != null && dec > maxDec)
950 dec = maxDec;
951
952 magn = Math.pow(10, -dec);
953 norm = delta / magn; // norm is between 1.0 and 10.0
954
955 if (norm < 1.5)
956 size = 1;
957 else if (norm < 3) {
958 size = 2;
959 // special case for 2.5, requires an extra decimal
960 if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
961 size = 2.5;
962 ++dec;
963 }
964 }
965 else if (norm < 7.5)
966 size = 5;
967 else
968 size = 10;
969
970 size *= magn;
971
972 if (axisOptions.minTickSize != null && size < axisOptions.minTickSize)
973 size = axisOptions.minTickSize;
974
975 if (axisOptions.tickSize != null)
976 size = axisOptions.tickSize;
977
978 axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec);
979
980 generator = function (axis) {
981 var ticks = [];
982
983 // spew out all possible ticks
984 var start = floorInBase(axis.min, axis.tickSize),
985 i = 0, v = Number.NaN, prev;
986 do {
987 prev = v;
988 v = start + i * axis.tickSize;
989 ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
990 ++i;
991 } while (v < axis.max && v != prev);
992 return ticks;
993 };
994
995 formatter = function (v, axis) {
996 return v.toFixed(axis.tickDecimals);
997 };
998 }
999
1000 axis.tickSize = unit ? [size, unit] : size;
1001 axis.tickGenerator = generator;
1002 if ($.isFunction(axisOptions.tickFormatter))
1003 axis.tickFormatter = function (v, axis) { return "" + axisOptions.tickFormatter(v, axis); };
1004 else
1005 axis.tickFormatter = formatter;
1006 }
1007
1008 function setTicks(axis, axisOptions) {
1009 axis.ticks = [];
1010
1011 if (!axis.used)
1012 return;
1013
1014 if (axisOptions.ticks == null)
1015 axis.ticks = axis.tickGenerator(axis);
1016 else if (typeof axisOptions.ticks == "number") {
1017 if (axisOptions.ticks > 0)
1018 axis.ticks = axis.tickGenerator(axis);
1019 }
1020 else if (axisOptions.ticks) {
1021 var ticks = axisOptions.ticks;
1022
1023 if ($.isFunction(ticks))
1024 // generate the ticks
1025 ticks = ticks({ min: axis.min, max: axis.max });
1026
1027 // clean up the user-supplied ticks, copy them over
1028 var i, v;
1029 for (i = 0; i < ticks.length; ++i) {
1030 var label = null;
1031 var t = ticks[i];
1032 if (typeof t == "object") {
1033 v = t[0];
1034 if (t.length > 1)
1035 label = t[1];
1036 }
1037 else
1038 v = t;
1039 if (label == null)
1040 label = axis.tickFormatter(v, axis);
1041 axis.ticks[i] = { v: v, label: label };
1042 }
1043 }
1044
1045 if (axisOptions.autoscaleMargin != null && axis.ticks.length > 0) {
1046 // snap to ticks
1047 if (axisOptions.min == null)
1048 axis.min = Math.min(axis.min, axis.ticks[0].v);
1049 if (axisOptions.max == null && axis.ticks.length > 1)
1050 axis.max = Math.max(axis.max, axis.ticks[axis.ticks.length - 1].v);
1051 }
1052 }
1053
1054 function draw() {
1055 ctx.clearRect(0, 0, canvasWidth, canvasHeight);
1056
1057 var grid = options.grid;
1058
1059 if (grid.show && !grid.aboveData)
1060 drawGrid();
1061
1062 for (var i = 0; i < series.length; ++i)
1063 drawSeries(series[i]);
1064
1065 executeHooks(hooks.draw, [ctx]);
1066
1067 if (grid.show && grid.aboveData)
1068 drawGrid();
1069 }
1070
1071 function extractRange(ranges, coord) {
1072 var firstAxis = coord + "axis",
1073 secondaryAxis = coord + "2axis",
1074 axis, from, to, reverse;
1075
1076 if (ranges[firstAxis]) {
1077 axis = axes[firstAxis];
1078 from = ranges[firstAxis].from;
1079 to = ranges[firstAxis].to;
1080 }
1081 else if (ranges[secondaryAxis]) {
1082 axis = axes[secondaryAxis];
1083 from = ranges[secondaryAxis].from;
1084 to = ranges[secondaryAxis].to;
1085 }
1086 else {
1087 // backwards-compat stuff - to be removed in future
1088 axis = axes[firstAxis];
1089 from = ranges[coord + "1"];
1090 to = ranges[coord + "2"];
1091 }
1092
1093 // auto-reverse as an added bonus
1094 if (from != null && to != null && from > to)
1095 return { from: to, to: from, axis: axis };
1096
1097 return { from: from, to: to, axis: axis };
1098 }
1099
1100 function drawGrid() {
1101 var i;
1102
1103 ctx.save();
1104 ctx.translate(plotOffset.left, plotOffset.top);
1105
1106 // draw background, if any
1107 if (options.grid.backgroundColor) {
1108 ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)");
1109 ctx.fillRect(0, 0, plotWidth, plotHeight);
1110 }
1111
1112 // draw markings
1113 var markings = options.grid.markings;
1114 if (markings) {
1115 if ($.isFunction(markings))
1116 // xmin etc. are backwards-compatible, to be removed in future
1117 markings = markings({ xmin: axes.xaxis.min, xmax: axes.xaxis.max, ymin: axes.yaxis.min, ymax: axes.yaxis.max, xaxis: axes.xaxis, yaxis: axes.yaxis, x2axis: axes.x2axis, y2axis: axes.y2axis });
1118
1119 for (i = 0; i < markings.length; ++i) {
1120 var m = markings[i],
1121 xrange = extractRange(m, "x"),
1122 yrange = extractRange(m, "y");
1123
1124 // fill in missing
1125 if (xrange.from == null)
1126 xrange.from = xrange.axis.min;
1127 if (xrange.to == null)
1128 xrange.to = xrange.axis.max;
1129 if (yrange.from == null)
1130 yrange.from = yrange.axis.min;
1131 if (yrange.to == null)
1132 yrange.to = yrange.axis.max;
1133
1134 // clip
1135 if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
1136 yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
1137 continue;
1138
1139 xrange.from = Math.max(xrange.from, xrange.axis.min);
1140 xrange.to = Math.min(xrange.to, xrange.axis.max);
1141 yrange.from = Math.max(yrange.from, yrange.axis.min);
1142 yrange.to = Math.min(yrange.to, yrange.axis.max);
1143
1144 if (xrange.from == xrange.to && yrange.from == yrange.to)
1145 continue;
1146
1147 // then draw
1148 xrange.from = xrange.axis.p2c(xrange.from);
1149 xrange.to = xrange.axis.p2c(xrange.to);
1150 yrange.from = yrange.axis.p2c(yrange.from);
1151 yrange.to = yrange.axis.p2c(yrange.to);
1152
1153 if (xrange.from == xrange.to || yrange.from == yrange.to) {
1154 // draw line
1155 ctx.beginPath();
1156 ctx.strokeStyle = m.color || options.grid.markingsColor;
1157 ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth;
1158 //ctx.moveTo(Math.floor(xrange.from), yrange.from);
1159 //ctx.lineTo(Math.floor(xrange.to), yrange.to);
1160 ctx.moveTo(xrange.from, yrange.from);
1161 ctx.lineTo(xrange.to, yrange.to);
1162 ctx.stroke();
1163 }
1164 else {
1165 // fill area
1166 ctx.fillStyle = m.color || options.grid.markingsColor;
1167 ctx.fillRect(xrange.from, yrange.to,
1168 xrange.to - xrange.from,
1169 yrange.from - yrange.to);
1170 }
1171 }
1172 }
1173
1174 // draw the inner grid
1175 ctx.lineWidth = 1;
1176 ctx.strokeStyle = options.grid.tickColor;
1177 ctx.beginPath();
1178 var v, axis = axes.xaxis;
1179 for (i = 0; i < axis.ticks.length; ++i) {
1180 v = axis.ticks[i].v;
1181 if (v <= axis.min || v >= axes.xaxis.max)
1182 continue; // skip those lying on the axes
1183
1184 ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 0);
1185 ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, plotHeight);
1186 }
1187
1188 axis = axes.yaxis;
1189 for (i = 0; i < axis.ticks.length; ++i) {
1190 v = axis.ticks[i].v;
1191 if (v <= axis.min || v >= axis.max)
1192 continue;
1193
1194 ctx.moveTo(0, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
1195 ctx.lineTo(plotWidth, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
1196 }
1197
1198 axis = axes.x2axis;
1199 for (i = 0; i < axis.ticks.length; ++i) {
1200 v = axis.ticks[i].v;
1201 if (v <= axis.min || v >= axis.max)
1202 continue;
1203
1204 ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, -5);
1205 ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 5);
1206 }
1207
1208 axis = axes.y2axis;
1209 for (i = 0; i < axis.ticks.length; ++i) {
1210 v = axis.ticks[i].v;
1211 if (v <= axis.min || v >= axis.max)
1212 continue;
1213
1214 ctx.moveTo(plotWidth-5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
1215 ctx.lineTo(plotWidth+5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
1216 }
1217
1218 ctx.stroke();
1219
1220 if (options.grid.borderWidth) {
1221 // draw border
1222 var bw = options.grid.borderWidth;
1223 ctx.lineWidth = bw;
1224 ctx.strokeStyle = options.grid.borderColor;
1225 ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw);
1226 }
1227
1228 ctx.restore();
1229 }
1230
1231 function insertLabels() {
1232 placeholder.find(".tickLabels").remove();
1233
1234 var html = ['<div class="tickLabels" style="font-size:smaller;color:' + options.grid.color + '">'];
1235
1236 function addLabels(axis, labelGenerator) {
1237 for (var i = 0; i < axis.ticks.length; ++i) {
1238 var tick = axis.ticks[i];
1239 if (!tick.label || tick.v < axis.min || tick.v > axis.max)
1240 continue;
1241 html.push(labelGenerator(tick, axis));
1242 }
1243 }
1244
1245 var margin = options.grid.labelMargin + options.grid.borderWidth;
1246
1247 addLabels(axes.xaxis, function (tick, axis) {
1248 return '<div style="position:absolute;top:' + (plotOffset.top + plotHeight + margin) + 'px;left:' + Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2) + 'px;width:' + axis.labelWidth + 'px;text-align:center" class="tickLabel">' + tick.label + "</div>";
1249 });
1250
1251
1252 addLabels(axes.yaxis, function (tick, axis) {
1253 return '<div style="position:absolute;top:' + Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2) + 'px;right:' + (plotOffset.right + plotWidth + margin) + 'px;width:' + axis.labelWidth + 'px;text-align:right" class="tickLabel">' + tick.label + "</div>";
1254 });
1255
1256 addLabels(axes.x2axis, function (tick, axis) {
1257 return '<div style="position:absolute;bottom:' + (plotOffset.bottom + plotHeight + margin) + 'px;left:' + Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2) + 'px;width:' + axis.labelWidth + 'px;text-align:center" class="tickLabel">' + tick.label + "</div>";
1258 });
1259
1260 addLabels(axes.y2axis, function (tick, axis) {
1261 return '<div style="position:absolute;top:' + Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2) + 'px;left:' + (plotOffset.left + plotWidth + margin) +'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + "</div>";
1262 });
1263
1264 html.push('</div>');
1265
1266 placeholder.append(html.join(""));
1267 }
1268
1269 function drawSeries(series) {
1270 if (series.lines.show)
1271 drawSeriesLines(series);
1272 if (series.bars.show)
1273 drawSeriesBars(series);
1274 if (series.points.show)
1275 drawSeriesPoints(series);
1276 }
1277
1278 function drawSeriesLines(series) {
1279 function plotLine(datapoints, xoffset, yoffset, axisx, axisy) {
1280 var points = datapoints.points,
1281 ps = datapoints.pointsize,
1282 prevx = null, prevy = null;
1283
1284 ctx.beginPath();
1285 for (var i = ps; i < points.length; i += ps) {
1286 var x1 = points[i - ps], y1 = points[i - ps + 1],
1287 x2 = points[i], y2 = points[i + 1];
1288
1289 if (x1 == null || x2 == null)
1290 continue;
1291
1292 // clip with ymin
1293 if (y1 <= y2 && y1 < axisy.min) {
1294 if (y2 < axisy.min)
1295 continue; // line segment is outside
1296 // compute new intersection point
1297 x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1298 y1 = axisy.min;
1299 }
1300 else if (y2 <= y1 && y2 < axisy.min) {
1301 if (y1 < axisy.min)
1302 continue;
1303 x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1304 y2 = axisy.min;
1305 }
1306
1307 // clip with ymax
1308 if (y1 >= y2 && y1 > axisy.max) {
1309 if (y2 > axisy.max)
1310 continue;
1311 x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1312 y1 = axisy.max;
1313 }
1314 else if (y2 >= y1 && y2 > axisy.max) {
1315 if (y1 > axisy.max)
1316 continue;
1317 x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1318 y2 = axisy.max;
1319 }
1320
1321 // clip with xmin
1322 if (x1 <= x2 && x1 < axisx.min) {
1323 if (x2 < axisx.min)
1324 continue;
1325 y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1326 x1 = axisx.min;
1327 }
1328 else if (x2 <= x1 && x2 < axisx.min) {
1329 if (x1 < axisx.min)
1330 continue;
1331 y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1332 x2 = axisx.min;
1333 }
1334
1335 // clip with xmax
1336 if (x1 >= x2 && x1 > axisx.max) {
1337 if (x2 > axisx.max)
1338 continue;
1339 y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1340 x1 = axisx.max;
1341 }
1342 else if (x2 >= x1 && x2 > axisx.max) {
1343 if (x1 > axisx.max)
1344 continue;
1345 y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1346 x2 = axisx.max;
1347 }
1348
1349 if (x1 != prevx || y1 != prevy)
1350 ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
1351
1352 prevx = x2;
1353 prevy = y2;
1354 ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset);
1355 }
1356 ctx.stroke();
1357 }
1358
1359 function plotLineArea(datapoints, axisx, axisy) {
1360 var points = datapoints.points,
1361 ps = datapoints.pointsize,
1362 bottom = Math.min(Math.max(0, axisy.min), axisy.max),
1363 top, lastX = 0, areaOpen = false;
1364
1365 for (var i = ps; i < points.length; i += ps) {
1366 var x1 = points[i - ps], y1 = points[i - ps + 1],
1367 x2 = points[i], y2 = points[i + 1];
1368
1369 if (areaOpen && x1 != null && x2 == null) {
1370 // close area
1371 ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
1372 ctx.fill();
1373 areaOpen = false;
1374 continue;
1375 }
1376
1377 if (x1 == null || x2 == null)
1378 continue;
1379
1380 // clip x values
1381
1382 // clip with xmin
1383 if (x1 <= x2 && x1 < axisx.min) {
1384 if (x2 < axisx.min)
1385 continue;
1386 y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1387 x1 = axisx.min;
1388 }
1389 else if (x2 <= x1 && x2 < axisx.min) {
1390 if (x1 < axisx.min)
1391 continue;
1392 y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1393 x2 = axisx.min;
1394 }
1395
1396 // clip with xmax
1397 if (x1 >= x2 && x1 > axisx.max) {
1398 if (x2 > axisx.max)
1399 continue;
1400 y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1401 x1 = axisx.max;
1402 }
1403 else if (x2 >= x1 && x2 > axisx.max) {
1404 if (x1 > axisx.max)
1405 continue;
1406 y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1407 x2 = axisx.max;
1408 }
1409
1410 if (!areaOpen) {
1411 // open area
1412 ctx.beginPath();
1413 ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
1414 areaOpen = true;
1415 }
1416
1417 // now first check the case where both is outside
1418 if (y1 >= axisy.max && y2 >= axisy.max) {
1419 ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
1420 ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
1421 lastX = x2;
1422 continue;
1423 }
1424 else if (y1 <= axisy.min && y2 <= axisy.min) {
1425 ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
1426 ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
1427 lastX = x2;
1428 continue;
1429 }
1430
1431 // else it's a bit more complicated, there might
1432 // be two rectangles and two triangles we need to fill
1433 // in; to find these keep track of the current x values
1434 var x1old = x1, x2old = x2;
1435
1436 // and clip the y values, without shortcutting
1437
1438 // clip with ymin
1439 if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
1440 x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1441 y1 = axisy.min;
1442 }
1443 else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
1444 x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1445 y2 = axisy.min;
1446 }
1447
1448 // clip with ymax
1449 if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
1450 x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1451 y1 = axisy.max;
1452 }
1453 else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
1454 x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1455 y2 = axisy.max;
1456 }
1457
1458
1459 // if the x value was changed we got a rectangle
1460 // to fill
1461 if (x1 != x1old) {
1462 if (y1 <= axisy.min)
1463 top = axisy.min;
1464 else
1465 top = axisy.max;
1466
1467 ctx.lineTo(axisx.p2c(x1old), axisy.p2c(top));
1468 ctx.lineTo(axisx.p2c(x1), axisy.p2c(top));
1469 }
1470
1471 // fill the triangles
1472 ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1));
1473 ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
1474
1475 // fill the other rectangle if it's there
1476 if (x2 != x2old) {
1477 if (y2 <= axisy.min)
1478 top = axisy.min;
1479 else
1480 top = axisy.max;
1481
1482 ctx.lineTo(axisx.p2c(x2), axisy.p2c(top));
1483 ctx.lineTo(axisx.p2c(x2old), axisy.p2c(top));
1484 }
1485
1486 lastX = Math.max(x2, x2old);
1487 }
1488
1489 if (areaOpen) {
1490 ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
1491 ctx.fill();
1492 }
1493 }
1494
1495 ctx.save();
1496 ctx.translate(plotOffset.left, plotOffset.top);
1497 ctx.lineJoin = "round";
1498
1499 var lw = series.lines.lineWidth,
1500 sw = series.shadowSize;
1501 // FIXME: consider another form of shadow when filling is turned on
1502 if (lw > 0 && sw > 0) {
1503 // draw shadow as a thick and thin line with transparency
1504 ctx.lineWidth = sw;
1505 ctx.strokeStyle = "rgba(0,0,0,0.1)";
1506 // position shadow at angle from the mid of line
1507 var angle = Math.PI/18;
1508 plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis);
1509 ctx.lineWidth = sw/2;
1510 plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis);
1511 }
1512
1513 ctx.lineWidth = lw;
1514 ctx.strokeStyle = series.color;
1515 var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight);
1516 if (fillStyle) {
1517 ctx.fillStyle = fillStyle;
1518 plotLineArea(series.datapoints, series.xaxis, series.yaxis);
1519 }
1520
1521 if (lw > 0)
1522 plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis);
1523 ctx.restore();
1524 }
1525
1526 function drawSeriesPoints(series) {
1527 function plotPoints(datapoints, radius, fillStyle, offset, circumference, axisx, axisy) {
1528 var points = datapoints.points, ps = datapoints.pointsize;
1529
1530 for (var i = 0; i < points.length; i += ps) {
1531 var x = points[i], y = points[i + 1];
1532 if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
1533 continue;
1534
1535 ctx.beginPath();
1536 ctx.arc(axisx.p2c(x), axisy.p2c(y) + offset, radius, 0, circumference, false);
1537 if (fillStyle) {
1538 ctx.fillStyle = fillStyle;
1539 ctx.fill();
1540 }
1541 ctx.stroke();
1542 }
1543 }
1544
1545 ctx.save();
1546 ctx.translate(plotOffset.left, plotOffset.top);
1547
1548 var lw = series.lines.lineWidth,
1549 sw = series.shadowSize,
1550 radius = series.points.radius;
1551 if (lw > 0 && sw > 0) {
1552 // draw shadow in two steps
1553 var w = sw / 2;
1554 ctx.lineWidth = w;
1555 ctx.strokeStyle = "rgba(0,0,0,0.1)";
1556 plotPoints(series.datapoints, radius, null, w + w/2, Math.PI,
1557 series.xaxis, series.yaxis);
1558
1559 ctx.strokeStyle = "rgba(0,0,0,0.2)";
1560 plotPoints(series.datapoints, radius, null, w/2, Math.PI,
1561 series.xaxis, series.yaxis);
1562 }
1563
1564 ctx.lineWidth = lw;
1565 ctx.strokeStyle = series.color;
1566 plotPoints(series.datapoints, radius,
1567 getFillStyle(series.points, series.color), 0, 2 * Math.PI,
1568 series.xaxis, series.yaxis);
1569 ctx.restore();
1570 }
1571
1572 function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal) {
1573 var left, right, bottom, top,
1574 drawLeft, drawRight, drawTop, drawBottom,
1575 tmp;
1576
1577 if (horizontal) {
1578 drawBottom = drawRight = drawTop = true;
1579 drawLeft = false;
1580 left = b;
1581 right = x;
1582 top = y + barLeft;
1583 bottom = y + barRight;
1584
1585 // account for negative bars
1586 if (right < left) {
1587 tmp = right;
1588 right = left;
1589 left = tmp;
1590 drawLeft = true;
1591 drawRight = false;
1592 }
1593 }
1594 else {
1595 drawLeft = drawRight = drawTop = true;
1596 drawBottom = false;
1597 left = x + barLeft;
1598 right = x + barRight;
1599 bottom = b;
1600 top = y;
1601
1602 // account for negative bars
1603 if (top < bottom) {
1604 tmp = top;
1605 top = bottom;
1606 bottom = tmp;
1607 drawBottom = true;
1608 drawTop = false;
1609 }
1610 }
1611
1612 // clip
1613 if (right < axisx.min || left > axisx.max ||
1614 top < axisy.min || bottom > axisy.max)
1615 return;
1616
1617 if (left < axisx.min) {
1618 left = axisx.min;
1619 drawLeft = false;
1620 }
1621
1622 if (right > axisx.max) {
1623 right = axisx.max;
1624 drawRight = false;
1625 }
1626
1627 if (bottom < axisy.min) {
1628 bottom = axisy.min;
1629 drawBottom = false;
1630 }
1631
1632 if (top > axisy.max) {
1633 top = axisy.max;
1634 drawTop = false;
1635 }
1636
1637 left = axisx.p2c(left);
1638 bottom = axisy.p2c(bottom);
1639 right = axisx.p2c(right);
1640 top = axisy.p2c(top);
1641
1642 // fill the bar
1643 if (fillStyleCallback) {
1644 c.beginPath();
1645 c.moveTo(left, bottom);
1646 c.lineTo(left, top);
1647 c.lineTo(right, top);
1648 c.lineTo(right, bottom);
1649 c.fillStyle = fillStyleCallback(bottom, top);
1650 c.fill();
1651 }
1652
1653 // draw outline
1654 if (drawLeft || drawRight || drawTop || drawBottom) {
1655 c.beginPath();
1656
1657 // FIXME: inline moveTo is buggy with excanvas
1658 c.moveTo(left, bottom + offset);
1659 if (drawLeft)
1660 c.lineTo(left, top + offset);
1661 else
1662 c.moveTo(left, top + offset);
1663 if (drawTop)
1664 c.lineTo(right, top + offset);
1665 else
1666 c.moveTo(right, top + offset);
1667 if (drawRight)
1668 c.lineTo(right, bottom + offset);
1669 else
1670 c.moveTo(right, bottom + offset);
1671 if (drawBottom)
1672 c.lineTo(left, bottom + offset);
1673 else
1674 c.moveTo(left, bottom + offset);
1675 c.stroke();
1676 }
1677 }
1678
1679 function drawSeriesBars(series) {
1680 function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
1681 var points = datapoints.points, ps = datapoints.pointsize;
1682
1683 for (var i = 0; i < points.length; i += ps) {
1684 if (points[i] == null)
1685 continue;
1686 drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal);
1687 }
1688 }
1689
1690 ctx.save();
1691 ctx.translate(plotOffset.left, plotOffset.top);
1692
1693 // FIXME: figure out a way to add shadows (for instance along the right edge)
1694 ctx.lineWidth = series.bars.lineWidth;
1695 ctx.strokeStyle = series.color;
1696 var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
1697 var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
1698 plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
1699 ctx.restore();
1700 }
1701
1702 function getFillStyle(filloptions, seriesColor, bottom, top) {
1703 var fill = filloptions.fill;
1704 if (!fill)
1705 return null;
1706
1707 if (filloptions.fillColor)
1708 return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
1709
1710 var c = $.color.parse(seriesColor);
1711 c.a = typeof fill == "number" ? fill : 0.4;
1712 c.normalize();
1713 return c.toString();
1714 }
1715
1716 function insertLegend() {
1717 placeholder.find(".legend").remove();
1718
1719 if (!options.legend.show)
1720 return;
1721
1722 var fragments = [], rowStarted = false,
1723 lf = options.legend.labelFormatter, s, label;
1724 for (i = 0; i < series.length; ++i) {
1725 s = series[i];
1726 label = s.label;
1727 if (!label)
1728 continue;
1729
1730 if (i % options.legend.noColumns == 0) {
1731 if (rowStarted)
1732 fragments.push('</tr>');
1733 fragments.push('<tr>');
1734 rowStarted = true;
1735 }
1736
1737 if (lf)
1738 label = lf(label, s);
1739
1740 fragments.push(
1741 '<td class="legendColorBox"><div style="border:1px solid ' + options.legend.labelBoxBorderColor + ';padding:1px"><div style="width:4px;height:0;border:5px solid ' + s.color + ';overflow:hidden"></div></div></td>' +
1742 '<td class="legendLabel">' + label + '</td>');
1743 }
1744 if (rowStarted)
1745 fragments.push('</tr>');
1746
1747 if (fragments.length == 0)
1748 return;
1749
1750 var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
1751 if (options.legend.container != null)
1752 $(options.legend.container).html(table);
1753 else {
1754 var pos = "",
1755 p = options.legend.position,
1756 m = options.legend.margin;
1757 if (m[0] == null)
1758 m = [m, m];
1759 if (p.charAt(0) == "n")
1760 pos += 'top:' + (m[1] + plotOffset.top) + 'px;';
1761 else if (p.charAt(0) == "s")
1762 pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;';
1763 if (p.charAt(1) == "e")
1764 pos += 'right:' + (m[0] + plotOffset.right) + 'px;';
1765 else if (p.charAt(1) == "w")
1766 pos += 'left:' + (m[0] + plotOffset.left) + 'px;';
1767 var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder);
1768 if (options.legend.backgroundOpacity != 0.0) {
1769 // put in the transparent background
1770 // separately to avoid blended labels and
1771 // label boxes
1772 var c = options.legend.backgroundColor;
1773 if (c == null) {
1774 c = options.grid.backgroundColor;
1775 if (c && typeof c == "string")
1776 c = $.color.parse(c);
1777 else
1778 c = $.color.extract(legend, 'background-color');
1779 c.a = 1;
1780 c = c.toString();
1781 }
1782 var div = legend.children();
1783 $('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
1784 }
1785 }
1786 }
1787
1788
1789 // interactive features
1790
1791 var highlights = [],
1792 redrawTimeout = null;
1793
1794 // returns the data item the mouse is over, or null if none is found
1795 function findNearbyItem(mouseX, mouseY, seriesFilter) {
1796 var maxDistance = options.grid.mouseActiveRadius,
1797 smallestDistance = maxDistance * maxDistance + 1,
1798 item = null, foundPoint = false, i, j;
1799
1800 for (i = 0; i < series.length; ++i) {
1801 if (!seriesFilter(series[i]))
1802 continue;
1803
1804 var s = series[i],
1805 axisx = s.xaxis,
1806 axisy = s.yaxis,
1807 points = s.datapoints.points,
1808 ps = s.datapoints.pointsize,
1809 mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster
1810 my = axisy.c2p(mouseY),
1811 maxx = maxDistance / axisx.scale,
1812 maxy = maxDistance / axisy.scale;
1813
1814 if (s.lines.show || s.points.show) {
1815 for (j = 0; j < points.length; j += ps) {
1816 var x = points[j], y = points[j + 1];
1817 if (x == null)
1818 continue;
1819
1820 // For points and lines, the cursor must be within a
1821 // certain distance to the data point
1822 if (x - mx > maxx || x - mx < -maxx ||
1823 y - my > maxy || y - my < -maxy)
1824 continue;
1825
1826 // We have to calculate distances in pixels, not in
1827 // data units, because the scales of the axes may be different
1828 var dx = Math.abs(axisx.p2c(x) - mouseX),
1829 dy = Math.abs(axisy.p2c(y) - mouseY),
1830 dist = dx * dx + dy * dy; // we save the sqrt
1831
1832 // use <= to ensure last point takes precedence
1833 // (last generally means on top of)
1834 if (dist <= smallestDistance) {
1835 smallestDistance = dist;
1836 item = [i, j / ps];
1837 }
1838 }
1839 }
1840
1841 if (s.bars.show && !item) { // no other point can be nearby
1842 var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
1843 barRight = barLeft + s.bars.barWidth;
1844
1845 for (j = 0; j < points.length; j += ps) {
1846 var x = points[j], y = points[j + 1], b = points[j + 2];
1847 if (x == null)
1848 continue;
1849
1850 // for a bar graph, the cursor must be inside the bar
1851 if (series[i].bars.horizontal ?
1852 (mx <= Math.max(b, x) && mx >= Math.min(b, x) &&
1853 my >= y + barLeft && my <= y + barRight) :
1854 (mx >= x + barLeft && mx <= x + barRight &&
1855 my >= Math.min(b, y) && my <= Math.max(b, y)))
1856 item = [i, j / ps];
1857 }
1858 }
1859 }
1860
1861 if (item) {
1862 i = item[0];
1863 j = item[1];
1864 ps = series[i].datapoints.pointsize;
1865
1866 return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps),
1867 dataIndex: j,
1868 series: series[i],
1869 seriesIndex: i };
1870 }
1871
1872 return null;
1873 }
1874
1875 function onMouseMove(e) {
1876 if (options.grid.hoverable)
1877 triggerClickHoverEvent("plothover", e,
1878 function (s) { return s["hoverable"] != false; });
1879 }
1880
1881 function onClick(e) {
1882 triggerClickHoverEvent("plotclick", e,
1883 function (s) { return s["clickable"] != false; });
1884 }
1885
1886 // trigger click or hover event (they send the same parameters
1887 // so we share their code)
1888 function triggerClickHoverEvent(eventname, event, seriesFilter) {
1889 var offset = eventHolder.offset(),
1890 pos = { pageX: event.pageX, pageY: event.pageY },
1891 canvasX = event.pageX - offset.left - plotOffset.left,
1892 canvasY = event.pageY - offset.top - plotOffset.top;
1893
1894 if (axes.xaxis.used)
1895 pos.x = axes.xaxis.c2p(canvasX);
1896 if (axes.yaxis.used)
1897 pos.y = axes.yaxis.c2p(canvasY);
1898 if (axes.x2axis.used)
1899 pos.x2 = axes.x2axis.c2p(canvasX);
1900 if (axes.y2axis.used)
1901 pos.y2 = axes.y2axis.c2p(canvasY);
1902
1903 var item = findNearbyItem(canvasX, canvasY, seriesFilter);
1904
1905 if (item) {
1906 // fill in mouse pos for any listeners out there
1907 item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left);
1908 item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top);
1909 }
1910
1911 if (options.grid.autoHighlight) {
1912 // clear auto-highlights
1913 for (var i = 0; i < highlights.length; ++i) {
1914 var h = highlights[i];
1915 if (h.auto == eventname &&
1916 !(item && h.series == item.series && h.point == item.datapoint))
1917 unhighlight(h.series, h.point);
1918 }
1919
1920 if (item)
1921 highlight(item.series, item.datapoint, eventname);
1922 }
1923
1924 placeholder.trigger(eventname, [ pos, item ]);
1925 }
1926
1927 function triggerRedrawOverlay() {
1928 if (!redrawTimeout)
1929 redrawTimeout = setTimeout(drawOverlay, 30);
1930 }
1931
1932 function drawOverlay() {
1933 redrawTimeout = null;
1934
1935 // draw highlights
1936 octx.save();
1937 octx.clearRect(0, 0, canvasWidth, canvasHeight);
1938 octx.translate(plotOffset.left, plotOffset.top);
1939
1940 var i, hi;
1941 for (i = 0; i < highlights.length; ++i) {
1942 hi = highlights[i];
1943
1944 if (hi.series.bars.show)
1945 drawBarHighlight(hi.series, hi.point);
1946 else
1947 drawPointHighlight(hi.series, hi.point);
1948 }
1949 octx.restore();
1950
1951 executeHooks(hooks.drawOverlay, [octx]);
1952 }
1953
1954 function highlight(s, point, auto) {
1955 if (typeof s == "number")
1956 s = series[s];
1957
1958 if (typeof point == "number")
1959 point = s.data[point];
1960
1961 var i = indexOfHighlight(s, point);
1962 if (i == -1) {
1963 highlights.push({ series: s, point: point, auto: auto });
1964
1965 triggerRedrawOverlay();
1966 }
1967 else if (!auto)
1968 highlights[i].auto = false;
1969 }
1970
1971 function unhighlight(s, point) {
1972 if (s == null && point == null) {
1973 highlights = [];
1974 triggerRedrawOverlay();
1975 }
1976
1977 if (typeof s == "number")
1978 s = series[s];
1979
1980 if (typeof point == "number")
1981 point = s.data[point];
1982
1983 var i = indexOfHighlight(s, point);
1984 if (i != -1) {
1985 highlights.splice(i, 1);
1986
1987 triggerRedrawOverlay();
1988 }
1989 }
1990
1991 function indexOfHighlight(s, p) {
1992 for (var i = 0; i < highlights.length; ++i) {
1993 var h = highlights[i];
1994 if (h.series == s && h.point[0] == p[0]
1995 && h.point[1] == p[1])
1996 return i;
1997 }
1998 return -1;
1999 }
2000
2001 function drawPointHighlight(series, point) {
2002 var x = point[0], y = point[1],
2003 axisx = series.xaxis, axisy = series.yaxis;
2004
2005 if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
2006 return;
2007
2008 var pointRadius = series.points.radius + series.points.lineWidth / 2;
2009 octx.lineWidth = pointRadius;
2010 octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2011 var radius = 1.5 * pointRadius;
2012 octx.beginPath();
2013 octx.arc(axisx.p2c(x), axisy.p2c(y), radius, 0, 2 * Math.PI, false);
2014 octx.stroke();
2015 }
2016
2017 function drawBarHighlight(series, point) {
2018 octx.lineWidth = series.bars.lineWidth;
2019 octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2020 var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2021 var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
2022 drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
2023 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal);
2024 }
2025
2026 function getColorOrGradient(spec, bottom, top, defaultColor) {
2027 if (typeof spec == "string")
2028 return spec;
2029 else {
2030 // assume this is a gradient spec; IE currently only
2031 // supports a simple vertical gradient properly, so that's
2032 // what we support too
2033 var gradient = ctx.createLinearGradient(0, top, 0, bottom);
2034
2035 for (var i = 0, l = spec.colors.length; i < l; ++i) {
2036 var c = spec.colors[i];
2037 if (typeof c != "string") {
2038 c = $.color.parse(defaultColor).scale('rgb', c.brightness);
2039 c.a *= c.opacity;
2040 c = c.toString();
2041 }
2042 gradient.addColorStop(i / (l - 1), c);
2043 }
2044
2045 return gradient;
2046 }
2047 }
2048 }
2049
2050 $.plot = function(placeholder, data, options) {
2051 var plot = new Plot($(placeholder), data, options, $.plot.plugins);
2052 /*var t0 = new Date();
2053 var t1 = new Date();
2054 var tstr = "time used (msecs): " + (t1.getTime() - t0.getTime())
2055 if (window.console)
2056 console.log(tstr);
2057 else
2058 alert(tstr);*/
2059 return plot;
2060 };
2061
2062 $.plot.plugins = [];
2063
2064 // returns a string with the date d formatted according to fmt
2065 $.plot.formatDate = function(d, fmt, monthNames) {
2066 var leftPad = function(n) {
2067 n = "" + n;
2068 return n.length == 1 ? "0" + n : n;
2069 };
2070
2071 var r = [];
2072 var escape = false;
2073 var hours = d.getUTCHours();
2074 var isAM = hours < 12;
2075 if (monthNames == null)
2076 monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2077
2078 if (fmt.search(/%p|%P/) != -1) {
2079 if (hours > 12) {
2080 hours = hours - 12;
2081 } else if (hours == 0) {
2082 hours = 12;
2083 }
2084 }
2085 for (var i = 0; i < fmt.length; ++i) {
2086 var c = fmt.charAt(i);
2087
2088 if (escape) {
2089 switch (c) {
2090 case 'h': c = "" + hours; break;
2091 case 'H': c = leftPad(hours); break;
2092 case 'M': c = leftPad(d.getUTCMinutes()); break;
2093 case 'S': c = leftPad(d.getUTCSeconds()); break;
2094 case 'd': c = "" + d.getUTCDate(); break;
2095 case 'm': c = "" + (d.getUTCMonth() + 1); break;
2096 case 'y': c = "" + d.getUTCFullYear(); break;
2097 case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
2098 case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
2099 case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
2100 }
2101 r.push(c);
2102 escape = false;
2103 }
2104 else {
2105 if (c == "%")
2106 escape = true;
2107 else
2108 r.push(c);
2109 }
2110 }
2111 return r.join("");
2112 };
2113
2114 // round to nearby lower multiple of base
2115 function floorInBase(n, base) {
2116 return base * Math.floor(n / base);
2117 }
2118
2119})(jQuery);
02120
=== added file 'webapp/content/js/jquery.flot.selection.js'
--- webapp/content/js/jquery.flot.selection.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.flot.selection.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,299 @@
1/*
2Flot plugin for selecting regions.
3
4The plugin defines the following options:
5
6 selection: {
7 mode: null or "x" or "y" or "xy",
8 color: color
9 }
10
11You enable selection support by setting the mode to one of "x", "y" or
12"xy". In "x" mode, the user will only be able to specify the x range,
13similarly for "y" mode. For "xy", the selection becomes a rectangle
14where both ranges can be specified. "color" is color of the selection.
15
16When selection support is enabled, a "plotselected" event will be emitted
17on the DOM element you passed into the plot function. The event
18handler gets one extra parameter with the ranges selected on the axes,
19like this:
20
21 placeholder.bind("plotselected", function(event, ranges) {
22 alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
23 // similar for yaxis, secondary axes are in x2axis
24 // and y2axis if present
25 });
26
27The "plotselected" event is only fired when the user has finished
28making the selection. A "plotselecting" event is fired during the
29process with the same parameters as the "plotselected" event, in case
30you want to know what's happening while it's happening,
31
32A "plotunselected" event with no arguments is emitted when the user
33clicks the mouse to remove the selection.
34
35The plugin allso adds the following methods to the plot object:
36
37- setSelection(ranges, preventEvent)
38
39 Set the selection rectangle. The passed in ranges is on the same
40 form as returned in the "plotselected" event. If the selection
41 mode is "x", you should put in either an xaxis (or x2axis) object,
42 if the mode is "y" you need to put in an yaxis (or y2axis) object
43 and both xaxis/x2axis and yaxis/y2axis if the selection mode is
44 "xy", like this:
45
46 setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
47
48 setSelection will trigger the "plotselected" event when called. If
49 you don't want that to happen, e.g. if you're inside a
50 "plotselected" handler, pass true as the second parameter.
51
52- clearSelection(preventEvent)
53
54 Clear the selection rectangle. Pass in true to avoid getting a
55 "plotunselected" event.
56
57- getSelection()
58
59 Returns the current selection in the same format as the
60 "plotselected" event. If there's currently no selection, the
61 function returns null.
62
63*/
64
65(function ($) {
66 function init(plot) {
67 var selection = {
68 first: { x: -1, y: -1}, second: { x: -1, y: -1},
69 show: false,
70 active: false
71 };
72
73 // FIXME: The drag handling implemented here should be
74 // abstracted out, there's some similar code from a library in
75 // the navigation plugin, this should be massaged a bit to fit
76 // the Flot cases here better and reused. Doing this would
77 // make this plugin much slimmer.
78 var savedhandlers = {};
79
80 function onMouseMove(e) {
81 if (selection.active) {
82 plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
83
84 updateSelection(e);
85 }
86 }
87
88 function onMouseDown(e) {
89 if (e.which != 1) // only accept left-click
90 return;
91
92 // cancel out any text selections
93 document.body.focus();
94
95 // prevent text selection and drag in old-school browsers
96 if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
97 savedhandlers.onselectstart = document.onselectstart;
98 document.onselectstart = function () { return false; };
99 }
100 if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
101 savedhandlers.ondrag = document.ondrag;
102 document.ondrag = function () { return false; };
103 }
104
105 setSelectionPos(selection.first, e);
106
107 selection.active = true;
108
109 $(document).one("mouseup", onMouseUp);
110 }
111
112 function onMouseUp(e) {
113 // revert drag stuff for old-school browsers
114 if (document.onselectstart !== undefined)
115 document.onselectstart = savedhandlers.onselectstart;
116 if (document.ondrag !== undefined)
117 document.ondrag = savedhandlers.ondrag;
118
119 // no more draggy-dee-drag
120 selection.active = false;
121 updateSelection(e);
122
123 if (selectionIsSane())
124 triggerSelectedEvent();
125 else {
126 // this counts as a clear
127 plot.getPlaceholder().trigger("plotunselected", [ ]);
128 plot.getPlaceholder().trigger("plotselecting", [ null ]);
129 }
130
131 return false;
132 }
133
134 function getSelection() {
135 if (!selectionIsSane())
136 return null;
137
138 var x1 = Math.min(selection.first.x, selection.second.x),
139 x2 = Math.max(selection.first.x, selection.second.x),
140 y1 = Math.max(selection.first.y, selection.second.y),
141 y2 = Math.min(selection.first.y, selection.second.y);
142
143 var r = {};
144 var axes = plot.getAxes();
145 if (axes.xaxis.used)
146 r.xaxis = { from: axes.xaxis.c2p(x1), to: axes.xaxis.c2p(x2) };
147 if (axes.x2axis.used)
148 r.x2axis = { from: axes.x2axis.c2p(x1), to: axes.x2axis.c2p(x2) };
149 if (axes.yaxis.used)
150 r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) };
151 if (axes.y2axis.used)
152 r.y2axis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) };
153 return r;
154 }
155
156 function triggerSelectedEvent() {
157 var r = getSelection();
158
159 plot.getPlaceholder().trigger("plotselected", [ r ]);
160
161 // backwards-compat stuff, to be removed in future
162 var axes = plot.getAxes();
163 if (axes.xaxis.used && axes.yaxis.used)
164 plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
165 }
166
167 function clamp(min, value, max) {
168 return value < min? min: (value > max? max: value);
169 }
170
171 function setSelectionPos(pos, e) {
172 var o = plot.getOptions();
173 var offset = plot.getPlaceholder().offset();
174 var plotOffset = plot.getPlotOffset();
175 pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
176 pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
177
178 if (o.selection.mode == "y")
179 pos.x = pos == selection.first? 0: plot.width();
180
181 if (o.selection.mode == "x")
182 pos.y = pos == selection.first? 0: plot.height();
183 }
184
185 function updateSelection(pos) {
186 if (pos.pageX == null)
187 return;
188
189 setSelectionPos(selection.second, pos);
190 if (selectionIsSane()) {
191 selection.show = true;
192 plot.triggerRedrawOverlay();
193 }
194 else
195 clearSelection(true);
196 }
197
198 function clearSelection(preventEvent) {
199 if (selection.show) {
200 selection.show = false;
201 plot.triggerRedrawOverlay();
202 if (!preventEvent)
203 plot.getPlaceholder().trigger("plotunselected", [ ]);
204 }
205 }
206
207 function setSelection(ranges, preventEvent) {
208 var axis, range, axes = plot.getAxes();
209 var o = plot.getOptions();
210
211 if (o.selection.mode == "y") {
212 selection.first.x = 0;
213 selection.second.x = plot.width();
214 }
215 else {
216 axis = ranges["xaxis"]? axes["xaxis"]: (ranges["x2axis"]? axes["x2axis"]: axes["xaxis"]);
217 range = ranges["xaxis"] || ranges["x2axis"] || { from:ranges["x1"], to:ranges["x2"] }
218 selection.first.x = axis.p2c(Math.min(range.from, range.to));
219 selection.second.x = axis.p2c(Math.max(range.from, range.to));
220 }
221
222 if (o.selection.mode == "x") {
223 selection.first.y = 0;
224 selection.second.y = plot.height();
225 }
226 else {
227 axis = ranges["yaxis"]? axes["yaxis"]: (ranges["y2axis"]? axes["y2axis"]: axes["yaxis"]);
228 range = ranges["yaxis"] || ranges["y2axis"] || { from:ranges["y1"], to:ranges["y2"] }
229 selection.first.y = axis.p2c(Math.min(range.from, range.to));
230 selection.second.y = axis.p2c(Math.max(range.from, range.to));
231 }
232
233 selection.show = true;
234 plot.triggerRedrawOverlay();
235 if (!preventEvent)
236 triggerSelectedEvent();
237 }
238
239 function selectionIsSane() {
240 var minSize = 5;
241 return Math.abs(selection.second.x - selection.first.x) >= minSize &&
242 Math.abs(selection.second.y - selection.first.y) >= minSize;
243 }
244
245 plot.clearSelection = clearSelection;
246 plot.setSelection = setSelection;
247 plot.getSelection = getSelection;
248
249 plot.hooks.bindEvents.push(function(plot, eventHolder) {
250 var o = plot.getOptions();
251 if (o.selection.mode != null)
252 eventHolder.mousemove(onMouseMove);
253
254 if (o.selection.mode != null)
255 eventHolder.mousedown(onMouseDown);
256 });
257
258
259 plot.hooks.drawOverlay.push(function (plot, ctx) {
260 // draw selection
261 if (selection.show && selectionIsSane()) {
262 var plotOffset = plot.getPlotOffset();
263 var o = plot.getOptions();
264
265 ctx.save();
266 ctx.translate(plotOffset.left, plotOffset.top);
267
268 var c = $.color.parse(o.selection.color);
269
270 ctx.strokeStyle = c.scale('a', 0.8).toString();
271 ctx.lineWidth = 1;
272 ctx.lineJoin = "round";
273 ctx.fillStyle = c.scale('a', 0.4).toString();
274
275 var x = Math.min(selection.first.x, selection.second.x),
276 y = Math.min(selection.first.y, selection.second.y),
277 w = Math.abs(selection.second.x - selection.first.x),
278 h = Math.abs(selection.second.y - selection.first.y);
279
280 ctx.fillRect(x, y, w, h);
281 ctx.strokeRect(x, y, w, h);
282
283 ctx.restore();
284 }
285 });
286 }
287
288 $.plot.plugins.push({
289 init: init,
290 options: {
291 selection: {
292 mode: null, // one of null, "x", "y" or "xy"
293 color: "#e8cfac"
294 }
295 },
296 name: 'selection',
297 version: '1.0'
298 });
299})(jQuery);
0300
=== added file 'webapp/content/js/jquery.graphite.js'
--- webapp/content/js/jquery.graphite.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.graphite.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,383 @@
1(function( $ ) {
2 $.fn.editable_in_place = function(callback) {
3 var editable = $(this);
4 if (editable.length > 1) {
5 console.error("Call $().editable_in_place only on a singular jquery object.");
6 }
7
8 var editing = false;
9
10 editable.bind('click', function () {
11 var $element = this;
12
13 if (editing == true) return;
14
15 editing = true;
16
17 var $edit = $('<input type="text" class="edit_in_place" value="' + editable.text() + '"/>');
18
19 $edit.css({'height' : editable.height(), 'width' : editable.width()});
20 editable.hide();
21 editable.after($edit);
22 $edit.focus();
23
24 $edit.bind('blur', function() { // on blur, forget edits and reset.
25 $edit.remove();
26 editable.show();
27 editing = false;
28 });
29
30 $edit.keydown(function(e) {
31 if(e.which===27)$edit.blur(); // blur on Esc: see above
32 if(e.which===13 || e.which===9) { // Enter or Tab: run the callback with the value
33 e.preventDefault();
34 $edit.hide();
35 editable.show();
36 if($edit.val()!=='') {
37 editing = false;
38 callback($element, $edit.val());
39 }
40 $edit.remove();
41 }
42 });
43 });
44 };
45
46 $.fn.graphiteGraph = function() {
47 return this.each(function() {
48
49 var graph = $(this);
50 var plot = null;
51 var graph_lines = {};
52 var metric_yaxis = {};
53 var xaxisranges = {};
54 var yaxisranges = {};
55 var legends = null;
56 var updateLegendTimeout = null;
57 var latestPosition = null;
58 var autocompleteoptions = {
59 minChars: 0,
60 selectFirst: false,
61 };
62
63 var parse_incoming = function(incoming_data) {
64 var result = [];
65 var start = incoming_data.start;
66 var end = incoming_data.end;
67 var step = incoming_data.step;
68
69 for (i in incoming_data.data) {
70 result.push([(start+step*i)*1000, incoming_data.data[i]]);
71
72 }
73 return {
74 label: incoming_data.name,
75 data: result,
76 lines: {show: true, fill: false}
77 };
78 };
79
80
81 var render = function () {
82 var lines = []
83 for (i in graph_lines) {
84 for (j in graph_lines[i]) {
85 var newline = $.extend({}, graph_lines[i][j]);
86 if (metric_yaxis[i] == "two") {
87 newline['yaxis'] = 2;
88 }
89 lines.push(newline);
90 }
91 }
92 var xaxismode = { mode: "time" };
93 var yaxismode = { };
94
95 $.extend(xaxismode, xaxisranges);
96 $.extend(yaxismode, yaxisranges);
97
98 plot = $.plot($("#graph"),
99 lines,
100 {
101 xaxis: xaxismode,
102 yaxis: yaxismode,
103 grid: { hoverable: true, },
104 selection: { mode: "xy" },
105 legend: { show: true, container: graph.find("#legend") },
106 crosshair: { mode: "x" },
107 }
108 );
109
110
111 for (i in lines) {
112 lines[i] = $.extend({}, lines[i]);
113 lines[i].label = null;
114 }
115 var overview = $.plot($("#overview"),
116 lines,
117 {
118 xaxis: { mode: "time" },
119 selection: { mode: "x" },
120 }
121 );
122
123 // legends magic
124 legends = graph.find(".legendLabel");
125 // update link
126 graph.find("#graphurl").attr("href", build_full_url());
127
128 }
129
130 function updateLegend() {
131 updateLegendTimeout = null;
132
133 var pos = latestPosition;
134
135 var axes = plot.getAxes();
136 if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
137 pos.y < axes.yaxis.min || pos.y > axes.yaxis.max) {
138 var i, j, dataset = plot.getData();
139 for (i = 0; i < dataset.length; ++i) {
140 var series = dataset[i];
141 legends.eq(i).text(series.label);
142 }
143 }
144
145 var i, j, dataset = plot.getData();
146 for (i = 0; i < dataset.length; ++i) {
147 var series = dataset[i];
148
149 // find the nearest points, x-wise
150 for (j = 0; j < series.data.length; ++j)
151 if (series.data[j][0] > pos.x)
152 break;
153
154 // now interpolate
155 var y, p1 = series.data[j - 1], p2 = series.data[j];
156 if (p1 == null)
157 y = p2[1];
158 else if (p2 == null)
159 y = p1[1];
160 else
161 y = p1[1] + (p2[1] - p1[1]) * (pos.x - p1[0]) / (p2[0] - p1[0]);
162
163 if ( y != null ) {
164 legends.eq(i).text(series.label + " = " + y.toFixed(2));
165 } else {
166 legends.eq(i).text(series.label);
167 }
168 legends.eq(i).css('width', legends.eq(i).width());
169 }
170 }
171
172 $("#graph").bind("plothover", function (event, pos, item) {
173 latestPosition = pos;
174 if (!updateLegendTimeout)
175 updateLegendTimeout = setTimeout(updateLegend, 50);
176 });
177
178 function showTooltip(x, y, contents) {
179 $('<div id="tooltip">' + contents + '</div>').css( {
180 position: 'absolute',
181 display: 'none',
182 top: y + 5,
183 left: x + 5,
184 border: '1px solid #fdd',
185 padding: '2px',
186 'background-color': '#fee',
187 opacity: 0.80
188 }).appendTo("body").fadeIn(200);
189 }
190
191 var previousPoint = null;
192 $("#graph").bind("plothover", function (event, pos, item) {
193 if (item) {
194 if (previousPoint != item.datapoint) {
195 previousPoint = item.datapoint;
196
197 $("#tooltip").remove();
198 var x = item.datapoint[0].toFixed(2),
199 y = item.datapoint[1].toFixed(2);
200
201 showTooltip(item.pageX, item.pageY,
202 item.series.label + " = " + y);
203 }
204 }
205 else {
206 $("#tooltip").remove();
207 previousPoint = null;
208 }
209 });
210
211 $("#overview").bind("plotselected", function (event, ranges) {
212 xaxisranges = { min: ranges.xaxis.from, max: ranges.xaxis.to };
213 yaxisranges = { min: ranges.yaxis.from, max: ranges.yaxis.to };
214 render()
215 });
216
217 $("#graph").bind("plotselected", function (event, ranges) {
218 xaxisranges = { min: ranges.xaxis.from, max: ranges.xaxis.to };
219 yaxisranges = { min: ranges.yaxis.from, max: ranges.yaxis.to };
220 render()
221 });
222
223 var clear_zoom = function () {
224 xaxisranges = {};
225 yaxisranges = {};
226 render();
227 }
228
229 var recalculate_all = function () {
230 graph.find('.metricrow').each(function () {
231 var metric = $(this);
232 update_metric_row(metric);
233 });
234 render();
235 }
236
237 var build_full_url = function() {
238 var url = window.location.protocol + '//' +
239 window.location.host + window.location.pathname +
240 '?' + build_when();
241 for (series in graph_lines) {
242 if (metric_yaxis[series] == "two") {
243 url = url + '&y2target=' + series;
244 } else {
245 url = url + '&target=' + series;
246 }
247 }
248 return url;
249 }
250
251 var build_when = function () {
252 var when = '';
253 var from = graph.find("#from").text();
254 if (from) {
255 when = when + '&from=' + from;
256 }
257 var until = graph.find("#until").text();
258 if (until) {
259 when = when + '&until=' + until;
260 }
261 return when
262 }
263 var build_url = function (series) {
264 when = build_when()
265 return 'rawdata?'+when+'&target='+series;
266 }
267
268 var update_metric_row = function(metric_row) {
269 var metric = $(metric_row);
270 var metric_name = metric.find(".metricname").text();
271 metric.find(".metricname").addClass("ajaxworking");
272 metric_yaxis[metric_name] = metric.find(".yaxis").text();
273
274 $.ajax({
275 url: build_url(metric_name),
276 success: function(req_data) {
277 metric.find(".metricname").removeClass("ajaxerror");
278 metric.find(".metricname").removeClass("ajaxworking");
279 graph_lines[metric_name] = [];
280 target = graph_lines[metric_name];
281 for (i in req_data) {
282 target.push(parse_incoming(req_data[i]));
283 }
284 render();
285 },
286 error: function(req, status, err) {
287 metric.find(".metricname").removeClass("ajaxworking");
288 metric.find(".metricname").addClass("ajaxerror");
289 render();
290 }
291 });
292
293
294 }
295
296 // configure the date boxes
297 graph.find('#from').editable_in_place(
298 function(editable, value) {
299 $(editable).text(value);
300 recalculate_all();
301 }
302 );
303
304
305 graph.find('#until').editable_in_place(
306 function(editable, value) {
307 $(editable).text(value);
308 recalculate_all();
309 }
310 );
311
312 graph.find('#update').bind('click',
313 function() {
314 recalculate_all();
315 }
316 );
317
318 graph.find('#clearzoom').bind('click',
319 clear_zoom
320 );
321
322 // configure metricrows
323 var setup_row = function (metric) {
324 var metric_name = metric.find('.metricname').text();
325
326 metric.find('.metricname').editable_in_place(
327 function(editable, value) {
328 delete graph_lines[$(editable).text()];
329 $(editable).text(value);
330 update_metric_row(metric);
331 }
332 );
333 metric.find('.killrow').bind('click', function() {
334 delete graph_lines[metric.find('.metricname').text()];
335 metric.remove();
336 render();
337 });
338
339 metric.find('.yaxis').bind('click', function() {
340 if ($(this).text() == "one") {
341 $(this).text("two");
342 } else {
343 $(this).text("one");
344 }
345 metric_yaxis[metric_name] = metric.find(".yaxis").text();
346 render();
347 });
348 }
349
350 graph.find('.metricrow').each(function() {
351 setup_row($(this));
352 });
353
354 graph.find('.metricrow').each(function() {
355 var row = $(this);
356
357 });
358 // configure new metric input
359 graph.find('#newmetric').each(function () {
360 var edit = $(this);
361 edit.autocomplete('findmetric', autocompleteoptions);
362 edit.keydown(function(e) {
363 if(e.which===13) { // on enter
364 // add row
365 edit.blur();
366 if (graph_lines[edit.val()] == null) {
367 var new_row = $('<tr class="metricrow"><td><a href=#><span class="metricName">'+edit.val()+'</span></a></td><td><a href=#><span class="yaxis">one</span></a></td><td class="killrow"><img src="../content/img/delete.png"></td></tr>');
368 setup_row(new_row);
369 graph.find('#newmetricrow').before(new_row);
370 update_metric_row(new_row);
371 // clear input
372 }
373 edit.val('');
374 }
375 });
376 });
377
378 // get data
379 recalculate_all();
380 });
381 };
382
383})( jQuery );
0\ No newline at end of file384\ No newline at end of file
1385
=== added file 'webapp/content/js/jquery.js'
--- webapp/content/js/jquery.js 1970-01-01 00:00:00 +0000
+++ webapp/content/js/jquery.js 2010-11-01 18:48:50 +0000
@@ -0,0 +1,166 @@
1/*!
2 * jQuery JavaScript Library v1.4.3
3 * http://jquery.com/
4 *
5 * Copyright 2010, John Resig
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
8 *
9 * Includes Sizzle.js
10 * http://sizzlejs.com/
11 * Copyright 2010, The Dojo Foundation
12 * Released under the MIT, BSD, and GPL Licenses.
13 *
14 * Date: Thu Oct 14 23:10:06 2010 -0400
15 */
16(function(E,A){function U(){return false}function ba(){return true}function ja(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ga(a){var b,d,e=[],f=[],h,k,l,n,s,v,B,D;k=c.data(this,this.nodeType?"events":"__events__");if(typeof k==="function")k=k.events;if(!(a.liveFired===this||!k||!k.live||a.button&&a.type==="click")){if(a.namespace)D=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var H=k.live.slice(0);for(n=0;n<H.length;n++){k=H[n];k.origType.replace(X,
17"")===a.type?f.push(k.selector):H.splice(n--,1)}f=c(a.target).closest(f,a.currentTarget);s=0;for(v=f.length;s<v;s++){B=f[s];for(n=0;n<H.length;n++){k=H[n];if(B.selector===k.selector&&(!D||D.test(k.namespace))){l=B.elem;h=null;if(k.preType==="mouseenter"||k.preType==="mouseleave"){a.type=k.preType;h=c(a.relatedTarget).closest(k.selector)[0]}if(!h||h!==l)e.push({elem:l,handleObj:k,level:B.level})}}}s=0;for(v=e.length;s<v;s++){f=e[s];if(d&&f.level>d)break;a.currentTarget=f.elem;a.data=f.handleObj.data;
18a.handleObj=f.handleObj;D=f.handleObj.origHandler.apply(f.elem,arguments);if(D===false||a.isPropagationStopped()){d=f.level;if(D===false)b=false}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(Ha,"`").replace(Ia,"&")}function ka(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Ja.test(b))return c.filter(b,
19e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function la(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this,e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var k in e[h])c.event.add(this,h,e[h][k],e[h][k].data)}}})}function Ka(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}
20function ma(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?La:Ma,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a,"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function ca(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Na.test(a)?e(a,h):ca(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?
21e(a,""):c.each(b,function(f,h){ca(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(na.concat.apply([],na.slice(0,b)),function(){d[this]=a});return d}function oa(a){if(!da[a]){var b=c("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";da[a]=d}return da[a]}function ea(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var u=E.document,c=function(){function a(){if(!b.isReady){try{u.documentElement.doScroll("left")}catch(i){setTimeout(a,
221);return}b.ready()}}var b=function(i,r){return new b.fn.init(i,r)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,k=/\S/,l=/^\s+/,n=/\s+$/,s=/\W/,v=/\d/,B=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,D=/^[\],:{}\s]*$/,H=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,G=/(?:^|:|,)(?:\s*\[)+/g,M=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,j=/(msie) ([\w.]+)/,o=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,
23q=[],t,x=Object.prototype.toString,C=Object.prototype.hasOwnProperty,P=Array.prototype.push,N=Array.prototype.slice,R=String.prototype.trim,Q=Array.prototype.indexOf,L={};b.fn=b.prototype={init:function(i,r){var y,z,F;if(!i)return this;if(i.nodeType){this.context=this[0]=i;this.length=1;return this}if(i==="body"&&!r&&u.body){this.context=u;this[0]=u.body;this.selector="body";this.length=1;return this}if(typeof i==="string")if((y=h.exec(i))&&(y[1]||!r))if(y[1]){F=r?r.ownerDocument||r:u;if(z=B.exec(i))if(b.isPlainObject(r)){i=
24[u.createElement(z[1])];b.fn.attr.call(i,r,true)}else i=[F.createElement(z[1])];else{z=b.buildFragment([y[1]],[F]);i=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this,i)}else{if((z=u.getElementById(y[2]))&&z.parentNode){if(z.id!==y[2])return f.find(i);this.length=1;this[0]=z}this.context=u;this.selector=i;return this}else if(!r&&!s.test(i)){this.selector=i;this.context=u;i=u.getElementsByTagName(i);return b.merge(this,i)}else return!r||r.jquery?(r||f).find(i):b(r).find(i);
25else if(b.isFunction(i))return f.ready(i);if(i.selector!==A){this.selector=i.selector;this.context=i.context}return b.makeArray(i,this)},selector:"",jquery:"1.4.3",length:0,size:function(){return this.length},toArray:function(){return N.call(this,0)},get:function(i){return i==null?this.toArray():i<0?this.slice(i)[0]:this[i]},pushStack:function(i,r,y){var z=b();b.isArray(i)?P.apply(z,i):b.merge(z,i);z.prevObject=this;z.context=this.context;if(r==="find")z.selector=this.selector+(this.selector?" ":
26"")+y;else if(r)z.selector=this.selector+"."+r+"("+y+")";return z},each:function(i,r){return b.each(this,i,r)},ready:function(i){b.bindReady();if(b.isReady)i.call(u,b);else q&&q.push(i);return this},eq:function(i){return i===-1?this.slice(i):this.slice(i,+i+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(i){return this.pushStack(b.map(this,function(r,y){return i.call(r,
27y,r)}))},end:function(){return this.prevObject||b(null)},push:P,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var i=arguments[0]||{},r=1,y=arguments.length,z=false,F,I,K,J,fa;if(typeof i==="boolean"){z=i;i=arguments[1]||{};r=2}if(typeof i!=="object"&&!b.isFunction(i))i={};if(y===r){i=this;--r}for(;r<y;r++)if((F=arguments[r])!=null)for(I in F){K=i[I];J=F[I];if(i!==J)if(z&&J&&(b.isPlainObject(J)||(fa=b.isArray(J)))){if(fa){fa=false;clone=K&&b.isArray(K)?K:[]}else clone=
28K&&b.isPlainObject(K)?K:{};i[I]=b.extend(z,clone,J)}else if(J!==A)i[I]=J}return i};b.extend({noConflict:function(i){E.$=e;if(i)E.jQuery=d;return b},isReady:false,readyWait:1,ready:function(i){i===true&&b.readyWait--;if(!b.readyWait||i!==true&&!b.isReady){if(!u.body)return setTimeout(b.ready,1);b.isReady=true;if(!(i!==true&&--b.readyWait>0)){if(q){for(var r=0;i=q[r++];)i.call(u,b);q=null}b.fn.triggerHandler&&b(u).triggerHandler("ready")}}},bindReady:function(){if(!p){p=true;if(u.readyState==="complete")return setTimeout(b.ready,
291);if(u.addEventListener){u.addEventListener("DOMContentLoaded",t,false);E.addEventListener("load",b.ready,false)}else if(u.attachEvent){u.attachEvent("onreadystatechange",t);E.attachEvent("onload",b.ready);var i=false;try{i=E.frameElement==null}catch(r){}u.documentElement.doScroll&&i&&a()}}},isFunction:function(i){return b.type(i)==="function"},isArray:Array.isArray||function(i){return b.type(i)==="array"},isWindow:function(i){return i&&typeof i==="object"&&"setInterval"in i},isNaN:function(i){return i==
30null||!v.test(i)||isNaN(i)},type:function(i){return i==null?String(i):L[x.call(i)]||"object"},isPlainObject:function(i){if(!i||b.type(i)!=="object"||i.nodeType||b.isWindow(i))return false;if(i.constructor&&!C.call(i,"constructor")&&!C.call(i.constructor.prototype,"isPrototypeOf"))return false;for(var r in i);return r===A||C.call(i,r)},isEmptyObject:function(i){for(var r in i)return false;return true},error:function(i){throw i;},parseJSON:function(i){if(typeof i!=="string"||!i)return null;i=b.trim(i);
31if(D.test(i.replace(H,"@").replace(w,"]").replace(G,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(i):(new Function("return "+i))();else b.error("Invalid JSON: "+i)},noop:function(){},globalEval:function(i){if(i&&k.test(i)){var r=u.getElementsByTagName("head")[0]||u.documentElement,y=u.createElement("script");y.type="text/javascript";if(b.support.scriptEval)y.appendChild(u.createTextNode(i));else y.text=i;r.insertBefore(y,r.firstChild);r.removeChild(y)}},nodeName:function(i,r){return i.nodeName&&i.nodeName.toUpperCase()===
32r.toUpperCase()},each:function(i,r,y){var z,F=0,I=i.length,K=I===A||b.isFunction(i);if(y)if(K)for(z in i){if(r.apply(i[z],y)===false)break}else for(;F<I;){if(r.apply(i[F++],y)===false)break}else if(K)for(z in i){if(r.call(i[z],z,i[z])===false)break}else for(y=i[0];F<I&&r.call(y,F,y)!==false;y=i[++F]);return i},trim:R?function(i){return i==null?"":R.call(i)}:function(i){return i==null?"":i.toString().replace(l,"").replace(n,"")},makeArray:function(i,r){var y=r||[];if(i!=null){var z=b.type(i);i.length==
33null||z==="string"||z==="function"||z==="regexp"||b.isWindow(i)?P.call(y,i):b.merge(y,i)}return y},inArray:function(i,r){if(r.indexOf)return r.indexOf(i);for(var y=0,z=r.length;y<z;y++)if(r[y]===i)return y;return-1},merge:function(i,r){var y=i.length,z=0;if(typeof r.length==="number")for(var F=r.length;z<F;z++)i[y++]=r[z];else for(;r[z]!==A;)i[y++]=r[z++];i.length=y;return i},grep:function(i,r,y){var z=[],F;y=!!y;for(var I=0,K=i.length;I<K;I++){F=!!r(i[I],I);y!==F&&z.push(i[I])}return z},map:function(i,
34r,y){for(var z=[],F,I=0,K=i.length;I<K;I++){F=r(i[I],I,y);if(F!=null)z[z.length]=F}return z.concat.apply([],z)},guid:1,proxy:function(i,r,y){if(arguments.length===2)if(typeof r==="string"){y=i;i=y[r];r=A}else if(r&&!b.isFunction(r)){y=r;r=A}if(!r&&i)r=function(){return i.apply(y||this,arguments)};if(i)r.guid=i.guid=i.guid||r.guid||b.guid++;return r},access:function(i,r,y,z,F,I){var K=i.length;if(typeof r==="object"){for(var J in r)b.access(i,J,r[J],z,F,y);return i}if(y!==A){z=!I&&z&&b.isFunction(y);
35for(J=0;J<K;J++)F(i[J],r,z?y.call(i[J],J,F(i[J],r)):y,I);return i}return K?F(i[0],r):A},now:function(){return(new Date).getTime()},uaMatch:function(i){i=i.toLowerCase();i=M.exec(i)||g.exec(i)||j.exec(i)||i.indexOf("compatible")<0&&o.exec(i)||[];return{browser:i[1]||"",version:i[2]||"0"}},browser:{}});b.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(i,r){L["[object "+r+"]"]=r.toLowerCase()});m=b.uaMatch(m);if(m.browser){b.browser[m.browser]=true;b.browser.version=
36m.version}if(b.browser.webkit)b.browser.safari=true;if(Q)b.inArray=function(i,r){return Q.call(r,i)};if(!/\s/.test("\u00a0")){l=/^[\s\xA0]+/;n=/[\s\xA0]+$/}f=b(u);if(u.addEventListener)t=function(){u.removeEventListener("DOMContentLoaded",t,false);b.ready()};else if(u.attachEvent)t=function(){if(u.readyState==="complete"){u.detachEvent("onreadystatechange",t);b.ready()}};return E.jQuery=E.$=b}();(function(){c.support={};var a=u.documentElement,b=u.createElement("script"),d=u.createElement("div"),
37e="script"+c.now();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],k=u.createElement("select"),l=k.appendChild(u.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),
38hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:l.selected,optDisabled:false,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};k.disabled=true;c.support.optDisabled=!l.disabled;b.type="text/javascript";try{b.appendChild(u.createTextNode("window."+e+"=1;"))}catch(n){}a.insertBefore(b,
39a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function s(){c.support.noCloneEvent=false;d.detachEvent("onclick",s)});d.cloneNode(true).fireEvent("onclick")}d=u.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=u.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var s=u.createElement("div");
40s.style.width=s.style.paddingLeft="1px";u.body.appendChild(s);c.boxModel=c.support.boxModel=s.offsetWidth===2;if("zoom"in s.style){s.style.display="inline";s.style.zoom=1;c.support.inlineBlockNeedsLayout=s.offsetWidth===2;s.style.display="";s.innerHTML="<div style='width:4px;'></div>";c.support.shrinkWrapBlocks=s.offsetWidth!==2}s.innerHTML="<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";var v=s.getElementsByTagName("td");c.support.reliableHiddenOffsets=v[0].offsetHeight===
410;v[0].style.display="";v[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&v[0].offsetHeight===0;s.innerHTML="";u.body.removeChild(s).style.display="none"});a=function(s){var v=u.createElement("div");s="on"+s;var B=s in v;if(!B){v.setAttribute(s,"return;");B=typeof v[s]==="function"}return B};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",
42cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var pa={},Oa=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?pa:a;var e=a.nodeType,f=e?a[c.expando]:null,h=c.cache;if(!(e&&!f&&typeof b==="string"&&d===A)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=
43c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==A)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?pa:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando);else if(d)delete f[e];else for(var k in a)delete a[k]}},acceptData:function(a){if(a.nodeName){var b=
44c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){if(typeof a==="undefined")return this.length?c.data(this[0]):null;else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===A){var e=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(e===A&&this.length){e=c.data(this[0],a);if(e===A&&this[0].nodeType===1){e=this[0].getAttribute("data-"+a);if(typeof e===
45"string")try{e=e==="true"?true:e==="false"?false:e==="null"?null:!c.isNaN(e)?parseFloat(e):Oa.test(e)?c.parseJSON(e):e}catch(f){}else e=A}}return e===A&&d[1]?this.data(d[0]):e}else return this.each(function(){var h=c(this),k=[d[0],b];h.triggerHandler("setData"+d[1]+"!",k);c.data(this,a,b);h.triggerHandler("changeData"+d[1]+"!",k)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var e=c.data(a,b);if(!d)return e||
46[];if(!e||c.isArray(d))e=c.data(a,b,c.makeArray(d));else e.push(d);return e}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),e=d.shift();if(e==="inprogress")e=d.shift();if(e){b==="fx"&&d.unshift("inprogress");e.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===A)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,
47a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var qa=/[\n\t]/g,ga=/\s+/,Pa=/\r/g,Qa=/^(?:href|src|style)$/,Ra=/^(?:button|input)$/i,Sa=/^(?:button|input|object|select|textarea)$/i,Ta=/^a(?:rea)?$/i,ra=/^(?:radio|checkbox)$/i;c.fn.extend({attr:function(a,b){return c.access(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,
48a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(s){var v=c(this);v.addClass(a.call(this,s,v.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ga),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===1)if(f.className){for(var h=" "+f.className+" ",k=f.className,l=0,n=b.length;l<n;l++)if(h.indexOf(" "+b[l]+" ")<0)k+=" "+b[l];f.className=c.trim(k)}else f.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(n){var s=
49c(this);s.removeClass(a.call(this,n,s.attr("class")))});if(a&&typeof a==="string"||a===A)for(var b=(a||"").split(ga),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===1&&f.className)if(a){for(var h=(" "+f.className+" ").replace(qa," "),k=0,l=b.length;k<l;k++)h=h.replace(" "+b[k]+" "," ");f.className=c.trim(h)}else f.className=""}return this},toggleClass:function(a,b){var d=typeof a,e=typeof b==="boolean";if(c.isFunction(a))return this.each(function(f){var h=c(this);h.toggleClass(a.call(this,
50f,h.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var f,h=0,k=c(this),l=b,n=a.split(ga);f=n[h++];){l=e?l:!k.hasClass(f);k[l?"addClass":"removeClass"](f)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(qa," ").indexOf(a)>-1)return true;return false},
51val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one";if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h<e;h++){var k=f[h];if(k.selected&&(c.support.optDisabled?!k.disabled:k.getAttribute("disabled")===null)&&(!k.parentNode.disabled||!c.nodeName(k.parentNode,"optgroup"))){a=c(k).val();if(b)return a;d.push(a)}}return d}if(ra.test(b.type)&&
52!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Pa,"")}return A}var l=c.isFunction(a);return this.each(function(n){var s=c(this),v=a;if(this.nodeType===1){if(l)v=a.call(this,n,s.val());if(v==null)v="";else if(typeof v==="number")v+="";else if(c.isArray(v))v=c.map(v,function(D){return D==null?"":D+""});if(c.isArray(v)&&ra.test(this.type))this.checked=c.inArray(s.val(),v)>=0;else if(c.nodeName(this,"select")){var B=c.makeArray(v);c("option",this).each(function(){this.selected=
53c.inArray(c(this).val(),B)>=0});if(!B.length)this.selectedIndex=-1}else this.value=v}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return A;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==A;b=e&&c.props[b]||b;if(a.nodeType===1){var h=Qa.test(b);if((b in a||a[b]!==A)&&e&&!h){if(f){b==="type"&&Ra.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
54if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Sa.test(a.nodeName)||Ta.test(a.nodeName)&&a.href?0:A;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return A;a=!c.support.hrefNormalized&&e&&
55h?a.getAttribute(b,2):a.getAttribute(b);return a===null?A:a}}});var X=/\.(.*)$/,ha=/^(?:textarea|input|select)$/i,Ha=/\./g,Ia=/ /g,Ua=/[^\w\s.|`]/g,Va=function(a){return a.replace(Ua,"\\$&")},sa={focusin:0,focusout:0};c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var k=a.nodeType?"events":"__events__",l=h[k],n=h.handle;if(typeof l===
56"function"){n=l.handle;l=l.events}else if(!l){a.nodeType||(h[k]=h=function(){});h.events=l={}}if(!n)h.handle=n=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(n.elem,arguments):A};n.elem=a;b=b.split(" ");for(var s=0,v;k=b[s++];){h=f?c.extend({},f):{handler:d,data:e};if(k.indexOf(".")>-1){v=k.split(".");k=v.shift();h.namespace=v.slice(0).sort().join(".")}else{v=[];h.namespace=""}h.type=k;if(!h.guid)h.guid=d.guid;var B=l[k],D=c.event.special[k]||{};if(!B){B=l[k]=[];
57if(!D.setup||D.setup.call(a,e,v,n)===false)if(a.addEventListener)a.addEventListener(k,n,false);else a.attachEvent&&a.attachEvent("on"+k,n)}if(D.add){D.add.call(a,h);if(!h.handler.guid)h.handler.guid=d.guid}B.push(h);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,k=0,l,n,s,v,B,D,H=a.nodeType?"events":"__events__",w=c.data(a),G=w&&w[H];if(w&&G){if(typeof G==="function"){w=G;G=G.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||
58typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in G)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[k++];){v=f;l=f.indexOf(".")<0;n=[];if(!l){n=f.split(".");f=n.shift();s=RegExp("(^|\\.)"+c.map(n.slice(0).sort(),Va).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(B=G[f])if(d){v=c.event.special[f]||{};for(h=e||0;h<B.length;h++){D=B[h];if(d.guid===D.guid){if(l||s.test(D.namespace)){e==null&&B.splice(h--,1);v.remove&&v.remove.call(a,D)}if(e!=null)break}}if(B.length===0||e!=null&&B.length===1){if(!v.teardown||
59v.teardown.call(a,n)===false)c.removeEvent(a,f,w.handle);delete G[f]}}else for(h=0;h<B.length;h++){D=B[h];if(l||s.test(D.namespace)){c.event.remove(a,v,D.handler,h);B.splice(h--,1)}}}if(c.isEmptyObject(G)){if(b=w.handle)b.elem=null;delete w.events;delete w.handle;if(typeof w==="function")c.removeData(a,H);else c.isEmptyObject(w)&&c.removeData(a)}}}}},trigger:function(a,b,d,e){var f=a.type||a;if(!e){a=typeof a==="object"?a[c.expando]?a:c.extend(c.Event(f),a):c.Event(f);if(f.indexOf("!")>=0){a.type=
60f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return A;a.result=A;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===
61false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){e=a.target;var k,l=f.replace(X,""),n=c.nodeName(e,"a")&&l==="click",s=c.event.special[l]||{};if((!s._default||s._default.call(d,a)===false)&&!n&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[l]){if(k=e["on"+l])e["on"+l]=null;c.event.triggered=true;e[l]()}}catch(v){}if(k)e["on"+l]=k;c.event.triggered=false}}},handle:function(a){var b,d,e;
62d=[];var f,h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var k=d.length;f<k;f++){var l=d[f];if(b||e.test(l.namespace)){a.handler=l.handler;a.data=
63l.data;a.handleObj=l;l=l.handler.apply(this,h);if(l!==A){a.result=l;if(l===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
64fix:function(a){if(a[c.expando])return a;var b=a;a=c.Event(b);for(var d=this.props.length,e;d;){e=this.props[--d];a[e]=b[e]}if(!a.target)a.target=a.srcElement||u;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=u.documentElement;d=u.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
65d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(a.which==null&&(a.charCode!=null||a.keyCode!=null))a.which=a.charCode!=null?a.charCode:a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==A)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,Y(a.origType,a.selector),c.extend({},a,{handler:Ga,guid:a.handler.guid}))},remove:function(a){c.event.remove(this,
66Y(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,d){if(c.isWindow(this))this.onbeforeunload=d},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.removeEvent=u.removeEventListener?function(a,b,d){a.removeEventListener&&a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent&&a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=
67c.now();this[c.expando]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=ba;var a=this.originalEvent;if(a)if(a.preventDefault)a.preventDefault();else a.returnValue=false},stopPropagation:function(){this.isPropagationStopped=ba;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ba;this.stopPropagation()},isDefaultPrevented:U,isPropagationStopped:U,isImmediatePropagationStopped:U};
68var ta=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},ua=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?ua:ta,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?ua:ta)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(){if(this.nodeName.toLowerCase()!==
69"form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length){a.liveFired=A;return ja("submit",this,arguments)}});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13){a.liveFired=A;return ja("submit",this,arguments)}})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};if(!c.support.changeBubbles){var V,
70va=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ha.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=va(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===A||f===e))if(e!=null||f){a.type="change";a.liveFired=
71A;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",va(a))}},setup:function(){if(this.type===
72"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ha.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ha.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}u.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){sa[b]++===0&&u.addEventListener(a,d,true)},teardown:function(){--sa[b]===
730&&u.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=A}var k=b==="one"?c.proxy(f,function(n){c(this).unbind(n,k);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var l=this.length;h<l;h++)c.event.add(this[h],d,k,e)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault)for(var d in a)this.unbind(d,
74a[d]);else{d=0;for(var e=this.length;d<e;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,e){return this.live(b,d,e,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){var d=c.Event(a);d.preventDefault();d.stopPropagation();c.event.trigger(d,b,this[0]);return d.result}},toggle:function(a){for(var b=arguments,d=
751;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(e){var f=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,f+1);e.preventDefault();return b[f].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var wa={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,e,f,h){var k,l=0,n,s,v=h||this.selector;h=h?this:c(this.context);if(typeof d===
76"object"&&!d.preventDefault){for(k in d)h[b](k,e,d[k],v);return this}if(c.isFunction(e)){f=e;e=A}for(d=(d||"").split(" ");(k=d[l++])!=null;){n=X.exec(k);s="";if(n){s=n[0];k=k.replace(X,"")}if(k==="hover")d.push("mouseenter"+s,"mouseleave"+s);else{n=k;if(k==="focus"||k==="blur"){d.push(wa[k]+s);k+=s}else k=(wa[k]||k)+s;if(b==="live"){s=0;for(var B=h.length;s<B;s++)c.event.add(h[s],"live."+Y(k,v),{data:e,selector:v,handler:f,origType:k,origHandler:f,preType:n})}else h.unbind("live."+Y(k,v),f)}}return this}});
77c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d,e){if(e==null){e=d;d=null}return arguments.length>0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});
78(function(){function a(g,j,o,m,p,q){p=0;for(var t=m.length;p<t;p++){var x=m[p];if(x){x=x[g];for(var C=false;x;){if(x.sizcache===o){C=m[x.sizset];break}if(x.nodeType===1&&!q){x.sizcache=o;x.sizset=p}if(x.nodeName.toLowerCase()===j){C=x;break}x=x[g]}m[p]=C}}}function b(g,j,o,m,p,q){p=0;for(var t=m.length;p<t;p++){var x=m[p];if(x){x=x[g];for(var C=false;x;){if(x.sizcache===o){C=m[x.sizset];break}if(x.nodeType===1){if(!q){x.sizcache=o;x.sizset=p}if(typeof j!=="string"){if(x===j){C=true;break}}else if(l.filter(j,
79[x]).length>0){C=x;break}}x=x[g]}m[p]=C}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,k=true;[0,0].sort(function(){k=false;return 0});var l=function(g,j,o,m){o=o||[];var p=j=j||u;if(j.nodeType!==1&&j.nodeType!==9)return[];if(!g||typeof g!=="string")return o;var q=[],t,x,C,P,N=true,R=l.isXML(j),Q=g,L;do{d.exec("");if(t=d.exec(Q)){Q=t[3];q.push(t[1]);if(t[2]){P=t[3];
80break}}}while(t);if(q.length>1&&s.exec(g))if(q.length===2&&n.relative[q[0]])x=M(q[0]+q[1],j);else for(x=n.relative[q[0]]?[j]:l(q.shift(),j);q.length;){g=q.shift();if(n.relative[g])g+=q.shift();x=M(g,x)}else{if(!m&&q.length>1&&j.nodeType===9&&!R&&n.match.ID.test(q[0])&&!n.match.ID.test(q[q.length-1])){t=l.find(q.shift(),j,R);j=t.expr?l.filter(t.expr,t.set)[0]:t.set[0]}if(j){t=m?{expr:q.pop(),set:D(m)}:l.find(q.pop(),q.length===1&&(q[0]==="~"||q[0]==="+")&&j.parentNode?j.parentNode:j,R);x=t.expr?l.filter(t.expr,
81t.set):t.set;if(q.length>0)C=D(x);else N=false;for(;q.length;){t=L=q.pop();if(n.relative[L])t=q.pop();else L="";if(t==null)t=j;n.relative[L](C,t,R)}}else C=[]}C||(C=x);C||l.error(L||g);if(f.call(C)==="[object Array]")if(N)if(j&&j.nodeType===1)for(g=0;C[g]!=null;g++){if(C[g]&&(C[g]===true||C[g].nodeType===1&&l.contains(j,C[g])))o.push(x[g])}else for(g=0;C[g]!=null;g++)C[g]&&C[g].nodeType===1&&o.push(x[g]);else o.push.apply(o,C);else D(C,o);if(P){l(P,p,o,m);l.uniqueSort(o)}return o};l.uniqueSort=function(g){if(w){h=
82k;g.sort(w);if(h)for(var j=1;j<g.length;j++)g[j]===g[j-1]&&g.splice(j--,1)}return g};l.matches=function(g,j){return l(g,null,null,j)};l.matchesSelector=function(g,j){return l(j,null,null,[g]).length>0};l.find=function(g,j,o){var m;if(!g)return[];for(var p=0,q=n.order.length;p<q;p++){var t=n.order[p],x;if(x=n.leftMatch[t].exec(g)){var C=x[1];x.splice(1,1);if(C.substr(C.length-1)!=="\\"){x[1]=(x[1]||"").replace(/\\/g,"");m=n.find[t](x,j,o);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=j.getElementsByTagName("*"));
83return{set:m,expr:g}};l.filter=function(g,j,o,m){for(var p=g,q=[],t=j,x,C,P=j&&j[0]&&l.isXML(j[0]);g&&j.length;){for(var N in n.filter)if((x=n.leftMatch[N].exec(g))!=null&&x[2]){var R=n.filter[N],Q,L;L=x[1];C=false;x.splice(1,1);if(L.substr(L.length-1)!=="\\"){if(t===q)q=[];if(n.preFilter[N])if(x=n.preFilter[N](x,t,o,q,m,P)){if(x===true)continue}else C=Q=true;if(x)for(var i=0;(L=t[i])!=null;i++)if(L){Q=R(L,x,i,t);var r=m^!!Q;if(o&&Q!=null)if(r)C=true;else t[i]=false;else if(r){q.push(L);C=true}}if(Q!==
84A){o||(t=q);g=g.replace(n.match[N],"");if(!C)return[];break}}}if(g===p)if(C==null)l.error(g);else break;p=g}return t};l.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=l.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
85POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,j){var o=typeof j==="string",m=o&&!/\W/.test(j);o=o&&!m;if(m)j=j.toLowerCase();m=0;for(var p=g.length,q;m<p;m++)if(q=g[m]){for(;(q=q.previousSibling)&&q.nodeType!==1;);g[m]=o||q&&q.nodeName.toLowerCase()===
86j?q||false:q===j}o&&l.filter(j,g,true)},">":function(g,j){var o=typeof j==="string",m,p=0,q=g.length;if(o&&!/\W/.test(j))for(j=j.toLowerCase();p<q;p++){if(m=g[p]){o=m.parentNode;g[p]=o.nodeName.toLowerCase()===j?o:false}}else{for(;p<q;p++)if(m=g[p])g[p]=o?m.parentNode:m.parentNode===j;o&&l.filter(j,g,true)}},"":function(g,j,o){var m=e++,p=b,q;if(typeof j==="string"&&!/\W/.test(j)){q=j=j.toLowerCase();p=a}p("parentNode",j,m,g,q,o)},"~":function(g,j,o){var m=e++,p=b,q;if(typeof j==="string"&&!/\W/.test(j)){q=
87j=j.toLowerCase();p=a}p("previousSibling",j,m,g,q,o)}},find:{ID:function(g,j,o){if(typeof j.getElementById!=="undefined"&&!o)return(g=j.getElementById(g[1]))&&g.parentNode?[g]:[]},NAME:function(g,j){if(typeof j.getElementsByName!=="undefined"){for(var o=[],m=j.getElementsByName(g[1]),p=0,q=m.length;p<q;p++)m[p].getAttribute("name")===g[1]&&o.push(m[p]);return o.length===0?null:o}},TAG:function(g,j){return j.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,j,o,m,p,q){g=" "+g[1].replace(/\\/g,
88"")+" ";if(q)return g;q=0;for(var t;(t=j[q])!=null;q++)if(t)if(p^(t.className&&(" "+t.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))o||m.push(t);else if(o)j[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var j=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=j[1]+(j[2]||1)-0;g[3]=j[3]-0}g[0]=e++;return g},ATTR:function(g,j,o,
89m,p,q){j=g[1].replace(/\\/g,"");if(!q&&n.attrMap[j])g[1]=n.attrMap[j];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,j,o,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=l(g[3],null,null,j);else{g=l.filter(g[3],j,o,true^p);o||m.push.apply(m,g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===
90true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,j,o){return!!l(o[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===
91g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,j){return j===0},last:function(g,j,o,m){return j===m.length-1},even:function(g,j){return j%2===0},odd:function(g,j){return j%2===1},lt:function(g,j,o){return j<o[3]-0},gt:function(g,j,o){return j>o[3]-0},nth:function(g,j,o){return o[3]-
920===j},eq:function(g,j,o){return o[3]-0===j}},filter:{PSEUDO:function(g,j,o,m){var p=j[1],q=n.filters[p];if(q)return q(g,o,j,m);else if(p==="contains")return(g.textContent||g.innerText||l.getText([g])||"").indexOf(j[3])>=0;else if(p==="not"){j=j[3];o=0;for(m=j.length;o<m;o++)if(j[o]===g)return false;return true}else l.error("Syntax error, unrecognized expression: "+p)},CHILD:function(g,j){var o=j[1],m=g;switch(o){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(o===
93"first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":o=j[2];var p=j[3];if(o===1&&p===0)return true;var q=j[0],t=g.parentNode;if(t&&(t.sizcache!==q||!g.nodeIndex)){var x=0;for(m=t.firstChild;m;m=m.nextSibling)if(m.nodeType===1)m.nodeIndex=++x;t.sizcache=q}m=g.nodeIndex-p;return o===0?m===0:m%o===0&&m/o>=0}},ID:function(g,j){return g.nodeType===1&&g.getAttribute("id")===j},TAG:function(g,j){return j==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===
94j},CLASS:function(g,j){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(j)>-1},ATTR:function(g,j){var o=j[1];o=n.attrHandle[o]?n.attrHandle[o](g):g[o]!=null?g[o]:g.getAttribute(o);var m=o+"",p=j[2],q=j[4];return o==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&o!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,j,o,m){var p=n.setFilters[j[2]];
95if(p)return p(g,o,j,m)}}},s=n.match.POS,v=function(g,j){return"\\"+(j-0+1)},B;for(B in n.match){n.match[B]=RegExp(n.match[B].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[B]=RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[B].source.replace(/\\(\d+)/g,v))}var D=function(g,j){g=Array.prototype.slice.call(g,0);if(j){j.push.apply(j,g);return j}return g};try{Array.prototype.slice.call(u.documentElement.childNodes,0)}catch(H){D=function(g,j){var o=j||[],m=0;if(f.call(g)==="[object Array]")Array.prototype.push.apply(o,
96g);else if(typeof g.length==="number")for(var p=g.length;m<p;m++)o.push(g[m]);else for(;g[m];m++)o.push(g[m]);return o}}var w,G;if(u.documentElement.compareDocumentPosition)w=function(g,j){if(g===j){h=true;return 0}if(!g.compareDocumentPosition||!j.compareDocumentPosition)return g.compareDocumentPosition?-1:1;return g.compareDocumentPosition(j)&4?-1:1};else{w=function(g,j){var o=[],m=[],p=g.parentNode,q=j.parentNode,t=p;if(g===j){h=true;return 0}else if(p===q)return G(g,j);else if(p){if(!q)return 1}else return-1;
97for(;t;){o.unshift(t);t=t.parentNode}for(t=q;t;){m.unshift(t);t=t.parentNode}p=o.length;q=m.length;for(t=0;t<p&&t<q;t++)if(o[t]!==m[t])return G(o[t],m[t]);return t===p?G(g,m[t],-1):G(o[t],j,1)};G=function(g,j,o){if(g===j)return o;for(g=g.nextSibling;g;){if(g===j)return-1;g=g.nextSibling}return 1}}l.getText=function(g){for(var j="",o,m=0;g[m];m++){o=g[m];if(o.nodeType===3||o.nodeType===4)j+=o.nodeValue;else if(o.nodeType!==8)j+=l.getText(o.childNodes)}return j};(function(){var g=u.createElement("div"),
98j="script"+(new Date).getTime();g.innerHTML="<a name='"+j+"'/>";var o=u.documentElement;o.insertBefore(g,o.firstChild);if(u.getElementById(j)){n.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:A:[]};n.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}o.removeChild(g);
99o=g=null})();(function(){var g=u.createElement("div");g.appendChild(u.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(j,o){var m=o.getElementsByTagName(j[1]);if(j[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(j){return j.getAttribute("href",2)};g=null})();u.querySelectorAll&&
100function(){var g=l,j=u.createElement("div");j.innerHTML="<p class='TEST'></p>";if(!(j.querySelectorAll&&j.querySelectorAll(".TEST").length===0)){l=function(m,p,q,t){p=p||u;if(!t&&!l.isXML(p))if(p.nodeType===9)try{return D(p.querySelectorAll(m),q)}catch(x){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var C=p.id,P=p.id="__sizzle__";try{return D(p.querySelectorAll("#"+P+" "+m),q)}catch(N){}finally{if(C)p.id=C;else p.removeAttribute("id")}}return g(m,p,q,t)};for(var o in g)l[o]=g[o];
101j=null}}();(function(){var g=u.documentElement,j=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,o=false;try{j.call(u.documentElement,":sizzle")}catch(m){o=true}if(j)l.matchesSelector=function(p,q){try{if(o||!n.match.PSEUDO.test(q))return j.call(p,q)}catch(t){}return l(q,null,null,[p]).length>0}})();(function(){var g=u.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===
1020)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(j,o,m){if(typeof o.getElementsByClassName!=="undefined"&&!m)return o.getElementsByClassName(j[1])};g=null}}})();l.contains=u.documentElement.contains?function(g,j){return g!==j&&(g.contains?g.contains(j):true)}:function(g,j){return!!(g.compareDocumentPosition(j)&16)};l.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var M=function(g,
103j){for(var o=[],m="",p,q=j.nodeType?[j]:j;p=n.match.PSEUDO.exec(g);){m+=p[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;p=0;for(var t=q.length;p<t;p++)l(g,q[p],o);return l.filter(m,o)};c.find=l;c.expr=l.selectors;c.expr[":"]=c.expr.filters;c.unique=l.uniqueSort;c.text=l.getText;c.isXMLDoc=l.isXML;c.contains=l.contains})();var Wa=/Until$/,Xa=/^(?:parents|prevUntil|prevAll)/,Ya=/,/,Ja=/^.[^:#\[\.,]*$/,Za=Array.prototype.slice,$a=c.expr.match.POS;c.fn.extend({find:function(a){for(var b=this.pushStack("",
104"find",a),d=0,e=0,f=this.length;e<f;e++){d=b.length;c.find(a,this[e],b);if(e>0)for(var h=d;h<b.length;h++)for(var k=0;k<d;k++)if(b[k]===b[h]){b.splice(h--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,e=b.length;d<e;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(ka(this,a,false),"not",a)},filter:function(a){return this.pushStack(ka(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,
105b){var d=[],e,f,h=this[0];if(c.isArray(a)){var k={},l,n=1;if(h&&a.length){e=0;for(f=a.length;e<f;e++){l=a[e];k[l]||(k[l]=c.expr.match.POS.test(l)?c(l,b||this.context):l)}for(;h&&h.ownerDocument&&h!==b;){for(l in k){e=k[l];if(e.jquery?e.index(h)>-1:c(h).is(e))d.push({selector:l,elem:h,level:n})}h=h.parentNode;n++}}return d}k=$a.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e<f;e++)for(h=this[e];h;)if(k?k.index(h)>-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||
106!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context):c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});
107c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",
108d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Wa.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||Ya.test(e))&&Xa.test(a))f=f.reverse();return this.pushStack(f,a,Za.call(arguments).join(","))}});
109c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===A||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var xa=/ jQuery\d+="(?:\d+|null)"/g,
110$=/^\s+/,ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,za=/<([\w:]+)/,ab=/<tbody/i,bb=/<|&#?\w+;/,Aa=/<(?:script|object|embed|option|style)/i,Ba=/checked\s*(?:[^=]|=\s*.checked.)/i,cb=/\=([^="'>\s]+\/)>/g,O={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],
111area:[1,"<map>","</map>"],_default:[0,"",""]};O.optgroup=O.option;O.tbody=O.tfoot=O.colgroup=O.caption=O.thead;O.th=O.td;if(!c.support.htmlSerialize)O._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==A)return this.empty().append((this[0]&&this[0].ownerDocument||u).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,
112d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},
113unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=
114c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));
115c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(xa,"").replace(cb,'="$1">').replace($,
116"")],e)[0]}else return this.cloneNode(true)});if(a===true){la(this,b);la(this.find("*"),b.find("*"))}return b},html:function(a){if(a===A)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(xa,""):null;else if(typeof a==="string"&&!Aa.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!O[(za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ya,"<$1></$2>");try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(e){this.empty().append(a)}}else c.isFunction(a)?
117this.each(function(f){var h=c(this);h.html(a.call(this,f,h.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),e=d.html();d.replaceWith(a.call(this,b,e))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,
118true)},domManip:function(a,b,d){var e,f,h=a[0],k=[],l;if(!c.support.checkClone&&arguments.length===3&&typeof h==="string"&&Ba.test(h))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(h))return this.each(function(s){var v=c(this);a[0]=h.call(this,s,b?v.html():A);v.domManip(a,b,d)});if(this[0]){e=h&&h.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:c.buildFragment(a,this,k);l=e.fragment;if(f=l.childNodes.length===1?l=l.firstChild:
119l.firstChild){b=b&&c.nodeName(f,"tr");f=0;for(var n=this.length;f<n;f++)d.call(b?c.nodeName(this[f],"table")?this[f].getElementsByTagName("tbody")[0]||this[f].appendChild(this[f].ownerDocument.createElement("tbody")):this[f]:this[f],f>0||e.cacheable||this.length>1?l.cloneNode(true):l)}k.length&&c.each(k,Ka)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:u;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===u&&!Aa.test(a[0])&&(c.support.checkClone||
120!Ba.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=
121d.length;f<h;f++){var k=(f>0?this.clone(true):this).get();c(d[f])[b](k);e=e.concat(k)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||u;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||u;for(var f=[],h=0,k;(k=a[h])!=null;h++){if(typeof k==="number")k+="";if(k){if(typeof k==="string"&&!bb.test(k))k=b.createTextNode(k);else if(typeof k==="string"){k=k.replace(ya,"<$1></$2>");var l=(za.exec(k)||["",""])[1].toLowerCase(),n=O[l]||O._default,
122s=n[0],v=b.createElement("div");for(v.innerHTML=n[1]+k+n[2];s--;)v=v.lastChild;if(!c.support.tbody){s=ab.test(k);l=l==="table"&&!s?v.firstChild&&v.firstChild.childNodes:n[1]==="<table>"&&!s?v.childNodes:[];for(n=l.length-1;n>=0;--n)c.nodeName(l[n],"tbody")&&!l[n].childNodes.length&&l[n].parentNode.removeChild(l[n])}!c.support.leadingWhitespace&&$.test(k)&&v.insertBefore(b.createTextNode($.exec(k)[0]),v.firstChild);k=v.childNodes}if(k.nodeType)f.push(k);else f=c.merge(f,k)}}if(d)for(h=0;f[h];h++)if(e&&
123c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script"))));d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,k=0,l;(l=a[k])!=null;k++)if(!(l.nodeName&&c.noData[l.nodeName.toLowerCase()]))if(d=l[c.expando]){if((b=e[d])&&b.events)for(var n in b.events)f[n]?
124c.event.remove(l,n):c.removeEvent(l,n,b.handle);if(h)delete l[c.expando];else l.removeAttribute&&l.removeAttribute(c.expando);delete e[d]}}});var Ca=/alpha\([^)]*\)/i,db=/opacity=([^)]*)/,eb=/-([a-z])/ig,fb=/([A-Z])/g,Da=/^-?\d+(?:px)?$/i,gb=/^-?\d/,hb={position:"absolute",visibility:"hidden",display:"block"},La=["Left","Right"],Ma=["Top","Bottom"],W,ib=u.defaultView&&u.defaultView.getComputedStyle,jb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===A)return this;
125return c.access(this,a,b,true,function(d,e,f){return f!==A?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),k=a.style,l=c.cssHooks[h];b=c.cssProps[h]||
126h;if(d!==A){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!l||!("set"in l)||(d=l.set(a,d))!==A)try{k[b]=d}catch(n){}}}else{if(l&&"get"in l&&(f=l.get(a,false,e))!==A)return f;return k[b]}}},css:function(a,b,d){var e,f=c.camelCase(b),h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==A)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=
127e[f]},camelCase:function(a){return a.replace(eb,jb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=ma(d,b,f);else c.swap(d,hb,function(){h=ma(d,b,f)});return h+"px"}},set:function(d,e){if(Da.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return db.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":
128b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f=d.filter||"";d.filter=Ca.test(f)?f.replace(Ca,e):d.filter+" "+e}};if(ib)W=function(a,b,d){var e;d=d.replace(fb,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return A;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};else if(u.documentElement.currentStyle)W=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],
129h=a.style;if(!Da.test(f)&&gb.test(f)){d=h.left;e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f};if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var kb=c.now(),lb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
130mb=/^(?:select|textarea)/i,nb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,ob=/^(?:GET|HEAD|DELETE)$/,Na=/\[\]$/,T=/\=\?(&|$)/,ia=/\?/,pb=/([?&])_=[^&]*/,qb=/^(\w+:)?\/\/([^\/?#]+)/,rb=/%20/g,sb=/#.*$/,Ea=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ea)return Ea.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=
131b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(k,l){if(l==="success"||l==="notmodified")h.html(f?c("<div>").append(k.responseText.replace(lb,"")).find(f):k.responseText);d&&h.each(d,[k.responseText,l,k])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&
132!this.disabled&&(this.checked||mb.test(this.nodeName)||nb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})},
133getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html",
134script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),k=ob.test(h);b.url=b.url.replace(sb,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ia.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data||
135!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+kb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var l=E[d];E[d]=function(m){f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);if(c.isFunction(l))l(m);else{E[d]=A;try{delete E[d]}catch(p){}}v&&v.removeChild(B)}}if(b.dataType==="script"&&b.cache===null)b.cache=
136false;if(b.cache===false&&h==="GET"){var n=c.now(),s=b.url.replace(pb,"$1_="+n);b.url=s+(s===b.url?(ia.test(b.url)?"&":"?")+"_="+n:"")}if(b.data&&h==="GET")b.url+=(ia.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");n=(n=qb.exec(b.url))&&(n[1]&&n[1]!==location.protocol||n[2]!==location.host);if(b.dataType==="script"&&h==="GET"&&n){var v=u.getElementsByTagName("head")[0]||u.documentElement,B=u.createElement("script");if(b.scriptCharset)B.charset=b.scriptCharset;B.src=
137b.url;if(!d){var D=false;B.onload=B.onreadystatechange=function(){if(!D&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){D=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);B.onload=B.onreadystatechange=null;v&&B.parentNode&&v.removeChild(B)}}}v.insertBefore(B,v.firstChild);return A}var H=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!k||a&&a.contentType)w.setRequestHeader("Content-Type",
138b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}n||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(G){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&&
139c.triggerGlobal(b,"ajaxSend",[w,b]);var M=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){H||c.handleComplete(b,w,e,f);H=true;if(w)w.onreadystatechange=c.noop}else if(!H&&w&&(w.readyState===4||m==="timeout")){H=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d||
140c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&g.call&&g.call(w);M("abort")}}catch(j){}b.async&&b.timeout>0&&setTimeout(function(){w&&!H&&M("timeout")},b.timeout);try{w.send(k||b.data==null?null:b.data)}catch(o){c.handleError(b,w,null,o);c.handleComplete(b,w,e,f)}b.async||M();return w}},param:function(a,b){var d=[],e=function(h,k){k=c.isFunction(k)?k():k;d[d.length]=encodeURIComponent(h)+
141"="+encodeURIComponent(k)};if(b===A)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)ca(f,a[f],b,e);return d.join("&").replace(rb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess",[b,a])},handleComplete:function(a,
142b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),e=a.getResponseHeader("Etag");
143if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}});if(E.ActiveXObject)c.ajaxSettings.xhr=
144function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var da={},tb=/^(?:toggle|show|hide)$/,ub=/^([+\-]=)?([\d+.\-]+)(.*)$/,aa,na=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show",3),a,b,d);else{a=
1450;for(b=this.length;a<b;a++){if(!c.data(this[a],"olddisplay")&&this[a].style.display==="none")this[a].style.display="";this[a].style.display===""&&c.css(this[a],"display")==="none"&&c.data(this[a],"olddisplay",oa(this[a].nodeName))}for(a=0;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b,d){if(a||a===0)return this.animate(S("hide",3),a,b,d);else{a=0;for(b=this.length;a<b;a++){d=c.css(this[a],"display");d!=="none"&&c.data(this[a],"olddisplay",d)}for(a=
1460;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b,d){var e=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||e?this.each(function(){var f=e?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(S("toggle",3),a,b,d);return this},fadeTo:function(a,b,d,e){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d,e)},animate:function(a,b,d,e){var f=c.speed(b,d,e);if(c.isEmptyObject(a))return this.each(f.complete);
147return this[f.queue===false?"each":"queue"](function(){var h=c.extend({},f),k,l=this.nodeType===1,n=l&&c(this).is(":hidden"),s=this;for(k in a){var v=c.camelCase(k);if(k!==v){a[v]=a[k];delete a[k];k=v}if(a[k]==="hide"&&n||a[k]==="show"&&!n)return h.complete.call(this);if(l&&(k==="height"||k==="width")){h.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(c.css(this,"display")==="inline"&&c.css(this,"float")==="none")if(c.support.inlineBlockNeedsLayout)if(oa(this.nodeName)===
148"inline")this.style.display="inline-block";else{this.style.display="inline";this.style.zoom=1}else this.style.display="inline-block"}if(c.isArray(a[k])){(h.specialEasing=h.specialEasing||{})[k]=a[k][1];a[k]=a[k][0]}}if(h.overflow!=null)this.style.overflow="hidden";h.curAnim=c.extend({},a);c.each(a,function(B,D){var H=new c.fx(s,h,B);if(tb.test(D))H[D==="toggle"?n?"show":"hide":D](a);else{var w=ub.exec(D),G=H.cur(true)||0;if(w){var M=parseFloat(w[2]),g=w[3]||"px";if(g!=="px"){c.style(s,B,(M||1)+g);
149G=(M||1)/H.cur(true)*G;c.style(s,B,G+g)}if(w[1])M=(w[1]==="-="?-1:1)*M+G;H.custom(G,M,g)}else H.custom(G,D,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var e=d.length-1;e>=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b,
150d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a*
151Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(h){return f.step(h)}
152this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var f=this;a=c.fx;e.elem=this.elem;if(e()&&c.timers.push(e)&&!aa)aa=setInterval(a.tick,a.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;
153this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(l,n){f.style["overflow"+n]=h.overflow[l]})}this.options.hide&&c(this.elem).hide();if(this.options.hide||
154this.options.show)for(var k in this.options.curAnim)c.style(this.elem,k,this.options.orig[k]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=
155c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},interval:13,stop:function(){clearInterval(aa);aa=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===
156b.elem}).length};var vb=/^t(?:able|d|h)$/i,Fa=/^(?:body|html)$/i;c.fn.offset="getBoundingClientRect"in u.documentElement?function(a){var b=this[0],d;if(a)return this.each(function(k){c.offset.setOffset(this,a,k)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);try{d=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,h=f.documentElement;if(!d||!c.contains(h,b))return d||{top:0,left:0};b=f.body;f=ea(f);return{top:d.top+(f.pageYOffset||c.support.boxModel&&
157h.scrollTop||b.scrollTop)-(h.clientTop||b.clientTop||0),left:d.left+(f.pageXOffset||c.support.boxModel&&h.scrollLeft||b.scrollLeft)-(h.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(s){c.offset.setOffset(this,a,s)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,e=b.ownerDocument,f,h=e.documentElement,k=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;
158for(var l=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==k&&b!==h;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;f=e?e.getComputedStyle(b,null):b.currentStyle;l-=b.scrollTop;n-=b.scrollLeft;if(b===d){l+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&vb.test(b.nodeName))){l+=parseFloat(f.borderTopWidth)||0;n+=parseFloat(f.borderLeftWidth)||0}d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&f.overflow!=="visible"){l+=
159parseFloat(f.borderTopWidth)||0;n+=parseFloat(f.borderLeftWidth)||0}f=f}if(f.position==="relative"||f.position==="static"){l+=k.offsetTop;n+=k.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){l+=Math.max(h.scrollTop,k.scrollTop);n+=Math.max(h.scrollLeft,k.scrollLeft)}return{top:l,left:n}};c.offset={initialize:function(){var a=u.body,b=u.createElement("div"),d,e,f,h=parseFloat(c.css(a,"marginTop"))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",
160height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);d=b.firstChild;e=d.firstChild;f=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=e.offsetTop!==5;this.doesAddBorderForTableAndCells=
161f.offsetTop===5;e.style.position="fixed";e.style.top="20px";this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15;e.style.position=e.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==h;a.removeChild(b);c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.css(a,
162"marginTop"))||0;d+=parseFloat(c.css(a,"marginLeft"))||0}return{top:b,left:d}},setOffset:function(a,b,d){var e=c.css(a,"position");if(e==="static")a.style.position="relative";var f=c(a),h=f.offset(),k=c.css(a,"top"),l=c.css(a,"left"),n=e==="absolute"&&c.inArray("auto",[k,l])>-1;e={};var s={};if(n)s=f.position();k=n?s.top:parseInt(k,10)||0;l=n?s.left:parseInt(l,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+k;if(b.left!=null)e.left=b.left-h.left+l;"using"in b?b.using.call(a,
163e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Fa.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||u.body;a&&!Fa.test(a.nodeName)&&
164c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==A)return this.each(function(){if(h=ea(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=ea(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();
165c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(h){var k=c(this);k[d](e.call(this,h,k[d]()))});return c.isWindow(f)?f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b]:f.nodeType===9?Math.max(f.documentElement["client"+
166b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]):e===A?parseFloat(c.css(f,d)):this.css(d,typeof e==="string"?e:e+"px")}})})(window);
0167
=== added directory 'webapp/graphite/graphlot'
=== added file 'webapp/graphite/graphlot/__init__.py'
=== added file 'webapp/graphite/graphlot/urls.py'
--- webapp/graphite/graphlot/urls.py 1970-01-01 00:00:00 +0000
+++ webapp/graphite/graphlot/urls.py 2010-11-01 18:48:50 +0000
@@ -0,0 +1,21 @@
1"""Copyright 2008 Orbitz WorldWide
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License."""
14
15from django.conf.urls.defaults import *
16
17urlpatterns = patterns('graphite.graphlot.views',
18 ('^rawdata$', 'get_data'),
19 ('^findmetric$', 'find_metric'),
20 ('^graphlot$', 'graphlot_render'),
21)
022
=== added file 'webapp/graphite/graphlot/views.py'
--- webapp/graphite/graphlot/views.py 1970-01-01 00:00:00 +0000
+++ webapp/graphite/graphlot/views.py 2010-11-01 18:48:50 +0000
@@ -0,0 +1,252 @@
1import re
2
3from django.shortcuts import render_to_response
4from django.http import HttpResponse, Http404
5from django.conf import settings
6import simplejson
7
8from graphite.render.views import parseOptions
9from graphite.render.evaluator import evaluateTarget
10
11
12def graphlot_render(request):
13 """Render the main graphlot view."""
14 metrics = []
15 for target in request.GET.getlist('target'):
16 metrics.append(dict(name=target, yaxis="one"))
17 for target in request.GET.getlist('y2target'):
18 metrics.append(dict(name=target, yaxis="two"))
19
20 untiltime = request.GET.get('until', "-0hour")
21 fromtime = request.GET.get('from', "-24hour")
22 context = dict(metric_list=metrics, fromtime=fromtime, untiltime=untiltime)
23 return render_to_response("graphlot.html", context)
24
25def get_data(request):
26 """Get the data for one series."""
27 (graphOptions, requestOptions) = parseOptions(request)
28 requestContext = {
29 'startTime' : requestOptions['startTime'],
30 'endTime' : requestOptions['endTime'],
31 'data' : []
32 }
33 target = requestOptions['targets'][0]
34 seriesList = evaluateTarget(requestContext, target)
35 result = [ dict(
36 name=timeseries.name,
37 data=[ x for x in timeseries ],
38 start=timeseries.start,
39 end=timeseries.end,
40 step=timeseries.step,
41 ) for timeseries in seriesList ]
42 if not result:
43 raise Http404
44 return HttpResponse(simplejson.dumps(result), mimetype="application/json")
45
46def find_metric(request):
47 """Autocomplete helper on metric names."""
48 try:
49 query = str( request.REQUEST['q'] )
50 except:
51 return HttpResponseBadRequest(
52 content="Missing required parameter 'q'", mimetype="text/plain")
53
54 store = settings.LOCAL_STORE
55
56 matches = list( store.find(query+"*") )
57 content = "\n".join([node.metric_path for node in matches ])
58 response = HttpResponse(content, mimetype='text/plain')
59
60 return response
61
62def header(request):
63 "View for the header frame of the browser UI"
64 context = {}
65 context['user'] = request.user
66 context['profile'] = getProfile(request)
67 context['documentation_url'] = settings.DOCUMENTATION_URL
68 return render_to_response("browserHeader.html", context)
69
70
71def browser(request):
72 "View for the top-level frame of the browser UI"
73 context = {
74 'queryString' : request.GET.urlencode(),
75 'target' : request.GET.get('target')
76 }
77 if context['queryString']:
78 context['queryString'] = context['queryString'].replace('#','%23')
79 if context['target']:
80 context['target'] = context['target'].replace('#','%23') #js libs terminate a querystring on #
81 return render_to_response("browser.html", context)
82
83
84def search(request):
85 query = request.POST['query']
86 if not query:
87 return HttpResponse("")
88
89 patterns = query.split()
90 regexes = [re.compile(p,re.I) for p in patterns]
91 def matches(s):
92 for regex in regexes:
93 if regex.search(s):
94 return True
95 return False
96
97 results = []
98
99 index_file = open(settings.INDEX_FILE)
100 for line in index_file:
101 if matches(line):
102 results.append( line.strip() )
103 if len(results) >= 100:
104 break
105
106 index_file.close()
107 result_string = ','.join(results)
108 return HttpResponse(result_string, mimetype='text/plain')
109
110
111def myGraphLookup(request):
112 "View for My Graphs navigation"
113 profile = getProfile(request,allowDefault=False)
114 assert profile
115
116 nodes = []
117 leafNode = {
118 'allowChildren' : 0,
119 'expandable' : 0,
120 'leaf' : 1,
121 }
122 branchNode = {
123 'allowChildren' : 1,
124 'expandable' : 1,
125 'leaf' : 0,
126 }
127
128 try:
129 path = str( request.GET['path'] )
130
131 if path:
132 if path.endswith('.'):
133 userpath_prefix = path
134
135 else:
136 userpath_prefix = path + '.'
137
138 else:
139 userpath_prefix = ""
140
141 matches = [ graph for graph in profile.mygraph_set.all().order_by('name') if graph.name.startswith(userpath_prefix) ]
142
143 log.info( "myGraphLookup: username=%s, path=%s, userpath_prefix=%s, %ld graph to process" % (profile.user.username, path, userpath_prefix, len(matches)) )
144 branch_inserted = set()
145 leaf_inserted = set()
146
147 for graph in matches: #Now let's add the matching graph
148 isBranch = False
149 dotPos = graph.name.find( '.', len(userpath_prefix) )
150
151 if dotPos >= 0:
152 isBranch = True
153 name = graph.name[ len(userpath_prefix) : dotPos ]
154 if name in branch_inserted: continue
155 branch_inserted.add(name)
156
157 else:
158 name = graph.name[ len(userpath_prefix): ]
159 if name in leaf_inserted: continue
160 leaf_inserted.add(name)
161
162 node = {'text' : str(name) }
163
164 if isBranch:
165 node.update( { 'id' : str(userpath_prefix + name + '.') } )
166 node.update(branchNode)
167
168 else:
169 node.update( { 'id' : str(userpath_prefix + name), 'graphUrl' : str(graph.url) } )
170 node.update(leafNode)
171
172 nodes.append(node)
173
174 except:
175 log.exception("browser.views.myGraphLookup(): could not complete request.")
176
177 if not nodes:
178 no_graphs = { 'text' : "No saved graphs", 'id' : 'no-click' }
179 no_graphs.update(leafNode)
180 nodes.append(no_graphs)
181
182 return json_response(nodes)
183
184def userGraphLookup(request):
185 "View for User Graphs navigation"
186 username = request.GET['path']
187 nodes = []
188
189 branchNode = {
190 'allowChildren' : 1,
191 'expandable' : 1,
192 'leaf' : 0,
193 }
194 leafNode = {
195 'allowChildren' : 0,
196 'expandable' : 0,
197 'leaf' : 1,
198 }
199
200 try:
201
202 if not username:
203 profiles = Profile.objects.exclude(user=defaultUser)
204
205 for profile in profiles:
206 if profile.mygraph_set.count():
207 node = {
208 'text' : str(profile.user.username),
209 'id' : str(profile.user.username)
210 }
211
212 node.update(branchNode)
213 nodes.append(node)
214
215 else:
216 profile = getProfileByUsername(username)
217 assert profile, "No profile for username '%s'" % username
218
219 for graph in profile.mygraph_set.all().order_by('name'):
220 node = {
221 'text' : str(graph.name),
222 'id' : str(graph.name),
223 'graphUrl' : str(graph.url)
224 }
225 node.update(leafNode)
226 nodes.append(node)
227
228 except:
229 log.exception("browser.views.userLookup(): could not complete request for %s" % username)
230
231 if not nodes:
232 no_graphs = { 'text' : "No saved graphs", 'id' : 'no-click' }
233 no_graphs.update(leafNode)
234 nodes.append(no_graphs)
235
236 return json_response(nodes)
237
238
239def json_response(nodes):
240 #json = str(nodes) #poor man's json encoder for simple types
241 json_data = json.dumps(nodes)
242 response = HttpResponse(json_data,mimetype="application/json")
243 response['Pragma'] = 'no-cache'
244 response['Cache-Control'] = 'no-cache'
245 return response
246
247
248def any(iterable): #python2.4 compatibility
249 for i in iterable:
250 if i:
251 return True
252 return False
0253
=== added file 'webapp/graphite/templates/graphlot.html'
--- webapp/graphite/templates/graphlot.html 1970-01-01 00:00:00 +0000
+++ webapp/graphite/templates/graphlot.html 2010-11-01 18:48:50 +0000
@@ -0,0 +1,99 @@
1{% autoescape off %}
2
3<html>
4 <head>
5 <title>Graphlot</title>
6 <script type="text/javascript" src="../content/js/jquery.js"></script>
7 <script type="text/javascript" src="../content/js/jquery.flot.js"></script>
8 <script type="text/javascript" src="../content/js/jquery.autocomplete.js"></script>
9 <script type="text/javascript" src="../content/js/jquery.flot.selection.js"></script>
10 <script type="text/javascript" src="../content/js/jquery.flot.crosshair.js"></script>
11 <script type="text/javascript" src="../content/js/jquery.graphite.js"></script>
12
13 <link rel="stylesheet" type="text/css" href="../content/css/jquery.autocomplete.css" />
14 <link rel="stylesheet" type="text/css" href="../content/css/table.css" />
15
16 <script type="text/javascript">
17
18 $(document).ready(function () {
19 $('.graphite').graphiteGraph();
20 });
21
22 </script>
23
24
25 <style type="text/css">
26 body {
27 font-family: sans-serif;
28 font-size: 16px;
29 margin: 50px;
30 max-width: 1200px;
31 }
32
33 .ajaxerror {
34 background: #ff0000;
35 }
36 .ajaxworking {
37 background: #0000ff;
38 }
39 </style>
40
41
42 </head>
43 <body>
44 <div id="title" style="text-align:center">
45 <h1>graphlot</h1>
46 </div>
47 <div class="graphite">
48 <div id="main" >
49 <div id="canvas" style="padding:15px">
50 <div id="graphcontainer" style=float:left;">
51 <div id="graph" style="width:600px;height:300px"></div>
52 <div id="overview" style="width:600px;height:66px"></div>
53 </div>
54 <div id="side" style="float:left">
55 <p id="legend" style="margin-left:10px"></p>
56 </div>
57 <p style="clear:left">&nbsp</p>
58 </div>
59 <br/>
60
61 <table id="rowlist" class="styledtable" style="float:left">
62 <tr><th style="width:750px">metric</th><th>y-axis</th></tr>
63 {% for metric in metric_list %}
64 <tr class="metricrow">
65 <td><a href=#><span class="metricName">{{metric.name}}</span></a>
66 </td>
67 <td><a href=#><span class="yaxis">{{metric.yaxis}}</span></a>
68 </td>
69 <td class="killrow"><img src="../content/img/delete.png">
70 </td>
71 </tr>
72 {% endfor %}
73
74 <tr id="newmetricrow"><td><input style="width:600px" type="text" id="newmetric"/></td></tr>
75 </table>
76
77 <table id="bounds" class="styledtable" style="float:right">
78 <tr><th>From</th><th>To</th></tr>
79 <tr>
80 <td><a href=#><span id="from">{{fromtime}}</span></a></td>
81 <td><a href=#><span id="until">{{untiltime}}</span></a></td>
82 </tr>
83 <tr> <td colspan="2" style="text-align:center">
84 <a href=#><span id="update">update</span></a>
85 </td></tr>
86 <tr> <td colspan="2" style="text-align:center">
87 <a href=#><span id="clearzoom">clear zoom</span></a>
88 </td></tr>
89 <tr> <td colspan="2" style="text-align:center">
90 <a href=# id="graphurl">link to graph</a>
91 </td></tr>
92 </table>
93 </div>
94
95 </div>
96 </body>
97</html>
98
99{% endautoescape %}
0\ No newline at end of file100\ No newline at end of file
1101
=== modified file 'webapp/graphite/urls.py'
--- webapp/graphite/urls.py 2009-11-12 03:35:45 +0000
+++ webapp/graphite/urls.py 2010-11-01 18:48:50 +0000
@@ -28,6 +28,7 @@
28 ('^account/?', include('graphite.account.urls')),28 ('^account/?', include('graphite.account.urls')),
29 ('^whitelist/?', include('graphite.whitelist.urls')),29 ('^whitelist/?', include('graphite.whitelist.urls')),
30 ('^content/(?P<path>.*)$', 'django.views.static.serve', {'document_root' : settings.CONTENT_DIR}),30 ('^content/(?P<path>.*)$', 'django.views.static.serve', {'document_root' : settings.CONTENT_DIR}),
31 ('', include('graphite.graphlot.urls')),
31 ('', include('graphite.browser.urls')),32 ('', include('graphite.browser.urls')),
32)33)
3334

Subscribers

People subscribed via source and target branches