packages feed

tkyprof 0.0.2 → 0.0.3

raw patch · 22 files changed

+1964/−4 lines, 22 filesbinary-added

Files

Handler/Home.hs view
@@ -14,7 +14,7 @@ getHomeR = do   defaultLayout $ do     setTitle "Devel.TKYProf Home"-    addScript $ StaticR js_jquery_ui_widgets_min_js+    addScript $ StaticR js_jquery_ui_widget_js     addScript $ StaticR js_jquery_iframe_transport_js     addScript $ StaticR js_jquery_fileupload_js     addWidget $(widgetFile "home")
Handler/Reports.hs view
@@ -34,8 +34,8 @@   let json = T.decodeUtf8 $ A.encode reportCostCentres   defaultLayout $ do     setTitle "Devel.TKYProf Report"-    addScript $ StaticR js_d3_js-    addScript $ StaticR js_d3_layout_js+    addScript $ StaticR js_d3_min_js+    addScript $ StaticR js_d3_layout_min_js     addWidget $(widgetFile "reports-id")  -- Helper functions
+ config/favicon.ico view

binary file changed (absent → 1150 bytes)

+ config/routes view
@@ -0,0 +1,6 @@+/                          HomeR              GET+/reports                   ReportsR           GET POST+/reports/#Integer          ReportsIdR         GET+/static                    StaticR            Static getStatic+/favicon.ico               FaviconR           GET+/robots.txt                RobotsR            GET
+ hamlet/default-layout.hamlet view
@@ -0,0 +1,18 @@+!!!+<html lang="en">+  <head>+    <meta charset="utf-8" />+    <title>#{pageTitle pc}+    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">+    ^{pageHead pc}+  <body>+    <nav #breadcrumbs>+      $forall bc <- bcs+        <a href=@{fst bc}>#{snd bc}+        <span .breadcrumbs-delimiter>>+      <a>#{title}+    $maybe msg <- mmsg+      <div #message>#{msg}+    ^{pageBody pc}+    <footer>+      Copyright &copy;<time datetime="2011-08-02">2011</time>Mitsutoshi Aoe
+ hamlet/home.hamlet view
@@ -0,0 +1,12 @@+<h1>Devel.TKYProf+<section>+  <h2>Select your profiling reports+  <form #uploader action=@{ReportsR} method=post enctype=#{Multipart}>+    <div #container>+      <div #dropbox .box>+        <p>Drop in the profiling reports from your desktop.+      <div #filedialog .box>+        <p>Click to open the file select dialog.+        <input type=file>+  <h2>+    <a href=@{ReportsR}>View reports
+ hamlet/reports-id.hamlet view
@@ -0,0 +1,64 @@+<h1>The Profiling Report ##{reportId}+<section #summary>+  <h1>Summary+  <div #report-summary .box>+    <dl>+      <dt>Timestamp+      <dd>#{show reportTimestamp}+      <dt>Command line+      <dd>#{reportCommandLine}+      <dt>Total time+      <dd>#{totalSecs reportTotalTime} seconds+      <dd>#{totalTicks reportTotalTime} ticks @ #{resolution reportTotalTime} ms+      <dt>Total allocations+      <dd>#{totalAllocBytes reportTotalAlloc} bytes+  <!--+  <div #hot-cost-centres .box>+    <table>+      <caption>Hot cost centres+      <thead>+        <tr>+          <th>Cost centre+          <th>Module+          <th>%time+          <th>%alloc+      <tbody>+        $forall bcc <- reportHotCostCentres+          <tr>+            <td>#{briefCostCentreName bcc}+            <td>#{briefCostCentreModule bcc}+            <td>#{briefCostCentreTime bcc}+            <td>#{briefCostCentreAlloc bcc}+  -->+<section #cost-centres>+  <header>+    <h1>Cost centres+    <button #time>Time report+    <button #alloc>Alloc report+  </header>+  <div #chart-container>+    <figure #chart>+    <div #sidebox>+      <div #current-node>+        <h3>Current node+        <dl>+          <dt>Module+          <dd #current-node-module>+          <dt>Name+          <dd #current-node-name>+          <dt>Node number+          <dd #current-node-number>+          <dt>Entries+          <dd #current-node-entries>+          <dt>Individual %time+          <dd #current-node-ind-time>+          <dt>Individual %alloc+          <dd #current-node-ind-alloc>+          <dt>Inherited %time+          <dd #current-node-inh-time>+          <dt>Inherited %alloc+          <dd #current-node-inh-alloc>+      <div #children>+        <h3>Children+        <ol>+
+ hamlet/reports.hamlet view
@@ -0,0 +1,6 @@+<h1>All reports+<ul>+  $forall report <- reports+    <li>+      <a href=@{ReportsIdR (fst report)}>#{reportCommandLine (snd report)}+
+ julius/home.julius view
@@ -0,0 +1,12 @@+$(function() {+  var uploader = $('#uploader');++  uploader.bind('fileuploaddone', function(e, data) {+    top.location.href = data.jqXHR.getResponseHeader('Location');+  });++  uploader.fileupload({+    url: '/reports',+    paramName: "reports"+  });+});
+ julius/reports-id.julius view
@@ -0,0 +1,121 @@+$(function() {+  var report = #{json};++  var w = $("#chart").width(),+      h = $("#chart").height(),+      r = Math.min(w, h) / 2,+      x = d3.scale.linear().range([0, 2*Math.PI]),+      y = d3.scale.sqrt().range([0, r]),+      color = d3.scale.category20c();++  var vis = d3.select("#chart").append("svg:svg")+    .attr("width", w)+    .attr("height", h)+    .append("svg:g")+    .attr("transform", "translate(" + w/2 + "," + h/2 + ")");++  var partition = d3.layout.partition()+    .value(function(d) { return d.individualTime; })+    .children(function(d) { return d.subForest; });++  var arc = d3.svg.arc()+    .startAngle(function(d) { return Math.max(0, Math.min(2*Math.PI, x(d.x))); })+    .endAngle(function(d) { return Math.max(0, Math.min(2*Math.PI, x(d.x + d.dx))); })+    .innerRadius(function(d) { return Math.max(0, y(d.y)); })+    .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });++  var path = vis.data([report]).selectAll("path")+    .data(partition.nodes)+    .enter().append("svg:path")+    .attr("id", function(d) { return "cc" + d.no + (d.isParent ? "p" : ""); })+    .attr("class", function(d) { return d.children || d.isParent ? "branch" : "leaf"; })+    .attr("d", arc)+    .style("fill", function(d) { return color((d.children ? d : d.parent).name); })+    .on("click", click)+    .on("mouseover", mouseover)+    .each(stash);++  d3.select("#time").on("click", function() {+    path.data(partition.value(function(d) { return d.individualTime; }))+      .transition()+      .duration(500)+      .attrTween("d", arcTween);++    d3.select("#time").classed("active", true);+    d3.select("#alloc").classed("active", false);+  });++  d3.select("#alloc").on("click", function() {+    path.data(partition.value(function(d) { return d.individualAlloc; }))+      .transition()+      .duration(500)+      .attrTween("d", arcTween);++    d3.select("#time").classed("active", false);+    d3.select("#alloc").classed("active", true);+  });++  function click(d) {+    showCostCentre(d);+    showChildren(d);+    path.transition()+      .duration(500)+      .attrTween("d", arcTweenZoom(d));+  }++  function mouseover(d) {++  }++  // Stash the old values for transition.+  function stash(d) {+    d.x0 = d.x;+    d.dx0 = d.dx;+  }++  // Interpolate the arcs in data space.+  function arcTween(a) {+    var i = d3.interpolate({x: a.x0, dx: a.dx0}, a);+    return function(t) {+      var b = i(t);+      a.x0 = b.x;+      a.dx0 = b.dx;+      return arc(b);+    };+  }++  function arcTweenZoom(d) {+    var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),+        yd = d3.interpolate(y.domain(), [d.y, 1]),+        yr = d3.interpolate(y.range(), [d.y ? 20 : 0, r]);+    return function(d, i) {+      return i+        ? function(t) { return arc(d); }+        : function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); };+    };+  }++  function showCostCentre(node) {+    var currentNode = $("#current-node dl");+    $("#current-node-module", currentNode).text(node.module);+    $("#current-node-name", currentNode).text(node.name);+    $("#current-node-number", currentNode).text(node.no);+    $("#current-node-entries", currentNode).text(node.entries);+    $("#current-node-ind-time", currentNode).text(node.individualTime);+    $("#current-node-ind-alloc", currentNode).text(node.individualAlloc);+    $("#current-node-inh-time", currentNode).text(node.inheritedTime);+    $("#current-node-inh-alloc", currentNode).text(node.inheritedAlloc);+  }++  function showChildren(node) {+    $("#children ol li").remove();+    var children = $("#children ol");+    var cs = node.children;+        n  = cs.length < 10 ? cs.length : 10;+    for (var i = 0; i < n; i++) {+      children.append("<li>" + cs[i].name + "</li>");+    }+  }+  showCostCentre(report);+  showChildren(report);+});
+ julius/reports.julius view
@@ -0,0 +1,3 @@+$(function() {+  console.log("reports");+});
+ lucius/default-layout.lucius view
@@ -0,0 +1,8 @@+h1, h2 {+  text-align: center;+}++.breadcrumbs-delimiter {+  margin-left: 0.5em;+  margin-right: 0.5em;+}
+ lucius/home.lucius view
@@ -0,0 +1,45 @@+#container {+  width: 100%;++  display: -webkit-box;+  display: -moz-box;+  display: box;++  -webkit-box-align: center;+  -moz-box-align: center;+  box-align: center;++  -webkit-box-pack: center;+  -moz-box-pack: center;+  box-pack: center;+}++.box {+  width: 50%;+  text-align: center;+}++#dropbox {+  height: 200px;+  border: 2px dashed #0687FF;++  display: -webkit-box;+  display: -moz-box;+  display: box;++  -webkit-box-align: center;+  -moz-box-align: center;+  box-align: center;++  -webkit-box-pack: center;+  -moz-box-pack: center;+  box-pack: center;++  -webkit-border-radius: 10px;+  -khtml-border-radius: 10px;+  -moz-border-radius: 10px;+  border-radius: 10px;+}++#filedialog {+}
+ lucius/reports-id.lucius view
@@ -0,0 +1,58 @@+#report-summary {+  width: 100%;+}++/*+#hot-cost-centres {+  width: 70%;+  float: right;+  border-left: 1px solid;+}+*/++#cost-centres {+}++#time {+  display: inline;+}++#alloc {+  display: inline;+}++#chart-container {+  width: 100%;+  display: -webkit-box;+  display: -moz-box;+  display: box;+}++#chart {+  -webkit-box-flex: 1;+  -moz-box-flex: 1;+  box-flex: 1;+  min-height: 400px;+  -webkit-box-ordinal-group: 1;+  -moz-box-ordinal-group: 1;+  box-ordinal-group: 1;+}++#chart path {+  stroke: #fff;+  fill-rule: evenodd;+}++#sidebox {+  width: 200px;+  -webkit-box-ordinal-group: 2;+  -moz-box-ordinal-group: 2;+  box-ordinal-group: 2;+}++#current-node {+}++#children {+}+
+ lucius/reports.lucius view
+ static/js/d3.layout.min.js view
@@ -0,0 +1,1 @@+(function(){function bj(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];e<0&&(c+=e/2,e=0),f<0&&(d+=f/2,f=0);return{x:c,y:d,dx:e,dy:f}}function bi(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function bh(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bg(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bf(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function be(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function bd(a,b){return a.depth-b.depth}function bc(a,b){return b.x-a.x}function bb(a,b){return a.x-b.x}function ba(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=ba(c[f],b),a)>0&&(a=d)}return a}function _(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function $(a){return a.children?a.children[0]:a._tree.thread}function Z(a,b){return a.parent==b.parent?1:2}function Y(a){var b=a.children;return b?Y(b[b.length-1]):a}function X(a){var b=a.children;return b?X(b[0]):a}function W(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function V(a){return 1+d3.max(a,function(a){return a.y})}function U(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function T(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)T(e[f],b,c,d)}}function S(a){var b=a.children;b?(b.forEach(S),a.r=P(b)):a.r=Math.sqrt(a.value)}function R(a){delete a._pack_next,delete a._pack_prev}function Q(a){a._pack_next=a._pack_prev=a}function P(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(Q),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],U(g,h,i),l(i),M(g,i),g._pack_prev=i,M(i,h),h=g._pack_next;for(var m=3;m<f;m++){U(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(O(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(O(k,i)){p<o&&(n=-1,j=k);break}n==0?(M(g,i),h=i,l(i)):n>0?(N(g,j),h=j,m--):(N(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(R);return s}function O(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function N(a,b){a._pack_next=b,b._pack_prev=a}function M(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function L(a,b){return a.value-b.value}function J(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function I(a,b){return b.value-a.value}function H(a){return a.value}function G(a){return a.children}function F(a,b){a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=J,a.value=d3.rebind(a,b.value),a.nodes=function(b){K=!0;return(a.nodes=a)(b)};return a}function E(a){return[d3.min(a),d3.max(a)]}function D(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function C(a,b){return D(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function B(a,b){return a+b[1]}function A(a){return a.reduce(B,0)}function z(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function w(a,b,c){a.y0=b,a.y=c}function v(a){return a.y}function u(a){return a.x}function t(a){return 1}function s(a){return 20}function r(a){var b=0,c=0;a.count=0;if(!a.leaf){var d=a.nodes,e=d.length,f=-1,g;while(++f<e){g=d[f];if(g==null)continue;r(g),a.count+=g.count,b+=g.count*g.cx,c+=g.count*g.cy}}a.point&&(a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5),a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function q(){d3.event.stopPropagation(),d3.event.preventDefault()}function p(){i&&(q(),i=!1)}function o(){!f||(g&&(i=!0,q()),d3.event.type==="mouseup"&&n(),f.fixed=!1,e=h=f=j=null)}function n(){if(!!f){var a=j.parentNode;if(!a){f.fixed=!1,h=f=j=null;return}var b=m(a);g=!0,f.px=b[0]-h[0],f.py=b[1]-h[1],q(),e.resume()}}function m(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function l(a){a!==f&&(a.fixed=!1)}function k(a){a.fixed=!0}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;b.push(a);return b}function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function k(){b.sort(function(a,b){return i(a.target.value,b.target.value)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function G(b,c){var d=m(this.parentNode);(f=b).fixed=!0,g=!1,j=this,e=a,h=[d[0]-b.x,d[1]-b.y],q()}function F(){var a=A.length,e=B.length,f=d3.geom.quadtree(A),g,h,j,k,l,m,n;for(g=0;g<e;++g){h=B[g],j=h.source,k=h.target,m=k.x-j.x,n=k.y-j.y;if(l=m*m+n*n)l=d*D[g]*((l=Math.sqrt(l))-C[g])/l,m*=l,n*=l,k.x-=m,k.y-=n,j.x+=m,j.y+=n}var o=d*x;m=c[0]/2,n=c[1]/2,g=-1;while(++g<a)h=A[g],h.x+=(m-h.x)*o,h.y+=(n-h.y)*o;r(f);var p=d*w;g=-1;while(++g<a)f.visit(E(A[g],p));g=-1;while(++g<a)h=A[g],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*i,h.y-=(h.py-(h.py=h.y))*i);b.tick.dispatch({type:"tick",alpha:d});return(d*=.99)<.005}function E(a,b){return function(c,d,e,f,g){if(c.point!==a){var h=c.cx-a.x,i=c.cy-a.y,j=1/Math.sqrt(h*h+i*i);if((f-d)*j<y){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point&&isFinite(j)){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var a={},b=d3.dispatch("tick"),c=[1,1],d,i=.9,u=s,v=t,w=-30,x=.1,y=.8,z,A=[],B=[],C,D;a.on=function(c,d){b[c].add(d);return a},a.nodes=function(b){if(!arguments.length)return A;A=b;return a},a.links=function(b){if(!arguments.length)return B;B=b;return a},a.size=function(b){if(!arguments.length)return c;c=b;return a},a.linkDistance=function(b){if(!arguments.length)return u;u=d3.functor(b);return a},a.distance=a.linkDistance,a.linkStrength=function(b){if(!arguments.length)return v;v=d3.functor(b);return a},a.friction=function(b){if(!arguments.length)return i;i=b;return a},a.charge=function(b){if(!arguments.length)return w;w=b;return a},a.gravity=function(b){if(!arguments.length)return x;x=b;return a},a.theta=function(b){if(!arguments.length)return y;y=b;return a},a.start=function(){function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=B[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}var b,d,e=A.length,f=B.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=A[b]).index=b;C=[],D=[];for(b=0;b<f;++b)j=B[b],typeof j.source=="number"&&(j.source=A[j.source]),typeof j.target=="number"&&(j.target=A[j.target]),C[b]=u.call(this,j,b),D[b]=v.call(this,j,b);for(b=0;b<e;++b)j=A[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);return a.resume()},a.resume=function(){d=.1,d3.timer(F);return a},a.stop=function(){d=0;return a},a.drag=function(){this.on("mouseover.force",k).on("mouseout.force",l).on("mousedown.force",G).on("touchstart.force",G),d3.select(window).on("mousemove.force",n).on("touchmove.force",n).on("mouseup.force",o,!0).on("touchend.force",o,!0).on("click.force",p,!0);return a};return a};var e,f,g,h,i,j;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d=a.value===0?0:d/a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.size=function(a){if(!arguments.length)return b;b=a;return e};return F(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{data:f[a],value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=x["default"],c=y.zero,d=w,e=u,f=v;g.values=function(b){if(!arguments.length)return a;a=b;return g},g.order=function(a){if(!arguments.length)return b;b=typeof a=="function"?a:x[a];return g},g.offset=function(a){if(!arguments.length)return c;c=typeof a=="function"?a:y[a];return g},g.x=function(a){if(!arguments.length)return e;e=a;return g},g.y=function(a){if(!arguments.length)return f;f=a;return g},g.out=function(a){if(!arguments.length)return d;d=a;return g};return g};var x={"inside-out":function(a){var b=a.length,c,d,e=a.map(z),f=a.map(A),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},y={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1:1/l,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=E,d=C;e.value=function(a){if(!arguments.length)return b;b=a;return e},e.range=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.bins=function(a){if(!arguments.length)return d;d=typeof a=="number"?function(b){return D(b,a)}:d3.functor(a);return e},e.frequency=function(b){if(!arguments.length)return a;a=!!b;return e};return e},d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,K?a:a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k=K?f:{data:f};k.depth=h,i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=I,b=G,c=H;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g};var K=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,S(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);T(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy().sort(L),b=[1,1];c.size=function(a){if(!arguments.length)return b;b=a;return c};return F(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;be(g,function(a){a.children?(a.x=W(a.children),a.y=V(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=X(g),m=Y(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=_(g),e=$(e),g&&e)h=$(h),f=_(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(bg(bh(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!_(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!$(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;bf(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];be(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=ba(g,bc),l=ba(g,bb),m=ba(g,bd),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.treemap=function(){function n(b){var d=g||a(b),e=d[0];e.x=0,e.y=0,e.dx=c[0],e.dy=c[1],g&&a.revalue(e),i([e],e.dx*e.dy/e.value),(g?k:j)(e),f&&(g=d);return d}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=j?b(k.area/j):0;k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=j?b(k.area/j):0;k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function l(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,i=a.length;while(++g<i){if(!(d=a[g].area))continue;d<f&&(f=d),d>e&&(e=d)}c*=c,b*=b;return c?Math.max(b*e*h/c,c/(b*f*h)):Infinity}function k(a){if(!!a.children){var b=e(a),c=a.children.slice(),d,f=[];i(c,b.dx*b.dy/a.value),f.area=0;while(d=c.pop())f.push(d),f.area+=d.area,d.z!=null&&(m(f,d.z?b.dx:b.dy,b,!c.length),f.length=f.area=0);a.children.forEach(k)}}function j(a){if(!!a.children){var b=e(a),c=[],d=a.children.slice(),f,g=Infinity,h,k=Math.min(b.dx,b.dy),n;i(d,b.dx*b.dy/a.value),c.area=0;while((n=d.length)>0)c.push(f=d[n-1]),c.area+=f.area,(h=l(c,k))<=g?(d.pop(),g=h):(c.area-=c.pop().area,m(c,k,b,!1),k=Math.min(b.dx,b.dy),c.length=c.area=0,g=Infinity);c.length&&(m(c,k,b,!0),c.length=c.area=0),a.children.forEach(j)}}function i(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value*(b<0?0:b),e.area=isNaN(f)||f<=0?0:f}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=null,e=bi,f=!1,g,h=.5*(1+Math.sqrt(5));n.size=function(a){if(!arguments.length)return c;c=a;return n},n.padding=function(a){function c(b){return bj(b,a)}function b(b){var c=a.call(n,b,b.depth);return c==null?bi(b):bj(b,typeof c=="number"?[c,c,c,c]:c)}if(!arguments.length)return d;var f;e=(d=a)==null?bi:(f=typeof a)==="function"?b:f==="number"?(a=[a,a,a,a],c):c;return n},n.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return n},n.sticky=function(a){if(!arguments.length)return f;f=a,g=null;return n},n.ratio=function(a){if(!arguments.length)return h;h=a;return n};return F(n,a)}})()
+ static/js/d3.min.js view
@@ -0,0 +1,2 @@+(function(){function ct(){return"circle"}function cs(){return 64}function cr(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cq<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),e=d[0][0].getScreenCTM();cq=!e.f&&!e.e,d.remove()}cq?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cp(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bB;return[c*Math.cos(d),c*Math.sin(d)]}}function co(a){return[a.x,a.y]}function cn(a){return a.endAngle}function cm(a){return a.startAngle}function cl(a){return a.radius}function ck(a){return a.target}function cj(a){return a.source}function ci(a){return function(b,c){return a[c][1]}}function ch(a){return function(b,c){return a[c][0]}}function cg(a){function i(f){if(f.length<1)return null;var i=bI(this,f,b,d),j=bI(this,f,b===c?ch(i):c,d===e?ci(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=bJ,c=bJ,d=0,e=bK,f="linear",g=bL[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=bL[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function cf(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bB,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function ce(a){return a.length<3?bM(a):a[0]+bS(a,cd(a))}function cd(a){var b=[],c,d,e,f,g=cc(a),h=-1,i=a.length-1;while(++h<i)c=cb(a[h],a[h+1]),Math.abs(c)<1e-6?g[h]=g[h+1]=0:(d=g[h]/c,e=g[h+1]/c,f=d*d+e*e,f>9&&(f=c*3/Math.sqrt(f),g[h]=f*d,g[h+1]=f*e));h=-1;while(++h<=i)f=(a[Math.min(i,h+1)][0]-a[Math.max(0,h-1)][0])/(6*(1+g[h]*g[h])),b.push([f||0,g[h]*f||0]);return b}function cc(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cb(e,f);while(++b<c)d[b]=g+(g=cb(e=f,f=a[b+1]));d[b]=g;return d}function cb(a,b){return(b[1]-a[1])/(b[0]-a[0])}function ca(a,b,c){a.push("C",bY(bZ,b),",",bY(bZ,c),",",bY(b$,b),",",bY(b$,c),",",bY(b_,b),",",bY(b_,c))}function bY(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function bX(a,b){var c=a.length-1,d=a[0][0],e=a[0][1],f=a[c][0]-d,g=a[c][1]-e,h=-1,i,j;while(++h<=c)i=a[h],j=h/c,i[0]=b*i[0]+(1-b)*(d+j*f),i[1]=b*i[1]+(1-b)*(e+j*g);return bU(a)}function bW(a){var b,c=-1,d=a.length,e=d+4,f,g=[],h=[];while(++c<4)f=a[c%d],g.push(f[0]),h.push(f[1]);b=[bY(b_,g),",",bY(b_,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),ca(b,g,h);return b.join("")}function bV(a){if(a.length<4)return bM(a);var b=[],c=-1,d=a.length,e,f=[0],g=[0];while(++c<3)e=a[c],f.push(e[0]),g.push(e[1]);b.push(bY(b_,f)+","+bY(b_,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),ca(b,f,g);return b.join("")}function bU(a){if(a.length<3)return bM(a);var b=[],c=1,d=a.length,e=a[0],f=e[0],g=e[1],h=[f,f,f,(e=a[1])[0]],i=[g,g,g,e[1]];b.push(f,",",g),ca(b,h,i);while(++c<d)e=a[c],h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),ca(b,h,i);c=-1;while(++c<2)h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),ca(b,h,i);return b.join("")}function bT(a,b){var c=[],d=(1-b)/2,e,f=a[0],g=a[1],h=1,i=a.length;while(++h<i)e=f,f=g,g=a[h],c.push([d*(g[0]-e[0]),d*(g[1]-e[1])]);return c}function bS(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return bM(a);var c=a.length!=b.length,d="",e=a[0],f=a[1],g=b[0],h=g,i=1;c&&(d+="Q"+(f[0]-g[0]*2/3)+","+(f[1]-g[1]*2/3)+","+f[0]+","+f[1],e=a[1],i=2);if(b.length>1){h=b[1],f=a[i],i++,d+="C"+(e[0]+g[0])+","+(e[1]+g[1])+","+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1];for(var j=2;j<b.length;j++,i++)f=a[i],h=b[j],d+="S"+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1]}if(c){var k=a[i];d+="Q"+(f[0]+h[0]*2/3)+","+(f[1]+h[1]*2/3)+","+k[0]+","+k[1]}return d}function bR(a,b,c){return a.length<3?bM(a):a[0]+bS(a,bT(a,b))}function bQ(a,b){return a.length<3?bM(a):a[0]+bS((a.push(a[0]),a),bT([a[a.length-2]].concat(a,[a[1]]),b))}function bP(a,b){return a.length<4?bM(a):a[1]+bS(a.slice(1,a.length-1),bT(a,b))}function bO(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("H",(e=a[c])[0],"V",e[1]);return b.join("")}function bN(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("V",(e=a[c])[1],"H",e[0]);return b.join("")}function bM(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("L",(e=a[c])[0],",",e[1]);return b.join("")}function bK(a){return a[1]}function bJ(a){return a[0]}function bI(a,b,c,d){var e=[],f=-1,g=b.length,h=typeof c=="function",i=typeof d=="function",j;if(h&&i)while(++f<g)e.push([c.call(a,j=b[f],f),d.call(a,j,f)]);else if(h)while(++f<g)e.push([c.call(a,b[f],f),d]);else if(i)while(++f<g)e.push([c,d.call(a,b[f],f)]);else while(++f<g)e.push([c,d]);return e}function bH(a){function g(d){return d.length<1?null:"M"+e(a(bI(this,d,b,c)),f)}var b=bJ,c=bK,d="linear",e=bL[d],f=.7;g.x=function(a){if(!arguments.length)return b;b=a;return g},g.y=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=bL[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g}function bG(a){return a.endAngle}function bF(a){return a.startAngle}function bE(a){return a.outerRadius}function bD(a){return a.innerRadius}function bw(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bv(a){return a.toPrecision(1)}function bu(a){return-Math.log(-a)/Math.LN10}function bt(a){return Math.log(a)/Math.LN10}function bs(a,b,c,d){var e=[],f=[],g=0,h=a.length;while(++g<h)e.push(c(a[g-1],a[g])),f.push(d(b[g-1],b[g]));return function(b){var c=d3.bisect(a,b,1,a.length-1)-1;return f[c](e[c](b))}}function br(a,b,c,d){var e=c(a[0],a[1]),f=d(b[0],b[1]);return function(a){return f(e(a))}}function bq(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bo(a,b)[2])/Math.LN10+.01))+"f")}function bp(a,b){return d3.range.apply(d3,bo(a,b))}function bo(a,b){var c=bj(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;f<=.15?e*=10:f<=.35?e*=5:f<=.75&&(e*=2),c[0]=Math.ceil(c[0]/e)*e,c[1]=Math.floor(c[1]/e)*e+e*.5,c[2]=e;return c}function bn(a){a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1);return{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bm(a,b){a.range=d3.rebind(a,b.range),a.rangeRound=d3.rebind(a,b.rangeRound),a.interpolate=d3.rebind(a,b.interpolate),a.clamp=d3.rebind(a,b.clamp);return a}function bl(){return Math}function bk(a,b){var c=0,d=a.length-1,e=a[c],f=a[d],g;f<e&&(g=c,c=d,d=g,g=e,e=f,f=g),b=b(f-e),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bj(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bi(){}function bg(){var a=null,b=bb,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bb=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function bf(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,a>c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bg()-b;d>24?(isFinite(d)&&(clearTimeout(bd),bd=setTimeout(bf,d)),bc=0):(bc=1,bh(bf))}function be(a,b){var c=Date.now(),d=!1,e,f=bb;if(!!isFinite(b)){while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(bb={callback:a,then:c,delay:b,next:bb}),bc||(bd=clearTimeout(bd),bc=1,bh(bf))}}function ba(a){return typeof a=="function"?function(b,c,d){var e=a.call(this,b,c)+"";return d!=e&&d3.interpolate(d,e)}:(a=a+"",function(b,c,d){return d!=a&&d3.interpolate(d,a)})}function _(a){function n(b){var h=!0,l=-1;a.each(function(){if(i[++l]!==2){var a=(b-j[l])/k[l],n=this.__transition__,o,p,q=e[l];if(a<1){h=!1;if(a<0)return}else a=1;if(i[l]){if(!n||n.active!==c){i[l]=2;return}}else{if(!n||n.active>c){i[l]=2;return}i[l]=1,g.start.dispatch.apply(this,arguments),q=e[l]={},n.active=c;for(p in d)if(o=d[p].apply(this,arguments))q[p]=o}o=m(a);for(p in q)q[p].call(this,o);if(a===1){i[l]=2;if(n.active===c){var r=n.owner;r===c&&(delete this.__transition__,f&&this.parentNode&&this.parentNode.removeChild(this)),$=c,g.end.dispatch.apply(this,arguments),$=0,n.owner=r}}}});return h}var b={},c=$||++Z,d={},e=[],f=!1,g=d3.dispatch("start","end"),i=[],j=[],k=[],l,m=d3.ease("cubic-in-out");a.each(function(){(this.__transition__||(this.__transition__={})).owner=c}),b.delay=function(c){var d=Infinity,e=-1;typeof c=="function"?a.each(function(a,b){var f=j[++e]=+c.apply(this,arguments);f<d&&(d=f)}):(d=+c,a.each(function(a,b){j[++e]=d})),be(n,d);return b},b.duration=function(c){var d=-1;typeof c=="function"?(l=0,a.each(function(a,b){var e=k[++d]=+c.apply(this,arguments);e>l&&(l=e)})):(l=+c,a.each(function(a,b){k[++d]=l}));return b},b.ease=function(a){m=typeof a=="function"?a:d3.ease.apply(d3,arguments);return b},b.attrTween=function(a,c){function f(b,d){var e=c.call(this,b,d,this.getAttributeNS(a.space,a.local));return e&&function(b){this.setAttributeNS(a.space,a.local,e(b))}}function e(b,d){var e=c.call(this,b,d,this.getAttribute(a));return e&&function(b){this.setAttribute(a,e(b))}}d["attr."+a]=a.local?f:e;return b},b.attr=function(a,c){return b.attrTween(a,ba(c))},b.styleTween=function(a,c,e){function f(b,d){var f=c.call(this,b,d,window.getComputedStyle(this,null).getPropertyValue(a));return f&&function(b){this.style.setProperty(a,f(b),e)}}arguments.length<3&&(e=null),d["style."+a]=f;return b},b.style=function(a,c,d){arguments.length<3&&(d=null);return b.styleTween(a,ba(c),d)},b.text=function(a){d.text=function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a};return b},b.select=function(b){var c,d=_(a.select(b)).ease(m);c=-1,d.delay(function(a,b){return j[++c]}),c=-1,d.duration(function(a,b){return k[++c]});return d},b.selectAll=function(b){var c,d=_(a.selectAll(b)).ease(m);c=-1,d.delay(function(a,b){return j[b?c:++c]}),c=-1,d.duration(function(a,b){return k[b?c:++c]});return d},b.remove=function(){f=!0;return b},b.each=function(a,c){g[a].add(c);return b},b.call=h;return b.delay(0).duration(250)}function Y(a){return{__data__:a}}function X(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function W(a){function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(f.parentNode)),e.__data__=g.__data__):d.push(null)}return V(c)}a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)};return a}function V(a){function d(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];if(h)return b.call(h,h.__data__,f)}}return null}function c(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g];for(var i=0,j=e.length;i<j;i++)if(f=e[i])c.push(d=b(f)),d.parentNode=f}return V(c)}function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(g)),e&&"__data__"in g&&(e.__data__=g.__data__)):d.push(null)}return V(c)}a.select=function(a){return b(function(b){return S(a,b)})},a.selectAll=function(a){return c(function(b){return T(a,b)})},a.filter=function(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g],c.push(d=[]),d.parentNode=e.parentNode;for(var i=0,j=e.length;i<j;i++)(f=e[i])&&b.call(f,f.__data__,i)&&d.push(f)}return V(c)},a.map=function(b){var c,d;for(var e=0,f=a.length;e<f;e++){c=a[e];for(var g=0,h=c.length;g<h;g++)if(d=c[g])d.__data__=b.call(d,d.__data__,g)}return a},a.data=function(b,c){function g(a,b){var g=0,h=a.length,i=b.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(c){var q={},r=[],s,t=b.length;for(g=0;g<h;g++)s=c.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=0;g<i;g++)o=q[s=c.call(b,p=b[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null),delete q[s];for(g=0;g<h;g++)r[g]in q&&(n[g]=a[g])}else{for(;g<j;g++)o=a[g],p=b[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null);for(;g<i;g++)m[g]=Y(b[g]),l[g]=n[g]=null;for(;g<k;g++)n[g]=a[g],m[g]=l[g]=null}m.parentNode=l.parentNode=n.parentNode=a.parentNode,d.push(m),e.push(l),f.push(n)}var d=[],e=[],f=[],h=-1,i=a.length,j;if(typeof b=="function")while(++h<i)g(j=a[h],b.call(j,j.parentNode.__data__,h));else while(++h<i)g(j=a[h],b);var k=V(e);k.enter=function(){return W(d)},k.exit=function(){return V(f)};return k},a.each=function(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];h&&b.call(h,h.__data__,f)}}return a},a.empty=function(){return!d(function(){return!0})},a.node=function(){return d(function(){return this})},a.attr=function(b,c){function j(){var a=c.apply(this,arguments);a==null?this.removeAttributeNS(b.space,b.local):this.setAttributeNS(b.space,b.local,a)}function i(){var a=c.apply(this,arguments);a==null?this.removeAttribute(b):this.setAttribute(b,a)}function h(){this.setAttributeNS(b.space,b.local,c)}function g(){this.setAttribute(b,c)}function f(){this.removeAttributeNS(b.space,b.local)}function e(){this.removeAttribute(b)}b=d3.ns.qualify(b);if(arguments.length<2)return d(b.local?function(){return this.getAttributeNS(b.space,b.local)}:function(){return this.getAttribute(b)});return a.each(c==null?b.local?f:e:typeof c=="function"?b.local?j:i:b.local?h:g)},a.classed=function(b,c){function i(){(c.apply(this,arguments)?f:h).call(this)}function h(){if(a=this.classList)return a.remove(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;d=g(d.replace(e," ")),c?a.baseVal=d:this.className=d}function f(){if(a=this.classList)return a.add(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;e.lastIndex=0,e.test(d)||(d=g(d+" "+b),c?a.baseVal=d:this.className=d)}var e=new RegExp("(^|\\s+)"+d3.requote(b)+"(\\s+|$)","g");if(arguments.length<2)return d(function(){if(a=this.classList)return a.contains(b);var a=this.className;e.lastIndex=0;return e.test(a.baseVal!=null?a.baseVal:a)});return a.each(typeof c=="function"?i:c?f:h)},a.style=function(b,c,e){function h(){var a=c.apply(this,arguments);a==null?this.style.removeProperty(b):this.style.setProperty(b,a,e)}function g(){this.style.setProperty(b,c,e)}function f(){this.style.removeProperty(b)}arguments.length<3&&(e="");if(arguments.length<2)return d(function(){return window.getComputedStyle(this,null).getPropertyValue(b)});return a.each(c==null?f:typeof c=="function"?h:g)},a.property=function(b,c){function g(){var a=c.apply(this,arguments);a==null?delete this[b]:this[b]=a}function f(){this[b]=c}function e(){delete this[b]}b=d3.ns.qualify(b);if(arguments.length<2)return d(function(){return this[b]});return a.each(c==null?e:typeof c=="function"?g:f)},a.text=function(b){function e(){this.textContent=b.apply(this,arguments)}function c(){this.textContent=b}if(arguments.length<1)return d(function(){return this.textContent});return a.each(typeof b=="function"?e:c)},a.html=function(b){function e(){this.innerHTML=b.apply(this,arguments)}function c(){this.innerHTML=b}if(arguments.length<1)return d(function(){return this.innerHTML});return a.each(typeof b=="function"?e:c)},a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)},a.remove=function(){return a.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},a.sort=function(b){b=X.apply(this,arguments);for(var c=0,d=a.length;c<d;c++){var e=a[c];e.sort(b);for(var f=1,g=e.length,h=e[0];f<g;f++){var i=e[f];i&&(h&&h.parentNode.insertBefore(i,h.nextSibling),h=i)}}return a},a.on=function(b,c,d){arguments.length<3&&(d=!1);var e=b.indexOf("."),f=e===-1?b:b.substring(0,e),g="__on"+b;return a.each(function(a,b){function h(a){var d=d3.event;d3.event=a;try{c.call(this,e.__data__,b)}finally{d3.event=d}}this[g]&&this.removeEventListener(f,this[g],d),c&&this.addEventListener(f,this[g]=h,d);var e=this})},a.transition=function(){return _(a)},a.call=h;return a}function R(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);if(a<60)return d+(e-d)*a/60;if(a<180)return e;if(a<240)return d+(e-d)*(240-a)/60;return d}var d,e;a=a%360,a<0&&(a+=360),b=b<0?0:b>1?1:b,c=c<0?0:c>1?1:c,e=c<=.5?c*(1+b):c+b-c*b,d=2*c-e;return H(g(a+120),g(a),g(a-120))}function Q(a,b,c){this.h=a,this.s=b,this.l=c}function P(a,b,c){return new Q(a,b,c)}function M(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function L(a,b,c){var d=Math.min(a/=255,b/=255,c/=255),e=Math.max(a,b,c),f=e-d,g,h,i=(e+d)/2;f?(h=i<.5?f/(e+d):f/(2-e-d),a==e?g=(b-c)/f+(b<c?6:0):b==e?g=(c-a)/f+2:g=(a-b)/f+4,g*=60):h=g=0;return P(g,h,i)}function K(a,b,c){var d=0,e=0,f=0,g,h,i;g=/([a-z]+)\((.*)\)/i.exec(a);if(g){h=g[2].split(",");switch(g[1]){case"hsl":return c(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case"rgb":return b(M(h[0]),M(h[1]),M(h[2]))}}if(i=N[a])return b(i.r,i.g,i.b);a!=null&&a.charAt(0)==="#"&&(a.length===4?(d=a.charAt(1),d+=d,e=a.charAt(2),e+=e,f=a.charAt(3),f+=f):a.length===7&&(d=a.substring(1,3),e=a.substring(3,5),f=a.substring(5,7)),d=parseInt(d,16),e=parseInt(e,16),f=parseInt(f,16));return b(d,e,f)}function J(a){return a<16?"0"+a.toString(16):a.toString(16)}function I(a,b,c){this.r=a,this.g=b,this.b=c}function H(a,b,c){return new I(a,b,c)}function G(a,b){b=1/(b-(a=+a));return function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function F(a,b){b=1/(b-(a=+a));return function(c){return(c-a)*b}}function E(a){return a in D||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function B(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}function A(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function z(a,b){var c;arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a);return function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function y(a){return 1-Math.sqrt(1-a*a)}function x(a){return a?Math.pow(2,10*(a-1))-.001:0}function w(a){return 1-Math.cos(a*Math.PI/2)}function v(a){return function(b){return Math.pow(b,a)}}function u(a){return a}function t(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function s(a){return function(b){return 1-a(1-b)}}function n(a){var b=a.lastIndexOf("."),c=b>=0?a.substring(b):(b=a.length,""),d=[];while(b>0)d.push(a.substring(b-=3,b+3));return d.reverse().join(",")+c}function m(a){return a+""}function j(a){var b={},c=[];b.add=function(a){for(var d=0;d<c.length;d++)if(c[d].listener==a)return b;c.push({listener:a,on:!0});return b},b.remove=function(a){for(var d=0;d<c.length;d++){var e=c[d];if(e.listener==a){e.on=!1,c=c.slice(0,d).concat(c.slice(d+1));break}}return b},b.dispatch=function(){var a=c;for(var b=0,d=a.length;b<d;b++){var e=a[b];e.on&&e.listener.apply(this,arguments)}};return b}function h(a){a.apply(this,(arguments[0]=this,arguments));return this}function g(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function f(a){return a==null}function e(a){return a.length}function c(a){return Array.prototype.slice.call(a)}function b(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}d3={version:"1.29.1"},Date.now||(Date.now=function(){return+(new Date)}),Object.create||(Object.create=function(a){function b(){}b.prototype=a;return new b});var a=c;try{a(document.documentElement.childNodes)[0].nodeType}catch(d){a=b}d3.functor=function(a){return typeof a=="function"?a:function(){return a}},d3.rebind=function(a,b){return function(){var c=b.apply(a,arguments);return arguments.length?a:c}},d3.ascending=function(a,b){return a<b?-1:a>b?1:0},d3.descending=function(a,b){return b<a?-1:b>a?1:0},d3.min=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&e>f&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&e>f&&(e=f)}return e},d3.max=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&f>e&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&f>e&&(e=f)}return e},d3.sum=function(a,b){var c=0,d=a.length,e,f=-1;if(arguments.length===1)while(++f<d)isNaN(e=+a[f])||(c+=e);else while(++f<d)isNaN(e=+b.call(a,a[f],f))||(c+=e);return c},d3.quantile=function(a,b){var c=(a.length-1)*b+1,d=Math.floor(c),e=a[d-1],f=c-d;return f?e+f*(a[d]-e):e},d3.zip=function(){if(!(f=arguments.length))return[];for(var a=-1,b=d3.min(arguments,e),c=Array(b);++a<b;)for(var d=-1,f,g=c[a]=Array(f);++d<f;)g[d]=arguments[d][a];return c},d3.bisectLeft=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;a[e]<b?c=e+1:d=e}return c},d3.bisect=d3.bisectRight=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;b<a[e]?d=e:c=e+1}return c},d3.first=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])>0&&(e=f);return e},d3.last=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])<=0&&(e=f);return e},d3.nest=function(){function g(a,d){if(d>=b.length)return a;var e=[],f=c[d++],h;for(h in a)e.push({key:h,values:g(a[h],d)});f&&e.sort(function(a,b){return f(a.key,b.key)});return e}function f(c,g){if(g>=b.length)return e?e.call(a,c):d?c.sort(d):c;var h=-1,i=c.length,j=b[g++],k,l,m={};while(++h<i)(k=j(l=c[h]))in m?m[k].push(l):m[k]=[l];for(k in m)m[k]=f(m[k],g);return m}var a={},b=[],c=[],d,e;a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){b.push(c);return a},a.sortKeys=function(d){c[b.length-1]=d;return a},a.sortValues=function(b){d=b;return a},a.rollup=function(b){e=b;return a};return a},d3.keys=function(a){var b=[];for(var c in a)b.push(c);return b},d3.values=function(a){var b=[];for(var c in a)b.push(a[c]);return b},d3.entries=function(a){var b=[];for(var c in a)b.push({key:c,value:a[c]});return b},d3.permute=function(a,b){var c=[],d=-1,e=b.length;while(++d<e)c[d]=a[b[d]];return c},d3.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],e,g=-1,h=a.length;arguments.length<2&&(b=f);while(++g<h)b.call(d,e=a[g],g)?d=[]:(d.length||c.push(d),d.push(e));return c},d3.range=function(a,b,c){arguments.length===1&&(b=a,a=0),c==null&&(c=1);if((b-a)/c==Infinity)throw new Error("infinite range");var d=[],e=-1,f;if(c<0)while((f=a+c*++e)>b)d.push(f);else while((f=a+c*++e)<b)d.push(f);return d},d3.requote=function(a){return a.replace(i,"\\$&")};var i=/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g;d3.round=function(a,b){return b?Math.round(a*Math.pow(10,b))*Math.pow(10,-b):Math.round(a)},d3.xhr=function(a,b,c){var d=new XMLHttpRequest;arguments.length<3?c=b:b&&d.overrideMimeType&&d.overrideMimeType(b),d.open("GET",a,!0),d.onreadystatechange=function(){d.readyState===4&&c(d.status<300?d:null)},d.send(null)},d3.text=function(a,b,c){function d(a){c(a&&a.responseText)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.json=function(a,b){d3.text(a,"application/json",function(a){b(a?JSON.parse(a):null)})},d3.html=function(a,b){d3.text(a,"text/html",function(a){if(a!=null){var c=document.createRange();c.selectNode(document.body),a=c.createContextualFragment(a)}b(a)})},d3.xml=function(a,b,c){function d(a){c(a&&a.responseXML)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}},d3.dispatch=function(a){var b={},c;for(var d=0,e=arguments.length;d<e;d++)c=arguments[d],b[c]=j(c);return b},d3.format=function(a){var b=k.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9],j=!1,o=!1;h&&(h=h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4)));switch(i){case"n":g=!0,i="g";break;case"%":j=!0,i="f";break;case"p":j=!0,i="r";break;case"d":o=!0,h="0"}i=l[i]||m;return function(a){var b=j?a*100:+a,k=b<0&&(b=-b)?"−":d;if(o&&b%1)return"";a=i(b,h);if(e){var l=a.length+k.length;l<f&&(a=Array(f-l+1).join(c)+a),g&&(a=n(a)),a=k+a}else{g&&(a=n(a)),a=k+a;var l=a.length;l<f&&(a=Array(f-l+1).join(c)+a)}j&&(a+="%");return a}};var k=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,l={g:function(a,b){return a.toPrecision(b)},e:function(a,b){return a.toExponential(b)},f:function(a,b){return a.toFixed(b)},r:function(a,b){var c=1+Math.floor(1e-15+Math.log(a)/Math.LN10);return d3.round(a,b-c).toFixed(Math.max(0,b-c))}},o=v(2),p=v(3),q={linear:function(){return u},poly:v,quad:function(){return o},cubic:function(){return p},sin:function(){return w},exp:function(){return x},circle:function(){return y},elastic:z,back:A,bounce:function(){return B}},r={"in":function(a){return a},out:s,"in-out":t,"out-in":function(a){return t(s(a))}};d3.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return r[d](q[c].apply(null,Array.prototype.slice.call(arguments,1)))},d3.event=null,d3.interpolate=function(a,b){var c=d3.interpolators.length,d;while(--c>=0&&!(d=d3.interpolators[c](a,b)));return d},d3.interpolateNumber=function(a,b){b-=a;return function(c){return a+b*c}},d3.interpolateRound=function(a,b){b-=a;return function(c){return Math.round(a+b*c)}},d3.interpolateString=function(a,b){var c,d,e,f=0,g=0,h=[],i=[],j,k;C.lastIndex=0;for(d=0;c=C.exec(b);++d)c.index&&h.push(b.substring(f,g=c.index)),i.push({i:h.length,x:c[0]}),h.push(null),f=C.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=C.exec(a))&&d<j;++d){k=i[d];if(k.x==c[0]){if(k.i)if(h[k.i+1]==null){h[k.i-1]+=k.x,h.splice(k.i,1);for(e=d+1;e<j;++e)i[e].i--}else{h[k.i-1]+=k.x+h[k.i+1],h.splice(k.i,2);for(e=d+1;e<j;++e)i[e].i-=2}else if(h[k.i+1]==null)h[k.i]=k.x;else{h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1);for(e=d+1;e<j;++e)i[e].i--}i.splice(d,1),j--,d--}else k.x=d3.interpolateNumber(parseFloat(c[0]),parseFloat(k.x))}while(d<j)k=i.pop(),h[k.i+1]==null?h[k.i]=k.x:(h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1)),j--;if(h.length===1)return h[0]==null?i[0].x:function(){return b};return function(a){for(d=0;d<j;++d)h[(k=i[d]).i]=k.x(a);return h.join("")}},d3.interpolateRgb=function(a,b){a=d3.rgb(a),b=d3.rgb(b);var c=a.r,d=a.g,e=a.b,f=b.r-c,g=b.g-d,h=b.b-e;return function(a){return"rgb("+Math.round(c+f*a)+","+Math.round(d+g*a)+","+Math.round(e+h*a)+")"}},d3.interpolateHsl=function(a,b){a=d3.hsl(a),b=d3.hsl(b);var c=a.h,d=a.s,e=a.l,f=b.h-c,g=b.s-d,h=b.l-e;return function(a){return R(c+f*a,d+g*a,e+h*a).toString()}},d3.interpolateArray=function(a,b){var c=[],d=[],e=a.length,f=b.length,g=Math.min(a.length,b.length),h;for(h=0;h<g;++h)c.push(d3.interpolate(a[h],b[h]));for(;h<e;++h)d[h]=a[h];for(;h<f;++h)d[h]=b[h];return function(a){for(h=0;h<g;++h)d[h]=c[h](a);return d}},d3.interpolateObject=function(a,b){var c={},d={},e;for(e in a)e in b?c[e]=E(e)(a[e],b[e]):d[e]=a[e];for(e in b)e in a||(d[e]=b[e]);return function(a){for(e in c)d[e]=c[e](a);return d}};var C=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,D={background:1,fill:1,stroke:1};d3.interpolators=[d3.interpolateObject,function(a,b){return b instanceof Array&&d3.interpolateArray(a,b)},function(a,b){return typeof b=="string"&&d3.interpolateString(String(a),b)},function(a,b){return(b in N||/^(#|rgb\(|hsl\()/.test(b))&&d3.interpolateRgb(String(a),b)},function(a,b){return typeof b=="number"&&d3.interpolateNumber(+a,b)}],d3.rgb=function(a,b,c){return arguments.length===1?K(""+a,H,R):H(~~a,~~b,~~c)},I.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;if(!b&&!c&&!d)return H(e,e,e);b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e);return H(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))},I.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return H(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)))},I.prototype.hsl=function(){return L(this.r,this.g,this.b)},I.prototype.toString=function(){return"#"+J(this.r)+J(this.g)+J(this.b)};var N={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};for(var O in N)N[O]=K(N[O],H,R);d3.hsl=function(a,b,c){return arguments.length===1?K(""+a,L,P):P(+a,+b,+c)},Q.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,this.l/a)},Q.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,a*this.l)},Q.prototype.rgb=function(){return R(this.h,this.s,this.l)},Q.prototype.toString=function(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"};var S=function(a,b){return b.querySelector(a)},T=function(b,c){return a(c.querySelectorAll(b))};typeof Sizzle=="function"&&(S=function(a,b){return Sizzle(a,b)[0]},T=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var U=V([[document+]]);U[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?U.select(a):V([[a]])},d3.selectAll=function(b){return typeof b=="string"?U.selectAll(b):V([a(b)])},d3.transition=U.transition;var Z=0,$=0,bb=null,bc,bd;d3.timer=function(a){be(a,0)},d3.timer.flush=function(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bg()};var bh=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){function h(a){return e(a)}function g(){var g=a.length==2?br:bs,i=d?G:F;e=g(a,b,i,c),f=g(b,a,i,d3.interpolate);return h}var a=[0,1],b=[0,1],c=d3.interpolate,d=!1,e,f;h.invert=function(a){return f(a)},h.domain=function(b){if(!arguments.length)return a;a=b.map(Number);return g()},h.range=function(a){if(!arguments.length)return b;b=a;return g()},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){if(!arguments.length)return d;d=a;return g()},h.interpolate=function(a){if(!arguments.length)return c;c=a;return g()},h.ticks=function(b){return bp(a,b)},h.tickFormat=function(b){return bq(a,b)},h.nice=function(){bk(a,bn);return g()};return g()},d3.scale.log=function(){function d(c){return a(b(c))}var a=d3.scale.linear(),b=bt,c=b.pow;d.invert=function(b){return c(a.invert(b))},d.domain=function(e){if(!arguments.length)return a.domain().map(c);b=e[0]<0?bu:bt,c=b.pow,a.domain(e.map(b));return d},d.nice=function(){a.domain(bk(a.domain(),bl));return d},d.ticks=function(){var d=bj(a.domain()),e=[];if(d.every(isFinite)){var f=Math.floor(d[0]),g=Math.ceil(d[1]),h=c(d[0]),i=c(d[1]);if(b===bu){e.push(c(f));for(;f++<g;)for(var j=9;j>0;j--)e.push(c(f)*j)}else{for(;f<g;f++)for(var j=1;j<10;j++)e.push(c(f)*j);e.push(c(f))}for(f=0;e[f]<h;f++);for(g=e.length;e[g-1]>i;g--);e=e.slice(f,g)}return e},d.tickFormat=function(){return bv};return bm(d,a)},bt.pow=function(a){return Math.pow(10,a)},bu.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){function e(b){return a(c(b))}var a=d3.scale.linear(),b=1,c=Number,d=c;e.invert=function(b){return d(a.invert(b))},e.domain=function(f){if(!arguments.length)return a.domain().map(d);c=bw(b),d=bw(1/b),a.domain(f.map(c));return e},e.ticks=function(a){return bp(e.domain(),a)},e.tickFormat=function(a){return bq(e.domain(),a)},e.nice=function(){return e.domain(bk(e.domain(),bn))},e.exponent=function(a){if(!arguments.length)return b;var c=e.domain();b=a;return e.domain(c)};return bm(e,a)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){function f(d){var e=d in b?b[d]:b[d]=a.push(d)-1;return c[e%c.length]}var a=[],b={},c=[],d=0,e=bi;f.domain=function(c){if(!arguments.length)return a;a=c,b={};var d=-1,g=-1,h=a.length;while(++d<h)c=a[d],c in b||(b[c]=++g);e();return f},f.range=function(a){if(!arguments.length)return c;c=a,e=bi;return f},f.rangePoints=function(b,g){arguments.length<2&&(g=0),(e=function(){var e=b[0],f=b[1],h=(f-e)/(a.length-1+g);c=a.length==1?[(e+f)/2]:d3.range(e+h*g/2,f+h/2,h),d=0})();return f},f.rangeBands=function(b,g){arguments.length<2&&(g=0),(e=function(){var e=b[0],f=b[1],h=(f-e)/(a.length+g);c=d3.range(e+h*g,f,h),d=h*(1-g)})();return f},f.rangeRoundBands=function(b,g){arguments.length<2&&(g=0),(e=function(){var e=b[0],f=b[1],h=f-e,i=Math.floor(h/(a.length+g)),j=h-(a.length-g)*i;c=d3.range(e+Math.round(j/2),f,i),d=Math.round(i*(1-g))})();return f},f.rangeBand=function(){return d};return f},d3.scale.category10=function(){return d3.scale.ordinal().range(bx)},d3.scale.category20=function(){return d3.scale.ordinal().range(by)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bz)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bA)};var bx=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],by=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bz=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bA=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){function e(a){if(isNaN(a=+a))return NaN;return b[d3.bisect(c,a)]}function d(){var d=0,e=a.length,f=b.length;c.length=Math.max(0,f-1);while(++d<f)c[d-1]=d3.quantile(a,d/f)}var a=[],b=[],c=[];e.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending),d();return e},e.range=function(a){if(!arguments.length)return b;b=a,d();return e},e.quantiles=function(){return c};return e},d3.scale.quantize=function(){function f(b){return e[Math.max(0,Math.min(d,Math.floor(c*(b-a))))]}var a=0,b=1,c=2,d=1,e=[0,1];f.domain=function(d){if(!arguments.length)return[a,b];a=d[0],b=d[1],c=e.length/(b-a);return f},f.range=function(g){if(!arguments.length)return e;e=g,c=e.length/(b-a),d=e.length-1;return f};return f},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+bB,h=d.apply(this,arguments)+bB,i=h-g,j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=bC?e?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+ -e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":e?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+e*m+","+e*n+"A"+e+","+e+" 0 "+j+",0 "+e*k+","+e*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0"+"Z"}var a=bD,b=bE,c=bF,d=bG;e.innerRadius=function(b){if(!arguments.length)return a;a=d3.functor(b);return e},e.outerRadius=function(a){if(!arguments.length)return b;b=d3.functor(a);return e},e.startAngle=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.endAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return e},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+bB;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bB=-Math.PI/2,bC=2*Math.PI-1e-6;d3.svg.line=function(){return bH(Object)};var bL={linear:bM,"step-before":bN,"step-after":bO,basis:bU,"basis-open":bV,"basis-closed":bW,bundle:bX,cardinal:bR,"cardinal-open":bP,"cardinal-closed":bQ,monotone:ce},bZ=[0,2/3,1/3,0],b$=[0,1/3,2/3,0],b_=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=bH(cf);a.radius=a.x,delete a.x,a.angle=a.y,delete a.y;return a},d3.svg.area=function(){return cg(Object)},d3.svg.area.radial=function(){var a=cg(cf);a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1;return a},d3.svg.chord=function(){function j(a,b,c,d){return"Q 0,0 "+d}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}function g(a,b,f,g){var h=b.call(a,f,g),i=c.call(a,h,g),j=d.call(a,h,g)+bB,k=e.call(a,h,g)+bB;return{r:i,a0:j,a1:k,p0:[i*Math.cos(j),i*Math.sin(j)],p1:[i*Math.cos(k),i*Math.sin(k)]}}function f(c,d){var e=g(this,a,c,d),f=g(this,b,c,d);return"M"+e.p0+i(e.r,e.p1)+(h(e,f)?j(e.r,e.p1,e.r,e.p0):j(e.r,e.p1,f.r,f.p0)+i(f.r,f.p1)+j(f.r,f.p1,e.r,e.p0))+"Z"}var a=cj,b=ck,c=cl,d=bF,e=bG;f.radius=function(a){if(!arguments.length)return c;c=d3.functor(a);return f},f.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return f},f.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return f},f.startAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return f},f.endAngle=function(a){if(!arguments.length)return e;e=d3.functor(a);return f};return f},d3.svg.diagonal=function(){function d(d,e){var f=a.call(this,d,e),g=b.call(this,d,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];i=i.map(c);return"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=cj,b=ck,c=co;d.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return d},d.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return d},d.projection=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=co,c=a.projection;a.projection=function(a){return arguments.length?c(cp(b=a)):b};return a},d3.svg.mouse=function(a){return cr(a,d3.event)};var cq=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(b){var c=d3.event.touches;return c?a(c).map(function(a){var c=cr(b,a);c.identifier=a.identifier;return c}):[]},d3.svg.symbol=function(){function c(c,d){return(cu[a.call(this,c,d)]||cu.circle)(b.call(this,c,d))}var a=ct,b=cs;c.type=function(b){if(!arguments.length)return a;a=d3.functor(b);return c},c.size=function(a){if(!arguments.length)return b;b=d3.functor(a);return c};return c};var cu={circle:function(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+ -b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"},cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+ -3*b+","+ -b+"H"+ -b+"V"+ -3*b+"H"+b+"V"+ -b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+ -b+"V"+b+"H"+ -3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*cw)),c=b*cw;return"M0,"+ -b+"L"+c+",0"+" 0,"+b+" "+ -c+",0"+"Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+ -b+","+ -b+"L"+b+","+ -b+" "+b+","+b+" "+ -b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/cv),c=b*cv/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cv),c=b*cv/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cu);var cv=Math.sqrt(3),cw=Math.tan(30*Math.PI/180)})()
+ static/js/jquery.fileupload.js view
@@ -0,0 +1,752 @@+/*+ * jQuery File Upload Plugin 5.1+ * https://github.com/blueimp/jQuery-File-Upload+ *+ * Copyright 2010, Sebastian Tschan+ * https://blueimp.net+ *+ * Licensed under the MIT license:+ * http://creativecommons.org/licenses/MIT/+ */++/*jslint nomen: true, unparam: true, regexp: true */+/*global document, XMLHttpRequestUpload, Blob, File, FormData, location, jQuery */++(function ($) {+    'use strict';++    // The fileupload widget listens for change events on file input fields+    // defined via fileInput setting and drop events of the given dropZone.+    // In addition to the default jQuery Widget methods, the fileupload widget+    // exposes the "add" and "send" methods, to add or directly send files+    // using the fileupload API.+    // By default, files added via file input selection, drag & drop or+    // "add" method are uploaded immediately, but it is possible to override+    // the "add" callback option to queue file uploads.+    $.widget('blueimp.fileupload', {+        +        options: {+            // The namespace used for event handler binding on the dropZone and+            // fileInput collections.+            // If not set, the name of the widget ("fileupload") is used.+            namespace: undefined,+            // The drop target collection, by the default the complete document.+            // Set to null or an empty collection to disable drag & drop support:+            dropZone: $(document),+            // The file input field collection, that is listened for change events.+            // If undefined, it is set to the file input fields inside+            // of the widget element on plugin initialization.+            // Set to null or an empty collection to disable the change listener.+            fileInput: undefined,+            // By default, the file input field is replaced with a clone after+            // each input field change event. This is required for iframe transport+            // queues and allows change events to be fired for the same file+            // selection, but can be disabled by setting the following option to false:+            replaceFileInput: true,+            // The parameter name for the file form data (the request argument name).+            // If undefined or empty, the name property of the file input field is+            // used, or "files[]" if the file input name property is also empty:+            paramName: undefined,+            // By default, each file of a selection is uploaded using an individual+            // request for XHR type uploads. Set to false to upload file+            // selections in one request each:+            singleFileUploads: true,+            // Set the following option to true to issue all file upload requests+            // in a sequential order:+            sequentialUploads: false,+            // To limit the number of concurrent uploads,+            // set the following option to an integer greater than 0:+            limitConcurrentUploads: undefined,+            // Set the following option to true to force iframe transport uploads:+            forceIframeTransport: false,+            // By default, XHR file uploads are sent as multipart/form-data.+            // The iframe transport is always using multipart/form-data.+            // Set to false to enable non-multipart XHR uploads:+            multipart: true,+            // To upload large files in smaller chunks, set the following option+            // to a preferred maximum chunk size. If set to 0, null or undefined,+            // or the browser does not support the required Blob API, files will+            // be uploaded as a whole.+            maxChunkSize: undefined,+            // When a non-multipart upload or a chunked multipart upload has been+            // aborted, this option can be used to resume the upload by setting+            // it to the size of the already uploaded bytes. This option is most+            // useful when modifying the options object inside of the "add" or+            // "send" callbacks, as the options are cloned for each file upload.+            uploadedBytes: undefined,+            // By default, failed (abort or error) file uploads are removed from the+            // global progress calculation. Set the following option to false to+            // prevent recalculating the global progress data:+            recalculateProgress: true,+            +            // Additional form data to be sent along with the file uploads can be set+            // using this option, which accepts an array of objects with name and+            // value properties, a function returning such an array, a FormData+            // object (for XHR file uploads), or a simple object.+            // The form of the first fileInput is given as parameter to the function:+            formData: function (form) {+                return form.serializeArray();+            },+            +            // The add callback is invoked as soon as files are added to the fileupload+            // widget (via file input selection, drag & drop or add API call).+            // If the singleFileUploads option is enabled, this callback will be+            // called once for each file in the selection for XHR file uplaods, else+            // once for each file selection.+            // The upload starts when the submit method is invoked on the data parameter.+            // The data object contains a files property holding the added files+            // and allows to override plugin options as well as define ajax settings.+            // Listeners for this callback can also be bound the following way:+            // .bind('fileuploadadd', func);+            // data.submit() returns a Promise object and allows to attach additional+            // handlers using jQuery's Deferred callbacks:+            // data.submit().done(func).fail(func).always(func);+            add: function (e, data) {+                data.submit();+            },+            +            // Other callbacks:+            // Callback for the start of each file upload request:+            // send: function (e, data) {}, // .bind('fileuploadsend', func);+            // Callback for successful uploads:+            // done: function (e, data) {}, // .bind('fileuploaddone', func);+            // Callback for failed (abort or error) uploads:+            // fail: function (e, data) {}, // .bind('fileuploadfail', func);+            // Callback for completed (success, abort or error) requests:+            // always: function (e, data) {}, // .bind('fileuploadalways', func);+            // Callback for upload progress events:+            // progress: function (e, data) {}, // .bind('fileuploadprogress', func);+            // Callback for global upload progress events:+            // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);+            // Callback for uploads start, equivalent to the global ajaxStart event:+            // start: function (e) {}, // .bind('fileuploadstart', func);+            // Callback for uploads stop, equivalent to the global ajaxStop event:+            // stop: function (e) {}, // .bind('fileuploadstop', func);+            // Callback for change events of the fileInput collection:+            // change: function (e, data) {}, // .bind('fileuploadchange', func);+            // Callback for drop events of the dropZone collection:+            // drop: function (e, data) {}, // .bind('fileuploaddrop', func);+            // Callback for dragover events of the dropZone collection:+            // dragover: function (e) {}, // .bind('fileuploaddragover', func);+            +            // The plugin options are used as settings object for the ajax calls.+            // The following are jQuery ajax settings required for the file uploads:+            processData: false,+            contentType: false,+            cache: false+        },+        +        // A list of options that require a refresh after assigning a new value:+        _refreshOptionsList: ['namespace', 'dropZone', 'fileInput'],++        _isXHRUpload: function (options) {+            var undef = 'undefined';+            return !options.forceIframeTransport &&+                typeof XMLHttpRequestUpload !== undef && typeof File !== undef &&+                (!options.multipart || typeof FormData !== undef);+        },++        _getFormData: function (options) {+            var formData;+            if (typeof options.formData === 'function') {+                return options.formData(options.form);+            } else if ($.isArray(options.formData)) {+                return options.formData;+            } else if (options.formData) {+                formData = [];+                $.each(options.formData, function (name, value) {+                    formData.push({name: name, value: value});+                });+                return formData;+            }+            return [];+        },++        _getTotal: function (files) {+            var total = 0;+            $.each(files, function (index, file) {+                total += file.size || 1;+            });+            return total;+        },++        _onProgress: function (e, data) {+            if (e.lengthComputable) {+                var total = data.total || this._getTotal(data.files),+                    loaded = parseInt(+                        e.loaded / e.total * (data.chunkSize || total),+                        10+                    ) + (data.uploadedBytes || 0);+                this._loaded += loaded - (data.loaded || data.uploadedBytes || 0);+                data.lengthComputable = true;+                data.loaded = loaded;+                data.total = total;+                // Trigger a custom progress event with a total data property set+                // to the file size(s) of the current upload and a loaded data+                // property calculated accordingly:+                this._trigger('progress', e, data);+                // Trigger a global progress event for all current file uploads,+                // including ajax calls queued for sequential file uploads:+                this._trigger('progressall', e, {+                    lengthComputable: true,+                    loaded: this._loaded,+                    total: this._total+                });+            }+        },++        _initProgressListener: function (options) {+            var that = this,+                xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();+            // Accesss to the native XHR object is required to add event listeners+            // for the upload progress event:+            if (xhr.upload && xhr.upload.addEventListener) {+                xhr.upload.addEventListener('progress', function (e) {+                    that._onProgress(e, options);+                }, false);+                options.xhr = function () {+                    return xhr;+                };+            }+        },++        _initXHRData: function (options) {+            var formData,+                file = options.files[0];+            if (!options.multipart || options.blob) {+                // For non-multipart uploads and chunked uploads,+                // file meta data is not part of the request body,+                // so we transmit this data as part of the HTTP headers.+                // For cross domain requests, these headers must be allowed+                // via Access-Control-Allow-Headers or removed using+                // the beforeSend callback:+                options.headers = $.extend(options.headers, {+                    'X-File-Name': file.name,+                    'X-File-Type': file.type,+                    'X-File-Size': file.size+                });+                if (!options.blob) {+                    // Non-chunked non-multipart upload:+                    options.contentType = file.type;+                    options.data = file;+                } else if (!options.multipart) {+                    // Chunked non-multipart upload:+                    options.contentType = 'application/octet-stream';+                    options.data = options.blob;+                }+            }+            if (options.multipart && typeof FormData !== 'undefined') {+                if (options.formData instanceof FormData) {+                    formData = options.formData;+                } else {+                    formData = new FormData();+                    $.each(this._getFormData(options), function (index, field) {+                        formData.append(field.name, field.value);+                    });+                }+                if (options.blob) {+                    formData.append(options.paramName, options.blob);+                } else {+                    $.each(options.files, function (index, file) {+                        // File objects are also Blob instances.+                        // This check allows the tests to run with+                        // dummy objects:+                        if (file instanceof Blob) {+                            formData.append(options.paramName, file);+                        }+                    });+                }+                options.data = formData;+            }+            // Blob reference is not needed anymore, free memory:+            options.blob = null;+        },+        +        _initIframeSettings: function (options) {+            // Setting the dataType to iframe enables the iframe transport:+            options.dataType = 'iframe ' + (options.dataType || '');+            // The iframe transport accepts a serialized array as form data:+            options.formData = this._getFormData(options);+        },+        +        _initDataSettings: function (options) {+            if (this._isXHRUpload(options)) {+                if (!this._chunkedUpload(options, true)) {+                    if (!options.data) {+                        this._initXHRData(options);+                    }+                    this._initProgressListener(options);+                }+            } else {+                this._initIframeSettings(options);+            }+        },+        +        _initFormSettings: function (options) {+            // Retrieve missing options from the input field and the+            // associated form, if available:+            if (!options.form || !options.form.length) {+                options.form = $(options.fileInput.prop('form'));+            }+            if (!options.paramName) {+                options.paramName = options.fileInput.prop('name') ||+                    'files[]';+            }+            if (!options.url) {+                options.url = options.form.prop('action') || location.href;+            }+            // The HTTP request method must be "POST" or "PUT":+            options.type = (options.type || options.form.prop('method') || '')+                .toUpperCase();+            if (options.type !== 'POST' && options.type !== 'PUT') {+                options.type = 'POST';+            }+        },+        +        _getAJAXSettings: function (data) {+            var options = $.extend({}, this.options, data);+            this._initFormSettings(options);+            this._initDataSettings(options);+            return options;+        },++        // Maps jqXHR callbacks to the equivalent+        // methods of the given Promise object:+        _enhancePromise: function (promise) {+            promise.success = promise.done;+            promise.error = promise.fail;+            promise.complete = promise.always;+            return promise;+        },++        // Creates and returns a Promise object enhanced with+        // the jqXHR methods abort, success, error and complete:+        _getXHRPromise: function (resolveOrReject, context, args) {+            var dfd = $.Deferred(),+                promise = dfd.promise();+            context = context || this.options.context || promise;+            if (resolveOrReject === true) {+                dfd.resolveWith(context, args);+            } else if (resolveOrReject === false) {+                dfd.rejectWith(context, args);+            }+            promise.abort = dfd.promise;+            return this._enhancePromise(promise);+        },++        // Uploads a file in multiple, sequential requests+        // by splitting the file up in multiple blob chunks.+        // If the second parameter is true, only tests if the file+        // should be uploaded in chunks, but does not invoke any+        // upload requests:+        _chunkedUpload: function (options, testOnly) {+            var that = this,+                file = options.files[0],+                fs = file.size,+                ub = options.uploadedBytes = options.uploadedBytes || 0,+                mcs = options.maxChunkSize || fs,+                // Use the Blob methods with the slice implementation+                // according to the W3C Blob API specification:+                slice = file.webkitSlice || file.mozSlice || file.slice,+                upload,+                n,+                jqXHR,+                pipe;+            if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||+                    options.data) {+                return false;+            }+            if (testOnly) {+                return true;+            }+            if (ub >= fs) {+                file.error = 'uploadedBytes';+                return this._getXHRPromise(false);+            }+            // n is the number of blobs to upload,+            // calculated via filesize, uploaded bytes and max chunk size:+            n = Math.ceil((fs - ub) / mcs);+            // The chunk upload method accepting the chunk number as parameter:+            upload = function (i) {+                if (!i) {+                    return that._getXHRPromise(true);+                }+                // Upload the blobs in sequential order:+                return upload(i -= 1).pipe(function () {+                    // Clone the options object for each chunk upload:+                    var o = $.extend({}, options);+                    o.blob = slice.call(+                        file,+                        ub + i * mcs,+                        ub + (i + 1) * mcs+                    );+                    // Store the current chunk size, as the blob itself+                    // will be dereferenced after data processing:+                    o.chunkSize = o.blob.size;+                    // Process the upload data (the blob and potential form data):+                    that._initXHRData(o);+                    // Add progress listeners for this chunk upload:+                    that._initProgressListener(o);+                    jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context))+                        .done(function () {+                            // Create a progress event if upload is done and+                            // no progress event has been invoked for this chunk:+                            if (!o.loaded) {+                                that._onProgress($.Event('progress', {+                                    lengthComputable: true,+                                    loaded: o.chunkSize,+                                    total: o.chunkSize+                                }), o);+                            }+                            options.uploadedBytes = o.uploadedBytes+                                += o.chunkSize;+                        });+                    return jqXHR;+                });+            };+            // Return the piped Promise object, enhanced with an abort method,+            // which is delegated to the jqXHR object of the current upload,+            // and jqXHR callbacks mapped to the equivalent Promise methods:+            pipe = upload(n);+            pipe.abort = function () {+                return jqXHR.abort();+            };+            return this._enhancePromise(pipe);+        },++        _beforeSend: function (e, data) {+            if (this._active === 0) {+                // the start callback is triggered when an upload starts+                // and no other uploads are currently running,+                // equivalent to the global ajaxStart event:+                this._trigger('start');+            }+            this._active += 1;+            // Initialize the global progress values:+            this._loaded += data.uploadedBytes || 0;+            this._total += this._getTotal(data.files);+        },++        _onDone: function (result, textStatus, jqXHR, options) {+            if (!this._isXHRUpload(options)) {+                // Create a progress event for each iframe load:+                this._onProgress($.Event('progress', {+                    lengthComputable: true,+                    loaded: 1,+                    total: 1+                }), options);+            }+            options.result = result;+            options.textStatus = textStatus;+            options.jqXHR = jqXHR;+            this._trigger('done', null, options);+        },++        _onFail: function (jqXHR, textStatus, errorThrown, options) {+            options.jqXHR = jqXHR;+            options.textStatus = textStatus;+            options.errorThrown = errorThrown;+            this._trigger('fail', null, options);+            if (options.recalculateProgress) {+                // Remove the failed (error or abort) file upload from+                // the global progress calculation:+                this._loaded -= options.loaded || options.uploadedBytes || 0;+                this._total -= options.total || this._getTotal(options.files);+            }+        },++        _onAlways: function (result, textStatus, jqXHR, errorThrown, options) {+            this._active -= 1;+            options.result = result;+            options.textStatus = textStatus;+            options.jqXHR = jqXHR;+            options.errorThrown = errorThrown;+            this._trigger('always', null, options);+            if (this._active === 0) {+                // The stop callback is triggered when all uploads have+                // been completed, equivalent to the global ajaxStop event:+                this._trigger('stop');+                // Reset the global progress values:+                this._loaded = this._total = 0;+            }+        },++        _onSend: function (e, data) {+            var that = this,+                jqXHR,+                slot,+                pipe,+                options = that._getAJAXSettings(data),+                send = function (resolve, args) {+                    that._sending += 1;+                    jqXHR = jqXHR || (+                        (resolve !== false &&+                        that._trigger('send', e, options) !== false &&+                        (that._chunkedUpload(options) || $.ajax(options))) ||+                        that._getXHRPromise(false, options.context, args)+                    ).done(function (result, textStatus, jqXHR) {+                        that._onDone(result, textStatus, jqXHR, options);+                    }).fail(function (jqXHR, textStatus, errorThrown) {+                        that._onFail(jqXHR, textStatus, errorThrown, options);+                    }).always(function (a1, a2, a3) {+                        that._sending -= 1;+                        if (a3 && a3.done) {+                            that._onAlways(a1, a2, a3, undefined, options);+                        } else {+                            that._onAlways(undefined, a2, a1, a3, options);+                        }+                        if (options.limitConcurrentUploads &&+                                options.limitConcurrentUploads > that._sending) {+                            // Start the next queued upload,+                            // that has not been aborted:+                            var nextSlot = that._slots.shift();+                            while (nextSlot) {+                                if (!nextSlot.isRejected()) {+                                    nextSlot.resolve();+                                    break;+                                }+                                nextSlot = that._slots.shift();+                            }+                        }+                    });+                    return jqXHR;+                };+            this._beforeSend(e, options);+            if (this.options.sequentialUploads ||+                    (this.options.limitConcurrentUploads &&+                    this.options.limitConcurrentUploads <= this._sending)) {+                if (this.options.limitConcurrentUploads > 1) {+                    slot = $.Deferred();+                    this._slots.push(slot);+                    pipe = slot.pipe(send);+                } else {+                    pipe = (this._sequence = this._sequence.pipe(send, send));+                }+                // Return the piped Promise object, enhanced with an abort method,+                // which is delegated to the jqXHR object of the current upload,+                // and jqXHR callbacks mapped to the equivalent Promise methods:+                pipe.abort = function () {+                    var args = [undefined, 'abort', 'abort'];+                    if (!jqXHR) {+                        if (slot) {+                            slot.rejectWith(args);+                        }+                        return send(false, args);+                    }+                    return jqXHR.abort();+                };+                return this._enhancePromise(pipe);+            }+            return send();+        },+        +        _onAdd: function (e, data) {+            var that = this,+                result = true,+                options = $.extend({}, this.options, data);+            if (options.singleFileUploads && this._isXHRUpload(options)) {+                $.each(data.files, function (index, file) {+                    var newData = $.extend({}, data, {files: [file]});+                    newData.submit = function () {+                        return that._onSend(e, newData);+                    };+                    return (result = that._trigger('add', e, newData));+                });+                return result;+            } else if (data.files.length) {+                data = $.extend({}, data);+                data.submit = function () {+                    return that._onSend(e, data);+                };+                return this._trigger('add', e, data);+            }+        },+        +        // File Normalization for Gecko 1.9.1 (Firefox 3.5) support:+        _normalizeFile: function (index, file) {+            if (file.name === undefined && file.size === undefined) {+                file.name = file.fileName;+                file.size = file.fileSize;+            }+        },++        _replaceFileInput: function (input) {+            var inputClone = input.clone(true);+            $('<form></form>').append(inputClone)[0].reset();+            // Detaching allows to insert the fileInput on another form+            // without loosing the file input value:+            input.after(inputClone).detach();+            // Replace the original file input element in the fileInput+            // collection with the clone, which has been copied including+            // event handlers:+            this.options.fileInput = this.options.fileInput.map(function (i, el) {+                if (el === input[0]) {+                    return inputClone[0];+                }+                return el;+            });+        },+        +        _onChange: function (e) {+            var that = e.data.fileupload,+                data = {+                    files: $.each($.makeArray(e.target.files), that._normalizeFile),+                    fileInput: $(e.target),+                    form: $(e.target.form)+                };+            if (!data.files.length) {+                // If the files property is not available, the browser does not+                // support the File API and we add a pseudo File object with+                // the input value as name with path information removed:+                data.files = [{name: e.target.value.replace(/^.*\\/, '')}];+            }+            // Store the form reference as jQuery data for other event handlers,+            // as the form property is not available after replacing the file input: +            if (data.form.length) {+                data.fileInput.data('blueimp.fileupload.form', data.form);+            } else {+                data.form = data.fileInput.data('blueimp.fileupload.form');+            }+            if (that.options.replaceFileInput) {+                that._replaceFileInput(data.fileInput);+            }+            if (that._trigger('change', e, data) === false ||+                    that._onAdd(e, data) === false) {+                return false;+            }+        },+        +        _onDrop: function (e) {+            var that = e.data.fileupload,+                dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,+                data = {+                    files: $.each(+                        $.makeArray(dataTransfer && dataTransfer.files),+                        that._normalizeFile+                    )+                };+            if (that._trigger('drop', e, data) === false ||+                    that._onAdd(e, data) === false) {+                return false;+            }+            e.preventDefault();+        },+        +        _onDragOver: function (e) {+            var that = e.data.fileupload,+                dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;+            if (that._trigger('dragover', e) === false) {+                return false;+            }+            if (dataTransfer) {+                dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';+            }+            e.preventDefault();+        },+        +        _initEventHandlers: function () {+            var ns = this.options.namespace || this.name;+            this.options.dropZone+                .bind('dragover.' + ns, {fileupload: this}, this._onDragOver)+                .bind('drop.' + ns, {fileupload: this}, this._onDrop);+            this.options.fileInput+                .bind('change.' + ns, {fileupload: this}, this._onChange);+        },++        _destroyEventHandlers: function () {+            var ns = this.options.namespace || this.name;+            this.options.dropZone+                .unbind('dragover.' + ns, this._onDragOver)+                .unbind('drop.' + ns, this._onDrop);+            this.options.fileInput+                .unbind('change.' + ns, this._onChange);+        },+        +        _beforeSetOption: function (key, value) {+            this._destroyEventHandlers();+        },+        +        _afterSetOption: function (key, value) {+            var options = this.options;+            if (!options.fileInput) {+                options.fileInput = $();+            }+            if (!options.dropZone) {+                options.dropZone = $();+            }+            this._initEventHandlers();+        },+        +        _setOption: function (key, value) {+            var refresh = $.inArray(key, this._refreshOptionsList) !== -1;+            if (refresh) {+                this._beforeSetOption(key, value);+            }+            $.Widget.prototype._setOption.call(this, key, value);+            if (refresh) {+                this._afterSetOption(key, value);+            }+        },++        _create: function () {+            var options = this.options;+            if (options.fileInput === undefined) {+                options.fileInput = this.element.is('input:file') ?+                    this.element : this.element.find('input:file');+            } else if (!options.fileInput) {+                options.fileInput = $();+            }+            if (!options.dropZone) {+                options.dropZone = $();+            }+            this._slots = [];+            this._sequence = this._getXHRPromise(true);+            this._sending = this._active = this._loaded = this._total = 0;+            this._initEventHandlers();+        },+        +        destroy: function () {+            this._destroyEventHandlers();+            $.Widget.prototype.destroy.call(this);+        },++        enable: function () {+            $.Widget.prototype.enable.call(this);+            this._initEventHandlers();+        },+        +        disable: function () {+            this._destroyEventHandlers();+            $.Widget.prototype.disable.call(this);+        },++        // This method is exposed to the widget API and allows adding files+        // using the fileupload API. The data parameter accepts an object which+        // must have a files property and can contain additional options:+        // .fileupload('add', {files: filesList});+        add: function (data) {+            if (!data || this.options.disabled) {+                return;+            }+            data.files = $.each($.makeArray(data.files), this._normalizeFile);+            this._onAdd(null, data);+        },+        +        // This method is exposed to the widget API and allows sending files+        // using the fileupload API. The data parameter accepts an object which+        // must have a files property and can contain additional options:+        // .fileupload('send', {files: filesList});+        // The method returns a Promise object for the file upload call.+        send: function (data) {+            if (data && !this.options.disabled) {+                data.files = $.each($.makeArray(data.files), this._normalizeFile);+                if (data.files.length) {+                    return this._onSend(null, data);+                }+            }+            return this._getXHRPromise(false, data && data.context);+        }+        +    });+    +}(jQuery));
+ static/js/jquery.iframe-transport.js view
@@ -0,0 +1,156 @@+/*+ * jQuery Iframe Transport Plugin 1.2.2+ * https://github.com/blueimp/jQuery-File-Upload+ *+ * Copyright 2011, Sebastian Tschan+ * https://blueimp.net+ *+ * Licensed under the MIT license:+ * http://creativecommons.org/licenses/MIT/+ */++/*jslint unparam: true */+/*global jQuery */++(function ($) {+    'use strict';++    // Helper variable to create unique names for the transport iframes:+    var counter = 0;++    // The iframe transport accepts three additional options:+    // options.fileInput: a jQuery collection of file input fields+    // options.paramName: the parameter name for the file form data,+    //  overrides the name property of the file input field(s)+    // options.formData: an array of objects with name and value properties,+    //  equivalent to the return data of .serializeArray(), e.g.:+    //  [{name: a, value: 1}, {name: b, value: 2}]+    $.ajaxTransport('iframe', function (options, originalOptions, jqXHR) {+        if (options.type === 'POST' || options.type === 'GET') {+            var form,+                iframe;+            return {+                send: function (headers, completeCallback) {+                    form = $('<form style="display:none;"></form>');+                    // javascript:false as initial iframe src+                    // prevents warning popups on HTTPS in IE6.+                    // IE versions below IE8 cannot set the name property of+                    // elements that have already been added to the DOM,+                    // so we set the name along with the iframe HTML markup:+                    iframe = $(+                        '<iframe src="javascript:false;" name="iframe-transport-' ++                            (counter += 1) + '"></iframe>'+                    ).bind('load', function () {+                        var fileInputClones;+                        iframe+                            .unbind('load')+                            .bind('load', function () {+                                var response;+                                // Wrap in a try/catch block to catch exceptions thrown+                                // when trying to access cross-domain iframe contents:+                                try {+                                    response = iframe.contents();+                                    // Google Chrome and Firefox do not throw an+                                    // exception when calling iframe.contents() on+                                    // cross-domain requests, so we unify the response:+                                    if (!response.length || !response[0].firstChild) {+                                        throw new Error();+                                    }+                                } catch (e) {+                                    response = undefined;+                                }+                                // The complete callback returns the+                                // iframe content document as response object:+                                completeCallback(+                                    200,+                                    'success',+                                    {'iframe': response}+                                );+                                // Fix for IE endless progress bar activity bug+                                // (happens on form submits to iframe targets):+                                $('<iframe src="javascript:false;"></iframe>')+                                    .appendTo(form);+                                form.remove();+                            });+                        form+                            .prop('target', iframe.prop('name'))+                            .prop('action', options.url)+                            .prop('method', options.type);+                        if (options.formData) {+                            $.each(options.formData, function (index, field) {+                                $('<input type="hidden"/>')+                                    .prop('name', field.name)+                                    .val(field.value)+                                    .appendTo(form);+                            });+                        }+                        if (options.fileInput && options.fileInput.length &&+                                options.type === 'POST') {+                            fileInputClones = options.fileInput.clone();+                            // Insert a clone for each file input field:+                            options.fileInput.after(function (index) {+                                return fileInputClones[index];+                            });+                            if (options.paramName) {+                                options.fileInput.each(function () {+                                    $(this).prop('name', options.paramName);+                                });+                            }+                            // Appending the file input fields to the hidden form+                            // removes them from their original location:+                            form+                                .append(options.fileInput)+                                .prop('enctype', 'multipart/form-data')+                                // enctype must be set as encoding for IE:+                                .prop('encoding', 'multipart/form-data');+                        }+                        form.submit();+                        // Insert the file input fields at their original location+                        // by replacing the clones with the originals:+                        if (fileInputClones && fileInputClones.length) {+                            options.fileInput.each(function (index, input) {+                                var clone = $(fileInputClones[index]);+                                $(input).prop('name', clone.prop('name'));+                                clone.replaceWith(input);+                            });+                        }+                    });+                    form.append(iframe).appendTo('body');+                },+                abort: function () {+                    if (iframe) {+                        // javascript:false as iframe src aborts the request+                        // and prevents warning popups on HTTPS in IE6.+                        // concat is used to avoid the "Script URL" JSLint error:+                        iframe+                            .unbind('load')+                            .prop('src', 'javascript'.concat(':false;'));+                    }+                    if (form) {+                        form.remove();+                    }+                }+            };+        }+    });++    // The iframe transport returns the iframe content document as response.+    // The following adds converters from iframe to text, json, html, and script:+    $.ajaxSetup({+        converters: {+            'iframe text': function (iframe) {+                return iframe.text();+            },+            'iframe json': function (iframe) {+                return $.parseJSON(iframe.text());+            },+            'iframe html': function (iframe) {+                return iframe.find('body').html();+            },+            'iframe script': function (iframe) {+                return $.globalEval(iframe.text());+            }+        }+    });++}(jQuery));
+ static/js/jquery.pjax.js view
@@ -0,0 +1,249 @@+// jquery.pjax.js+// copyright chris wanstrath+// https://github.com/defunkt/jquery-pjax++(function($){++// When called on a link, fetches the href with ajax into the+// container specified as the first parameter or with the data-pjax+// attribute on the link itself.+//+// Tries to make sure the back button and ctrl+click work the way+// you'd expect.+//+// Accepts a jQuery ajax options object that may include these+// pjax specific options:+//+// container - Where to stick the response body. Usually a String selector.+//             $(container).html(xhr.responseBody)+//      push - Whether to pushState the URL. Defaults to true (of course).+//   replace - Want to use replaceState instead? That's cool.+//+// For convenience the first parameter can be either the container or+// the options object.+//+// Returns the jQuery object+$.fn.pjax = function( container, options ) {+  if ( options )+    options.container = container+  else+    options = $.isPlainObject(container) ? container : {container:container}++  // We can't persist $objects using the history API so we must use+  // a String selector. Bail if we got anything else.+  if ( options.container && typeof options.container !== 'string' ) {+    throw "pjax container must be a string selector!"+    return false+  }++  return this.live('click', function(event){+    // Middle click, cmd click, and ctrl click should open+    // links in a new tab as normal.+    if ( event.which > 1 || event.metaKey )+      return true++    var defaults = {+      url: this.href,+      container: $(this).attr('data-pjax'),+      clickedElement: $(this),+      fragment: null+    }++    $.pjax($.extend({}, defaults, options))++    event.preventDefault()+  })+}+++// Loads a URL with ajax, puts the response body inside a container,+// then pushState()'s the loaded URL.+//+// Works just like $.ajax in that it accepts a jQuery ajax+// settings object (with keys like url, type, data, etc).+//+// Accepts these extra keys:+//+// container - Where to stick the response body. Must be a String.+//             $(container).html(xhr.responseBody)+//      push - Whether to pushState the URL. Defaults to true (of course).+//   replace - Want to use replaceState instead? That's cool.+//+// Use it just like $.ajax:+//+//   var xhr = $.pjax({ url: this.href, container: '#main' })+//   console.log( xhr.readyState )+//+// Returns whatever $.ajax returns.+$.pjax = function( options ) {+  var $container = $(options.container),+      success = options.success || $.noop++  // We don't want to let anyone override our success handler.+  delete options.success++  // We can't persist $objects using the history API so we must use+  // a String selector. Bail if we got anything else.+  if ( typeof options.container !== 'string' )+    throw "pjax container must be a string selector!"++  var defaults = {+    timeout: 650,+    push: true,+    replace: false,+    // We want the browser to maintain two separate internal caches: one for+    // pjax'd partial page loads and one for normal page loads. Without+    // adding this secret parameter, some browsers will often confuse the two.+    data: { _pjax: true },+    type: 'GET',+    dataType: 'html',+    beforeSend: function(xhr){+      $container.trigger('start.pjax')+      xhr.setRequestHeader('X-PJAX', 'true')+    },+    error: function(){+      window.location = options.url+    },+    complete: function(){+      $container.trigger('end.pjax')+    },+    success: function(data){+      if ( options.fragment ) {+        // If they specified a fragment, look for it in the response+        // and pull it out.+        var $fragment = $(data).find(options.fragment)+        if ( $fragment.length )+          data = $fragment.children()+        else+          return window.location = options.url+      } else {+          // If we got no data or an entire web page, go directly+          // to the page and let normal error handling happen.+          if ( !$.trim(data) || /<html/i.test(data) )+            return window.location = options.url+      }++      // Make it happen.+      $container.html(data)++      // If there's a <title> tag in the response, use it as+      // the page's title.+      var oldTitle = document.title,+          title = $.trim( $container.find('title').remove().text() )+      if ( title ) document.title = title++      var state = {+        pjax: options.container,+        fragment: options.fragment,+        timeout: options.timeout+      }++      // If there are extra params, save the complete URL in the state object+      var query = $.param(options.data)+      if ( query != "_pjax=true" )+        state.url = options.url + (/\?/.test(options.url) ? "&" : "?") + query++      if ( options.replace ) {+        window.history.replaceState(state, document.title, options.url)+      } else if ( options.push ) {+        // this extra replaceState before first push ensures good back+        // button behavior+        if ( !$.pjax.active ) {+          window.history.replaceState($.extend({}, state, {url:null}), oldTitle)+          $.pjax.active = true+        }++        window.history.pushState(state, document.title, options.url)+      }++      // Google Analytics support+      if ( (options.replace || options.push) && window._gaq )+        _gaq.push(['_trackPageview'])++      // If the URL has a hash in it, make sure the browser+      // knows to navigate to the hash.+      var hash = window.location.hash.toString()+      if ( hash !== '' ) {+        window.location.href = hash+      }++      // Invoke their success handler if they gave us one.+      success.apply(this, arguments)+    }+  }++  options = $.extend(true, {}, defaults, options)++  if ( $.isFunction(options.url) ) {+    options.url = options.url()+  }++  // Cancel the current request if we're already pjaxing+  var xhr = $.pjax.xhr+  if ( xhr && xhr.readyState < 4) {+    xhr.onreadystatechange = $.noop+    xhr.abort()+  }++  $.pjax.xhr = $.ajax(options)+  $(document).trigger('pjax', $.pjax.xhr, options)++  return $.pjax.xhr+}+++// Used to detect initial (useless) popstate.+// If history.state exists, assume browser isn't going to fire initial popstate.+var popped = ('state' in window.history), initialURL = location.href+++// popstate handler takes care of the back and forward buttons+//+// You probably shouldn't use pjax on pages with other pushState+// stuff yet.+$(window).bind('popstate', function(event){+  // Ignore inital popstate that some browsers fire on page load+  var initialPop = !popped && location.href == initialURL+  popped = true+  if ( initialPop ) return++  var state = event.state++  if ( state && state.pjax ) {+    var container = state.pjax+    if ( $(container+'').length )+      $.pjax({+        url: state.url || location.href,+        fragment: state.fragment,+        container: container,+        push: false,+        timeout: state.timeout+      })+    else+      window.location = location.href+  }+})+++// Add the state property to jQuery's event object so we can use it in+// $(window).bind('popstate')+if ( $.inArray('state', $.event.props) < 0 )+  $.event.props.push('state')+++// Is pjax supported by this browser?+$.support.pjax =+  window.history && window.history.pushState && window.history.replaceState+  // pushState isn't reliable on iOS yet.+  && !navigator.userAgent.match(/(iPod|iPhone|iPad|WebApps\/.+CFNetwork)/)+++// Fall back to normalcy for older browsers.+if ( !$.support.pjax ) {+  $.pjax = function( options ) {+    window.location = $.isFunction(options.url) ? options.url() : options.url+  }+  $.fn.pjax = function() { return this }+}++})(jQuery);
+ static/js/jquery.ui.widget.js view
@@ -0,0 +1,435 @@+/*!+ * jQuery UI Widget @VERSION+ *+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)+ * Dual licensed under the MIT or GPL Version 2 licenses.+ * http://jquery.org/license+ *+ * http://docs.jquery.com/UI/Widget+ */+(function( $, undefined ) {++var slice = Array.prototype.slice;++var _cleanData = $.cleanData;+$.cleanData = function( elems ) {+	for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {+		try {+			$( elem ).triggerHandler( "remove" );+		// http://bugs.jquery.com/ticket/8235+		} catch( e ) {}+	}+	_cleanData( elems );+};++$.widget = function( name, base, prototype ) {+	var namespace = name.split( "." )[ 0 ],+		fullName;+	name = name.split( "." )[ 1 ];+	fullName = namespace + "-" + name;++	if ( !prototype ) {+		prototype = base;+		base = $.Widget;+	}++	// create selector for plugin+	$.expr[ ":" ][ fullName ] = function( elem ) {+		return !!$.data( elem, name );+	};++	$[ namespace ] = $[ namespace ] || {};+	// create the constructor using $.extend() so we can carry over any+	// static properties stored on the existing constructor (if there is one)+	$[ namespace ][ name ] = $.extend( function( options, element ) {+		// allow instantiation without "new" keyword+		if ( !this._createWidget ) {+			return new $[ namespace ][ name ]( options, element );+		}++		// allow instantiation without initializing for simple inheritance+		// must use "new" keyword (the code above always passes args)+		if ( arguments.length ) {+			this._createWidget( options, element );+		}+	}, $[ namespace ][ name ], { version: prototype.version } );++	var basePrototype = new base();+	// we need to make the options hash a property directly on the new instance+	// otherwise we'll modify the options hash on the prototype that we're+	// inheriting from+	basePrototype.options = $.widget.extend( {}, basePrototype.options );+	$.each( prototype, function( prop, value ) {+		if ( $.isFunction( value ) ) {+			prototype[ prop ] = (function() {+				var _super = function( method ) {+					return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) );+				};+				var _superApply = function( method, args ) {+					return base.prototype[ method ].apply( this, args );+				};+				return function() {+					var __super = this._super,+						__superApply = this._superApply,+						returnValue;++					this._super = _super;+					this._superApply = _superApply;++					returnValue = value.apply( this, arguments );++					this._super = __super;+					this._superApply = __superApply;++					return returnValue;+				};+			}());+		}+	});+	$[ namespace ][ name ].prototype = $.widget.extend( basePrototype, {+		namespace: namespace,+		widgetName: name,+		widgetEventPrefix: name,+		widgetBaseClass: fullName+	}, prototype );++	$.widget.bridge( name, $[ namespace ][ name ] );+};++$.widget.extend = function( target ) {+	var input = slice.call( arguments, 1 ),+		inputIndex = 0,+		inputLength = input.length,+		key,+		value;+	for ( ; inputIndex < inputLength; inputIndex++ ) {+		for ( key in input[ inputIndex ] ) {+			value = input[ inputIndex ][ key ];+			if (input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {+				target[ key ] = $.isPlainObject( value ) ? $.widget.extend( {}, target[ key ], value ) : value;+			}+		}+	}+	return target;+};++$.widget.bridge = function( name, object ) {+	$.fn[ name ] = function( options ) {+		var isMethodCall = typeof options === "string",+			args = slice.call( arguments, 1 ),+			returnValue = this;++		// allow multiple hashes to be passed on init+		options = !isMethodCall && args.length ?+			$.widget.extend.apply( null, [ options ].concat(args) ) :+			options;++		if ( isMethodCall ) {+			this.each(function() {+				var instance = $.data( this, name );+				if ( !instance ) {+					return $.error( "cannot call methods on " + name + " prior to initialization; " ++						"attempted to call method '" + options + "'" );+				}+				if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {+					return $.error( "no such method '" + options + "' for " + name + " widget instance" );+				}+				var methodValue = instance[ options ].apply( instance, args );+				if ( methodValue !== instance && methodValue !== undefined ) {+					returnValue = methodValue && methodValue.jquery ?+						returnValue.pushStack( methodValue.get() ) :+						methodValue;+					return false;+				}+			});+		} else {+			this.each(function() {+				var instance = $.data( this, name );+				if ( instance ) {+					instance.option( options || {} )._init();+				} else {+					object( options, this );+				}+			});+		}++		return returnValue;+	};+};++$.Widget = function( options, element ) {+	// allow instantiation without "new" keyword+	if ( !this._createWidget ) {+		return new $[ namespace ][ name ]( options, element );+	}++	// allow instantiation without initializing for simple inheritance+	// must use "new" keyword (the code above always passes args)+	if ( arguments.length ) {+		this._createWidget( options, element );+	}+};++$.Widget.prototype = {+	widgetName: "widget",+	widgetEventPrefix: "",+	defaultElement: "<div>",+	options: {+		disabled: false,++		// callbacks+		create: null+	},+	_createWidget: function( options, element ) {+		element = $( element || this.defaultElement || this )[ 0 ];+		this.element = $( element );+		this.options = $.widget.extend( {},+			this.options,+			this._getCreateOptions(),+			options );++		this.bindings = $();+		this.hoverable = $();+		this.focusable = $();++		if ( element !== this ) {+			$.data( element, this.widgetName, this );+			this._bind({ remove: "destroy" });+		}++		this._create();+		this._trigger( "create" );+		this._init();+	},+	_getCreateOptions: $.noop,+	_create: $.noop,+	_init: $.noop,++	destroy: function() {+		this._destroy();+		// we can probably remove the unbind calls in 2.0+		// all event bindings should go through this._bind()+		this.element+			.unbind( "." + this.widgetName )+			.removeData( this.widgetName );+		this.widget()+			.unbind( "." + this.widgetName )+			.removeAttr( "aria-disabled" )+			.removeClass(+				this.widgetBaseClass + "-disabled " ++				"ui-state-disabled" );++		// clean up events and states+		this.bindings.unbind( "." + this.widgetName );+		this.hoverable.removeClass( "ui-state-hover" );+		this.focusable.removeClass( "ui-state-focus" );+	},+	_destroy: $.noop,++	widget: function() {+		return this.element;+	},++	option: function( key, value ) {+		var options = key,+			parts,+			curOption,+			i;++		if ( arguments.length === 0 ) {+			// don't return a reference to the internal hash+			return $.widget.extend( {}, this.options );+		}++		if ( typeof key === "string" ) {+			// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }+			options = {};+			parts = key.split( "." );+			key = parts.shift();+			if ( parts.length ) {+				curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );+				for ( i = 0; i < parts.length - 1; i++ ) {+					curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};+					curOption = curOption[ parts[ i ] ];+				}+				key = parts.pop();+				if ( value === undefined ) {+					return curOption[ key ] === undefined ? null : curOption[ key ];+				}+				curOption[ key ] = value;+			} else {+				if ( value === undefined ) {+					return this.options[ key ] === undefined ? null : this.options[ key ];+				}+				options[ key ] = value;+			}+		}++		this._setOptions( options );++		return this;+	},+	_setOptions: function( options ) {+		var self = this;+		$.each( options, function( key, value ) {+			self._setOption( key, value );+		});++		return this;+	},+	_setOption: function( key, value ) {+		this.options[ key ] = value;++		if ( key === "disabled" ) {+			this.widget()+				.toggleClass( this.widgetBaseClass + "-disabled ui-state-disabled", !!value )+				.attr( "aria-disabled", value );+			this.hoverable.removeClass( "ui-state-hover" );+			this.focusable.removeClass( "ui-state-focus" );+		}++		return this;+	},++	enable: function() {+		return this._setOption( "disabled", false );+	},+	disable: function() {+		return this._setOption( "disabled", true );+	},++	_bind: function( element, handlers ) {+		// no element argument, shuffle and use this.element+		if ( !handlers ) {+			handlers = element;+			element = this.element;+		} else {+			// accept selectors, DOM elements+			element = $( element );+			this.bindings = this.bindings.add( element );+		}++		var instance = this;+		$.each( handlers, function( event, handler ) {+			function handlerProxy() {+				// allow widgets to customize the disabled handling+				// - disabled as an array instead of boolean+				// - disabled class as method for disabling individual parts+				if ( instance.options.disabled === true ||+						$( this ).hasClass( "ui-state-disabled" ) ) {+					return;+				}+				return ( typeof handler === "string" ? instance[ handler ] : handler )+					.apply( instance, arguments );+			}+			var match = event.match( /^(\w+)\s*(.*)$/ ),+				eventName = match[1] + "." + instance.widgetName,+				selector = match[2];+			if ( selector ) {+				element.delegate( selector, eventName, handlerProxy );+			} else {+				element.bind( eventName, handlerProxy );+			}+		});+	},++	_hoverable: function( element ) {+		this.hoverable = this.hoverable.add( element );+		this._bind( element, {+			mouseenter: function( event ) {+				$( event.currentTarget ).addClass( "ui-state-hover" );+			},+			mouseleave: function( event ) {+				$( event.currentTarget ).removeClass( "ui-state-hover" );+			}+		});+	},++	_focusable: function( element ) {+		this.focusable = this.focusable.add( element );+		this._bind( element, {+			focusin: function( event ) {+				$( event.currentTarget ).addClass( "ui-state-focus" );+			},+			focusout: function( event ) {+				$( event.currentTarget ).removeClass( "ui-state-focus" );+			}+		});+	},++	_trigger: function( type, event, data ) {+		var callback = this.options[ type ],+			args;++		event = $.Event( event );+		event.type = ( type === this.widgetEventPrefix ?+			type :+			this.widgetEventPrefix + type ).toLowerCase();+		data = data || {};++		// copy original event properties over to the new event+		// this would happen if we could call $.event.fix instead of $.Event+		// but we don't have a way to force an event to be fixed multiple times+		if ( event.originalEvent ) {+			for ( var i = $.event.props.length, prop; i; ) {+				prop = $.event.props[ --i ];+				event[ prop ] = event.originalEvent[ prop ];+			}+		}++		this.element.trigger( event, data );++		args = $.isArray( data ) ?+			[ event ].concat( data ) :+			[ event, data ];++		return !( $.isFunction( callback ) &&+			callback.apply( this.element[0], args ) === false ||+			event.isDefaultPrevented() );+	}+};++$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {+	$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {+		if ( typeof options === "string" ) {+			options = { effect: options };+		}+		var hasOptions,+			effectName = !options ?+				method :+				options === true || typeof options === "number" ?+					defaultEffect :+					options.effect || defaultEffect;+		options = options || {};+		if ( typeof options === "number" ) {+			options = { duration: options };+		}+		hasOptions = !$.isEmptyObject( options );+		options.complete = callback;+		if ( options.delay ) {+			element.delay( options.delay );+		}+		if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {+			element[ method ]( options );+		} else if ( effectName !== method && element[ effectName ] ) {+			element[ effectName ]( options.duration, options.easing, callback );+		} else {+			element.queue(function( next ) {+				$( this )[ method ]();+				if ( callback ) {+					callback.call( element[ 0 ] );+				}+				next();+			});+		}+	};+});++// DEPRECATED+if ( $.uiBackCompat !== false ) {+	$.Widget.prototype._getCreateOptions = function() {+		return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];+	};+}++})( jQuery );
tkyprof.cabal view
@@ -1,5 +1,5 @@ name:                 tkyprof-version:              0.0.2+version:              0.0.3 license:              BSD3 license-file:         LICENSE author:               Mitsutoshi Aoe@@ -11,6 +11,18 @@ cabal-version:        >= 1.6 build-type:           Simple homepage:             https://github.com/maoe/tkyprof+bug-reports:          https://github.com/maoe/tkyprof/issues+data-files:           static/js/d3.layout.min.js+                      static/js/d3.min.js+                      static/js/jquery.fileupload.js+                      static/js/jquery.iframe-transport.js+                      static/js/jquery.pjax.js+                      static/js/jquery.ui.widget.js+                      config/favicon.ico+                      config/routes+                      hamlet/*.hamlet+                      julius/*.julius+                      lucius/*.lucius  flag production   description:        Build the production executable.