subduino 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/Readme.textile +48 -2
  2. data/VERSION +1 -1
  3. data/bin/subduino +21 -5
  4. data/duino/Makefile +53 -50
  5. data/duino/duino.pde +271 -5
  6. data/lib/subduino.rb +1 -1
  7. data/lib/subduino/parse.rb +23 -34
  8. data/lib/subduino/parse/bool.rb +13 -0
  9. data/lib/subduino/parse/lux.rb +13 -0
  10. data/lib/subduino/parse/temp.rb +17 -0
  11. data/lib/subduino/scaffold/Makefile +59 -51
  12. data/lib/subduino/store.rb +21 -12
  13. data/subduino.gemspec +88 -2
  14. data/webapp/config.yml +20 -0
  15. data/webapp/lib/app.rb +2 -2
  16. data/webapp/lib/duino.rb +9 -16
  17. data/webapp/public/custom.js +187 -0
  18. data/webapp/public/date_input.css +149 -0
  19. data/webapp/public/facebox.css +83 -0
  20. data/webapp/public/facebox.js +319 -0
  21. data/webapp/public/favicon.ico +0 -0
  22. data/webapp/public/icons/current.png +0 -0
  23. data/webapp/public/icons/day.png +0 -0
  24. data/webapp/public/icons/door-big.png +0 -0
  25. data/webapp/public/icons/favicon.png +0 -0
  26. data/webapp/public/icons/irrigation.png +0 -0
  27. data/webapp/public/icons/lamp-big.png +0 -0
  28. data/webapp/public/icons/lightbulb_off.png +0 -0
  29. data/webapp/public/icons/locked.png +0 -0
  30. data/webapp/public/icons/lux.png +0 -0
  31. data/webapp/public/icons/night.png +0 -0
  32. data/webapp/public/icons/noise.png +0 -0
  33. data/webapp/public/icons/onoff.png +0 -0
  34. data/webapp/public/icons/rain.png +0 -0
  35. data/webapp/public/icons/refrigeration.png +0 -0
  36. data/webapp/public/icons/temp.png +0 -0
  37. data/webapp/public/icons/unlocked.png +0 -0
  38. data/webapp/public/images/ajax-loader.gif +0 -0
  39. data/webapp/public/images/b.png +0 -0
  40. data/webapp/public/images/bendl.gif +0 -0
  41. data/webapp/public/images/bendr.gif +0 -0
  42. data/webapp/public/images/bendsb.gif +0 -0
  43. data/webapp/public/images/bg.jpg +0 -0
  44. data/webapp/public/images/bhead.gif +0 -0
  45. data/webapp/public/images/bheadl.gif +0 -0
  46. data/webapp/public/images/bheadr.gif +0 -0
  47. data/webapp/public/images/bl.png +0 -0
  48. data/webapp/public/images/bnd.gif +0 -0
  49. data/webapp/public/images/br.png +0 -0
  50. data/webapp/public/images/bread.gif +0 -0
  51. data/webapp/public/images/btnb.gif +0 -0
  52. data/webapp/public/images/btnb_.gif +0 -0
  53. data/webapp/public/images/btnm.gif +0 -0
  54. data/webapp/public/images/btnm_.gif +0 -0
  55. data/webapp/public/images/btns.gif +0 -0
  56. data/webapp/public/images/btns_.gif +0 -0
  57. data/webapp/public/images/cal.jpg +0 -0
  58. data/webapp/public/images/close.png +0 -0
  59. data/webapp/public/images/closelabel.gif +0 -0
  60. data/webapp/public/images/error.gif +0 -0
  61. data/webapp/public/images/ft.gif +0 -0
  62. data/webapp/public/images/hdr.gif +0 -0
  63. data/webapp/public/images/hdrl.gif +0 -0
  64. data/webapp/public/images/hdrr.gif +0 -0
  65. data/webapp/public/images/hld.jpg +0 -0
  66. data/webapp/public/images/imgb.gif +0 -0
  67. data/webapp/public/images/imgo.gif +0 -0
  68. data/webapp/public/images/imgt.gif +0 -0
  69. data/webapp/public/images/info.gif +0 -0
  70. data/webapp/public/images/jquery.wysiwyg.gif +0 -0
  71. data/webapp/public/images/li.gif +0 -0
  72. data/webapp/public/images/mbg.png +0 -0
  73. data/webapp/public/images/nsp.gif +0 -0
  74. data/webapp/public/images/phs.gif +0 -0
  75. data/webapp/public/images/sdd.jpg +0 -0
  76. data/webapp/public/images/sdd_.jpg +0 -0
  77. data/webapp/public/images/sidebar.gif +0 -0
  78. data/webapp/public/images/sorta.gif +0 -0
  79. data/webapp/public/images/sortd.gif +0 -0
  80. data/webapp/public/images/srch.gif +0 -0
  81. data/webapp/public/images/srch_.gif +0 -0
  82. data/webapp/public/images/success.gif +0 -0
  83. data/webapp/public/images/thumb1.jpg +0 -0
  84. data/webapp/public/images/thumb2.jpg +0 -0
  85. data/webapp/public/images/thumb3.jpg +0 -0
  86. data/webapp/public/images/tiny.gif +0 -0
  87. data/webapp/public/images/tiny_.gif +0 -0
  88. data/webapp/public/images/tl.png +0 -0
  89. data/webapp/public/images/tr.png +0 -0
  90. data/webapp/public/images/upload.gif +0 -0
  91. data/webapp/public/images/warning.gif +0 -0
  92. data/webapp/public/jquery.img.preload.js +152 -0
  93. data/webapp/public/jquery.sparkline.js +85 -0
  94. data/webapp/public/jquery.tablesorter.min.js +2 -0
  95. data/webapp/public/jquery.visualize.js +452 -0
  96. data/webapp/public/jquery.wysiwyg.css +56 -0
  97. data/webapp/public/style.css +881 -0
  98. data/webapp/public/visualize.css +32 -0
  99. data/webapp/views/index.haml +365 -49
  100. data/webapp/views/layout.haml +78 -7
  101. data/webapp/views/template.haml +676 -0
  102. metadata +89 -3
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,152 @@
1
+ /**
2
+ * jQuery-Plugin "preloadCssImages"
3
+ * by Scott Jehl, scott@filamentgroup.com
4
+ * http://www.filamentgroup.com
5
+ * reference article: http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/
6
+ * demo page: http://www.filamentgroup.com/examples/preloadImages/index_v2.php
7
+ *
8
+ * Copyright (c) 2008 Filament Group, Inc
9
+ * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
10
+ *
11
+ * Version: 5.0, 10.31.2008
12
+ * Changelog:
13
+ * 02.20.2008 initial Version 1.0
14
+ * 06.04.2008 Version 2.0 : removed need for any passed arguments. Images load from any and all directories.
15
+ * 06.21.2008 Version 3.0 : Added options for loading status. Fixed IE abs image path bug (thanks Sam Pohlenz).
16
+ * 07.24.2008 Version 4.0 : Added support for @imported CSS (credit: http://marcarea.com/). Fixed support in Opera as well.
17
+ * 10.31.2008 Version: 5.0 : Many feature and performance enhancements from trixta
18
+ * --------------------------------------------------------------------
19
+ */
20
+
21
+ ;jQuery.preloadCssImages = function(settings){
22
+ settings = jQuery.extend({
23
+ statusTextEl: null,
24
+ statusBarEl: null,
25
+ errorDelay: 999, // handles 404-Errors in IE
26
+ simultaneousCacheLoading: 2
27
+ }, settings);
28
+ var allImgs = [],
29
+ loaded = 0,
30
+ imgUrls = [],
31
+ thisSheetRules,
32
+ errorTimer;
33
+
34
+ function onImgComplete(){
35
+ clearTimeout(errorTimer);
36
+ if (imgUrls && imgUrls.length && imgUrls[loaded]) {
37
+ loaded++;
38
+ if (settings.statusTextEl) {
39
+ var nowloading = (imgUrls[loaded]) ?
40
+ 'Now Loading: <span>' + imgUrls[loaded].split('/')[imgUrls[loaded].split('/').length - 1] :
41
+ 'Loading complete'; // wrong status-text bug fixed
42
+ jQuery(settings.statusTextEl).html('<span class="numLoaded">' + loaded + '</span> of <span class="numTotal">' + imgUrls.length + '</span> loaded (<span class="percentLoaded">' + (loaded / imgUrls.length * 100).toFixed(0) + '%</span>) <span class="currentImg">' + nowloading + '</span></span>');
43
+ }
44
+ if (settings.statusBarEl) {
45
+ var barWidth = jQuery(settings.statusBarEl).width();
46
+ jQuery(settings.statusBarEl).css('background-position', -(barWidth - (barWidth * loaded / imgUrls.length).toFixed(0)) + 'px 50%');
47
+ }
48
+ loadImgs();
49
+ }
50
+ }
51
+
52
+ function loadImgs(){
53
+ //only load 1 image at the same time / most browsers can only handle 2 http requests, 1 should remain for user-interaction (Ajax, other images, normal page requests...)
54
+ // otherwise set simultaneousCacheLoading to a higher number for simultaneous downloads
55
+ if(imgUrls && imgUrls.length && imgUrls[loaded]){
56
+ var img = new Image(); //new img obj
57
+ img.src = imgUrls[loaded]; //set src either absolute or rel to css dir
58
+ if(!img.complete){
59
+ jQuery(img).bind('error load onreadystatechange', onImgComplete);
60
+ } else {
61
+ onImgComplete();
62
+ }
63
+ errorTimer = setTimeout(onImgComplete, settings.errorDelay); // handles 404-Errors in IE
64
+ }
65
+ }
66
+
67
+ function parseCSS(sheets, urls) {
68
+ var w3cImport = false,
69
+ imported = [],
70
+ importedSrc = [],
71
+ baseURL;
72
+ var sheetIndex = sheets.length;
73
+ while(sheetIndex--){//loop through each stylesheet
74
+
75
+ var cssPile = '';//create large string of all css rules in sheet
76
+
77
+ if(urls && urls[sheetIndex]){
78
+ baseURL = urls[sheetIndex];
79
+ } else {
80
+ var csshref = (sheets[sheetIndex].href) ? sheets[sheetIndex].href : 'window.location.href';
81
+ var baseURLarr = csshref.split('/');//split href at / to make array
82
+ baseURLarr.pop();//remove file path from baseURL array
83
+ baseURL = baseURLarr.join('/');//create base url for the images in this sheet (css file's dir)
84
+ if (baseURL) {
85
+ baseURL += '/'; //tack on a / if needed
86
+ }
87
+ }
88
+ if(sheets[sheetIndex].cssRules || sheets[sheetIndex].rules){
89
+ thisSheetRules = (sheets[sheetIndex].cssRules) ? //->>> http://www.quirksmode.org/dom/w3c_css.html
90
+ sheets[sheetIndex].cssRules : //w3
91
+ sheets[sheetIndex].rules; //ie
92
+ var ruleIndex = thisSheetRules.length;
93
+ while(ruleIndex--){
94
+ if(thisSheetRules[ruleIndex].style && thisSheetRules[ruleIndex].style.cssText){
95
+ var text = thisSheetRules[ruleIndex].style.cssText;
96
+ if(text.toLowerCase().indexOf('url') != -1){ // only add rules to the string if you can assume, to find an image, speed improvement
97
+ cssPile += text; // thisSheetRules[ruleIndex].style.cssText instead of thisSheetRules[ruleIndex].cssText is a huge speed improvement
98
+ }
99
+ } else if(thisSheetRules[ruleIndex].styleSheet) {
100
+ imported.push(thisSheetRules[ruleIndex].styleSheet);
101
+ w3cImport = true;
102
+ }
103
+
104
+ }
105
+ }
106
+ //parse cssPile for image urls
107
+ var tmpImage = cssPile.match(/[^\("]+\.(gif|jpg|jpeg|png)/g);//reg ex to get a string of between a "(" and a ".filename" / '"' for opera-bugfix
108
+ if(tmpImage){
109
+ var i = tmpImage.length;
110
+ while(i--){ // handle baseUrl here for multiple stylesheets in different folders bug
111
+ var imgSrc = (tmpImage[i].charAt(0) == '/' || tmpImage[i].match('://')) ? // protocol-bug fixed
112
+ tmpImage[i] :
113
+ baseURL + tmpImage[i];
114
+
115
+ if(jQuery.inArray(imgSrc, imgUrls) == -1){
116
+ imgUrls.push(imgSrc);
117
+ }
118
+ }
119
+ }
120
+
121
+ if(!w3cImport && sheets[sheetIndex].imports && sheets[sheetIndex].imports.length) {
122
+ for(var iImport = 0, importLen = sheets[sheetIndex].imports.length; iImport < importLen; iImport++){
123
+ var iHref = sheets[sheetIndex].imports[iImport].href;
124
+ iHref = iHref.split('/');
125
+ iHref.pop();
126
+ iHref = iHref.join('/');
127
+ if (iHref) {
128
+ iHref += '/'; //tack on a / if needed
129
+ }
130
+ var iSrc = (iHref.charAt(0) == '/' || iHref.match('://')) ? // protocol-bug fixed
131
+ iHref :
132
+ baseURL + iHref;
133
+
134
+ importedSrc.push(iSrc);
135
+ imported.push(sheets[sheetIndex].imports[iImport]);
136
+ }
137
+
138
+
139
+ }
140
+ }//loop
141
+ if(imported.length){
142
+ parseCSS(imported, importedSrc);
143
+ return false;
144
+ }
145
+ var downloads = settings.simultaneousCacheLoading;
146
+ while( downloads--){
147
+ setTimeout(loadImgs, downloads);
148
+ }
149
+ }
150
+ parseCSS(document.styleSheets);
151
+ return imgUrls;
152
+ };
@@ -0,0 +1,85 @@
1
+ /* jquery.sparkline 1.5.1 - http://omnipotent.net/jquery.sparkline/ */
2
+
3
+ (function($){$.fn.simpledraw=function(width,height,use_existing){if(use_existing&&this[0].vcanvas)return this[0].vcanvas;if(width==undefined)width=$(this).innerWidth();if(height==undefined)height=$(this).innerHeight();if($.browser.hasCanvas){return new vcanvas_canvas(width,height,this);}else if($.browser.msie){return new vcanvas_vml(width,height,this);}else{return false;}};var pending=[];$.fn.sparkline=function(uservalues,options){var options=$.extend({type:'line',lineColor:'#00f',fillColor:'#cdf',defaultPixelsPerValue:3,width:'auto',height:'auto',composite:false},options?options:{});return this.each(function(){var render=function(){var values=(uservalues=='html'||uservalues==undefined)?$(this).text().split(','):uservalues;var width=options.width=='auto'?values.length*options.defaultPixelsPerValue:options.width;if(options.height=='auto'){if(!options.composite||!this.vcanvas){var tmp=document.createElement('span');tmp.innerHTML='a';$(this).html(tmp);height=$(tmp).innerHeight();$(tmp).remove();}}else{height=options.height;}
4
+ $.fn.sparkline[options.type].call(this,values,options,width,height);}
5
+ if(($(this).html()&&$(this).is(':hidden'))||($.fn.jquery<"1.3.0"&&$(this).parents().is(':hidden'))){pending.push([this,render]);}else{render.call(this);}});};$.sparkline_display_visible=function(){for(var i=pending.length-1;i>=0;i--){var el=pending[i][0];if($(el).is(':visible')&&!$(el).parents().is(':hidden')){pending[i][1].call(el);pending.splice(i,1);}}};$.fn.sparkline.line=function(values,options,width,height){var options=$.extend({spotColor:'#f80',spotRadius:1.5,minSpotColor:'#f80',maxSpotColor:'#f80',lineWidth:1,normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:'#ccc',chartRangeMin:undefined,chartRangeMax:undefined,chartRangeMinX:undefined,chartRangeMaxX:undefined},options?options:{});var xvalues=[],yvalues=[],yminmax=[];for(i=0;i<values.length;i++){var v=values[i];var isstr=typeof(values[i])=='string';var isarray=typeof(values[i])=='object'&&values[i]instanceof Array;var sp=isstr&&values[i].split(':');if(isstr&&sp.length==2){xvalues.push(Number(sp[0]));yvalues.push(Number(sp[1]));yminmax.push(Number(sp[1]));}else if(isarray){xvalues.push(values[i][0]);yvalues.push(values[i][1]);yminmax.push(values[i][1]);}else{xvalues.push(i);if(values[i]===null||values[i]=='null'){yvalues.push(null);}else{yvalues.push(Number(values[i]));yminmax.push(Number(values[i]));}}}
6
+ if(options.xvalues){xvalues=options.xvalues;}
7
+ var maxy=Math.max.apply(Math,yminmax);var maxyval=maxy;var miny=Math.min.apply(Math,yminmax);var minyval=miny;var maxx=Math.max.apply(Math,xvalues);var maxxval=maxx;var minx=Math.min.apply(Math,xvalues);var minxval=minx;if(options.normalRangeMin!=undefined){if(options.normalRangeMin<miny)
8
+ miny=options.normalRangeMin;if(options.normalRangeMax>maxy)
9
+ maxy=options.normalRangeMax;}
10
+ if(options.chartRangeMin!=undefined&&(options.chartRangeClip||options.chartRangeMin<miny)){miny=options.chartRangeMin;}
11
+ if(options.chartRangeMax!=undefined&&(options.chartRangeClip||options.chartRangeMax>maxy)){maxy=options.chartRangeMax;}
12
+ if(options.chartRangeMinX!=undefined&&(options.chartRangeClipX||options.chartRangeMinX<minx)){minx=options.chartRangeMinX;}
13
+ if(options.chartRangeMaxX!=undefined&&(options.chartRangeClipX||options.chartRangeMaxX>maxx)){maxx=options.chartRangeMaxX;}
14
+ var rangex=maxx-minx==0?1:maxx-minx;var rangey=maxy-miny==0?1:maxy-miny;var vl=yvalues.length-1;if(vl<1){this.innerHTML='';return;}
15
+ var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var canvas_top=0;var canvas_left=0;if(options.spotRadius&&(canvas_width<(options.spotRadius*4)||canvas_height<(options.spotRadius*4))){options.spotRadius=0;}
16
+ if(options.spotRadius){if(options.minSpotColor||(options.spotColor&&yvalues[vl]==miny))
17
+ canvas_height-=Math.ceil(options.spotRadius);if(options.maxSpotColor||(options.spotColor&&yvalues[vl]==maxy)){canvas_height-=Math.ceil(options.spotRadius);canvas_top+=Math.ceil(options.spotRadius);}
18
+ if(options.minSpotColor||options.maxSpotColor&&(yvalues[0]==miny||yvalues[0]==maxy)){canvas_left+=Math.ceil(options.spotRadius);canvas_width-=Math.ceil(options.spotRadius);}
19
+ if(options.spotColor||(options.minSpotColor||options.maxSpotColor&&(yvalues[vl]==miny||yvalues[vl]==maxy)))
20
+ canvas_width-=Math.ceil(options.spotRadius);}
21
+ canvas_height--;if(options.normalRangeMin!=undefined){var ytop=canvas_top+Math.round(canvas_height-(canvas_height*((options.normalRangeMax-miny)/rangey)));var height=Math.round((canvas_height*(options.normalRangeMax-options.normalRangeMin))/rangey);target.drawRect(canvas_left,ytop,canvas_width,height,undefined,options.normalRangeColor);}
22
+ var path=[];var paths=[path];for(var i=0,vlen=yvalues.length;i<vlen;i++){var x=xvalues[i],y=yvalues[i];if(y===null){if(i){if(yvalues[i-1]!==null){path=[];paths.push(path);}}}else{if(y<miny)y=miny;if(y>maxy)y=maxy;if(!path.length){path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+canvas_height]);}
23
+ path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((y-miny)/rangey)))]);}}
24
+ for(var i=0,plen=paths.length;i<plen;i++){path=paths[i];if(!path.length)
25
+ continue;if(options.fillColor){path.push([path[path.length-1][0],canvas_top+canvas_height-1]);target.drawShape(path,undefined,options.fillColor);path.pop();}
26
+ if(path.length>2){path[0]=[path[0][0],path[1][1]];}
27
+ target.drawShape(path,options.lineColor,undefined,options.lineWidth);}
28
+ if(options.spotRadius&&options.spotColor){target.drawCircle(canvas_left+Math.round(xvalues[xvalues.length-1]*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((yvalues[vl]-miny)/rangey))),options.spotRadius,undefined,options.spotColor);}
29
+ if(maxy!=minyval){if(options.spotRadius&&options.minSpotColor){var x=xvalues[yvalues.indexOf(minyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((minyval-miny)/rangey))),options.spotRadius,undefined,options.minSpotColor);}
30
+ if(options.spotRadius&&options.maxSpotColor){var x=xvalues[yvalues.indexOf(maxyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((maxyval-miny)/rangey))),options.spotRadius,undefined,options.maxSpotColor);}}}else{this.innerHTML='';}};$.fn.sparkline.bar=function(values,options,width,height){var options=$.extend({type:'bar',barColor:'#00f',negBarColor:'#f44',zeroColor:undefined,nullColor:undefined,zeroAxis:undefined,barWidth:4,barSpacing:1,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false,colorMap:undefined},options?options:{});var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);var num_values=[];for(var i=0,vlen=values.length;i<vlen;i++){if(values[i]=='null'||values[i]===null){values[i]=null;}else{values[i]=Number(values[i]);num_values.push(Number(values[i]));}}
31
+ var max=Math.max.apply(Math,num_values);var min=Math.min.apply(Math,num_values);if(options.chartRangeMin!=undefined&&(options.chartRangeClip||options.chartRangeMin<min)){min=options.chartRangeMin;}
32
+ if(options.chartRangeMax!=undefined&&(options.chartRangeClip||options.chartRangeMax>max)){max=options.chartRangeMax;}
33
+ if(options.zeroAxis==undefined)options.zeroAxis=min<0;var range=max-min==0?1:max-min;if($.isArray(options.colorMap)){var colorMapByIndex=options.colorMap;var colorMapByValue=null;}else{var colorMapByIndex=null;var colorMapByValue=options.colorMap;}
34
+ var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var yzero=min<0&&options.zeroAxis?canvas_height-Math.round(canvas_height*(Math.abs(min)/range))-1:canvas_height-1;for(var i=0,vlen=values.length;i<vlen;i++){var x=i*(options.barWidth+options.barSpacing);var val=values[i];if(val===null){if(options.nullColor){color=options.nullColor;val=(options.zeroAxis&&min<0)?0:min;var height=1;var y=(options.zeroAxis&&min<0)?yzero:canvas_height-height;}else{continue;}}else{if(val<min)val=min;if(val>max)val=max;var color=(val<0)?options.negBarColor:options.barColor;if(options.zeroAxis&&min<0){var height=Math.round(canvas_height*((Math.abs(val)/range)))+1;var y=(val<0)?yzero:yzero-height;}else{var height=Math.round(canvas_height*((val-min)/range))+1;var y=canvas_height-height;}
35
+ if(val==0&&options.zeroColor!=undefined){color=options.zeroColor;}
36
+ if(colorMapByValue&&colorMapByValue[val]){color=colorMapByValue[val];}else if(colorMapByIndex&&colorMapByIndex.length>i){color=colorMapByIndex[i];}
37
+ if(color===null){continue;}}
38
+ target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.tristate=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({barWidth:4,barSpacing:1,posBarColor:'#6f6',negBarColor:'#f44',zeroBarColor:'#999',colorMap:{}},options);var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);if($.isArray(options.colorMap)){var colorMapByIndex=options.colorMap;var colorMapByValue=null;}else{var colorMapByIndex=null;var colorMapByValue=options.colorMap;}
39
+ var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var half_height=Math.round(canvas_height/2);for(var i=0,vlen=values.length;i<vlen;i++){var x=i*(options.barWidth+options.barSpacing);if(values[i]<0){var y=half_height;var height=half_height-1;var color=options.negBarColor;}else if(values[i]>0){var y=0;var height=half_height-1;var color=options.posBarColor;}else{var y=half_height-1;var height=2;var color=options.zeroBarColor;}
40
+ if(colorMapByValue&&colorMapByValue[values[i]]){color=colorMapByValue[values[i]];}else if(colorMapByIndex&&colorMapByIndex.length>i){color=colorMapByIndex[i];}
41
+ if(color===null){continue;}
42
+ target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.discrete=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({lineHeight:'auto',thresholdColor:undefined,thresholdValue:0,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false},options);width=options.width=='auto'?values.length*2:width;var interval=Math.floor(width/values.length);var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var line_height=options.lineHeight=='auto'?Math.round(canvas_height*0.3):options.lineHeight;var pheight=canvas_height-line_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.chartRangeMin!=undefined&&(options.chartRangeClip||options.chartRangeMin<min)){min=options.chartRangeMin;}
43
+ if(options.chartRangeMax!=undefined&&(options.chartRangeClip||options.chartRangeMax>max)){max=options.chartRangeMax;}
44
+ var range=max-min;for(var i=0,vlen=values.length;i<vlen;i++){var val=values[i];if(val<min)val=min;if(val>max)val=max;var x=(i*interval);var ytop=Math.round(pheight-pheight*((val-min)/range));target.drawLine(x,ytop,x,ytop+line_height,(options.thresholdColor&&val<options.thresholdValue)?options.thresholdColor:options.lineColor);}}else{this.innerHTML='';}};$.fn.sparkline.bullet=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({targetColor:'red',targetWidth:3,performanceColor:'blue',rangeColors:['#D3DAFE','#A8B6FF','#7F94FF'],base:undefined},options);width=options.width=='auto'?'4.0em':width;var target=$(this).simpledraw(width,height,options.composite);if(target&&values.length>1){var canvas_width=target.pixel_width-Math.ceil(options.targetWidth/2);var canvas_height=target.pixel_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.base==undefined){var min=min<0?min:0;}else{min=options.base;}
45
+ var range=max-min;for(i=2,vlen=values.length;i<vlen;i++){var rangeval=parseInt(values[i]);var rangewidth=Math.round(canvas_width*((rangeval-min)/range));target.drawRect(0,0,rangewidth-1,canvas_height-1,options.rangeColors[i-2],options.rangeColors[i-2]);}
46
+ var perfval=parseInt(values[1]);var perfwidth=Math.round(canvas_width*((perfval-min)/range));target.drawRect(0,Math.round(canvas_height*0.3),perfwidth-1,Math.round(canvas_height*0.4)-1,options.performanceColor,options.performanceColor);var targetval=parseInt(values[0]);var x=Math.round(canvas_width*((targetval-min)/range)-(options.targetWidth/2));var targettop=Math.round(canvas_height*0.10);var targetheight=canvas_height-(targettop*2);target.drawRect(x,targettop,options.targetWidth-1,targetheight-1,options.targetColor,options.targetColor);}else{this.innerHTML='';}};$.fn.sparkline.pie=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({sliceColors:['#f00','#0f0','#00f']},options);width=options.width=='auto'?height:width;var target=$(this).simpledraw(width,height,options.composite);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var radius=Math.floor(Math.min(canvas_width,canvas_height)/2);var total=0;for(var i=0,vlen=values.length;i<vlen;i++)
47
+ total+=values[i];var next=0;if(options.offset){next+=(2*Math.PI)*(options.offset/360);}
48
+ var circle=2*Math.PI;for(var i=0,vlen=values.length;i<vlen;i++){var start=next;var end=next;if(total>0){end=next+(circle*(values[i]/total));}
49
+ target.drawPieSlice(radius,radius,radius,start,end,undefined,options.sliceColors[i%options.sliceColors.length]);next=end;}}};function quartile(values,q){if(q==2){var vl2=Math.floor(values.length/2);return values.length%2?values[vl2]:(values[vl2]+values[vl2+1])/2;}else{var vl4=Math.floor(values.length/4);return values.length%2?(values[vl4*q]+values[vl4*q+1])/2:values[vl4*q];}};$.fn.sparkline.box=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({raw:false,boxLineColor:'black',boxFillColor:'#cdf',whiskerColor:'black',outlierLineColor:'#333',outlierFillColor:'white',medianColor:'red',showOutliers:true,outlierIQR:1.5,spotRadius:1.5,target:undefined,targetColor:'#4a2',chartRangeMax:undefined,chartRangeMin:undefined},options);width=options.width=='auto'?'4.0em':width;minvalue=options.chartRangeMin==undefined?Math.min.apply(Math,values):options.chartRangeMin;maxvalue=options.chartRangeMax==undefined?Math.max.apply(Math,values):options.chartRangeMax;var target=$(this).simpledraw(width,height,options.composite);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;if(options.raw){if(options.showOutliers&&values.length>5){var loutlier=values[0],lwhisker=values[1],q1=values[2],q2=values[3],q3=values[4],rwhisker=values[5],routlier=values[6];}else{var lwhisker=values[0],q1=values[1],q2=values[2],q3=values[3],rwhisker=values[4];}}else{values.sort(function(a,b){return a-b;});var q1=quartile(values,1);var q2=quartile(values,2);var q3=quartile(values,3);var iqr=q3-q1;if(options.showOutliers){var lwhisker=undefined,rwhisker=undefined;for(var i=0,vlen=values.length;i<vlen;i++){if(lwhisker==undefined&&values[i]>q1-(iqr*options.outlierIQR))
50
+ lwhisker=values[i];if(values[i]<q3+(iqr*options.outlierIQR))
51
+ rwhisker=values[i];}
52
+ var loutlier=values[0];var routlier=values[values.length-1];}else{var lwhisker=values[0];var rwhisker=values[values.length-1];}}
53
+ var unitsize=canvas_width/(maxvalue-minvalue+1);var canvas_left=0;if(options.showOutliers){canvas_left=Math.ceil(options.spotRadius);canvas_width-=2*Math.ceil(options.spotRadius);var unitsize=canvas_width/(maxvalue-minvalue+1);if(loutlier<lwhisker)
54
+ target.drawCircle((loutlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);if(routlier>rwhisker)
55
+ target.drawCircle((routlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);}
56
+ target.drawRect(Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q3-q1)*unitsize),Math.round(canvas_height*0.8),options.boxLineColor,options.boxFillColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q3-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.9),options.medianColor);if(options.target){var size=Math.ceil(options.spotRadius);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)-size),Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)+size),options.targetColor);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left-size),Math.round(canvas_height/2),Math.round((options.target-minvalue)*unitsize+canvas_left+size),Math.round(canvas_height/2),options.targetColor);}}else{this.innerHTML='';}};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(entry){for(var i=0,vlen=this.length;i<vlen;i++){if(this[i]==entry)
57
+ return i;}
58
+ return-1;}}
59
+ if($.browser.msie&&!document.namespaces['v']){document.namespaces.add('v','urn:schemas-microsoft-com:vml','#default#VML');}
60
+ if($.browser.hasCanvas==undefined){var t=document.createElement('canvas');$.browser.hasCanvas=t.getContext!=undefined;}
61
+ var vcanvas_base=function(width,height,target){};vcanvas_base.prototype={init:function(width,height,target){this.width=width;this.height=height;this.target=target;if(target[0])target=target[0];target.vcanvas=this;},drawShape:function(path,lineColor,fillColor,lineWidth){alert('drawShape not implemented');},drawLine:function(x1,y1,x2,y2,lineColor,lineWidth){return this.drawShape([[x1,y1],[x2,y2]],lineColor,lineWidth);},drawCircle:function(x,y,radius,lineColor,fillColor){alert('drawCircle not implemented');},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){alert('drawPieSlice not implemented');},drawRect:function(x,y,width,height,lineColor,fillColor){alert('drawRect not implemented');},getElement:function(){return this.canvas;},_insert:function(el,target){$(target).html(el);}};var vcanvas_canvas=function(width,height,target){return this.init(width,height,target);};vcanvas_canvas.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);this.canvas=document.createElement('canvas');if(target[0])target=target[0];target.vcanvas=this;$(this.canvas).css({display:'inline-block',width:width,height:height,verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;$(this.canvas).css({width:this.pixel_width,height:this.pixel_height});},_getContext:function(lineColor,fillColor,lineWidth){var context=this.canvas.getContext('2d');if(lineColor!=undefined)
62
+ context.strokeStyle=lineColor;context.lineWidth=lineWidth==undefined?1:lineWidth;if(fillColor!=undefined)
63
+ context.fillStyle=fillColor;return context;},drawShape:function(path,lineColor,fillColor,lineWidth){var context=this._getContext(lineColor,fillColor,lineWidth);context.beginPath();context.moveTo(path[0][0]+0.5,path[0][1]+0.5);for(var i=1,plen=path.length;i<plen;i++){context.lineTo(path[i][0]+0.5,path[i][1]+0.5);}
64
+ if(lineColor!=undefined){context.stroke();}
65
+ if(fillColor!=undefined){context.fill();}},drawCircle:function(x,y,radius,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.arc(x,y,radius,0,2*Math.PI,false);if(lineColor!=undefined){context.stroke();}
66
+ if(fillColor!=undefined){context.fill();}},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.moveTo(x,y);context.arc(x,y,radius,startAngle,endAngle,false);context.lineTo(x,y);context.closePath();if(lineColor!=undefined){context.stroke();}
67
+ if(fillColor){context.fill();}},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x+width,y],[x+width,y+height],[x,y+height],[x,y]],lineColor,fillColor);}});var vcanvas_vml=function(width,height,target){return this.init(width,height,target);};vcanvas_vml.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);if(target[0])target=target[0];target.vcanvas=this;this.canvas=document.createElement('span');$(this.canvas).css({display:'inline-block',position:'relative',overflow:'hidden',width:width,height:height,margin:'0px',padding:'0px',verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;;var groupel='<v:group coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'"'
68
+ +' style="position:absolute;top:0;left:0;width:'+this.pixel_width+'px;height='+this.pixel_height+'px;"></v:group>';this.canvas.insertAdjacentHTML('beforeEnd',groupel);this.group=$(this.canvas).children()[0];},drawShape:function(path,lineColor,fillColor,lineWidth){var vpath=[];for(var i=0,plen=path.length;i<plen;i++){vpath[i]=''+(path[i][0])+','+(path[i][1]);}
69
+ var initial=vpath.splice(0,1);lineWidth=lineWidth==undefined?1:lineWidth;var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="'+lineWidth+'" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var closed=vpath[0]==vpath[vpath.length-1]?'x ':'';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '
70
+ +stroke
71
+ +fill
72
+ +' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '
73
+ +' path="m '+initial+' l '+vpath.join(', ')+' '+closed+'e">'
74
+ +' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawCircle:function(x,y,radius,lineColor,fillColor){x-=radius+1;y-=radius+1;var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:oval '
75
+ +stroke
76
+ +fill
77
+ +' style="position:absolute;top:'+y+'px; left:'+x+'px; width:'+(radius*2)+'px; height:'+(radius*2)+'px"></v:oval>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){if(startAngle==endAngle){return;}
78
+ if((endAngle-startAngle)==(2*Math.PI)){startAngle=0.0;endAngle=(2*Math.PI);}
79
+ var startx=x+Math.round(Math.cos(startAngle)*radius);var starty=y+Math.round(Math.sin(startAngle)*radius);var endx=x+Math.round(Math.cos(endAngle)*radius);var endy=y+Math.round(Math.sin(endAngle)*radius);if(startx==endx&&starty==endy&&(endAngle-startAngle)<Math.PI)
80
+ return;var vpath=[x-radius,y-radius,x+radius,y+radius,startx,starty,endx,endy];var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '
81
+ +stroke
82
+ +fill
83
+ +' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '
84
+ +' path="m '+x+','+y+' wa '+vpath.join(', ')+' x e">'
85
+ +' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x,y+height],[x+width,y+height],[x+width,y],[x,y]],lineColor,fillColor);}});})(jQuery);
@@ -0,0 +1,2 @@
1
+
2
+ (function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,cells[i]);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}return parsers[0];}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}return t;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false,tableHeadersRows=[];for(var i=0;i<table.tHead.rows.length;i++){tableHeadersRows[i]=0;};$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}return i;}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
@@ -0,0 +1,452 @@
1
+ /*
2
+ * --------------------------------------------------------------------
3
+ * jQuery inputToButton plugin
4
+ * Author: Scott Jehl, scott@filamentgroup.com
5
+ * Copyright (c) 2009 Filament Group
6
+ * licensed under MIT (filamentgroup.com/examples/mit-license.txt)
7
+ * --------------------------------------------------------------------
8
+ */
9
+ (function($) {
10
+ $.fn.visualize = function(options, container){
11
+ return $(this).each(function(){
12
+ //configuration
13
+ var o = $.extend({
14
+ type: 'bar', //also available: area, pie, line
15
+ width: $(this).width(), //height of canvas - defaults to table height
16
+ height: $(this).height(), //height of canvas - defaults to table height
17
+ appendTitle: true, //table caption text is added to chart
18
+ title: null, //grabs from table caption if null
19
+ appendKey: true, //color key is added to chart
20
+ colors: ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744'],
21
+ textColors: [], //corresponds with colors array. null/undefined items will fall back to CSS
22
+ parseDirection: 'x', //which direction to parse the table data
23
+ pieMargin: 20, //pie charts only - spacing around pie
24
+ pieLabelPos: 'inside',
25
+ lineWeight: 4, //for line and area - stroke weight
26
+ barGroupMargin: 10,
27
+ barMargin: 1, //space around bars in bar chart (added to both sides of bar)
28
+ yLabelInterval: 30 //distance between y labels
29
+ },options);
30
+
31
+ //reset width, height to numbers
32
+ o.width = parseFloat(o.width);
33
+ o.height = parseFloat(o.height);
34
+
35
+
36
+ var self = $(this);
37
+
38
+ //function to scrape data from html table
39
+ function scrapeTable(){
40
+ var colors = o.colors;
41
+ var textColors = o.textColors;
42
+ var tableData = {
43
+ dataGroups: function(){
44
+ var dataGroups = [];
45
+ if(o.parseDirection == 'x'){
46
+ self.find('tr:gt(0)').each(function(i){
47
+ dataGroups[i] = {};
48
+ dataGroups[i].points = [];
49
+ dataGroups[i].color = colors[i];
50
+ if(textColors[i]){ dataGroups[i].textColor = textColors[i]; }
51
+ $(this).find('td').each(function(){
52
+ dataGroups[i].points.push( parseFloat($(this).text()) );
53
+ });
54
+ });
55
+ }
56
+ else {
57
+ var cols = self.find('tr:eq(1) td').size();
58
+ for(var i=0; i<cols; i++){
59
+ dataGroups[i] = {};
60
+ dataGroups[i].points = [];
61
+ dataGroups[i].color = colors[i];
62
+ if(textColors[i]){ dataGroups[i].textColor = textColors[i]; }
63
+ self.find('tr:gt(0)').each(function(){
64
+ dataGroups[i].points.push( $(this).find('td').eq(i).text()*1 );
65
+ });
66
+ };
67
+ }
68
+ return dataGroups;
69
+ },
70
+ allData: function(){
71
+ var allData = [];
72
+ $(this.dataGroups()).each(function(){
73
+ allData.push(this.points);
74
+ });
75
+ return allData;
76
+ },
77
+ dataSum: function(){
78
+ var dataSum = 0;
79
+ var allData = this.allData().join(',').split(',');
80
+ $(allData).each(function(){
81
+ dataSum += parseFloat(this);
82
+ });
83
+ return dataSum
84
+ },
85
+ topValue: function(){
86
+ var topValue = 0;
87
+ var allData = this.allData().join(',').split(',');
88
+ $(allData).each(function(){
89
+ if(parseFloat(this,10)>topValue) topValue = parseFloat(this);
90
+ });
91
+ return topValue;
92
+ },
93
+ bottomValue: function(){
94
+ var bottomValue = 0;
95
+ var allData = this.allData().join(',').split(',');
96
+ $(allData).each(function(){
97
+ if(this<bottomValue) bottomValue = parseFloat(this);
98
+ });
99
+ return bottomValue;
100
+ },
101
+ memberTotals: function(){
102
+ var memberTotals = [];
103
+ var dataGroups = this.dataGroups();
104
+ $(dataGroups).each(function(l){
105
+ var count = 0;
106
+ $(dataGroups[l].points).each(function(m){
107
+ count +=dataGroups[l].points[m];
108
+ });
109
+ memberTotals.push(count);
110
+ });
111
+ return memberTotals;
112
+ },
113
+ yTotals: function(){
114
+ var yTotals = [];
115
+ var dataGroups = this.dataGroups();
116
+ var loopLength = this.xLabels().length;
117
+ for(var i = 0; i<loopLength; i++){
118
+ yTotals[i] =[];
119
+ var thisTotal = 0;
120
+ $(dataGroups).each(function(l){
121
+ yTotals[i].push(this.points[i]);
122
+ });
123
+ yTotals[i].join(',').split(',');
124
+ $(yTotals[i]).each(function(){
125
+ thisTotal += parseFloat(this);
126
+ });
127
+ yTotals[i] = thisTotal;
128
+
129
+ }
130
+ return yTotals;
131
+ },
132
+ topYtotal: function(){
133
+ var topYtotal = 0;
134
+ var yTotals = this.yTotals().join(',').split(',');
135
+ $(yTotals).each(function(){
136
+ if(parseFloat(this,10)>topYtotal) topYtotal = parseFloat(this);
137
+ });
138
+ return topYtotal;
139
+ },
140
+ totalYRange: function(){
141
+ return this.topValue() - this.bottomValue();
142
+ },
143
+ xLabels: function(){
144
+ var xLabels = [];
145
+ if(o.parseDirection == 'x'){
146
+ self.find('tr:eq(0) th').each(function(){
147
+ xLabels.push($(this).html());
148
+ });
149
+ }
150
+ else {
151
+ self.find('tr:gt(0) th').each(function(){
152
+ xLabels.push($(this).html());
153
+ });
154
+ }
155
+ return xLabels;
156
+ },
157
+ yLabels: function(){
158
+ var yLabels = [];
159
+ yLabels.push(bottomValue);
160
+ var numLabels = Math.round(o.height / o.yLabelInterval);
161
+ var loopInterval = Math.ceil(totalYRange / numLabels) || 1;
162
+ while( yLabels[yLabels.length-1] < topValue - loopInterval){
163
+ yLabels.push(yLabels[yLabels.length-1] + loopInterval);
164
+ }
165
+ yLabels.push(topValue);
166
+ return yLabels;
167
+ }
168
+ };
169
+
170
+ return tableData;
171
+ };
172
+
173
+
174
+ //function to create a chart
175
+ var createChart = {
176
+ pie: function(){
177
+
178
+ canvasContain.addClass('visualize-pie');
179
+
180
+ if(o.pieLabelPos == 'outside'){ canvasContain.addClass('visualize-pie-outside'); }
181
+
182
+ var centerx = Math.round(canvas.width()/2);
183
+ var centery = Math.round(canvas.height()/2);
184
+ var radius = centery - o.pieMargin;
185
+ var counter = 0.0;
186
+ var toRad = function(integer){ return (Math.PI/180)*integer; };
187
+ var labels = $('<ul class="visualize-labels"></ul>')
188
+ .insertAfter(canvas);
189
+
190
+ //draw the pie pieces
191
+ $.each(memberTotals, function(i){
192
+ var fraction = (this <= 0 || isNaN(this))? 0 : this / dataSum;
193
+ ctx.beginPath();
194
+ ctx.moveTo(centerx, centery);
195
+ ctx.arc(centerx, centery, radius,
196
+ counter * Math.PI * 2 - Math.PI * 0.5,
197
+ (counter + fraction) * Math.PI * 2 - Math.PI * 0.5,
198
+ false);
199
+ ctx.lineTo(centerx, centery);
200
+ ctx.closePath();
201
+ ctx.fillStyle = dataGroups[i].color;
202
+ ctx.fill();
203
+ // draw labels
204
+ var sliceMiddle = (counter + fraction/2);
205
+ var distance = o.pieLabelPos == 'inside' ? radius/1.5 : radius + radius / 5;
206
+ var labelx = Math.round(centerx + Math.sin(sliceMiddle * Math.PI * 2) * (distance));
207
+ var labely = Math.round(centery - Math.cos(sliceMiddle * Math.PI * 2) * (distance));
208
+ var leftRight = (labelx > centerx) ? 'right' : 'left';
209
+ var topBottom = (labely > centery) ? 'bottom' : 'top';
210
+ var percentage = Math.round(fraction*100);
211
+ if(percentage){
212
+ var labeltext = $('<span class="visualize-label">' + percentage + '%</span>')
213
+ .css(leftRight, 0)
214
+ .css(topBottom, 0);
215
+ if(labeltext)
216
+ var label = $('<li class="visualize-label-pos"></li>')
217
+ .appendTo(labels)
218
+ .css({left: labelx, top: labely})
219
+ .append(labeltext);
220
+ labeltext
221
+ .css('font-size', radius / 8)
222
+ .css('margin-'+leftRight, -labeltext.width()/2)
223
+ .css('margin-'+topBottom, -labeltext.outerHeight()/2);
224
+
225
+
226
+ if(dataGroups[i].textColor){ labeltext.css('color', dataGroups[i].textColor); }
227
+ }
228
+ counter+=fraction;
229
+ });
230
+ },
231
+
232
+ line: function(area){
233
+
234
+ if(area){ canvasContain.addClass('visualize-area'); }
235
+ else{ canvasContain.addClass('visualize-line'); }
236
+
237
+ //write X labels
238
+ var xInterval = canvas.width() / (xLabels.length -1);
239
+ var xlabelsUL = $('<ul class="visualize-labels-x"></ul>')
240
+ .width(canvas.width())
241
+ .height(canvas.height())
242
+ .insertBefore(canvas);
243
+ $.each(xLabels, function(i){
244
+ var thisLi = $('<li><span>'+this+'</span></li>')
245
+ .prepend('<span class="line" />')
246
+ .css('left', xInterval * i)
247
+ .appendTo(xlabelsUL);
248
+ var label = thisLi.find('span:not(.line)');
249
+ var leftOffset = label.width()/-2;
250
+ if(i == 0){ leftOffset = 0; }
251
+ else if(i== xLabels.length-1){ leftOffset = -label.width(); }
252
+ label
253
+ .css('margin-left', leftOffset)
254
+ .addClass('label');
255
+ });
256
+
257
+ //write Y labels
258
+ var yScale = canvas.height() / totalYRange;
259
+ var liBottom = canvas.height() / (yLabels.length-1);
260
+ var ylabelsUL = $('<ul class="visualize-labels-y"></ul>')
261
+ .width(canvas.width())
262
+ .height(canvas.height())
263
+ .insertBefore(canvas);
264
+
265
+ $.each(yLabels, function(i){
266
+ var thisLi = $('<li><span>'+this+'</span></li>')
267
+ .prepend('<span class="line" />')
268
+ .css('bottom',liBottom*i)
269
+ .prependTo(ylabelsUL);
270
+ var label = thisLi.find('span:not(.line)');
271
+ var topOffset = label.height()/-2;
272
+ if(i == 0){ topOffset = -label.height(); }
273
+ else if(i== yLabels.length-1){ topOffset = 0; }
274
+ label
275
+ .css('margin-top', topOffset)
276
+ .addClass('label');
277
+ });
278
+
279
+ //start from the bottom left
280
+ ctx.translate(0,zeroLoc);
281
+ //iterate and draw
282
+ $.each(dataGroups,function(h){
283
+ ctx.beginPath();
284
+ ctx.lineWidth = o.lineWeight;
285
+ ctx.lineJoin = 'round';
286
+ var points = this.points;
287
+ var integer = 0;
288
+ ctx.moveTo(0,-(points[0]*yScale));
289
+ $.each(points, function(){
290
+ ctx.lineTo(integer,-(this*yScale));
291
+ integer+=xInterval;
292
+ });
293
+ ctx.strokeStyle = this.color;
294
+ ctx.stroke();
295
+ if(area){
296
+ ctx.lineTo(integer,0);
297
+ ctx.lineTo(0,0);
298
+ ctx.closePath();
299
+ ctx.fillStyle = this.color;
300
+ ctx.globalAlpha = .3;
301
+ ctx.fill();
302
+ ctx.globalAlpha = 1.0;
303
+ }
304
+ else {ctx.closePath();}
305
+ });
306
+ },
307
+
308
+ area: function(){
309
+ createChart.line(true);
310
+ },
311
+
312
+ bar: function(){
313
+
314
+ canvasContain.addClass('visualize-bar');
315
+
316
+ //write X labels
317
+ var xInterval = canvas.width() / (xLabels.length);
318
+ var xlabelsUL = $('<ul class="visualize-labels-x"></ul>')
319
+ .width(canvas.width())
320
+ .height(canvas.height())
321
+ .insertBefore(canvas);
322
+ $.each(xLabels, function(i){
323
+ var thisLi = $('<li><span class="label">'+this+'</span></li>')
324
+ .prepend('<span class="line" />')
325
+ .css('left', xInterval * i)
326
+ .width(xInterval)
327
+ .appendTo(xlabelsUL);
328
+ var label = thisLi.find('span.label');
329
+ label.addClass('label');
330
+ });
331
+
332
+ //write Y labels
333
+ var yScale = canvas.height() / totalYRange;
334
+ var liBottom = canvas.height() / (yLabels.length-1);
335
+ var ylabelsUL = $('<ul class="visualize-labels-y"></ul>')
336
+ .width(canvas.width())
337
+ .height(canvas.height())
338
+ .insertBefore(canvas);
339
+ $.each(yLabels, function(i){
340
+ var thisLi = $('<li><span>'+this+'</span></li>')
341
+ .prepend('<span class="line" />')
342
+ .css('bottom',liBottom*i)
343
+ .prependTo(ylabelsUL);
344
+ var label = thisLi.find('span:not(.line)');
345
+ var topOffset = label.height()/-2;
346
+ if(i == 0){ topOffset = -label.height(); }
347
+ else if(i== yLabels.length-1){ topOffset = 0; }
348
+ label
349
+ .css('margin-top', topOffset)
350
+ .addClass('label');
351
+ });
352
+
353
+ //start from the bottom left
354
+ ctx.translate(0,zeroLoc);
355
+ //iterate and draw
356
+ for(var h=0; h<dataGroups.length; h++){
357
+ ctx.beginPath();
358
+ var linewidth = (xInterval-o.barGroupMargin*2) / dataGroups.length; //removed +1
359
+ var strokeWidth = linewidth - (o.barMargin*2);
360
+ ctx.lineWidth = strokeWidth;
361
+ var points = dataGroups[h].points;
362
+ var integer = 0;
363
+ for(var i=0; i<points.length; i++){
364
+ var xVal = (integer-o.barGroupMargin)+(h*linewidth)+linewidth/2;
365
+ xVal += o.barGroupMargin*2;
366
+
367
+ ctx.moveTo(xVal, 0);
368
+ ctx.lineTo(xVal, Math.round(-points[i]*yScale));
369
+ integer+=xInterval;
370
+ }
371
+ ctx.strokeStyle = dataGroups[h].color;
372
+ ctx.stroke();
373
+ ctx.closePath();
374
+ }
375
+ }
376
+ };
377
+
378
+ //create new canvas, set w&h attrs (not inline styles)
379
+ var canvasNode = document.createElement("canvas");
380
+ canvasNode.setAttribute('height',o.height);
381
+ canvasNode.setAttribute('width',o.width);
382
+ var canvas = $(canvasNode);
383
+
384
+ //get title for chart
385
+ var title = o.title || self.find('caption').text();
386
+
387
+ //create canvas wrapper div, set inline w&h, append
388
+ var canvasContain = (container || $('<div class="visualize" role="img" aria-label="Chart representing data from the table: '+ title +'" />'))
389
+ .height(o.height)
390
+ .width(o.width)
391
+ .append(canvas);
392
+
393
+ //scrape table (this should be cleaned up into an obj)
394
+ var tableData = scrapeTable();
395
+ var dataGroups = tableData.dataGroups();
396
+ var allData = tableData.allData();
397
+ var dataSum = tableData.dataSum();
398
+ var topValue = tableData.topValue();
399
+ var bottomValue = tableData.bottomValue();
400
+ var memberTotals = tableData.memberTotals();
401
+ var totalYRange = tableData.totalYRange();
402
+ var zeroLoc = o.height * (topValue/totalYRange);
403
+ var xLabels = tableData.xLabels();
404
+ var yLabels = tableData.yLabels();
405
+
406
+ //title/key container
407
+ if(o.appendTitle || o.appendKey){
408
+ var infoContain = $('<div class="visualize-info"></div>')
409
+ .appendTo(canvasContain);
410
+ }
411
+
412
+ //append title
413
+ if(o.appendTitle){
414
+ $('<div class="visualize-title">'+ title +'</div>').appendTo(infoContain);
415
+ }
416
+
417
+
418
+ //append key
419
+ if(o.appendKey){
420
+ var newKey = $('<ul class="visualize-key"></ul>');
421
+ var selector = (o.parseDirection == 'x') ? 'tr:gt(0) th' : 'tr:eq(0) th' ;
422
+ self.find(selector).each(function(i){
423
+ $('<li><span class="visualize-key-color" style="background: '+dataGroups[i].color+'"></span><span class="visualize-key-label">'+ $(this).text() +'</span></li>')
424
+ .appendTo(newKey);
425
+ });
426
+ newKey.appendTo(infoContain);
427
+ };
428
+
429
+ //append new canvas to page
430
+
431
+ if(!container){canvasContain.insertAfter(this); }
432
+ if( typeof(G_vmlCanvasManager) != 'undefined' ){ G_vmlCanvasManager.init(); G_vmlCanvasManager.initElement(canvas[0]); }
433
+
434
+ //set up the drawing board
435
+ var ctx = canvas[0].getContext('2d');
436
+
437
+ //create chart
438
+ createChart[o.type]();
439
+
440
+ //clean up some doubled lines that sit on top of canvas borders (done via JS due to IE)
441
+ $('.visualize-line li:first-child span.line, .visualize-line li:last-child span.line, .visualize-area li:first-child span.line, .visualize-area li:last-child span.line, .visualize-bar li:first-child span.line,.visualize-bar .visualize-labels-y li:last-child span.line').css('border','none');
442
+ if(!container){
443
+ //add event for updating
444
+ canvasContain.bind('visualizeRefresh', function(){
445
+ self.visualize(o, $(this).empty());
446
+ });
447
+ }
448
+ }).next(); //returns canvas(es)
449
+ };
450
+ })(jQuery);
451
+
452
+