diff --git a/Gruntfile.js b/Gruntfile.js index 5757692e..c3ec9796 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,10 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-coffee'); grunt.loadNpmTasks('grunt-contrib-watch'); +/* NOTE: Client and Plugins are no longer here, so none of this is needed. */ +/* TODO: Review if we still need grunt here. */ +/* IDEA: Use to run docco to produce github pages (probably replace docco...). + grunt.initConfig({ browserify: { client: { diff --git a/ReadMe.md b/ReadMe.md index 9c6f5d83..9d470190 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,124 +1,47 @@ -# Wiki +# Wiki-Node-Server -Wiki is a single-page application for browsing and editing content distributed throughout a federation of similar creative-commons licensed sites. What is a federated wiki, and why does federation matter? Authors throughout the federation pull content towards themselves as they edit. With this package authors publish their own edits back to the federation as they edit. +Federated wiki node.js server as a npm module. -Over the past two years, the [Smallest Federated Wiki](https://github.com/WardCunningham/Smallest-Federated-Wiki) project has explored the concept and implementation details of the federated wiki concept. This code has been extracted from that project, with the goal of releasing a polished, easy to deploy package. +**N.B.** Following a code re-organization over the New Year 2013/4 this +repository now only contains the code for the node.js server implementation. +You will also notice that the GitHub reposistory name and location has +changed, it is now fedwiki/wiki-node-server. It you have previously forked, +and cloned, this repository you will want to update your clone's upstream +remote to reflect this change. +This package is now published as ```wiki-node-server```. The ```wiki``` +package which depends on this package, to provide the federated wiki server, +can be found as [fedwiki/wiki-node]. -### Using Federated Wiki +* * * -Learn [how to wiki](http://fed.wiki.org/view/how-to-wiki) by reading [fed.wiki.org](http://fed.wiki.org/view/welcome-visitors) +## Goals -### Running your own Server +Over its first two years the Smallest Federated Wiki (SFW) project explored +many ways that a wiki could embrace HTML5 and related technologies. Here +we will cautiously reorganize this work as small independent modules that +favor ongoing innovation. -The quickest way to set up wiki on your local machine is to install it globally with `npm`: +We proceed by dividing SFW first into large pieces and then these into +smaller pieces as we simplify and regularize the communications between them. +We now favor the node.js module and event conventions, dependency injection, +and increased separation between the DOM and the logic that manages it. - $ npm install -g wiki - $ wiki +Federated wiki's single-page application reads page content from many sources +and writes updates to a few. Read-write server backends are maintained in +ruby (sinatra) and node (express). Read-only servers have been realized +with static files and cgi scripts. Encouraging experiments have exploited +exotic service architectures such as CCNx content-addressable networks. -:warning: The default location used to store your pages *should not* be used for more than testing. Any content you create will be lost when you update the package, or run ```npm update -g```. See Datastore options, below, on how to specify an alternative location. - +## Participation -Visit localhost:3000 to see your wiki. If you choose a host visible to the internet then others in the federation can use your work. +We're happy to take issues or pull requests regarding the goals and +their implementation within this code. -### Server Options +A wider-ranging conversation is documented in the GitHub ReadMe of the +founding project, [SFW](https://github.com/WardCunningham/Smallest-Federated-Wiki/blob/master/ReadMe.md). -Options for the server can be passed in many ways: - -* As command line flags -* As a configuration JSON file specified with --config -* As a config.json file in the root folder or cwd. -* As env vars prefixed with `wiki_` - -Higher in the list takes precedence. -The server will then try to guess all unspecified options. - -#### Datastore options - -A number of datastores are supported. Use the --database and --data options to configure, or use the config.json. - -##### flatfiles (default) - -The default path to store page data is in a "default-data" subdirectory of the install directory. You can override it like this: - - $ wiki --data FILESYSTEM_PATH - -##### mongodb - -The mongodb connection arguments are specified as follows: - - $ wiki --database '{"type": "./mongodb", "url": "...", "options": {...}}' - -For convenience the url will also be read from MONGO_URI, MONGOLAB_URI, or MONGOHQ_URL. This smooths the Heroku deployment process somewhat. - -The mongodb datastore allows for a graceful upgrade path. If a page is not found in mongodb the flatfile datastore will be consulted. - -##### redis - -The Redis connection arguments are specified as follows: - - $ wiki --database '{"type": "./redis", "host": "...", "port": nnn, "options": {...}}' - -The Redis datastore allows for a graceful upgrade path. If a page is not found in redis the flatfile datastore will be consulted. - -##### leveldb - -The leveldb datastore uses JSON encoded leveldb format and is configured by providing a filesystem path: - - $ wiki --database '{"type": "./leveldb"}' --data FILESYSTEM_PATH - -The leveldb datastore allows for a graceful upgrade path. If a page is not found in leveldb the flatfile datastore will be consulted. - -##### Example config.json for Redis - -``` -{ - "database" : { - "type" : "./redis", - "host" : "your.redis_instance.com", - "port" : 6379, - "options": { "auth_pass" : "all_mimsy_were_the_borogroves" } - } -} -``` - -### Running in the Cloud - -We're enthusiastic about hosting wiki on cloud platform services. There are many alternatives, each with its own strengths and -weaknesses. Here we list projects that document procedures for specific services. Look here for ideas about running -on your service or roll your own and contribute it here. - -* [RedHat's OpenShift](https://github.com/paul90/wiki-openshift-quickstart/) by @paul90 - -### Developing Wiki - -This package consists of client and server code as well as a number of sample plugins that create special purpose markups that can be used on a paragraph by paragraph basis. Get the code, build the client, and start the server: - - $ git clone https://github.com/WardCunningham/wiki.git - $ cd wiki - $ npm install - $ grunt build - $ npm start - -While you're coding, you can also watch for files to change. This will rebuild the client each time you save a file. - - $ grunt watch - -Test the server-side code by running `$ grunt test`. - -Test the client-side code by starting your wiki server with `$npm start` and opening [`http://localhost:3000/runtests.html`](http://localhost:3000/runtests.html) - - - -### How to Participate - -* Join the developer IRC channel, `#fedwiki` on freenode -* Stop by the [Google Hangout](http://bit.ly/SFWhangout) at 10am Pacific every Wednesday -* Submit [Issues](https://github.com/WardCunningham/wiki/issues) -* Fork, commit and submit [Pull Requests](https://github.com/WardCunningham/wiki/pulls) - - -### License +## License You may use the Wiki under either the [MIT License](https://github.com/WardCunningham/wiki/blob/master/mit-license.txt) or the diff --git a/Windows.md b/Windows.md deleted file mode 100644 index 1493785a..00000000 --- a/Windows.md +++ /dev/null @@ -1,78 +0,0 @@ -Windows Notes -============= - -These notes will help with installing and running the Smallest Federated Wiki on Windows. - -* [Install and Launch (Sinatra)](Windows.md#install-and-launch-sinatra) -* [Install and Launch (Node.js Express)](Windows.md#install-and-launch-nodejs-express) - - - -Install and Launch (Sinatra) -============================ - -The Sinstra server requires Ruby, this can be installed from [RubyInstaller for Windows](http://rubyinstaller.org/). -As well as the Ruby Installer, you will also need the Development Kit to compile some of the Gem files. These notes -have been written/tested with Ruby version 1.9.3. - -> **N.B.** See [Development Kit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit) for installation -> instructions. - -Open a command window - ensure that Ruby, the Development Kit, and Git have all been added to the environment (there -are scripts in the ruby and development kit directories if necessary). - -The server is a ruby bundle. Get the bundler gem and then use it to get everything else: - - gem install bundler - bundle update - -> It is probably best to use ```bundle update``` rather than ```bundle install``` so that the latest version of the -> gems are installed. There are know problems with eventmachine (0.12.10) not installing, and with in-line code in the PNG (1.2.0) gem -> this will be seen as an error when the server is started - if the update to the PNG gem has not been release, see [Fixed a misordered block of C code](https://github.com/bensomers/png/commit/eff179b3e5849b287251d0c33435852e8842597e) -> for the changes needed to the PNG gem code. - - -Launch the server with this bundle command: - - cd server\sinatra - bundle exec rackup -s thin -p 1111 - -Now go to your browser and browse your new wiki: - - http://localhost:1111 - - -Install and Launch (Node.js Express) -==================================== - -The express server requires Node.js, if not already installed it is available from [node.js](http://nodejs.org/). -You will also need a Visual C compiler, the current version of the Visual Studio Express is free from -[Visual Studio Express](www.microsoft.com/express/) - **N.B.** you will want the version for Windows Desktop. - -Open a command window - ensure that node, and Visual C are both on path. Also worth checking that windows\system32 is -not missing from the path, as that causes a know problem. - -Run ```npm install``` in the following directories: - - client - client\plugins - client\plugins\linkmap - client\plugins\parse - server\express - -The server is launched by: - - cd server\express - node bin\server.js - -You should not get any error messages when starting, if any new plugins are added that require installing you will get -a message similar to: - - starting plugin xxxxx - failed to start plugin xxxxx { [Error: Cannot find module 'ws'] code: 'MODULE_NOT_FOUND' } - -If that happens you just need to run ```npm install``` in that plugin's directory. - -Now got to your browser and browse your new wiki: - - http://localhost:3000 diff --git a/client/ReadMe.md b/client/ReadMe.md deleted file mode 100644 index 284d0e31..00000000 --- a/client/ReadMe.md +++ /dev/null @@ -1,67 +0,0 @@ -Client Goals -============ - -A server offers direct restful read/write access to pages it owns and proxy access to pages held elsewhere in federated space. -A page is owned if it was created with the server or has been cloned and edited such that it is believed to be the most authoritative copy of a page previously owned elsewhere. -A server operates as a proxy to the rest of the federated wiki. -In this role it reformats data and metadata providing a unified experience. -It is welcome to collect behavioral statistics in order to improve this experience by anticipating permitted peer-to-peer server operations. - -In summary, the server's client side exists to: - -* Offer to a user a browsing experience that is independent of any specific server. -* Support writing, editing and curating of one server in a way that offers suitable influence over others. - -Working with Browserify -======================= - -The client side is written in CoffeeScript, and built with Browserify. -If you are not checking in changes you need not concern yourself with this. -We've checked in the generated Javascript for the client application. - -If you do want to check in changes, install node v0.6.x - -* On Linux download the source from [GitHub](https://github.com/joyent/node) -* On Windows get the installer from the [main node.js site](http://nodejs.org). -* On Mac you should be able to choose either. - -Once node is installed come back to this directory and run: - -* `npm install` To install CoffeeScript, Browserify, and all their dependencies. - -You can now use: - -* `npm start` To build the main client. -* `npm test` To build the test client. - -These commands build client.js and test/testclient.js from client.coffee and -testclient.coffee respectively. They use their entry files to require the -rest of the coffee script they need from the source CS files in /lib. - -We also have a cool automated talking (Mac only) Perl build script that uses -a globally installed browserify via `npm install -g browserify`, it watches -for changes, builds the clients automatically, and gives a verbal report -when you have syntax errors. - -Testing -======= - -All the client tests can be run by visiting /runtests.html on your server -or by running the full ruby test suite. Information about the libraries we -are using for testing can be found at: - -* http://visionmedia.github.com/mocha/ -* https://github.com/LearnBoost/expect.js -* http://sinonjs.org/ - -CoffeeScript hints -================== - -We recommend taking time to learn the CoffeeScript syntax and the rationale for the Javascript idioms it employs. Start here: - - http://jashkenas.github.com/coffee-script/ - -We used a Javascript to Coffeescript converter to create the first draft of client.coffee. You may find this converter useful for importing sample codes. - - http://ricostacruz.com/js2coffee/ - diff --git a/client/client.coffee b/client/client.coffee deleted file mode 100644 index 8d1f797d..00000000 --- a/client/client.coffee +++ /dev/null @@ -1,2 +0,0 @@ -window.wiki = require('wiki-client') - diff --git a/client/images/crosses.png b/client/images/crosses.png deleted file mode 100644 index 78d745ff..00000000 Binary files a/client/images/crosses.png and /dev/null differ diff --git a/client/images/email_sign_in_blue.png b/client/images/email_sign_in_blue.png deleted file mode 100644 index 5986020a..00000000 Binary files a/client/images/email_sign_in_blue.png and /dev/null differ diff --git a/client/images/external-link-ltr-icon.png b/client/images/external-link-ltr-icon.png deleted file mode 100644 index a4977952..00000000 Binary files a/client/images/external-link-ltr-icon.png and /dev/null differ diff --git a/client/images/noise.png b/client/images/noise.png deleted file mode 100755 index f0b4de42..00000000 Binary files a/client/images/noise.png and /dev/null differ diff --git a/client/images/oops.jpg b/client/images/oops.jpg deleted file mode 100644 index 4642e67e..00000000 Binary files a/client/images/oops.jpg and /dev/null differ diff --git a/client/js/d3/d3.behavior.js b/client/js/d3/d3.behavior.js deleted file mode 100755 index 8c67949a..00000000 --- a/client/js/d3/d3.behavior.js +++ /dev/null @@ -1,198 +0,0 @@ -(function(){d3.behavior = {}; -// TODO unbind zoom behavior? -// TODO unbind listener? -d3.behavior.zoom = function() { - var xyz = [0, 0, 0], - event = d3.dispatch("zoom"); - - function zoom() { - this - .on("mousedown.zoom", mousedown) - .on("mousewheel.zoom", mousewheel) - .on("DOMMouseScroll.zoom", dblclick) - .on("dblclick.zoom", dblclick) - .on("touchstart.zoom", touchstart); - - d3.select(window) - .on("mousemove.zoom", d3_behavior_zoomMousemove) - .on("mouseup.zoom", d3_behavior_zoomMouseup) - .on("touchmove.zoom", d3_behavior_zoomTouchmove) - .on("touchend.zoom", d3_behavior_zoomTouchup); - } - - // snapshot the local context for subsequent dispatch - function start() { - d3_behavior_zoomXyz = xyz; - d3_behavior_zoomDispatch = event.zoom.dispatch; - d3_behavior_zoomTarget = this; - d3_behavior_zoomArguments = arguments; - } - - function mousedown() { - start.apply(this, arguments); - d3_behavior_zoomPanning = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget)); - d3.event.preventDefault(); - window.focus(); - } - - // store starting mouse location - function mousewheel() { - start.apply(this, arguments); - if (!d3_behavior_zoomZooming) d3_behavior_zoomZooming = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget)); - d3_behavior_zoomTo(d3_behavior_zoomDelta() + xyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomZooming); - } - - function dblclick() { - start.apply(this, arguments); - var mouse = d3.svg.mouse(d3_behavior_zoomTarget); - d3_behavior_zoomTo(d3.event.shiftKey ? Math.ceil(xyz[2] - 1) : Math.floor(xyz[2] + 1), mouse, d3_behavior_zoomLocation(mouse)); - } - - // doubletap detection - function touchstart() { - start.apply(this, arguments); - var touches = d3_behavior_zoomTouchup(), - touch, - now = Date.now(); - if ((touches.length === 1) && (now - d3_behavior_zoomLast < 300)) { - d3_behavior_zoomTo(1 + Math.floor(xyz[2]), touch = touches[0], d3_behavior_zoomLocations[touch.identifier]); - } - d3_behavior_zoomLast = now; - } - - zoom.on = function(type, listener) { - event[type].add(listener); - return zoom; - }; - - return zoom; -}; - -var d3_behavior_zoomDiv, - d3_behavior_zoomPanning, - d3_behavior_zoomZooming, - d3_behavior_zoomLocations = {}, // identifier -> location - d3_behavior_zoomLast = 0, - d3_behavior_zoomXyz, - d3_behavior_zoomDispatch, - d3_behavior_zoomTarget, - d3_behavior_zoomArguments; - -function d3_behavior_zoomLocation(point) { - return [ - point[0] - d3_behavior_zoomXyz[0], - point[1] - d3_behavior_zoomXyz[1], - d3_behavior_zoomXyz[2] - ]; -} - -// detect the pixels that would be scrolled by this wheel event -function d3_behavior_zoomDelta() { - - // mousewheel events are totally broken! - // https://bugs.webkit.org/show_bug.cgi?id=40441 - // not only that, but Chrome and Safari differ in re. to acceleration! - if (!d3_behavior_zoomDiv) { - d3_behavior_zoomDiv = d3.select("body").append("div") - .style("visibility", "hidden") - .style("top", 0) - .style("height", 0) - .style("width", 0) - .style("overflow-y", "scroll") - .append("div") - .style("height", "2000px") - .node().parentNode; - } - - var e = d3.event, delta; - try { - d3_behavior_zoomDiv.scrollTop = 1000; - d3_behavior_zoomDiv.dispatchEvent(e); - delta = 1000 - d3_behavior_zoomDiv.scrollTop; - } catch (error) { - delta = e.wheelDelta || -e.detail; - } - - return delta * .005; -} - -// Note: Since we don't rotate, it's possible for the touches to become -// slightly detached from their original positions. Thus, we recompute the -// touch points on touchend as well as touchstart! -function d3_behavior_zoomTouchup() { - var touches = d3.svg.touches(d3_behavior_zoomTarget), - i = -1, - n = touches.length, - touch; - while (++i < n) d3_behavior_zoomLocations[(touch = touches[i]).identifier] = d3_behavior_zoomLocation(touch); - return touches; -} - -function d3_behavior_zoomTouchmove() { - var touches = d3.svg.touches(d3_behavior_zoomTarget); - switch (touches.length) { - - // single-touch pan - case 1: { - var touch = touches[0]; - d3_behavior_zoomTo(d3_behavior_zoomXyz[2], touch, d3_behavior_zoomLocations[touch.identifier]); - break; - } - - // double-touch pan + zoom - case 2: { - var p0 = touches[0], - p1 = touches[1], - p2 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2], - l0 = d3_behavior_zoomLocations[p0.identifier], - l1 = d3_behavior_zoomLocations[p1.identifier], - l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2, l0[2]]; - d3_behavior_zoomTo(Math.log(d3.event.scale) / Math.LN2 + l0[2], p2, l2); - break; - } - } -} - -function d3_behavior_zoomMousemove() { - d3_behavior_zoomZooming = null; - if (d3_behavior_zoomPanning) d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning); -} - -function d3_behavior_zoomMouseup() { - if (d3_behavior_zoomPanning) { - d3_behavior_zoomMousemove(); - d3_behavior_zoomPanning = null; - } -} - -function d3_behavior_zoomTo(z, x0, x1) { - var K = Math.pow(2, (d3_behavior_zoomXyz[2] = z) - x1[2]), - x = d3_behavior_zoomXyz[0] = x0[0] - K * x1[0], - y = d3_behavior_zoomXyz[1] = x0[1] - K * x1[1], - o = d3.event, // Events can be reentrant (e.g., focus). - k = Math.pow(2, z); - - d3.event = { - scale: k, - translate: [x, y], - transform: function(sx, sy) { - if (sx) transform(sx, x); - if (sy) transform(sy, y); - } - }; - - function transform(scale, o) { - var domain = scale.__domain || (scale.__domain = scale.domain()), - range = scale.range().map(function(v) { return (v - o) / k; }); - scale.domain(domain).domain(range.map(scale.invert)); - } - - try { - d3_behavior_zoomDispatch.apply(d3_behavior_zoomTarget, d3_behavior_zoomArguments); - } finally { - d3.event = o; - } - - o.preventDefault(); -} -})(); diff --git a/client/js/d3/d3.chart.js b/client/js/d3/d3.chart.js deleted file mode 100755 index 281d0072..00000000 --- a/client/js/d3/d3.chart.js +++ /dev/null @@ -1,984 +0,0 @@ -(function(){d3.chart = {}; -// Inspired by http://informationandvisualization.de/blog/box-plot -d3.chart.box = function() { - var width = 1, - height = 1, - duration = 0, - domain = null, - value = Number, - whiskers = d3_chart_boxWhiskers, - quartiles = d3_chart_boxQuartiles, - tickFormat = null; - - // For each small multiple… - function box(g) { - g.each(function(d, i) { - d = d.map(value).sort(d3.ascending); - var g = d3.select(this), - n = d.length, - min = d[0], - max = d[n - 1]; - - // Compute quartiles. Must return exactly 3 elements. - var quartileData = d.quartiles = quartiles(d); - - // Compute whiskers. Must return exactly 2 elements, or null. - var whiskerIndices = whiskers && whiskers.call(this, d, i), - whiskerData = whiskerIndices && whiskerIndices.map(function(i) { return d[i]; }); - - // Compute outliers. If no whiskers are specified, all data are "outliers". - // We compute the outliers as indices, so that we can join across transitions! - var outlierIndices = whiskerIndices - ? d3.range(0, whiskerIndices[0]).concat(d3.range(whiskerIndices[1] + 1, n)) - : d3.range(n); - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain(domain && domain.call(this, d, i) || [min, max]) - .range([height, 0]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - // Note: the box, median, and box tick elements are fixed in number, - // so we only have to handle enter and update. In contrast, the outliers - // and other elements are variable, so we need to exit them! Variable - // elements also fade in and out. - - // Update center line: the vertical line spanning the whiskers. - var center = g.selectAll("line.center") - .data(whiskerData ? [whiskerData] : []); - - center.enter().insert("svg:line", "rect") - .attr("class", "center") - .attr("x1", width / 2) - .attr("y1", function(d) { return x0(d[0]); }) - .attr("x2", width / 2) - .attr("y2", function(d) { return x0(d[1]); }) - .style("opacity", 1e-6) - .transition() - .duration(duration) - .style("opacity", 1) - .attr("y1", function(d) { return x1(d[0]); }) - .attr("y2", function(d) { return x1(d[1]); }); - - center.transition() - .duration(duration) - .style("opacity", 1) - .attr("y1", function(d) { return x1(d[0]); }) - .attr("y2", function(d) { return x1(d[1]); }); - - center.exit().transition() - .duration(duration) - .style("opacity", 1e-6) - .attr("y1", function(d) { return x1(d[0]); }) - .attr("y2", function(d) { return x1(d[1]); }) - .remove(); - - // Update innerquartile box. - var box = g.selectAll("rect.box") - .data([quartileData]); - - box.enter().append("svg:rect") - .attr("class", "box") - .attr("x", 0) - .attr("y", function(d) { return x0(d[2]); }) - .attr("width", width) - .attr("height", function(d) { return x0(d[0]) - x0(d[2]); }) - .transition() - .duration(duration) - .attr("y", function(d) { return x1(d[2]); }) - .attr("height", function(d) { return x1(d[0]) - x1(d[2]); }); - - box.transition() - .duration(duration) - .attr("y", function(d) { return x1(d[2]); }) - .attr("height", function(d) { return x1(d[0]) - x1(d[2]); }); - - // Update median line. - var medianLine = g.selectAll("line.median") - .data([quartileData[1]]); - - medianLine.enter().append("svg:line") - .attr("class", "median") - .attr("x1", 0) - .attr("y1", x0) - .attr("x2", width) - .attr("y2", x0) - .transition() - .duration(duration) - .attr("y1", x1) - .attr("y2", x1); - - medianLine.transition() - .duration(duration) - .attr("y1", x1) - .attr("y2", x1); - - // Update whiskers. - var whisker = g.selectAll("line.whisker") - .data(whiskerData || []); - - whisker.enter().insert("svg:line", "circle, text") - .attr("class", "whisker") - .attr("x1", 0) - .attr("y1", x0) - .attr("x2", width) - .attr("y2", x0) - .style("opacity", 1e-6) - .transition() - .duration(duration) - .attr("y1", x1) - .attr("y2", x1) - .style("opacity", 1); - - whisker.transition() - .duration(duration) - .attr("y1", x1) - .attr("y2", x1) - .style("opacity", 1); - - whisker.exit().transition() - .duration(duration) - .attr("y1", x1) - .attr("y2", x1) - .style("opacity", 1e-6) - .remove(); - - // Update outliers. - var outlier = g.selectAll("circle.outlier") - .data(outlierIndices, Number); - - outlier.enter().insert("svg:circle", "text") - .attr("class", "outlier") - .attr("r", 5) - .attr("cx", width / 2) - .attr("cy", function(i) { return x0(d[i]); }) - .style("opacity", 1e-6) - .transition() - .duration(duration) - .attr("cy", function(i) { return x1(d[i]); }) - .style("opacity", 1); - - outlier.transition() - .duration(duration) - .attr("cy", function(i) { return x1(d[i]); }) - .style("opacity", 1); - - outlier.exit().transition() - .duration(duration) - .attr("cy", function(i) { return x1(d[i]); }) - .style("opacity", 1e-6) - .remove(); - - // Compute the tick format. - var format = tickFormat || x1.tickFormat(8); - - // Update box ticks. - var boxTick = g.selectAll("text.box") - .data(quartileData); - - boxTick.enter().append("svg:text") - .attr("class", "box") - .attr("dy", ".3em") - .attr("dx", function(d, i) { return i & 1 ? 6 : -6 }) - .attr("x", function(d, i) { return i & 1 ? width : 0 }) - .attr("y", x0) - .attr("text-anchor", function(d, i) { return i & 1 ? "start" : "end"; }) - .text(format) - .transition() - .duration(duration) - .attr("y", x1); - - boxTick.transition() - .duration(duration) - .text(format) - .attr("y", x1); - - // Update whisker ticks. These are handled separately from the box - // ticks because they may or may not exist, and we want don't want - // to join box ticks pre-transition with whisker ticks post-. - var whiskerTick = g.selectAll("text.whisker") - .data(whiskerData || []); - - whiskerTick.enter().append("svg:text") - .attr("class", "whisker") - .attr("dy", ".3em") - .attr("dx", 6) - .attr("x", width) - .attr("y", x0) - .text(format) - .style("opacity", 1e-6) - .transition() - .duration(duration) - .attr("y", x1) - .style("opacity", 1); - - whiskerTick.transition() - .duration(duration) - .text(format) - .attr("y", x1) - .style("opacity", 1); - - whiskerTick.exit().transition() - .duration(duration) - .attr("y", x1) - .style("opacity", 1e-6) - .remove(); - }); - d3.timer.flush(); - } - - box.width = function(x) { - if (!arguments.length) return width; - width = x; - return box; - }; - - box.height = function(x) { - if (!arguments.length) return height; - height = x; - return box; - }; - - box.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return box; - }; - - box.duration = function(x) { - if (!arguments.length) return duration; - duration = x; - return box; - }; - - box.domain = function(x) { - if (!arguments.length) return domain; - domain = x == null ? x : d3.functor(x); - return box; - }; - - box.value = function(x) { - if (!arguments.length) return value; - value = x; - return box; - }; - - box.whiskers = function(x) { - if (!arguments.length) return whiskers; - whiskers = x; - return box; - }; - - box.quartiles = function(x) { - if (!arguments.length) return quartiles; - quartiles = x; - return box; - }; - - return box; -}; - -function d3_chart_boxWhiskers(d) { - return [0, d.length - 1]; -} - -function d3_chart_boxQuartiles(d) { - return [ - d3.quantile(d, .25), - d3.quantile(d, .5), - d3.quantile(d, .75) - ]; -} -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ -d3.chart.bullet = function() { - var orient = "left", // TODO top & bottom - reverse = false, - duration = 0, - ranges = d3_chart_bulletRanges, - markers = d3_chart_bulletMarkers, - measures = d3_chart_bulletMeasures, - width = 380, - height = 30, - tickFormat = null; - - // For each small multiple… - function bullet(g) { - g.each(function(d, i) { - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending), - g = d3.select(this); - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) - .range(reverse ? [width, 0] : [0, width]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - // Derive width-scales from the x-scales. - var w0 = d3_chart_bulletWidth(x0), - w1 = d3_chart_bulletWidth(x1); - - // Update the range rects. - var range = g.selectAll("rect.range") - .data(rangez); - - range.enter().append("svg:rect") - .attr("class", function(d, i) { return "range s" + i; }) - .attr("width", w0) - .attr("height", height) - .attr("x", reverse ? x0 : 0) - .transition() - .duration(duration) - .attr("width", w1) - .attr("x", reverse ? x1 : 0); - - range.transition() - .duration(duration) - .attr("x", reverse ? x1 : 0) - .attr("width", w1) - .attr("height", height); - - // Update the measure rects. - var measure = g.selectAll("rect.measure") - .data(measurez); - - measure.enter().append("svg:rect") - .attr("class", function(d, i) { return "measure s" + i; }) - .attr("width", w0) - .attr("height", height / 3) - .attr("x", reverse ? x0 : 0) - .attr("y", height / 3) - .transition() - .duration(duration) - .attr("width", w1) - .attr("x", reverse ? x1 : 0); - - measure.transition() - .duration(duration) - .attr("width", w1) - .attr("height", height / 3) - .attr("x", reverse ? x1 : 0) - .attr("y", height / 3); - - // Update the marker lines. - var marker = g.selectAll("line.marker") - .data(markerz); - - marker.enter().append("svg:line") - .attr("class", "marker") - .attr("x1", x0) - .attr("x2", x0) - .attr("y1", height / 6) - .attr("y2", height * 5 / 6) - .transition() - .duration(duration) - .attr("x1", x1) - .attr("x2", x1); - - marker.transition() - .duration(duration) - .attr("x1", x1) - .attr("x2", x1) - .attr("y1", height / 6) - .attr("y2", height * 5 / 6); - - // Compute the tick format. - var format = tickFormat || x1.tickFormat(8); - - // Update the tick groups. - var tick = g.selectAll("g.tick") - .data(x1.ticks(8), function(d) { - return this.textContent || format(d); - }); - - // Initialize the ticks with the old scale, x0. - var tickEnter = tick.enter().append("svg:g") - .attr("class", "tick") - .attr("transform", d3_chart_bulletTranslate(x0)) - .style("opacity", 1e-6); - - tickEnter.append("svg:line") - .attr("y1", height) - .attr("y2", height * 7 / 6); - - tickEnter.append("svg:text") - .attr("text-anchor", "middle") - .attr("dy", "1em") - .attr("y", height * 7 / 6) - .text(format); - - // Transition the entering ticks to the new scale, x1. - tickEnter.transition() - .duration(duration) - .attr("transform", d3_chart_bulletTranslate(x1)) - .style("opacity", 1); - - // Transition the updating ticks to the new scale, x1. - var tickUpdate = tick.transition() - .duration(duration) - .attr("transform", d3_chart_bulletTranslate(x1)) - .style("opacity", 1); - - tickUpdate.select("line") - .attr("y1", height) - .attr("y2", height * 7 / 6); - - tickUpdate.select("text") - .attr("y", height * 7 / 6); - - // Transition the exiting ticks to the new scale, x1. - tick.exit().transition() - .duration(duration) - .attr("transform", d3_chart_bulletTranslate(x1)) - .style("opacity", 1e-6) - .remove(); - }); - d3.timer.flush(); - } - - // left, right, top, bottom - bullet.orient = function(x) { - if (!arguments.length) return orient; - orient = x; - reverse = orient == "right" || orient == "bottom"; - return bullet; - }; - - // ranges (bad, satisfactory, good) - bullet.ranges = function(x) { - if (!arguments.length) return ranges; - ranges = x; - return bullet; - }; - - // markers (previous, goal) - bullet.markers = function(x) { - if (!arguments.length) return markers; - markers = x; - return bullet; - }; - - // measures (actual, forecast) - bullet.measures = function(x) { - if (!arguments.length) return measures; - measures = x; - return bullet; - }; - - bullet.width = function(x) { - if (!arguments.length) return width; - width = x; - return bullet; - }; - - bullet.height = function(x) { - if (!arguments.length) return height; - height = x; - return bullet; - }; - - bullet.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return bullet; - }; - - bullet.duration = function(x) { - if (!arguments.length) return duration; - duration = x; - return bullet; - }; - - return bullet; -}; - -function d3_chart_bulletRanges(d) { - return d.ranges; -} - -function d3_chart_bulletMarkers(d) { - return d.markers; -} - -function d3_chart_bulletMeasures(d) { - return d.measures; -} - -function d3_chart_bulletTranslate(x) { - return function(d) { - return "translate(" + x(d) + ",0)"; - }; -} - -function d3_chart_bulletWidth(x) { - var x0 = x(0); - return function(d) { - return Math.abs(x(d) - x0); - }; -} -// Implements a horizon layout, which is a variation of a single-series -// area chart where the area is folded into multiple bands. Color is used to -// encode band, allowing the size of the chart to be reduced significantly -// without impeding readability. This layout algorithm is based on the work of -// J. Heer, N. Kong and M. Agrawala in "Sizing the Horizon: The Effects of Chart -// Size and Layering on the Graphical Perception of Time Series Visualizations", -// CHI 2009. http://hci.stanford.edu/publications/2009/heer-horizon-chi09.pdf -d3.chart.horizon = function() { - var bands = 1, // between 1 and 5, typically - mode = "offset", // or mirror - interpolate = "linear", // or basis, monotone, step-before, etc. - x = d3_chart_horizonX, - y = d3_chart_horizonY, - w = 960, - h = 40, - duration = 0; - - var color = d3.scale.linear() - .domain([-1, 0, 1]) - .range(["#d62728", "#fff", "#1f77b4"]); - - // For each small multiple… - function horizon(g) { - g.each(function(d, i) { - var g = d3.select(this), - n = 2 * bands + 1, - xMin = Infinity, - xMax = -Infinity, - yMax = -Infinity, - x0, // old x-scale - y0, // old y-scale - id; // unique id for paths - - // Compute x- and y-values along with extents. - var data = d.map(function(d, i) { - var xv = x.call(this, d, i), - yv = y.call(this, d, i); - if (xv < xMin) xMin = xv; - if (xv > xMax) xMax = xv; - if (-yv > yMax) yMax = -yv; - if (yv > yMax) yMax = yv; - return [xv, yv]; - }); - - // Compute the new x- and y-scales. - var x1 = d3.scale.linear().domain([xMin, xMax]).range([0, w]), - y1 = d3.scale.linear().domain([0, yMax]).range([0, h * bands]); - - // Retrieve the old scales, if this is an update. - if (this.__chart__) { - x0 = this.__chart__.x; - y0 = this.__chart__.y; - id = this.__chart__.id; - } else { - x0 = d3.scale.linear().domain([0, Infinity]).range(x1.range()); - y0 = d3.scale.linear().domain([0, Infinity]).range(y1.range()); - id = ++d3_chart_horizonId; - } - - // We'll use a defs to store the area path and the clip path. - var defs = g.selectAll("defs") - .data([data]); - - var defsEnter = defs.enter().append("svg:defs"); - - // The clip path is a simple rect. - defsEnter.append("svg:clipPath") - .attr("id", "d3_chart_horizon_clip" + id) - .append("svg:rect") - .attr("width", w) - .attr("height", h); - - defs.select("rect").transition() - .duration(duration) - .attr("width", w) - .attr("height", h); - - // The area path is rendered with our resuable d3.svg.area. - defsEnter.append("svg:path") - .attr("id", "d3_chart_horizon_path" + id) - .attr("d", d3_chart_horizonArea - .interpolate(interpolate) - .x(function(d) { return x0(d[0]); }) - .y0(h * bands) - .y1(function(d) { return h * bands - y0(d[1]); })) - .transition() - .duration(duration) - .attr("d", d3_chart_horizonArea - .x(function(d) { return x1(d[0]); }) - .y1(function(d) { return h * bands - y1(d[1]); })); - - defs.select("path").transition() - .duration(duration) - .attr("d", d3_chart_horizonArea); - - // We'll use a container to clip all horizon layers at once. - g.selectAll("g") - .data([null]) - .enter().append("svg:g") - .attr("clip-path", "url(#d3_chart_horizon_clip" + id + ")"); - - // Define the transform function based on the mode. - var transform = mode == "offset" - ? function(d) { return "translate(0," + (d + (d < 0) - bands) * h + ")"; } - : function(d) { return (d < 0 ? "scale(1,-1)" : "") + "translate(0," + (d - bands) * h + ")"; }; - - // Instantiate each copy of the path with different transforms. - var u = g.select("g").selectAll("use") - .data(d3.range(-1, -bands - 1, -1).concat(d3.range(1, bands + 1)), Number); - - // TODO don't fudge the enter transition - u.enter().append("svg:use") - .attr("xlink:href", "#d3_chart_horizon_path" + id) - .attr("transform", function(d) { return transform(d + (d > 0 ? 1 : -1)); }) - .style("fill", color) - .transition() - .duration(duration) - .attr("transform", transform); - - u.transition() - .duration(duration) - .attr("transform", transform) - .style("fill", color); - - u.exit().transition() - .duration(duration) - .attr("transform", transform) - .remove(); - - // Stash the new scales. - this.__chart__ = {x: x1, y: y1, id: id}; - }); - d3.timer.flush(); - } - - horizon.duration = function(x) { - if (!arguments.length) return duration; - duration = +x; - return horizon; - }; - - horizon.bands = function(x) { - if (!arguments.length) return bands; - bands = +x; - color.domain([-bands, 0, bands]); - return horizon; - }; - - horizon.mode = function(x) { - if (!arguments.length) return mode; - mode = x + ""; - return horizon; - }; - - horizon.colors = function(x) { - if (!arguments.length) return color.range(); - color.range(x); - return horizon; - }; - - horizon.interpolate = function(x) { - if (!arguments.length) return interpolate; - interpolate = x + ""; - return horizon; - }; - - horizon.x = function(z) { - if (!arguments.length) return x; - x = z; - return horizon; - }; - - horizon.y = function(z) { - if (!arguments.length) return y; - y = z; - return horizon; - }; - - horizon.width = function(x) { - if (!arguments.length) return w; - w = +x; - return horizon; - }; - - horizon.height = function(x) { - if (!arguments.length) return h; - h = +x; - return horizon; - }; - - return horizon; -}; - -var d3_chart_horizonArea = d3.svg.area(), - d3_chart_horizonId = 0; - -function d3_chart_horizonX(d) { - return d[0]; -} - -function d3_chart_horizonY(d) { - return d[1]; -} -// Based on http://vis.stanford.edu/protovis/ex/qqplot.html -d3.chart.qq = function() { - var width = 1, - height = 1, - duration = 0, - domain = null, - tickFormat = null, - n = 100, - x = d3_chart_qqX, - y = d3_chart_qqY; - - // For each small multiple… - function qq(g) { - g.each(function(d, i) { - var g = d3.select(this), - qx = d3_chart_qqQuantiles(n, x.call(this, d, i)), - qy = d3_chart_qqQuantiles(n, y.call(this, d, i)), - xd = domain && domain.call(this, d, i) || [d3.min(qx), d3.max(qx)], // new x-domain - yd = domain && domain.call(this, d, i) || [d3.min(qy), d3.max(qy)], // new y-domain - x0, // old x-scale - y0; // old y-scale - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain(xd) - .range([0, width]); - - // Compute the new y-scale. - var y1 = d3.scale.linear() - .domain(yd) - .range([height, 0]); - - // Retrieve the old scales, if this is an update. - if (this.__chart__) { - x0 = this.__chart__.x; - y0 = this.__chart__.y; - } else { - x0 = d3.scale.linear().domain([0, Infinity]).range(x1.range()); - y0 = d3.scale.linear().domain([0, Infinity]).range(y1.range()); - } - - // Stash the new scales. - this.__chart__ = {x: x1, y: y1}; - - // Update diagonal line. - var diagonal = g.selectAll("line.diagonal") - .data([null]); - - diagonal.enter().append("svg:line") - .attr("class", "diagonal") - .attr("x1", x1(yd[0])) - .attr("y1", y1(xd[0])) - .attr("x2", x1(yd[1])) - .attr("y2", y1(xd[1])); - - diagonal.transition() - .duration(duration) - .attr("x1", x1(yd[0])) - .attr("y1", y1(xd[0])) - .attr("x2", x1(yd[1])) - .attr("y2", y1(xd[1])); - - // Update quantile plots. - var circle = g.selectAll("circle") - .data(d3.range(n).map(function(i) { - return {x: qx[i], y: qy[i]}; - })); - - circle.enter().append("svg:circle") - .attr("class", "quantile") - .attr("r", 4.5) - .attr("cx", function(d) { return x0(d.x); }) - .attr("cy", function(d) { return y0(d.y); }) - .style("opacity", 1e-6) - .transition() - .duration(duration) - .attr("cx", function(d) { return x1(d.x); }) - .attr("cy", function(d) { return y1(d.y); }) - .style("opacity", 1); - - circle.transition() - .duration(duration) - .attr("cx", function(d) { return x1(d.x); }) - .attr("cy", function(d) { return y1(d.y); }) - .style("opacity", 1); - - circle.exit().transition() - .duration(duration) - .attr("cx", function(d) { return x1(d.x); }) - .attr("cy", function(d) { return y1(d.y); }) - .style("opacity", 1e-6) - .remove(); - - var xformat = tickFormat || x1.tickFormat(4), - yformat = tickFormat || y1.tickFormat(4), - tx = function(d) { return "translate(" + x1(d) + "," + height + ")"; }, - ty = function(d) { return "translate(0," + y1(d) + ")"; }; - - // Update x-ticks. - var xtick = g.selectAll("g.x.tick") - .data(x1.ticks(4), function(d) { - return this.textContent || xformat(d); - }); - - var xtickEnter = xtick.enter().append("svg:g") - .attr("class", "x tick") - .attr("transform", function(d) { return "translate(" + x0(d) + "," + height + ")"; }) - .style("opacity", 1e-6); - - xtickEnter.append("svg:line") - .attr("y1", 0) - .attr("y2", -6); - - xtickEnter.append("svg:text") - .attr("text-anchor", "middle") - .attr("dy", "1em") - .text(xformat); - - // Transition the entering ticks to the new scale, x1. - xtickEnter.transition() - .duration(duration) - .attr("transform", tx) - .style("opacity", 1); - - // Transition the updating ticks to the new scale, x1. - xtick.transition() - .duration(duration) - .attr("transform", tx) - .style("opacity", 1); - - // Transition the exiting ticks to the new scale, x1. - xtick.exit().transition() - .duration(duration) - .attr("transform", tx) - .style("opacity", 1e-6) - .remove(); - - // Update ticks. - var ytick = g.selectAll("g.y.tick") - .data(y1.ticks(4), function(d) { - return this.textContent || yformat(d); - }); - - var ytickEnter = ytick.enter().append("svg:g") - .attr("class", "y tick") - .attr("transform", function(d) { return "translate(0," + y0(d) + ")"; }) - .style("opacity", 1e-6); - - ytickEnter.append("svg:line") - .attr("x1", 0) - .attr("x2", 6); - - ytickEnter.append("svg:text") - .attr("text-anchor", "end") - .attr("dx", "-.5em") - .attr("dy", ".3em") - .text(yformat); - - // Transition the entering ticks to the new scale, y1. - ytickEnter.transition() - .duration(duration) - .attr("transform", ty) - .style("opacity", 1); - - // Transition the updating ticks to the new scale, y1. - ytick.transition() - .duration(duration) - .attr("transform", ty) - .style("opacity", 1); - - // Transition the exiting ticks to the new scale, y1. - ytick.exit().transition() - .duration(duration) - .attr("transform", ty) - .style("opacity", 1e-6) - .remove(); - }); - } - - qq.width = function(x) { - if (!arguments.length) return width; - width = x; - return qq; - }; - - qq.height = function(x) { - if (!arguments.length) return height; - height = x; - return qq; - }; - - qq.duration = function(x) { - if (!arguments.length) return duration; - duration = x; - return qq; - }; - - qq.domain = function(x) { - if (!arguments.length) return domain; - domain = x == null ? x : d3.functor(x); - return qq; - }; - - qq.count = function(z) { - if (!arguments.length) return n; - n = z; - return qq; - }; - - qq.x = function(z) { - if (!arguments.length) return x; - x = z; - return qq; - }; - - qq.y = function(z) { - if (!arguments.length) return y; - y = z; - return qq; - }; - - qq.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return qq; - }; - - return qq; -}; - -function d3_chart_qqQuantiles(n, values) { - var m = values.length - 1; - values = values.slice().sort(d3.ascending); - return d3.range(n).map(function(i) { - return values[~~(i * m / n)]; - }); -} - -function d3_chart_qqX(d) { - return d.x; -} - -function d3_chart_qqY(d) { - return d.y; -} -})(); diff --git a/client/js/d3/d3.csv.js b/client/js/d3/d3.csv.js deleted file mode 100755 index 7565b83b..00000000 --- a/client/js/d3/d3.csv.js +++ /dev/null @@ -1,92 +0,0 @@ -(function(){d3.csv = function(url, callback) { - d3.text(url, "text/csv", function(text) { - callback(text && d3.csv.parse(text)); - }); -}; -d3.csv.parse = function(text) { - var header; - return d3.csv.parseRows(text, function(row, i) { - if (i) { - var o = {}, j = -1, m = header.length; - while (++j < m) o[header[j]] = row[j]; - return o; - } else { - header = row; - return null; - } - }); -}; - -d3.csv.parseRows = function(text, f) { - var EOL = {}, // sentinel value for end-of-line - EOF = {}, // sentinel value for end-of-file - rows = [], // output rows - re = /\r\n|[,\r\n]/g, // field separator regex - n = 0, // the current line number - t, // the current token - eol; // is the current token followed by EOL? - - re.lastIndex = 0; // work-around bug in FF 3.6 - - /** @private Returns the next token. */ - function token() { - if (re.lastIndex >= text.length) return EOF; // special case: end of file - if (eol) { eol = false; return EOL; } // special case: end of line - - // special case: quotes - var j = re.lastIndex; - if (text.charCodeAt(j) === 34) { - var i = j; - while (i++ < text.length) { - if (text.charCodeAt(i) === 34) { - if (text.charCodeAt(i + 1) !== 34) break; - i++; - } - } - re.lastIndex = i + 2; - var c = text.charCodeAt(i + 1); - if (c === 13) { - eol = true; - if (text.charCodeAt(i + 2) === 10) re.lastIndex++; - } else if (c === 10) { - eol = true; - } - return text.substring(j + 1, i).replace(/""/g, "\""); - } - - // common case - var m = re.exec(text); - if (m) { - eol = m[0].charCodeAt(0) !== 44; - return text.substring(j, m.index); - } - re.lastIndex = text.length; - return text.substring(j); - } - - while ((t = token()) !== EOF) { - var a = []; - while ((t !== EOL) && (t !== EOF)) { - a.push(t); - t = token(); - } - if (f && !(a = f(a, n++))) continue; - rows.push(a); - } - - return rows; -}; -d3.csv.format = function(rows) { - return rows.map(d3_csv_formatRow).join("\n"); -}; - -function d3_csv_formatRow(row) { - return row.map(d3_csv_formatValue).join(","); -} - -function d3_csv_formatValue(text) { - return /[",\n]/.test(text) - ? "\"" + text.replace(/\"/g, "\"\"") + "\"" - : text; -} -})(); diff --git a/client/js/d3/d3.geo.js b/client/js/d3/d3.geo.js deleted file mode 100755 index 253d6a3d..00000000 --- a/client/js/d3/d3.geo.js +++ /dev/null @@ -1,566 +0,0 @@ -(function(){d3.geo = {}; -// TODO clip input coordinates on opposite hemisphere -d3.geo.azimuthal = function() { - var mode = "orthographic", // or stereographic - origin, - scale = 200, - translate = [480, 250], - x0, - y0, - cy0, - sy0; - - function azimuthal(coordinates) { - var x1 = coordinates[0] * d3_radians - x0, - y1 = coordinates[1] * d3_radians, - cx1 = Math.cos(x1), - sx1 = Math.sin(x1), - cy1 = Math.cos(y1), - sy1 = Math.sin(y1), - k = mode == "stereographic" ? 1 / (1 + sy0 * sy1 + cy0 * cy1 * cx1) : 1, - x = k * cy1 * sx1, - y = k * (sy0 * cy1 * cx1 - cy0 * sy1); - return [ - scale * x + translate[0], - scale * y + translate[1] - ]; - } - - azimuthal.mode = function(x) { - if (!arguments.length) return mode; - mode = x; - return azimuthal; - }; - - azimuthal.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - x0 = origin[0] * d3_radians; - y0 = origin[1] * d3_radians; - cy0 = Math.cos(y0); - sy0 = Math.sin(y0); - return azimuthal; - }; - - azimuthal.scale = function(x) { - if (!arguments.length) return scale; - scale = +x; - return azimuthal; - }; - - azimuthal.translate = function(x) { - if (!arguments.length) return translate; - translate = [+x[0], +x[1]]; - return azimuthal; - }; - - return azimuthal.origin([0, 0]); -}; -// Derived from Tom Carden's Albers implementation for Protovis. -// http://gist.github.com/476238 -// http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html - -d3.geo.albers = function() { - var origin = [-98, 38], - parallels = [29.5, 45.5], - scale = 1000, - translate = [480, 250], - lng0, // d3_radians * origin[0] - n, - C, - p0; - - function albers(coordinates) { - var t = n * (d3_radians * coordinates[0] - lng0), - p = Math.sqrt(C - 2 * n * Math.sin(d3_radians * coordinates[1])) / n; - return [ - scale * p * Math.sin(t) + translate[0], - scale * (p * Math.cos(t) - p0) + translate[1] - ]; - } - - function reload() { - var phi1 = d3_radians * parallels[0], - phi2 = d3_radians * parallels[1], - lat0 = d3_radians * origin[1], - s = Math.sin(phi1), - c = Math.cos(phi1); - lng0 = d3_radians * origin[0]; - n = .5 * (s + Math.sin(phi2)); - C = c * c + 2 * n * s; - p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n; - return albers; - } - - albers.origin = function(x) { - if (!arguments.length) return origin; - origin = [+x[0], +x[1]]; - return reload(); - }; - - albers.parallels = function(x) { - if (!arguments.length) return parallels; - parallels = [+x[0], +x[1]]; - return reload(); - }; - - albers.scale = function(x) { - if (!arguments.length) return scale; - scale = +x; - return albers; - }; - - albers.translate = function(x) { - if (!arguments.length) return translate; - translate = [+x[0], +x[1]]; - return albers; - }; - - return reload(); -}; - -// A composite projection for the United States, 960x500. The set of standard -// parallels for each region comes from USGS, which is published here: -// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers -// TODO allow the composite projection to be rescaled? -d3.geo.albersUsa = function() { - var lower48 = d3.geo.albers(); - - var alaska = d3.geo.albers() - .origin([-160, 60]) - .parallels([55, 65]); - - var hawaii = d3.geo.albers() - .origin([-160, 20]) - .parallels([8, 18]); - - var puertoRico = d3.geo.albers() - .origin([-60, 10]) - .parallels([8, 18]); - - function albersUsa(coordinates) { - var lon = coordinates[0], - lat = coordinates[1]; - return (lat < 25 - ? (lon < -100 ? hawaii : puertoRico) - : (lat > 50 ? alaska : lower48))(coordinates); - } - - albersUsa.scale = function(x) { - if (!arguments.length) return lower48.scale(); - lower48.scale(x); - alaska.scale(x * .6); - hawaii.scale(x); - puertoRico.scale(x * 1.5); - return albersUsa.translate(lower48.translate()); - }; - - albersUsa.translate = function(x) { - if (!arguments.length) return lower48.translate(); - var dz = lower48.scale() / 1000, - dx = x[0], - dy = x[1]; - lower48.translate(x); - alaska.translate([dx - 400 * dz, dy + 170 * dz]); - hawaii.translate([dx - 190 * dz, dy + 200 * dz]); - puertoRico.translate([dx + 580 * dz, dy + 430 * dz]); - return albersUsa; - }; - - return albersUsa.scale(lower48.scale()); -}; - -var d3_radians = Math.PI / 180; -d3.geo.mercator = function() { - var scale = 500, - translate = [480, 250]; - - function mercator(coordinates) { - var x = (coordinates[0]) / 360, - y = (-180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + coordinates[1] * Math.PI / 360))) / 360; - return [ - scale * x + translate[0], - scale * Math.max(-.5, Math.min(.5, y)) + translate[1] - ]; - } - - mercator.scale = function(x) { - if (!arguments.length) return scale; - scale = +x; - return mercator; - }; - - mercator.translate = function(x) { - if (!arguments.length) return translate; - translate = [+x[0], +x[1]]; - return mercator; - }; - - return mercator; -}; -/** - * Returns a function that, given a GeoJSON object (e.g., a feature), returns - * the corresponding SVG path. The function can be customized by overriding the - * projection. Point features are mapped to circles with a default radius of - * 4.5px; the radius can be specified either as a constant or a function that - * is evaluated per object. - */ -d3.geo.path = function() { - var pointRadius = 4.5, - pointCircle = d3_path_circle(pointRadius), - projection = d3.geo.albersUsa(); - - function path(d, i) { - if (typeof pointRadius === "function") { - pointCircle = d3_path_circle(pointRadius.apply(this, arguments)); - } - return d3_geo_pathType(pathTypes, d); - } - - function project(coordinates) { - return projection(coordinates).join(","); - } - - var pathTypes = { - - FeatureCollection: function(f) { - var path = [], - features = f.features, - i = -1, // features.index - n = features.length; - while (++i < n) path.push(d3_geo_pathType(pathTypes, features[i].geometry)); - return path.join(""); - }, - - Feature: function(f) { - return d3_geo_pathType(pathTypes, f.geometry); - }, - - Point: function(o) { - return "M" + project(o.coordinates) + pointCircle; - }, - - MultiPoint: function(o) { - var path = [], - coordinates = o.coordinates, - i = -1, // coordinates.index - n = coordinates.length; - while (++i < n) path.push("M", project(coordinates[i]), pointCircle); - return path.join(""); - }, - - LineString: function(o) { - var path = ["M"], - coordinates = o.coordinates, - i = -1, // coordinates.index - n = coordinates.length; - while (++i < n) path.push(project(coordinates[i]), "L"); - path.pop(); - return path.join(""); - }, - - MultiLineString: function(o) { - var path = [], - coordinates = o.coordinates, - i = -1, // coordinates.index - n = coordinates.length, - subcoordinates, // coordinates[i] - j, // subcoordinates.index - m; // subcoordinates.length - while (++i < n) { - subcoordinates = coordinates[i]; - j = -1; - m = subcoordinates.length; - path.push("M"); - while (++j < m) path.push(project(subcoordinates[j]), "L"); - path.pop(); - } - return path.join(""); - }, - - Polygon: function(o) { - var path = [], - coordinates = o.coordinates, - i = -1, // coordinates.index - n = coordinates.length, - subcoordinates, // coordinates[i] - j, // subcoordinates.index - m; // subcoordinates.length - while (++i < n) { - subcoordinates = coordinates[i]; - j = -1; - m = subcoordinates.length; - path.push("M"); - while (++j < m) path.push(project(subcoordinates[j]), "L"); - path[path.length - 1] = "Z"; - } - return path.join(""); - }, - - MultiPolygon: function(o) { - var path = [], - coordinates = o.coordinates, - i = -1, // coordinates index - n = coordinates.length, - subcoordinates, // coordinates[i] - j, // subcoordinates index - m, // subcoordinates.length - subsubcoordinates, // subcoordinates[j] - k, // subsubcoordinates index - p; // subsubcoordinates.length - while (++i < n) { - subcoordinates = coordinates[i]; - j = -1; - m = subcoordinates.length; - while (++j < m) { - subsubcoordinates = subcoordinates[j]; - k = -1; - p = subsubcoordinates.length - 1; - path.push("M"); - while (++k < p) path.push(project(subsubcoordinates[k]), "L"); - path[path.length - 1] = "Z"; - } - } - return path.join(""); - }, - - GeometryCollection: function(o) { - var path = [], - geometries = o.geometries, - i = -1, // geometries index - n = geometries.length; - while (++i < n) path.push(d3_geo_pathType(pathTypes, geometries[i])); - return path.join(""); - } - - }; - - var areaTypes = { - - FeatureCollection: function(f) { - var area = 0, - features = f.features, - i = -1, // features.index - n = features.length; - while (++i < n) area += d3_geo_pathType(areaTypes, features[i]); - return area; - }, - - Feature: function(f) { - return d3_geo_pathType(areaTypes, f.geometry); - }, - - Point: d3_geo_pathZero, - MultiPoint: d3_geo_pathZero, - LineString: d3_geo_pathZero, - MultiLineString: d3_geo_pathZero, - - Polygon: function(o) { - return polygonArea(o.coordinates); - }, - - MultiPolygon: function(o) { - var sum = 0, - coordinates = o.coordinates, - i = -1, // coordinates index - n = coordinates.length; - while (++i < n) sum += polygonArea(coordinates[i]); - return sum; - }, - - GeometryCollection: function(o) { - var sum = 0, - geometries = o.geometries, - i = -1, // geometries index - n = geometries.length; - while (++i < n) sum += d3_geo_pathType(areaTypes, geometries[i]); - return sum; - } - - }; - - function polygonArea(coordinates) { - var sum = area(coordinates[0]), // exterior ring - i = 0, // coordinates.index - n = coordinates.length; - while (++i < n) sum -= area(coordinates[i]); // holes - return sum; - } - - function polygonCentroid(coordinates) { - var polygon = d3.geom.polygon(coordinates[0].map(projection)), // exterior ring - centroid = polygon.centroid(1), - x = centroid[0], - y = centroid[1], - z = Math.abs(polygon.area()), - i = 0, // coordinates index - n = coordinates.length; - while (++i < n) { - polygon = d3.geom.polygon(coordinates[i].map(projection)); // holes - centroid = polygon.centroid(1); - x -= centroid[0]; - y -= centroid[1]; - z -= Math.abs(polygon.area()); - } - return [x, y, 6 * z]; // weighted centroid - } - - var centroidTypes = { - - // TODO FeatureCollection - // TODO Point - // TODO MultiPoint - // TODO LineString - // TODO MultiLineString - // TODO GeometryCollection - - Feature: function(f) { - return d3_geo_pathType(centroidTypes, f.geometry); - }, - - Polygon: function(o) { - var centroid = polygonCentroid(o.coordinates); - return [centroid[0] / centroid[2], centroid[1] / centroid[2]]; - }, - - MultiPolygon: function(o) { - var area = 0, - coordinates = o.coordinates, - centroid, - x = 0, - y = 0, - z = 0, - i = -1, // coordinates index - n = coordinates.length; - while (++i < n) { - centroid = polygonCentroid(coordinates[i]); - x += centroid[0]; - y += centroid[1]; - z += centroid[2]; - } - return [x / z, y / z]; - } - - }; - - - function area(coordinates) { - return Math.abs(d3.geom.polygon(coordinates.map(projection)).area()); - } - - path.projection = function(x) { - projection = x; - return path; - }; - - path.area = function(d) { - return d3_geo_pathType(areaTypes, d); - }; - - path.centroid = function(d) { - return d3_geo_pathType(centroidTypes, d); - }; - - path.pointRadius = function(x) { - if (typeof x === "function") pointRadius = x; - else { - pointRadius = +x; - pointCircle = d3_path_circle(pointRadius); - } - return path; - }; - - return path; -}; - -function d3_path_circle(radius) { - return "m0," + radius - + "a" + radius + "," + radius + " 0 1,1 0," + (-2 * radius) - + "a" + radius + "," + radius + " 0 1,1 0," + (+2 * radius) - + "z"; -} - -function d3_geo_pathZero() { - return 0; -} - -function d3_geo_pathType(types, o) { - return o && o.type in types ? types[o.type](o) : ""; -} -/** - * Given a GeoJSON object, returns the corresponding bounding box. The bounding - * box is represented by a two-dimensional array: [[left, bottom], [right, - * top]], where left is the minimum longitude, bottom is the minimum latitude, - * right is maximum longitude, and top is the maximum latitude. - */ -d3.geo.bounds = function(feature) { - var left = Infinity, - bottom = Infinity, - right = -Infinity, - top = -Infinity; - d3_geo_bounds(feature, function(x, y) { - if (x < left) left = x; - if (x > right) right = x; - if (y < bottom) bottom = y; - if (y > top) top = y; - }); - return [[left, bottom], [right, top]]; -}; - -function d3_geo_bounds(o, f) { - if (o.type in d3_geo_boundsTypes) d3_geo_boundsTypes[o.type](o, f); -} - -var d3_geo_boundsTypes = { - Feature: d3_geo_boundsFeature, - FeatureCollection: d3_geo_boundsFeatureCollection, - LineString: d3_geo_boundsLineString, - MultiLineString: d3_geo_boundsMultiLineString, - MultiPoint: d3_geo_boundsLineString, - MultiPolygon: d3_geo_boundsMultiPolygon, - Point: d3_geo_boundsPoint, - Polygon: d3_geo_boundsPolygon -}; - -function d3_geo_boundsFeature(o, f) { - d3_geo_bounds(o.geometry, f); -} - -function d3_geo_boundsFeatureCollection(o, f) { - for (var a = o.features, i = 0, n = a.length; i < n; i++) { - d3_geo_bounds(a[i].geometry, f); - } -} - -function d3_geo_boundsLineString(o, f) { - for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { - f.apply(null, a[i]); - } -} - -function d3_geo_boundsMultiLineString(o, f) { - for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { - for (var b = a[i], j = 0, m = b.length; j < m; j++) { - f.apply(null, b[j]); - } - } -} - -function d3_geo_boundsMultiPolygon(o, f) { - for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { - for (var b = a[i][0], j = 0, m = b.length; j < m; j++) { - f.apply(null, b[j]); - } - } -} - -function d3_geo_boundsPoint(o, f) { - f.apply(null, o.coordinates); -} - -function d3_geo_boundsPolygon(o, f) { - for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) { - f.apply(null, a[i]); - } -} -})(); diff --git a/client/js/d3/d3.geom.js b/client/js/d3/d3.geom.js deleted file mode 100755 index 9d8bc31a..00000000 --- a/client/js/d3/d3.geom.js +++ /dev/null @@ -1,825 +0,0 @@ -(function(){d3.geom = {}; -/** - * Computes a contour for a given input grid function using the marching - * squares algorithm. Returns the contour polygon as an array of points. - * - * @param grid a two-input function(x, y) that returns true for values - * inside the contour and false for values outside the contour. - * @param start an optional starting point [x, y] on the grid. - * @returns polygon [[x1, y1], [x2, y2], …] - */ -d3.geom.contour = function(grid, start) { - var s = start || d3_geom_contourStart(grid), // starting point - c = [], // contour polygon - x = s[0], // current x position - y = s[1], // current y position - dx = 0, // next x direction - dy = 0, // next y direction - pdx = NaN, // previous x direction - pdy = NaN, // previous y direction - i = 0; - - do { - // determine marching squares index - i = 0; - if (grid(x-1, y-1)) i += 1; - if (grid(x, y-1)) i += 2; - if (grid(x-1, y )) i += 4; - if (grid(x, y )) i += 8; - - // determine next direction - if (i === 6) { - dx = pdy === -1 ? -1 : 1; - dy = 0; - } else if (i === 9) { - dx = 0; - dy = pdx === 1 ? -1 : 1; - } else { - dx = d3_geom_contourDx[i]; - dy = d3_geom_contourDy[i]; - } - - // update contour polygon - if (dx != pdx && dy != pdy) { - c.push([x, y]); - pdx = dx; - pdy = dy; - } - - x += dx; - y += dy; - } while (s[0] != x || s[1] != y); - - return c; -}; - -// lookup tables for marching directions -var d3_geom_contourDx = [1, 0, 1, 1,-1, 0,-1, 1,0, 0,0,0,-1, 0,-1,NaN], - d3_geom_contourDy = [0,-1, 0, 0, 0,-1, 0, 0,1,-1,1,1, 0,-1, 0,NaN]; - -function d3_geom_contourStart(grid) { - var x = 0, - y = 0; - - // search for a starting point; begin at origin - // and proceed along outward-expanding diagonals - while (true) { - if (grid(x,y)) { - return [x,y]; - } - if (x === 0) { - x = y + 1; - y = 0; - } else { - x = x - 1; - y = y + 1; - } - } -} -/** - * Computes the 2D convex hull of a set of points using Graham's scanning - * algorithm. The algorithm has been implemented as described in Cormen, - * Leiserson, and Rivest's Introduction to Algorithms. The running time of - * this algorithm is O(n log n), where n is the number of input points. - * - * @param vertices [[x1, y1], [x2, y2], …] - * @returns polygon [[x1, y1], [x2, y2], …] - */ -d3.geom.hull = function(vertices) { - if (vertices.length < 3) return []; - - var len = vertices.length, - plen = len - 1, - points = [], - stack = [], - i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; - - // find the starting ref point: leftmost point with the minimum y coord - for (i=1; i= (x2*x2 + y2*y2)) { - points[i].index = -1; - } else { - points[u].index = -1; - a = points[i].angle; - u = i; - v = j; - } - } else { - a = points[i].angle; - u = i; - v = j; - } - } - - // initialize the stack - stack.push(h); - for (i=0, j=0; i<2; ++j) { - if (points[j].index !== -1) { - stack.push(points[j].index); - i++; - } - } - sp = stack.length; - - // do graham's scan - for (; j 0; -} -// Note: requires coordinates to be counterclockwise and convex! -d3.geom.polygon = function(coordinates) { - - coordinates.area = function() { - var i = 0, - n = coordinates.length, - a = coordinates[n - 1][0] * coordinates[0][1], - b = coordinates[n - 1][1] * coordinates[0][0]; - while (++i < n) { - a += coordinates[i - 1][0] * coordinates[i][1]; - b += coordinates[i - 1][1] * coordinates[i][0]; - } - return (b - a) * .5; - }; - - coordinates.centroid = function(k) { - var i = -1, - n = coordinates.length - 1, - x = 0, - y = 0, - a, - b, - c; - if (!arguments.length) k = 1 / (6 * coordinates.area()); - while (++i < n) { - a = coordinates[i]; - b = coordinates[i + 1]; - c = a[0] * b[1] - b[0] * a[1]; - x += (a[0] + b[0]) * c; - y += (a[1] + b[1]) * c; - } - return [x * k, y * k]; - }; - - // The Sutherland-Hodgman clipping algorithm. - coordinates.clip = function(subject) { - var input, - i = -1, - n = coordinates.length, - j, - m, - a = coordinates[n - 1], - b, - c, - d; - while (++i < n) { - input = subject.slice(); - subject.length = 0; - b = coordinates[i]; - c = input[(m = input.length) - 1]; - j = -1; - while (++j < m) { - d = input[j]; - if (d3_geom_polygonInside(d, a, b)) { - if (!d3_geom_polygonInside(c, a, b)) { - subject.push(d3_geom_polygonIntersect(c, d, a, b)); - } - subject.push(d); - } else if (d3_geom_polygonInside(c, a, b)) { - subject.push(d3_geom_polygonIntersect(c, d, a, b)); - } - c = d; - } - a = b; - } - return subject; - }; - - return coordinates; -}; - -function d3_geom_polygonInside(p, a, b) { - return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); -} - -// Intersect two infinite lines cd and ab. -function d3_geom_polygonIntersect(c, d, a, b) { - var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0], - y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1], - x13 = x1 - x3, - x21 = x2 - x1, - x43 = x4 - x3, - y13 = y1 - y3, - y21 = y2 - y1, - y43 = y4 - y3, - ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21); - return [x1 + ua * x21, y1 + ua * y21]; -} -// Adapted from Nicolas Garcia Belmonte's JIT implementation: -// http://blog.thejit.org/2010/02/12/voronoi-tessellation/ -// http://blog.thejit.org/assets/voronoijs/voronoi.js -// See lib/jit/LICENSE for details. - -/** - * @param vertices [[x1, y1], [x2, y2], …] - * @returns polygons [[[x1, y1], [x2, y2], …], …] - */ -d3.geom.voronoi = function(vertices) { - var polygons = vertices.map(function() { return []; }); - - // Note: we expect the caller to clip the polygons, if needed. - d3_voronoi_tessellate(vertices, function(e) { - var s1, - s2, - x1, - x2, - y1, - y2; - if (e.a === 1 && e.b >= 0) { - s1 = e.ep.r; - s2 = e.ep.l; - } else { - s1 = e.ep.l; - s2 = e.ep.r; - } - if (e.a === 1) { - y1 = s1 ? s1.y : -1e6; - x1 = e.c - e.b * y1; - y2 = s2 ? s2.y : 1e6; - x2 = e.c - e.b * y2; - } else { - x1 = s1 ? s1.x : -1e6; - y1 = e.c - e.a * x1; - x2 = s2 ? s2.x : 1e6; - y2 = e.c - e.a * x2; - } - var v1 = [x1, y1], - v2 = [x2, y2]; - polygons[e.region.l.index].push(v1, v2); - polygons[e.region.r.index].push(v1, v2); - }); - - // Reconnect the polygon segments into counterclockwise loops. - return polygons.map(function(polygon, i) { - var cx = vertices[i][0], - cy = vertices[i][1]; - polygon.forEach(function(v) { - v.angle = Math.atan2(v[0] - cx, v[1] - cy); - }); - return polygon.sort(function(a, b) { - return a.angle - b.angle; - }).filter(function(d, i) { - return !i || (d.angle - polygon[i - 1].angle > 1e-10); - }); - }); -}; - -var d3_voronoi_opposite = {"l": "r", "r": "l"}; - -function d3_voronoi_tessellate(vertices, callback) { - - var Sites = { - list: vertices - .map(function(v, i) { - return { - index: i, - x: v[0], - y: v[1] - }; - }) - .sort(function(a, b) { - return a.y < b.y ? -1 - : a.y > b.y ? 1 - : a.x < b.x ? -1 - : a.x > b.x ? 1 - : 0; - }), - bottomSite: null - }; - - var EdgeList = { - list: [], - leftEnd: null, - rightEnd: null, - - init: function() { - EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l"); - EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l"); - EdgeList.leftEnd.r = EdgeList.rightEnd; - EdgeList.rightEnd.l = EdgeList.leftEnd; - EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd); - }, - - createHalfEdge: function(edge, side) { - return { - edge: edge, - side: side, - vertex: null, - "l": null, - "r": null - }; - }, - - insert: function(lb, he) { - he.l = lb; - he.r = lb.r; - lb.r.l = he; - lb.r = he; - }, - - leftBound: function(p) { - var he = EdgeList.leftEnd; - do { - he = he.r; - } while (he != EdgeList.rightEnd && Geom.rightOf(he, p)); - he = he.l; - return he; - }, - - del: function(he) { - he.l.r = he.r; - he.r.l = he.l; - he.edge = null; - }, - - right: function(he) { - return he.r; - }, - - left: function(he) { - return he.l; - }, - - leftRegion: function(he) { - return he.edge == null - ? Sites.bottomSite - : he.edge.region[he.side]; - }, - - rightRegion: function(he) { - return he.edge == null - ? Sites.bottomSite - : he.edge.region[d3_voronoi_opposite[he.side]]; - } - }; - - var Geom = { - - bisect: function(s1, s2) { - var newEdge = { - region: {"l": s1, "r": s2}, - ep: {"l": null, "r": null} - }; - - var dx = s2.x - s1.x, - dy = s2.y - s1.y, - adx = dx > 0 ? dx : -dx, - ady = dy > 0 ? dy : -dy; - - newEdge.c = s1.x * dx + s1.y * dy - + (dx * dx + dy * dy) * .5; - - if (adx > ady) { - newEdge.a = 1; - newEdge.b = dy / dx; - newEdge.c /= dx; - } else { - newEdge.b = 1; - newEdge.a = dx / dy; - newEdge.c /= dy; - } - - return newEdge; - }, - - intersect: function(el1, el2) { - var e1 = el1.edge, - e2 = el2.edge; - if (!e1 || !e2 || (e1.region.r == e2.region.r)) { - return null; - } - var d = (e1.a * e2.b) - (e1.b * e2.a); - if (Math.abs(d) < 1e-10) { - return null; - } - var xint = (e1.c * e2.b - e2.c * e1.b) / d, - yint = (e2.c * e1.a - e1.c * e2.a) / d, - e1r = e1.region.r, - e2r = e2.region.r, - el, - e; - if ((e1r.y < e2r.y) || - (e1r.y == e2r.y && e1r.x < e2r.x)) { - el = el1; - e = e1; - } else { - el = el2; - e = e2; - } - var rightOfSite = (xint >= e.region.r.x); - if ((rightOfSite && (el.side === "l")) || - (!rightOfSite && (el.side === "r"))) { - return null; - } - return { - x: xint, - y: yint - }; - }, - - rightOf: function(he, p) { - var e = he.edge, - topsite = e.region.r, - rightOfSite = (p.x > topsite.x); - - if (rightOfSite && (he.side === "l")) { - return 1; - } - if (!rightOfSite && (he.side === "r")) { - return 0; - } - if (e.a === 1) { - var dyp = p.y - topsite.y, - dxp = p.x - topsite.x, - fast = 0, - above = 0; - - if ((!rightOfSite && (e.b < 0)) || - (rightOfSite && (e.b >= 0))) { - above = fast = (dyp >= e.b * dxp); - } else { - above = ((p.x + p.y * e.b) > e.c); - if (e.b < 0) { - above = !above; - } - if (!above) { - fast = 1; - } - } - if (!fast) { - var dxs = topsite.x - e.region.l.x; - above = (e.b * (dxp * dxp - dyp * dyp)) < - (dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b)); - - if (e.b < 0) { - above = !above; - } - } - } else /* e.b == 1 */ { - var yl = e.c - e.a * p.x, - t1 = p.y - yl, - t2 = p.x - topsite.x, - t3 = yl - topsite.y; - - above = (t1 * t1) > (t2 * t2 + t3 * t3); - } - return he.side === "l" ? above : !above; - }, - - endPoint: function(edge, side, site) { - edge.ep[side] = site; - if (!edge.ep[d3_voronoi_opposite[side]]) return; - callback(edge); - }, - - distance: function(s, t) { - var dx = s.x - t.x, - dy = s.y - t.y; - return Math.sqrt(dx * dx + dy * dy); - } - }; - - var EventQueue = { - list: [], - - insert: function(he, site, offset) { - he.vertex = site; - he.ystar = site.y + offset; - for (var i=0, list=EventQueue.list, l=list.length; i next.ystar || - (he.ystar == next.ystar && - site.x > next.vertex.x)) { - continue; - } else { - break; - } - } - list.splice(i, 0, he); - }, - - del: function(he) { - for (var i=0, ls=EventQueue.list, l=ls.length; i top.y) { - temp = bot; - bot = top; - top = temp; - pm = "r"; - } - e = Geom.bisect(bot, top); - bisector = EdgeList.createHalfEdge(e, pm); - EdgeList.insert(llbnd, bisector); - Geom.endPoint(e, d3_voronoi_opposite[pm], v); - p = Geom.intersect(llbnd, bisector); - if (p) { - EventQueue.del(llbnd); - EventQueue.insert(llbnd, p, Geom.distance(p, bot)); - } - p = Geom.intersect(bisector, rrbnd); - if (p) { - EventQueue.insert(bisector, p, Geom.distance(p, bot)); - } - } else { - break; - } - }//end while - - for (lbnd = EdgeList.right(EdgeList.leftEnd); - lbnd != EdgeList.rightEnd; - lbnd = EdgeList.right(lbnd)) { - callback(lbnd.edge); - } -} -/** -* @param vertices [[x1, y1], [x2, y2], …] -* @returns triangles [[[x1, y1], [x2, y2], [x3, y3]], …] - */ -d3.geom.delaunay = function(vertices) { - var edges = vertices.map(function() { return []; }), - triangles = []; - - // Use the Voronoi tessellation to determine Delaunay edges. - d3_voronoi_tessellate(vertices, function(e) { - edges[e.region.l.index].push(vertices[e.region.r.index]); - }); - - // Reconnect the edges into counterclockwise triangles. - edges.forEach(function(edge, i) { - var v = vertices[i], - cx = v[0], - cy = v[1]; - edge.forEach(function(v) { - v.angle = Math.atan2(v[0] - cx, v[1] - cy); - }); - edge.sort(function(a, b) { - return a.angle - b.angle; - }); - for (var j = 0, m = edge.length - 1; j < m; j++) { - triangles.push([v, edge[j], edge[j + 1]]); - } - }); - - return triangles; -}; -// Constructs a new quadtree for the specified array of points. A quadtree is a -// two-dimensional recursive spatial subdivision. This implementation uses -// square partitions, dividing each square into four equally-sized squares. Each -// point exists in a unique node; if multiple points are in the same position, -// some points may be stored on internal nodes rather than leaf nodes. Quadtrees -// can be used to accelerate various spatial operations, such as the Barnes-Hut -// approximation for computing n-body forces, or collision detection. -d3.geom.quadtree = function(points, x1, y1, x2, y2) { - var p, - i = -1, - n = points.length; - - // Type conversion for deprecated API. - if (n && isNaN(points[0].x)) points = points.map(d3_geom_quadtreePoint); - - // Allow bounds to be specified explicitly. - if (arguments.length < 5) { - if (arguments.length === 3) { - y2 = x2 = y1; - y1 = x1; - } else { - x1 = y1 = Infinity; - x2 = y2 = -Infinity; - - // Compute bounds. - while (++i < n) { - p = points[i]; - if (p.x < x1) x1 = p.x; - if (p.y < y1) y1 = p.y; - if (p.x > x2) x2 = p.x; - if (p.y > y2) y2 = p.y; - } - - // Squarify the bounds. - var dx = x2 - x1, - dy = y2 - y1; - if (dx > dy) y2 = y1 + dx; - else x2 = x1 + dy; - } - } - - // Recursively inserts the specified point p at the node n or one of its - // descendants. The bounds are defined by [x1, x2] and [y1, y2]. - function insert(n, p, x1, y1, x2, y2) { - if (isNaN(p.x) || isNaN(p.y)) return; // ignore invalid points - if (n.leaf) { - var v = n.point; - if (v) { - // If the point at this leaf node is at the same position as the new - // point we are adding, we leave the point associated with the - // internal node while adding the new point to a child node. This - // avoids infinite recursion. - if ((Math.abs(v.x - p.x) + Math.abs(v.y - p.y)) < .01) { - insertChild(n, p, x1, y1, x2, y2); - } else { - n.point = null; - insertChild(n, v, x1, y1, x2, y2); - insertChild(n, p, x1, y1, x2, y2); - } - } else { - n.point = p; - } - } else { - insertChild(n, p, x1, y1, x2, y2); - } - } - - // Recursively inserts the specified point p into a descendant of node n. The - // bounds are defined by [x1, x2] and [y1, y2]. - function insertChild(n, p, x1, y1, x2, y2) { - // Compute the split point, and the quadrant in which to insert p. - var sx = (x1 + x2) * .5, - sy = (y1 + y2) * .5, - right = p.x >= sx, - bottom = p.y >= sy, - i = (bottom << 1) + right; - - // Recursively insert into the child node. - n.leaf = false; - n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); - - // Update the bounds as we recurse. - if (right) x1 = sx; else x2 = sx; - if (bottom) y1 = sy; else y2 = sy; - insert(n, p, x1, y1, x2, y2); - } - - // Create the root node. - var root = d3_geom_quadtreeNode(); - - root.add = function(p) { - insert(root, p, x1, y1, x2, y2); - }; - - root.visit = function(f) { - d3_geom_quadtreeVisit(f, root, x1, y1, x2, y2); - }; - - // Insert all points. - points.forEach(root.add); - return root; -}; - -function d3_geom_quadtreeNode() { - return { - leaf: true, - nodes: [], - point: null - }; -} - -function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { - if (!f(node, x1, y1, x2, y2)) { - var sx = (x1 + x2) * .5, - sy = (y1 + y2) * .5, - children = node.nodes; - if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); - if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); - if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); - if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); - } -} - -function d3_geom_quadtreePoint(p) { - return { - x: p[0], - y: p[1] - }; -} -})(); diff --git a/client/js/d3/d3.js b/client/js/d3/d3.js deleted file mode 100755 index 1120591d..00000000 --- a/client/js/d3/d3.js +++ /dev/null @@ -1,3597 +0,0 @@ -(function(){d3 = {version: "1.29.4"}; // semver -if (!Date.now) Date.now = function() { - return +new Date; -}; -if (!Object.create) Object.create = function(o) { - /** @constructor */ function f() {} - f.prototype = o; - return new f; -}; -var d3_array = d3_arraySlice; // conversion for NodeLists - -function d3_arrayCopy(psuedoarray) { - var i = -1, n = psuedoarray.length, array = []; - while (++i < n) array.push(psuedoarray[i]); - return array; -} - -function d3_arraySlice(psuedoarray) { - return Array.prototype.slice.call(psuedoarray); -} - -try { - d3_array(document.documentElement.childNodes)[0].nodeType; -} catch(e) { - d3_array = d3_arrayCopy; -} -d3.functor = function(v) { - return typeof v === "function" ? v : function() { return v; }; -}; -// A getter-setter method that preserves the appropriate `this` context. -d3.rebind = function(object, method) { - return function() { - var x = method.apply(object, arguments); - return arguments.length ? object : x; - }; -}; -d3.ascending = function(a, b) { - return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; -}; -d3.descending = function(a, b) { - return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; -}; -d3.min = function(array, f) { - var i = -1, - n = array.length, - a, - b; - if (arguments.length === 1) { - while (++i < n && ((a = array[i]) == null || a != a)) a = undefined; - while (++i < n) if ((b = array[i]) != null && a > b) a = b; - } else { - while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined; - while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; - } - return a; -}; -d3.max = function(array, f) { - var i = -1, - n = array.length, - a, - b; - if (arguments.length === 1) { - while (++i < n && ((a = array[i]) == null || a != a)) a = undefined; - while (++i < n) if ((b = array[i]) != null && b > a) a = b; - } else { - while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined; - while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; - } - return a; -}; -d3.sum = function(array, f) { - var s = 0, - n = array.length, - a, - i = -1; - - if (arguments.length === 1) { - while (++i < n) if (!isNaN(a = +array[i])) s += a; - } else { - while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; - } - - return s; -}; -// R-7 per -d3.quantile = function(values, p) { - var H = (values.length - 1) * p + 1, - h = Math.floor(H), - v = values[h - 1], - e = H - h; - return e ? v + e * (values[h] - v) : v; -}; -d3.zip = function() { - if (!(n = arguments.length)) return []; - for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m;) { - for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n;) { - zip[j] = arguments[j][i]; - } - } - return zips; -}; - -function d3_zipLength(d) { - return d.length; -} -// Locate the insertion point for x in a to maintain sorted order. The -// arguments lo and hi may be used to specify a subset of the array which should -// be considered; by default the entire array is used. If x is already present -// in a, the insertion point will be before (to the left of) any existing -// entries. The return value is suitable for use as the first argument to -// `array.splice` assuming that a is already sorted. -// -// The returned insertion point i partitions the array a into two halves so that -// all v < x for v in a[lo:i] for the left side and all v >= x for v in a[i:hi] -// for the right side. -d3.bisectLeft = function(a, x, lo, hi) { - if (arguments.length < 3) lo = 0; - if (arguments.length < 4) hi = a.length; - while (lo < hi) { - var mid = (lo + hi) >> 1; - if (a[mid] < x) lo = mid + 1; - else hi = mid; - } - return lo; -}; - -// Similar to bisectLeft, but returns an insertion point which comes after (to -// the right of) any existing entries of x in a. -// -// The returned insertion point i partitions the array into two halves so that -// all v <= x for v in a[lo:i] for the left side and all v > x for v in a[i:hi] -// for the right side. -d3.bisect = -d3.bisectRight = function(a, x, lo, hi) { - if (arguments.length < 3) lo = 0; - if (arguments.length < 4) hi = a.length; - while (lo < hi) { - var mid = (lo + hi) >> 1; - if (x < a[mid]) hi = mid; - else lo = mid + 1; - } - return lo; -}; -d3.first = function(array, f) { - var i = 0, - n = array.length, - a = array[0], - b; - if (arguments.length === 1) f = d3.ascending; - while (++i < n) { - if (f.call(array, a, b = array[i]) > 0) { - a = b; - } - } - return a; -}; -d3.last = function(array, f) { - var i = 0, - n = array.length, - a = array[0], - b; - if (arguments.length === 1) f = d3.ascending; - while (++i < n) { - if (f.call(array, a, b = array[i]) <= 0) { - a = b; - } - } - return a; -}; -d3.nest = function() { - var nest = {}, - keys = [], - sortKeys = [], - sortValues, - rollup; - - function map(array, depth) { - if (depth >= keys.length) return rollup - ? rollup.call(nest, array) : (sortValues - ? array.sort(sortValues) - : array); - - var i = -1, - n = array.length, - key = keys[depth++], - keyValue, - object, - o = {}; - - while (++i < n) { - if ((keyValue = key(object = array[i])) in o) { - o[keyValue].push(object); - } else { - o[keyValue] = [object]; - } - } - - for (keyValue in o) { - o[keyValue] = map(o[keyValue], depth); - } - - return o; - } - - function entries(map, depth) { - if (depth >= keys.length) return map; - - var a = [], - sortKey = sortKeys[depth++], - key; - - for (key in map) { - a.push({key: key, values: entries(map[key], depth)}); - } - - if (sortKey) a.sort(function(a, b) { - return sortKey(a.key, b.key); - }); - - return a; - } - - nest.map = function(array) { - return map(array, 0); - }; - - nest.entries = function(array) { - return entries(map(array, 0), 0); - }; - - nest.key = function(d) { - keys.push(d); - return nest; - }; - - // Specifies the order for the most-recently specified key. - // Note: only applies to entries. Map keys are unordered! - nest.sortKeys = function(order) { - sortKeys[keys.length - 1] = order; - return nest; - }; - - // Specifies the order for leaf values. - // Applies to both maps and entries array. - nest.sortValues = function(order) { - sortValues = order; - return nest; - }; - - nest.rollup = function(f) { - rollup = f; - return nest; - }; - - return nest; -}; -d3.keys = function(map) { - var keys = []; - for (var key in map) keys.push(key); - return keys; -}; -d3.values = function(map) { - var values = []; - for (var key in map) values.push(map[key]); - return values; -}; -d3.entries = function(map) { - var entries = []; - for (var key in map) entries.push({key: key, value: map[key]}); - return entries; -}; -d3.permute = function(array, indexes) { - var permutes = [], - i = -1, - n = indexes.length; - while (++i < n) permutes[i] = array[indexes[i]]; - return permutes; -}; -d3.merge = function(arrays) { - return Array.prototype.concat.apply([], arrays); -}; -d3.split = function(array, f) { - var arrays = [], - values = [], - value, - i = -1, - n = array.length; - if (arguments.length < 2) f = d3_splitter; - while (++i < n) { - if (f.call(values, value = array[i], i)) { - values = []; - } else { - if (!values.length) arrays.push(values); - values.push(value); - } - } - return arrays; -}; - -function d3_splitter(d) { - return d == null; -} -function d3_collapse(s) { - return s.replace(/(^\s+)|(\s+$)/g, "").replace(/\s+/g, " "); -} -// -// Note: assigning to the arguments array simultaneously changes the value of -// the corresponding argument! -// -// TODO The `this` argument probably shouldn't be the first argument to the -// callback, anyway, since it's redundant. However, that will require a major -// version bump due to backwards compatibility, so I'm not changing it right -// away. -// -function d3_call(callback) { - callback.apply(this, (arguments[0] = this, arguments)); - return this; -} -/** - * @param {number} start - * @param {number=} stop - * @param {number=} step - */ -d3.range = function(start, stop, step) { - if (arguments.length < 3) { - step = 1; - if (arguments.length < 2) { - stop = start; - start = 0; - } - } - if ((stop - start) / step == Infinity) throw new Error("infinite range"); - var range = [], - i = -1, - j; - if (step < 0) while ((j = start + step * ++i) > stop) range.push(j); - else while ((j = start + step * ++i) < stop) range.push(j); - return range; -}; -d3.requote = function(s) { - return s.replace(d3_requote_re, "\\$&"); -}; - -var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; -d3.round = function(x, n) { - return n - ? Math.round(x * Math.pow(10, n)) * Math.pow(10, -n) - : Math.round(x); -}; -d3.xhr = function(url, mime, callback) { - var req = new XMLHttpRequest; - if (arguments.length < 3) callback = mime; - else if (mime && req.overrideMimeType) req.overrideMimeType(mime); - req.open("GET", url, true); - req.onreadystatechange = function() { - if (req.readyState === 4) callback(req.status < 300 ? req : null); - }; - req.send(null); -}; -d3.text = function(url, mime, callback) { - function ready(req) { - callback(req && req.responseText); - } - if (arguments.length < 3) { - callback = mime; - mime = null; - } - d3.xhr(url, mime, ready); -}; -d3.json = function(url, callback) { - d3.text(url, "application/json", function(text) { - callback(text ? JSON.parse(text) : null); - }); -}; -d3.html = function(url, callback) { - d3.text(url, "text/html", function(text) { - if (text != null) { // Treat empty string as valid HTML. - var range = document.createRange(); - range.selectNode(document.body); - text = range.createContextualFragment(text); - } - callback(text); - }); -}; -d3.xml = function(url, mime, callback) { - function ready(req) { - callback(req && req.responseXML); - } - if (arguments.length < 3) { - callback = mime; - mime = null; - } - d3.xhr(url, mime, ready); -}; -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(name) { - var i = name.indexOf(":"); - return i < 0 ? name : { - space: d3.ns.prefix[name.substring(0, i)], - local: name.substring(i + 1) - }; - } - -}; -/** @param {...string} types */ -d3.dispatch = function(types) { - var dispatch = {}, - type; - for (var i = 0, n = arguments.length; i < n; i++) { - type = arguments[i]; - dispatch[type] = d3_dispatch(type); - } - return dispatch; -}; - -function d3_dispatch(type) { - var dispatch = {}, - listeners = []; - - dispatch.add = function(listener) { - for (var i = 0; i < listeners.length; i++) { - if (listeners[i].listener == listener) return dispatch; // already registered - } - listeners.push({listener: listener, on: true}); - return dispatch; - }; - - dispatch.remove = function(listener) { - for (var i = 0; i < listeners.length; i++) { - var l = listeners[i]; - if (l.listener == listener) { - l.on = false; - listeners = listeners.slice(0, i).concat(listeners.slice(i + 1)); - break; - } - } - return dispatch; - }; - - dispatch.dispatch = function() { - var ls = listeners; // defensive reference - for (var i = 0, n = ls.length; i < n; i++) { - var l = ls[i]; - if (l.on) l.listener.apply(this, arguments); - } - }; - - return dispatch; -}; -// TODO align -d3.format = function(specifier) { - var match = d3_format_re.exec(specifier), - fill = match[1] || " ", - sign = match[3] || "", - zfill = match[5], - width = +match[6], - comma = match[7], - precision = match[8], - type = match[9], - percentage = false, - integer = false; - - if (precision) precision = precision.substring(1); - - if (zfill) { - fill = "0"; // TODO align = "="; - if (comma) width -= Math.floor((width - 1) / 4); - } - - switch (type) { - case "n": comma = true; type = "g"; break; - case "%": percentage = true; type = "f"; break; - case "p": percentage = true; type = "r"; break; - case "d": integer = true; precision = "0"; break; - } - - type = d3_format_types[type] || d3_format_typeDefault; - - return function(value) { - var number = percentage ? value * 100 : +value, - negative = (number < 0) && (number = -number) ? "\u2212" : sign; - - // Return the empty string for floats formatted as ints. - if (integer && (number % 1)) return ""; - - // Convert the input value to the desired precision. - value = type(number, precision); - - // If the fill character is 0, the sign and group is applied after the fill. - if (zfill) { - var length = value.length + negative.length; - if (length < width) value = new Array(width - length + 1).join(fill) + value; - if (comma) value = d3_format_group(value); - value = negative + value; - } - - // Otherwise (e.g., space-filling), the sign and group is applied before. - else { - if (comma) value = d3_format_group(value); - value = negative + value; - var length = value.length; - if (length < width) value = new Array(width - length + 1).join(fill) + value; - } - if (percentage) value += "%"; - - return value; - }; -}; - -// [[fill]align][sign][#][0][width][,][.precision][type] -var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/; - -var d3_format_types = { - g: function(x, p) { return x.toPrecision(p); }, - e: function(x, p) { return x.toExponential(p); }, - f: function(x, p) { return x.toFixed(p); }, - r: function(x, p) { - var n = 1 + Math.floor(1e-15 + Math.log(x) / Math.LN10); - return d3.round(x, p - n).toFixed(Math.max(0, p - n)); - } -}; - -function d3_format_typeDefault(x) { - return x + ""; -} - -// Apply comma grouping for thousands. -function d3_format_group(value) { - var i = value.lastIndexOf("."), - f = i >= 0 ? value.substring(i) : (i = value.length, ""), - t = []; - while (i > 0) t.push(value.substring(i -= 3, i + 3)); - return t.reverse().join(",") + f; -} -/* - * TERMS OF USE - EASING EQUATIONS - * - * Open source under the BSD License. - * - * Copyright 2001 Robert Penner - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the author nor the names of contributors may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -var d3_ease_quad = d3_ease_poly(2), - d3_ease_cubic = d3_ease_poly(3); - -var d3_ease = { - linear: function() { return d3_ease_linear; }, - poly: d3_ease_poly, - quad: function() { return d3_ease_quad; }, - cubic: function() { return d3_ease_cubic; }, - sin: function() { return d3_ease_sin; }, - exp: function() { return d3_ease_exp; }, - circle: function() { return d3_ease_circle; }, - elastic: d3_ease_elastic, - back: d3_ease_back, - bounce: function() { return d3_ease_bounce; } -}; - -var d3_ease_mode = { - "in": function(f) { return f; }, - "out": d3_ease_reverse, - "in-out": d3_ease_reflect, - "out-in": function(f) { return d3_ease_reflect(d3_ease_reverse(f)); } -}; - -d3.ease = function(name) { - var i = name.indexOf("-"), - t = i >= 0 ? name.substring(0, i) : name, - m = i >= 0 ? name.substring(i + 1) : "in"; - return d3_ease_mode[m](d3_ease[t].apply(null, Array.prototype.slice.call(arguments, 1))); -}; - -function d3_ease_reverse(f) { - return function(t) { - return 1 - f(1 - t); - }; -} - -function d3_ease_reflect(f) { - return function(t) { - return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t))); - }; -} - -function d3_ease_linear(t) { - return t; -} - -function d3_ease_poly(e) { - return function(t) { - return Math.pow(t, e); - } -} - -function d3_ease_sin(t) { - return 1 - Math.cos(t * Math.PI / 2); -} - -function d3_ease_exp(t) { - return Math.pow(2, 10 * (t - 1)); -} - -function d3_ease_circle(t) { - return 1 - Math.sqrt(1 - t * t); -} - -function d3_ease_elastic(a, p) { - var s; - if (arguments.length < 2) p = 0.45; - if (arguments.length < 1) { a = 1; s = p / 4; } - else s = p / (2 * Math.PI) * Math.asin(1 / a); - return function(t) { - return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * Math.PI / p); - }; -} - -function d3_ease_back(s) { - if (!s) s = 1.70158; - return function(t) { - return t * t * ((s + 1) * t - s); - }; -} - -function d3_ease_bounce(t) { - return t < 1 / 2.75 ? 7.5625 * t * t - : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 - : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 - : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; -} -d3.event = null; -d3.interpolate = function(a, b) { - var i = d3.interpolators.length, f; - while (--i >= 0 && !(f = d3.interpolators[i](a, b))); - return f; -}; - -d3.interpolateNumber = function(a, b) { - b -= a; - return function(t) { return a + b * t; }; -}; - -d3.interpolateRound = function(a, b) { - b -= a; - return function(t) { return Math.round(a + b * t); }; -}; - -d3.interpolateString = function(a, b) { - var m, // current match - i, // current index - j, // current index (for coallescing) - s0 = 0, // start index of current string prefix - s1 = 0, // end index of current string prefix - s = [], // string constants and placeholders - q = [], // number interpolators - n, // q.length - o; - - // Reset our regular expression! - d3_interpolate_number.lastIndex = 0; - - // Find all numbers in b. - for (i = 0; m = d3_interpolate_number.exec(b); ++i) { - if (m.index) s.push(b.substring(s0, s1 = m.index)); - q.push({i: s.length, x: m[0]}); - s.push(null); - s0 = d3_interpolate_number.lastIndex; - } - if (s0 < b.length) s.push(b.substring(s0)); - - // Find all numbers in a. - for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { - o = q[i]; - if (o.x == m[0]) { // The numbers match, so coallesce. - if (o.i) { - if (s[o.i + 1] == null) { // This match is followed by another number. - s[o.i - 1] += o.x; - s.splice(o.i, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } else { // This match is followed by a string, so coallesce twice. - s[o.i - 1] += o.x + s[o.i + 1]; - s.splice(o.i, 2); - for (j = i + 1; j < n; ++j) q[j].i -= 2; - } - } else { - if (s[o.i + 1] == null) { // This match is followed by another number. - s[o.i] = o.x; - } else { // This match is followed by a string, so coallesce twice. - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } - } - q.splice(i, 1); - n--; - i--; - } else { - o.x = d3.interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); - } - } - - // Remove any numbers in b not found in a. - while (i < n) { - o = q.pop(); - if (s[o.i + 1] == null) { // This match is followed by another number. - s[o.i] = o.x; - } else { // This match is followed by a string, so coallesce twice. - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - } - n--; - } - - // Special optimization for only a single match. - if (s.length === 1) { - return s[0] == null ? q[0].x : function() { return b; }; - } - - // Otherwise, interpolate each of the numbers and rejoin the string. - return function(t) { - for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); - return s.join(""); - }; -}; - -d3.interpolateRgb = function(a, b) { - a = d3.rgb(a); - b = d3.rgb(b); - var ar = a.r, - ag = a.g, - ab = a.b, - br = b.r - ar, - bg = b.g - ag, - bb = b.b - ab; - return function(t) { - return "rgb(" + Math.round(ar + br * t) - + "," + Math.round(ag + bg * t) - + "," + Math.round(ab + bb * t) - + ")"; - }; -}; - -// interpolates HSL space, but outputs RGB string (for compatibility) -d3.interpolateHsl = function(a, b) { - a = d3.hsl(a); - b = d3.hsl(b); - var h0 = a.h, - s0 = a.s, - l0 = a.l, - h1 = b.h - h0, - s1 = b.s - s0, - l1 = b.l - l0; - return function(t) { - return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t).toString(); - }; -}; - -d3.interpolateArray = function(a, b) { - var x = [], - c = [], - na = a.length, - nb = b.length, - n0 = Math.min(a.length, b.length), - i; - for (i = 0; i < n0; ++i) x.push(d3.interpolate(a[i], b[i])); - for (; i < na; ++i) c[i] = a[i]; - for (; i < nb; ++i) c[i] = b[i]; - return function(t) { - for (i = 0; i < n0; ++i) c[i] = x[i](t); - return c; - }; -}; - -d3.interpolateObject = function(a, b) { - var i = {}, - c = {}, - k; - for (k in a) { - if (k in b) { - i[k] = d3_interpolateByName(k)(a[k], b[k]); - } else { - c[k] = a[k]; - } - } - for (k in b) { - if (!(k in a)) { - c[k] = b[k]; - } - } - return function(t) { - for (k in i) c[k] = i[k](t); - return c; - }; -} - -var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g, - d3_interpolate_rgb = {background: 1, fill: 1, stroke: 1}; - -function d3_interpolateByName(n) { - return n in d3_interpolate_rgb || /\bcolor\b/.test(n) - ? d3.interpolateRgb - : d3.interpolate; -} - -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 (typeof b === "string" ? b in d3_rgb_names || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(String(a), b); }, - function(a, b) { return (typeof b === "number") && d3.interpolateNumber(+a, b); } -]; -function d3_uninterpolateNumber(a, b) { - b = 1 / (b - (a = +a)); - return function(x) { return (x - a) * b; }; -} - -function d3_uninterpolateClamp(a, b) { - b = 1 / (b - (a = +a)); - return function(x) { return Math.max(0, Math.min(1, (x - a) * b)); }; -} -d3.rgb = function(r, g, b) { - return arguments.length === 1 - ? d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) - : d3_rgb(~~r, ~~g, ~~b); -}; - -function d3_rgb(r, g, b) { - return new d3_Rgb(r, g, b); -} - -function d3_Rgb(r, g, b) { - this.r = r; - this.g = g; - this.b = b; -} - -d3_Rgb.prototype.brighter = function(k) { - k = Math.pow(0.7, arguments.length ? k : 1); - var r = this.r, - g = this.g, - b = this.b, - i = 30; - if (!r && !g && !b) return d3_rgb(i, i, i); - if (r && r < i) r = i; - if (g && g < i) g = i; - if (b && b < i) b = i; - return d3_rgb( - Math.min(255, Math.floor(r / k)), - Math.min(255, Math.floor(g / k)), - Math.min(255, Math.floor(b / k))); -}; - -d3_Rgb.prototype.darker = function(k) { - k = Math.pow(0.7, arguments.length ? k : 1); - return d3_rgb( - Math.max(0, Math.floor(k * this.r)), - Math.max(0, Math.floor(k * this.g)), - Math.max(0, Math.floor(k * this.b))); -}; - -d3_Rgb.prototype.hsl = function() { - return d3_rgb_hsl(this.r, this.g, this.b); -}; - -d3_Rgb.prototype.toString = function() { - return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); -}; - -function d3_rgb_hex(v) { - return v < 0x10 ? "0" + v.toString(16) : v.toString(16); -} - -function d3_rgb_parse(format, rgb, hsl) { - var r = 0, // red channel; int in [0, 255] - g = 0, // green channel; int in [0, 255] - b = 0, // blue channel; int in [0, 255] - m1, // CSS color specification match - m2, // CSS color specification type (e.g., rgb) - name; - - /* Handle hsl, rgb. */ - m1 = /([a-z]+)\((.*)\)/i.exec(format); - if (m1) { - m2 = m1[2].split(","); - switch (m1[1]) { - case "hsl": { - return hsl( - parseFloat(m2[0]), // degrees - parseFloat(m2[1]) / 100, // percentage - parseFloat(m2[2]) / 100 // percentage - ); - } - case "rgb": { - return rgb( - d3_rgb_parseNumber(m2[0]), - d3_rgb_parseNumber(m2[1]), - d3_rgb_parseNumber(m2[2]) - ); - } - } - } - - /* Named colors. */ - if (name = d3_rgb_names[format]) return rgb(name.r, name.g, name.b); - - /* Hexadecimal colors: #rgb and #rrggbb. */ - if (format != null && format.charAt(0) === "#") { - if (format.length === 4) { - r = format.charAt(1); r += r; - g = format.charAt(2); g += g; - b = format.charAt(3); b += b; - } else if (format.length === 7) { - r = format.substring(1, 3); - g = format.substring(3, 5); - b = format.substring(5, 7); - } - r = parseInt(r, 16); - g = parseInt(g, 16); - b = parseInt(b, 16); - } - - return rgb(r, g, b); -} - -function d3_rgb_hsl(r, g, b) { - var min = Math.min(r /= 255, g /= 255, b /= 255), - max = Math.max(r, g, b), - d = max - min, - h, - s, - l = (max + min) / 2; - if (d) { - s = l < .5 ? d / (max + min) : d / (2 - max - min); - if (r == max) h = (g - b) / d + (g < b ? 6 : 0); - else if (g == max) h = (b - r) / d + 2; - else h = (r - g) / d + 4; - h *= 60; - } else { - s = h = 0; - } - return d3_hsl(h, s, l); -} - -function d3_rgb_parseNumber(c) { // either integer or percentage - var f = parseFloat(c); - return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; -} - -var d3_rgb_names = { - 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 d3_rgb_name in d3_rgb_names) { - d3_rgb_names[d3_rgb_name] = d3_rgb_parse( - d3_rgb_names[d3_rgb_name], - d3_rgb, - d3_hsl_rgb); -} -d3.hsl = function(h, s, l) { - return arguments.length === 1 - ? d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) - : d3_hsl(+h, +s, +l); -}; - -function d3_hsl(h, s, l) { - return new d3_Hsl(h, s, l); -} - -function d3_Hsl(h, s, l) { - this.h = h; - this.s = s; - this.l = l; -} - -d3_Hsl.prototype.brighter = function(k) { - k = Math.pow(0.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, this.l / k); -}; - -d3_Hsl.prototype.darker = function(k) { - k = Math.pow(0.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, k * this.l); -}; - -d3_Hsl.prototype.rgb = function() { - return d3_hsl_rgb(this.h, this.s, this.l); -}; - -d3_Hsl.prototype.toString = function() { - return "hsl(" + this.h + "," + this.s * 100 + "%," + this.l * 100 + "%)"; -}; - -function d3_hsl_rgb(h, s, l) { - var m1, - m2; - - /* Some simple corrections for h, s and l. */ - h = h % 360; if (h < 0) h += 360; - s = s < 0 ? 0 : s > 1 ? 1 : s; - l = l < 0 ? 0 : l > 1 ? 1 : l; - - /* From FvD 13.37, CSS Color Module Level 3 */ - m2 = l <= .5 ? l * (1 + s) : l + s - l * s; - m1 = 2 * l - m2; - - function v(h) { - if (h > 360) h -= 360; - else if (h < 0) h += 360; - if (h < 60) return m1 + (m2 - m1) * h / 60; - if (h < 180) return m2; - if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; - return m1; - } - - function vv(h) { - return Math.round(v(h) * 255); - } - - return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); -} -var d3_select = function(s, n) { return n.querySelector(s); }, - d3_selectAll = function(s, n) { return d3_array(n.querySelectorAll(s)); }; - -// Use Sizzle, if available. -if (typeof Sizzle === "function") { - d3_select = function(s, n) { return Sizzle(s, n)[0]; }; - d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); }; -} - -var d3_root = d3_selection([[document]]); -d3_root[0].parentNode = document.documentElement; - -// TODO fast singleton implementation! -d3.select = function(selector) { - return typeof selector === "string" - ? d3_root.select(selector) - : d3_selection([[selector]]); // assume node -}; - -d3.selectAll = function(selector) { - return typeof selector === "string" - ? d3_root.selectAll(selector) - : d3_selection([d3_array(selector)]); // assume node[] -}; - -function d3_selection(groups) { - - function select(select) { - var subgroups = [], - subgroup, - subnode, - group, - node; - for (var j = 0, m = groups.length; j < m; j++) { - group = groups[j]; - subgroups.push(subgroup = []); - subgroup.parentNode = group.parentNode; - for (var i = 0, n = group.length; i < n; i++) { - if (node = group[i]) { - subgroup.push(subnode = select(node)); - if (subnode && "__data__" in node) subnode.__data__ = node.__data__; - } else { - subgroup.push(null); - } - } - } - return d3_selection(subgroups); - } - - function selectAll(selectAll) { - var subgroups = [], - subgroup, - group, - node; - for (var j = 0, m = groups.length; j < m; j++) { - group = groups[j]; - for (var i = 0, n = group.length; i < n; i++) { - if (node = group[i]) { - subgroups.push(subgroup = selectAll(node)); - subgroup.parentNode = node; - } - } - } - return d3_selection(subgroups); - } - - // TODO select(function)? - groups.select = function(selector) { - return select(function(node) { - return d3_select(selector, node); - }); - }; - - // TODO selectAll(function)? - groups.selectAll = function(selector) { - return selectAll(function(node) { - return d3_selectAll(selector, node); - }); - }; - - // TODO preserve null elements to maintain index? - groups.filter = function(filter) { - var subgroups = [], - subgroup, - group, - node; - for (var j = 0, m = groups.length; j < m; j++) { - group = groups[j]; - subgroups.push(subgroup = []); - subgroup.parentNode = group.parentNode; - for (var i = 0, n = group.length; i < n; i++) { - if ((node = group[i]) && filter.call(node, node.__data__, i)) { - subgroup.push(node); - } - } - } - return d3_selection(subgroups); - }; - - groups.map = function(map) { - var group, - node; - for (var j = 0, m = groups.length; j < m; j++) { - group = groups[j]; - for (var i = 0, n = group.length; i < n; i++) { - if (node = group[i]) node.__data__ = map.call(node, node.__data__, i); - } - } - return groups; - }; - - // TODO data(null) for clearing data? - groups.data = function(data, join) { - var enter = [], - update = [], - exit = []; - - function bind(group, groupData) { - var i = 0, - n = group.length, - m = groupData.length, - n0 = Math.min(n, m), - n1 = Math.max(n, m), - updateNodes = [], - enterNodes = [], - exitNodes = [], - node, - nodeData; - - if (join) { - var nodeByKey = {}, - keys = [], - key, - j = groupData.length; - - for (i = 0; i < n; i++) { - key = join.call(node = group[i], node.__data__, i); - if (key in nodeByKey) { - exitNodes[j++] = node; // duplicate key - } else { - nodeByKey[key] = node; - } - keys.push(key); - } - - for (i = 0; i < m; i++) { - node = nodeByKey[key = join.call(groupData, nodeData = groupData[i], i)]; - if (node) { - node.__data__ = nodeData; - updateNodes[i] = node; - enterNodes[i] = exitNodes[i] = null; - } else { - enterNodes[i] = d3_selection_enterNode(nodeData); - updateNodes[i] = exitNodes[i] = null; - } - delete nodeByKey[key]; - } - - for (i = 0; i < n; i++) { - if (keys[i] in nodeByKey) { - exitNodes[i] = group[i]; - } - } - } else { - for (; i < n0; i++) { - node = group[i]; - nodeData = groupData[i]; - if (node) { - node.__data__ = nodeData; - updateNodes[i] = node; - enterNodes[i] = exitNodes[i] = null; - } else { - enterNodes[i] = d3_selection_enterNode(nodeData); - updateNodes[i] = exitNodes[i] = null; - } - } - for (; i < m; i++) { - enterNodes[i] = d3_selection_enterNode(groupData[i]); - updateNodes[i] = exitNodes[i] = null; - } - for (; i < n1; i++) { - exitNodes[i] = group[i]; - enterNodes[i] = updateNodes[i] = null; - } - } - - enterNodes.parentNode - = updateNodes.parentNode - = exitNodes.parentNode - = group.parentNode; - - enter.push(enterNodes); - update.push(updateNodes); - exit.push(exitNodes); - } - - var i = -1, - n = groups.length, - group; - if (typeof data === "function") { - while (++i < n) { - bind(group = groups[i], data.call(group, group.parentNode.__data__, i)); - } - } else { - while (++i < n) { - bind(group = groups[i], data); - } - } - - var selection = d3_selection(update); - selection.enter = function() { - return d3_selectionEnter(enter); - }; - selection.exit = function() { - return d3_selection(exit); - }; - return selection; - }; - - // TODO mask forEach? or rename for eachData? - // TODO offer the same semantics for map, reduce, etc.? - groups.each = function(callback) { - for (var j = 0, m = groups.length; j < m; j++) { - var group = groups[j]; - for (var i = 0, n = group.length; i < n; i++) { - var node = group[i]; - if (node) callback.call(node, node.__data__, i); - } - } - return groups; - }; - - function first(callback) { - for (var j = 0, m = groups.length; j < m; j++) { - var group = groups[j]; - for (var i = 0, n = group.length; i < n; i++) { - var node = group[i]; - if (node) return callback.call(node, node.__data__, i); - } - } - return null; - } - - groups.empty = function() { - return !first(function() { return true; }); - }; - - groups.node = function() { - return first(function() { return this; }); - }; - - groups.attr = function(name, value) { - name = d3.ns.qualify(name); - - // If no value is specified, return the first value. - if (arguments.length < 2) { - return first(name.local - ? function() { return this.getAttributeNS(name.space, name.local); } - : function() { return this.getAttribute(name); }); - } - - /** @this {Element} */ - function attrNull() { - this.removeAttribute(name); - } - - /** @this {Element} */ - function attrNullNS() { - this.removeAttributeNS(name.space, name.local); - } - - /** @this {Element} */ - function attrConstant() { - this.setAttribute(name, value); - } - - /** @this {Element} */ - function attrConstantNS() { - this.setAttributeNS(name.space, name.local, value); - } - - /** @this {Element} */ - function attrFunction() { - var x = value.apply(this, arguments); - if (x == null) this.removeAttribute(name); - else this.setAttribute(name, x); - } - - /** @this {Element} */ - function attrFunctionNS() { - var x = value.apply(this, arguments); - if (x == null) this.removeAttributeNS(name.space, name.local); - else this.setAttributeNS(name.space, name.local, x); - } - - return groups.each(value == null - ? (name.local ? attrNullNS : attrNull) : (typeof value === "function" - ? (name.local ? attrFunctionNS : attrFunction) - : (name.local ? attrConstantNS : attrConstant))); - }; - - groups.classed = function(name, value) { - var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g"); - - // If no value is specified, return the first value. - if (arguments.length < 2) { - return first(function() { - if (c = this.classList) return c.contains(name); - var c = this.className; - re.lastIndex = 0; - return re.test(c.baseVal != null ? c.baseVal : c); - }); - } - - /** @this {Element} */ - function classedAdd() { - if (c = this.classList) return c.add(name); - var c = this.className, - cb = c.baseVal != null, - cv = cb ? c.baseVal : c; - re.lastIndex = 0; - if (!re.test(cv)) { - cv = d3_collapse(cv + " " + name); - if (cb) c.baseVal = cv; - else this.className = cv; - } - } - - /** @this {Element} */ - function classedRemove() { - if (c = this.classList) return c.remove(name); - var c = this.className, - cb = c.baseVal != null, - cv = cb ? c.baseVal : c; - cv = d3_collapse(cv.replace(re, " ")); - if (cb) c.baseVal = cv; - else this.className = cv; - } - - /** @this {Element} */ - function classedFunction() { - (value.apply(this, arguments) - ? classedAdd - : classedRemove).call(this); - } - - return groups.each(typeof value === "function" - ? classedFunction : value - ? classedAdd - : classedRemove); - }; - - groups.style = function(name, value, priority) { - if (arguments.length < 3) priority = ""; - - // If no value is specified, return the first value. - if (arguments.length < 2) { - return first(function() { - return window.getComputedStyle(this, null).getPropertyValue(name); - }); - } - - /** @this {Element} */ - function styleNull() { - this.style.removeProperty(name); - } - - /** @this {Element} */ - function styleConstant() { - this.style.setProperty(name, value, priority); - } - - /** @this {Element} */ - function styleFunction() { - var x = value.apply(this, arguments); - if (x == null) this.style.removeProperty(name); - else this.style.setProperty(name, x, priority); - } - - return groups.each(value == null - ? styleNull : (typeof value === "function" - ? styleFunction : styleConstant)); - }; - - groups.property = function(name, value) { - name = d3.ns.qualify(name); - - // If no value is specified, return the first value. - if (arguments.length < 2) { - return first(function() { - return this[name]; - }); - } - - /** @this {Element} */ - function propertyNull() { - delete this[name]; - } - - /** @this {Element} */ - function propertyConstant() { - this[name] = value; - } - - /** @this {Element} */ - function propertyFunction() { - var x = value.apply(this, arguments); - if (x == null) delete this[name]; - else this[name] = x; - } - - return groups.each(value == null - ? propertyNull : (typeof value === "function" - ? propertyFunction : propertyConstant)); - }; - - groups.text = function(value) { - - // If no value is specified, return the first value. - if (arguments.length < 1) { - return first(function() { - return this.textContent; - }); - } - - /** @this {Element} */ - function textConstant() { - this.textContent = value; - } - - /** @this {Element} */ - function textFunction() { - this.textContent = value.apply(this, arguments); - } - - return groups.each(typeof value === "function" - ? textFunction : textConstant); - }; - - groups.html = function(value) { - - // If no value is specified, return the first value. - if (arguments.length < 1) { - return first(function() { - return this.innerHTML; - }); - } - - /** @this {Element} */ - function htmlConstant() { - this.innerHTML = value; - } - - /** @this {Element} */ - function htmlFunction() { - this.innerHTML = value.apply(this, arguments); - } - - return groups.each(typeof value === "function" - ? htmlFunction : htmlConstant); - }; - - // TODO append(node)? - // TODO append(function)? - groups.append = function(name) { - name = d3.ns.qualify(name); - - function append(node) { - return node.appendChild(document.createElement(name)); - } - - function appendNS(node) { - return node.appendChild(document.createElementNS(name.space, name.local)); - } - - return select(name.local ? appendNS : append); - }; - - // TODO insert(node, function)? - // TODO insert(function, string)? - // TODO insert(function, function)? - groups.insert = function(name, before) { - name = d3.ns.qualify(name); - - function insert(node) { - return node.insertBefore( - document.createElement(name), - d3_select(before, node)); - } - - function insertNS(node) { - return node.insertBefore( - document.createElementNS(name.space, name.local), - d3_select(before, node)); - } - - return select(name.local ? insertNS : insert); - }; - - // TODO remove(selector)? - // TODO remove(node)? - // TODO remove(function)? - groups.remove = function() { - return groups.each(function() { - var parent = this.parentNode; - if (parent) parent.removeChild(this); - }); - }; - - groups.sort = function(comparator) { - comparator = d3_selection_comparator.apply(this, arguments); - for (var j = 0, m = groups.length; j < m; j++) { - var group = groups[j]; - group.sort(comparator); - for (var i = 1, n = group.length, prev = group[0]; i < n; i++) { - var node = group[i]; - if (node) { - if (prev) prev.parentNode.insertBefore(node, prev.nextSibling); - prev = node; - } - } - } - return groups; - }; - - // type can be namespaced, e.g., "click.foo" - // listener can be null for removal - groups.on = function(type, listener, capture) { - if (arguments.length < 3) capture = false; - - // parse the type specifier - var i = type.indexOf("."), - typo = i === -1 ? type : type.substring(0, i), - name = "__on" + type; - - // remove the old event listener, and add the new event listener - return groups.each(function(d, i) { - if (this[name]) this.removeEventListener(typo, this[name], capture); - if (listener) this.addEventListener(typo, this[name] = l, capture); - - // wrapped event listener that preserves i - var node = this; - function l(e) { - var o = d3.event; // Events can be reentrant (e.g., focus). - d3.event = e; - try { - listener.call(this, node.__data__, i); - } finally { - d3.event = o; - } - } - }); - }; - - // TODO slice? - - groups.transition = function() { - return d3_transition(groups); - }; - - groups.call = d3_call; - - return groups; -} - -function d3_selectionEnter(groups) { - - function select(select) { - var subgroups = [], - subgroup, - subnode, - group, - node; - for (var j = 0, m = groups.length; j < m; j++) { - group = groups[j]; - subgroups.push(subgroup = []); - subgroup.parentNode = group.parentNode; - for (var i = 0, n = group.length; i < n; i++) { - if (node = group[i]) { - subgroup.push(subnode = select(group.parentNode)); - subnode.__data__ = node.__data__; - } else { - subgroup.push(null); - } - } - } - return d3_selection(subgroups); - } - - // TODO append(node)? - // TODO append(function)? - groups.append = function(name) { - name = d3.ns.qualify(name); - - function append(node) { - return node.appendChild(document.createElement(name)); - } - - function appendNS(node) { - return node.appendChild(document.createElementNS(name.space, name.local)); - } - - return select(name.local ? appendNS : append); - }; - - // TODO insert(node, function)? - // TODO insert(function, string)? - // TODO insert(function, function)? - groups.insert = function(name, before) { - name = d3.ns.qualify(name); - - function insert(node) { - return node.insertBefore( - document.createElement(name), - d3_select(before, node)); - } - - function insertNS(node) { - return node.insertBefore( - document.createElementNS(name.space, name.local), - d3_select(before, node)); - } - - return select(name.local ? insertNS : insert); - }; - - return groups; -} - -function d3_selection_comparator(comparator) { - if (!arguments.length) comparator = d3.ascending; - return function(a, b) { - return comparator(a && a.__data__, b && b.__data__); - }; -} - -function d3_selection_enterNode(data) { - return {__data__: data}; -} -d3.transition = d3_root.transition; - -var d3_transitionId = 0, - d3_transitionInheritId = 0; - -function d3_transition(groups) { - var transition = {}, - transitionId = d3_transitionInheritId || ++d3_transitionId, - tweens = {}, - interpolators = [], - remove = false, - event = d3.dispatch("start", "end"), - stage = [], - delay = [], - duration = [], - durationMax, - ease = d3.ease("cubic-in-out"); - - // - // Be careful with concurrent transitions! - // - // Say transition A causes an exit. Before A finishes, a transition B is - // created, and believes it only needs to do an update, because the elements - // haven't been removed yet (which happens at the very end of the exit - // transition). - // - // Even worse, what if either transition A or B has a staggered delay? Then, - // some elements may be removed, while others remain. Transition B does not - // know to enter the elements because they were still present at the time - // the transition B was created (but not yet started). - // - // To prevent such confusion, we only trigger end events for transitions if - // the transition ending is the only one scheduled for the given element. - // Similarly, we only allow one transition to be active for any given - // element, so that concurrent transitions do not overwrite each other's - // properties. - // - // TODO Support transition namespaces, so that transitions can proceed - // concurrently on the same element if needed. Hopefully, this is rare! - // - - groups.each(function() { - (this.__transition__ || (this.__transition__ = {})).owner = transitionId; - }); - - function step(elapsed) { - var clear = true, - k = -1; - groups.each(function() { - if (stage[++k] === 2) return; // ended - var t = (elapsed - delay[k]) / duration[k], - tx = this.__transition__, - te, // ease(t) - tk, // tween key - ik = interpolators[k]; - - // Check if the (un-eased) time is outside the range [0,1]. - if (t < 1) { - clear = false; - if (t < 0) return; - } else { - t = 1; - } - - // Determine the stage of this transition. - // 0 - Not yet started. - // 1 - In progress. - // 2 - Ended. - if (stage[k]) { - if (!tx || tx.active !== transitionId) { - stage[k] = 2; - return; - } - } else if (!tx || tx.active > transitionId) { - stage[k] = 2; - return; - } else { - stage[k] = 1; - event.start.dispatch.apply(this, arguments); - ik = interpolators[k] = {}; - tx.active = transitionId; - for (tk in tweens) { - if (te = tweens[tk].apply(this, arguments)) { - ik[tk] = te; - } - } - } - - // Apply the interpolators! - te = ease(t); - for (tk in ik) ik[tk].call(this, te); - - // Handle ending transitions. - if (t === 1) { - stage[k] = 2; - if (tx.active === transitionId) { - var owner = tx.owner; - if (owner === transitionId) { - delete this.__transition__; - if (remove && this.parentNode) this.parentNode.removeChild(this); - } - d3_transitionInheritId = transitionId; - event.end.dispatch.apply(this, arguments); - d3_transitionInheritId = 0; - tx.owner = owner; - } - } - }); - return clear; - } - - transition.delay = function(value) { - var delayMin = Infinity, - k = -1; - if (typeof value === "function") { - groups.each(function(d, i) { - var x = delay[++k] = +value.apply(this, arguments); - if (x < delayMin) delayMin = x; - }); - } else { - delayMin = +value; - groups.each(function(d, i) { - delay[++k] = delayMin; - }); - } - d3_timer(step, delayMin); - return transition; - }; - - transition.duration = function(value) { - var k = -1; - if (typeof value === "function") { - durationMax = 0; - groups.each(function(d, i) { - var x = duration[++k] = +value.apply(this, arguments); - if (x > durationMax) durationMax = x; - }); - } else { - durationMax = +value; - groups.each(function(d, i) { - duration[++k] = durationMax; - }); - } - return transition; - }; - - transition.ease = function(value) { - ease = typeof value === "function" ? value : d3.ease.apply(d3, arguments); - return transition; - }; - - transition.attrTween = function(name, tween) { - - /** @this {Element} */ - function attrTween(d, i) { - var f = tween.call(this, d, i, this.getAttribute(name)); - return f && function(t) { - this.setAttribute(name, f(t)); - }; - } - - /** @this {Element} */ - function attrTweenNS(d, i) { - var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); - return f && function(t) { - this.setAttributeNS(name.space, name.local, f(t)); - }; - } - - tweens["attr." + name] = name.local ? attrTweenNS : attrTween; - return transition; - }; - - transition.attr = function(name, value) { - return transition.attrTween(name, d3_transitionTween(value)); - }; - - transition.styleTween = function(name, tween, priority) { - if (arguments.length < 3) priority = null; - - /** @this {Element} */ - function styleTween(d, i) { - var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); - return f && function(t) { - this.style.setProperty(name, f(t), priority); - }; - } - - tweens["style." + name] = styleTween; - return transition; - }; - - transition.style = function(name, value, priority) { - if (arguments.length < 3) priority = null; - return transition.styleTween(name, d3_transitionTween(value), priority); - }; - - transition.text = function(value) { - tweens.text = function(d, i) { - this.textContent = typeof value === "function" - ? value.call(this, d, i) - : value; - }; - return transition; - }; - - transition.select = function(query) { - var k, t = d3_transition(groups.select(query)).ease(ease); - k = -1; t.delay(function(d, i) { return delay[++k]; }); - k = -1; t.duration(function(d, i) { return duration[++k]; }); - return t; - }; - - transition.selectAll = function(query) { - var k, t = d3_transition(groups.selectAll(query)).ease(ease); - k = -1; t.delay(function(d, i) { return delay[i ? k : ++k]; }) - k = -1; t.duration(function(d, i) { return duration[i ? k : ++k]; }); - return t; - }; - - transition.remove = function() { - remove = true; - return transition; - }; - - transition.each = function(type, listener) { - event[type].add(listener); - return transition; - }; - - transition.call = d3_call; - - return transition.delay(0).duration(250); -} - -function d3_transitionTween(b) { - return typeof b === "function" - ? function(d, i, a) { var v = b.call(this, d, i) + ""; return a != v && d3.interpolate(a, v); } - : (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); }); -} -var d3_timer_queue = null, - d3_timer_interval, // is an interval (or frame) active? - d3_timer_timeout; // is a timeout active? - -// The timer will continue to fire until callback returns true. -d3.timer = function(callback) { - d3_timer(callback, 0); -}; - -function d3_timer(callback, delay) { - var now = Date.now(), - found = false, - t0, - t1 = d3_timer_queue; - - if (!isFinite(delay)) return; - - // See if the callback's already in the queue. - while (t1) { - if (t1.callback === callback) { - t1.then = now; - t1.delay = delay; - found = true; - break; - } - t0 = t1; - t1 = t1.next; - } - - // Otherwise, add the callback to the queue. - if (!found) d3_timer_queue = { - callback: callback, - then: now, - delay: delay, - next: d3_timer_queue - }; - - // Start animatin'! - if (!d3_timer_interval) { - d3_timer_timeout = clearTimeout(d3_timer_timeout); - d3_timer_interval = 1; - d3_timer_frame(d3_timer_step); - } -} - -function d3_timer_step() { - var elapsed, - now = Date.now(), - t1 = d3_timer_queue; - - while (t1) { - elapsed = now - t1.then; - if (elapsed > t1.delay) t1.flush = t1.callback(elapsed); - t1 = t1.next; - } - - var delay = d3_timer_flush() - now; - if (delay > 24) { - if (isFinite(delay)) { - clearTimeout(d3_timer_timeout); - d3_timer_timeout = setTimeout(d3_timer_step, delay); - } - d3_timer_interval = 0; - } else { - d3_timer_interval = 1; - d3_timer_frame(d3_timer_step); - } -} - -d3.timer.flush = function() { - var elapsed, - now = Date.now(), - t1 = d3_timer_queue; - - while (t1) { - elapsed = now - t1.then; - if (!t1.delay) t1.flush = t1.callback(elapsed); - t1 = t1.next; - } - - d3_timer_flush(); -}; - -// Flush after callbacks, to avoid concurrent queue modification. -function d3_timer_flush() { - var t0 = null, - t1 = d3_timer_queue, - then = Infinity; - while (t1) { - if (t1.flush) { - t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next; - } else { - then = Math.min(then, t1.then + t1.delay); - t1 = (t0 = t1).next; - } - } - return then; -} - -var d3_timer_frame = window.requestAnimationFrame - || window.webkitRequestAnimationFrame - || window.mozRequestAnimationFrame - || window.oRequestAnimationFrame - || window.msRequestAnimationFrame - || function(callback) { setTimeout(callback, 17); }; -function d3_noop() {} -d3.scale = {}; - -function d3_scaleExtent(domain) { - var start = domain[0], stop = domain[domain.length - 1]; - return start < stop ? [start, stop] : [stop, start]; -} -function d3_scale_nice(domain, nice) { - var i0 = 0, - i1 = domain.length - 1, - x0 = domain[i0], - x1 = domain[i1], - dx; - - if (x1 < x0) { - dx = i0; i0 = i1; i1 = dx; - dx = x0; x0 = x1; x1 = dx; - } - - nice = nice(x1 - x0); - domain[i0] = nice.floor(x0); - domain[i1] = nice.ceil(x1); - return domain; -} - -function d3_scale_niceDefault() { - return Math; -} -d3.scale.linear = function() { - var domain = [0, 1], - range = [0, 1], - interpolate = d3.interpolate, - clamp = false, - output, - input; - - function rescale() { - var linear = domain.length == 2 ? d3_scale_bilinear : d3_scale_polylinear, - uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; - output = linear(domain, range, uninterpolate, interpolate); - input = linear(range, domain, uninterpolate, d3.interpolate); - return scale; - } - - function scale(x) { - return output(x); - } - - // Note: requires range is coercible to number! - scale.invert = function(y) { - return input(y); - }; - - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = x.map(Number); - return rescale(); - }; - - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - return rescale(); - }; - - scale.rangeRound = function(x) { - return scale.range(x).interpolate(d3.interpolateRound); - }; - - scale.clamp = function(x) { - if (!arguments.length) return clamp; - clamp = x; - return rescale(); - }; - - scale.interpolate = function(x) { - if (!arguments.length) return interpolate; - interpolate = x; - return rescale(); - }; - - scale.ticks = function(m) { - return d3_scale_linearTicks(domain, m); - }; - - scale.tickFormat = function(m) { - return d3_scale_linearTickFormat(domain, m); - }; - - scale.nice = function() { - d3_scale_nice(domain, d3_scale_linearNice); - return rescale(); - }; - - return rescale(); -}; - -function d3_scale_linearRebind(scale, linear) { - scale.range = d3.rebind(scale, linear.range); - scale.rangeRound = d3.rebind(scale, linear.rangeRound); - scale.interpolate = d3.rebind(scale, linear.interpolate); - scale.clamp = d3.rebind(scale, linear.clamp); - return scale; -} - -function d3_scale_linearNice(dx) { - dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1); - return { - floor: function(x) { return Math.floor(x / dx) * dx; }, - ceil: function(x) { return Math.ceil(x / dx) * dx; } - }; -} - -// TODO Dates? Ugh. -function d3_scale_linearTickRange(domain, m) { - var extent = d3_scaleExtent(domain), - span = extent[1] - extent[0], - step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), - err = m / span * step; - - // Filter ticks to get closer to the desired count. - if (err <= .15) step *= 10; - else if (err <= .35) step *= 5; - else if (err <= .75) step *= 2; - - // Round start and stop values to step interval. - extent[0] = Math.ceil(extent[0] / step) * step; - extent[1] = Math.floor(extent[1] / step) * step + step * .5; // inclusive - extent[2] = step; - return extent; -} - -function d3_scale_linearTicks(domain, m) { - return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); -} - -function d3_scale_linearTickFormat(domain, m) { - return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f"); -} -function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { - var u = uninterpolate(domain[0], domain[1]), - i = interpolate(range[0], range[1]); - return function(x) { - return i(u(x)); - }; -} -function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { - var u = [], - i = [], - j = 0, - n = domain.length; - - while (++j < n) { - u.push(uninterpolate(domain[j - 1], domain[j])); - i.push(interpolate(range[j - 1], range[j])); - } - - return function(x) { - var j = d3.bisect(domain, x, 1, domain.length - 1) - 1; - return i[j](u[j](x)); - }; -} -d3.scale.log = function() { - var linear = d3.scale.linear(), - log = d3_scale_log, - pow = log.pow; - - function scale(x) { - return linear(log(x)); - } - - scale.invert = function(x) { - return pow(linear.invert(x)); - }; - - scale.domain = function(x) { - if (!arguments.length) return linear.domain().map(pow); - log = x[0] < 0 ? d3_scale_logn : d3_scale_log; - pow = log.pow; - linear.domain(x.map(log)); - return scale; - }; - - scale.nice = function() { - linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault)); - return scale; - }; - - scale.ticks = function() { - var extent = d3_scaleExtent(linear.domain()), - ticks = []; - if (extent.every(isFinite)) { - var i = Math.floor(extent[0]), - j = Math.ceil(extent[1]), - u = pow(extent[0]), - v = pow(extent[1]); - if (log === d3_scale_logn) { - ticks.push(pow(i)); - for (; i++ < j;) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k); - } else { - for (; i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k); - ticks.push(pow(i)); - } - for (i = 0; ticks[i] < u; i++) {} // strip small values - for (j = ticks.length; ticks[j - 1] > v; j--) {} // strip big values - ticks = ticks.slice(i, j); - } - return ticks; - }; - - scale.tickFormat = function() { - return d3_scale_logTickFormat; - }; - - return d3_scale_linearRebind(scale, linear); -}; - -function d3_scale_log(x) { - return Math.log(x) / Math.LN10; -} - -function d3_scale_logn(x) { - return -Math.log(-x) / Math.LN10; -} - -d3_scale_log.pow = function(x) { - return Math.pow(10, x); -}; - -d3_scale_logn.pow = function(x) { - return -Math.pow(10, -x); -}; - -function d3_scale_logTickFormat(d) { - return d.toPrecision(1); -} -d3.scale.pow = function() { - var linear = d3.scale.linear(), - exponent = 1, - powp = Number, - powb = powp; - - function scale(x) { - return linear(powp(x)); - } - - scale.invert = function(x) { - return powb(linear.invert(x)); - }; - - scale.domain = function(x) { - if (!arguments.length) return linear.domain().map(powb); - powp = d3_scale_powPow(exponent); - powb = d3_scale_powPow(1 / exponent); - linear.domain(x.map(powp)); - return scale; - }; - - scale.ticks = function(m) { - return d3_scale_linearTicks(scale.domain(), m); - }; - - scale.tickFormat = function(m) { - return d3_scale_linearTickFormat(scale.domain(), m); - }; - - scale.nice = function() { - return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice)); - }; - - scale.exponent = function(x) { - if (!arguments.length) return exponent; - var domain = scale.domain(); - exponent = x; - return scale.domain(domain); - }; - - return d3_scale_linearRebind(scale, linear); -}; - -function d3_scale_powPow(e) { - return function(x) { - return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); - }; -} -d3.scale.sqrt = function() { - return d3.scale.pow().exponent(.5); -}; -d3.scale.ordinal = function() { - var domain = [], - index = {}, - range = [], - rangeBand = 0, - rerange = d3_noop; - - function scale(x) { - var i = x in index ? index[x] : (index[x] = domain.push(x) - 1); - return range[i % range.length]; - } - - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = x; - index = {}; - var i = -1, j = -1, n = domain.length; while (++i < n) { - x = domain[i]; - if (!(x in index)) index[x] = ++j; - } - rerange(); - return scale; - }; - - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - rerange = d3_noop; - return scale; - }; - - scale.rangePoints = function(x, padding) { - if (arguments.length < 2) padding = 0; - (rerange = function() { - var start = x[0], - stop = x[1], - step = (stop - start) / (domain.length - 1 + padding); - range = domain.length == 1 - ? [(start + stop) / 2] - : d3.range(start + step * padding / 2, stop + step / 2, step); - rangeBand = 0; - })(); - return scale; - }; - - scale.rangeBands = function(x, padding) { - if (arguments.length < 2) padding = 0; - (rerange = function() { - var start = x[0], - stop = x[1], - step = (stop - start) / (domain.length + padding); - range = d3.range(start + step * padding, stop, step); - rangeBand = step * (1 - padding); - })(); - return scale; - }; - - scale.rangeRoundBands = function(x, padding) { - if (arguments.length < 2) padding = 0; - (rerange = function() { - var start = x[0], - stop = x[1], - diff = stop - start, - step = Math.floor(diff / (domain.length + padding)), - err = diff - (domain.length - padding) * step; - range = d3.range(start + Math.round(err / 2), stop, step); - rangeBand = Math.round(step * (1 - padding)); - })(); - return scale; - }; - - scale.rangeBand = function() { - return rangeBand; - }; - - return scale; -}; -/* - * This product includes color specifications and designs developed by Cynthia - * Brewer (http://colorbrewer.org/). See lib/colorbrewer for more information. - */ - -d3.scale.category10 = function() { - return d3.scale.ordinal().range(d3_category10); -}; - -d3.scale.category20 = function() { - return d3.scale.ordinal().range(d3_category20); -}; - -d3.scale.category20b = function() { - return d3.scale.ordinal().range(d3_category20b); -}; - -d3.scale.category20c = function() { - return d3.scale.ordinal().range(d3_category20c); -}; - -var d3_category10 = [ - "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", - "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf" -]; - -var d3_category20 = [ - "#1f77b4", "#aec7e8", - "#ff7f0e", "#ffbb78", - "#2ca02c", "#98df8a", - "#d62728", "#ff9896", - "#9467bd", "#c5b0d5", - "#8c564b", "#c49c94", - "#e377c2", "#f7b6d2", - "#7f7f7f", "#c7c7c7", - "#bcbd22", "#dbdb8d", - "#17becf", "#9edae5" -]; - -var d3_category20b = [ - "#393b79", "#5254a3", "#6b6ecf", "#9c9ede", - "#637939", "#8ca252", "#b5cf6b", "#cedb9c", - "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94", - "#843c39", "#ad494a", "#d6616b", "#e7969c", - "#7b4173", "#a55194", "#ce6dbd", "#de9ed6" -]; - -var d3_category20c = [ - "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", - "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", - "#31a354", "#74c476", "#a1d99b", "#c7e9c0", - "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", - "#636363", "#969696", "#bdbdbd", "#d9d9d9" -]; -d3.scale.quantile = function() { - var domain = [], - range = [], - thresholds = []; - - function rescale() { - var k = 0, - n = domain.length, - q = range.length; - thresholds.length = Math.max(0, q - 1); - while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); - } - - function scale(x) { - if (isNaN(x = +x)) return NaN; - return range[d3.bisect(thresholds, x)]; - } - - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = x.filter(function(d) { return !isNaN(d); }).sort(d3.ascending); - rescale(); - return scale; - }; - - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - rescale(); - return scale; - }; - - scale.quantiles = function() { - return thresholds; - }; - - return scale; -}; -d3.scale.quantize = function() { - var x0 = 0, - x1 = 1, - kx = 2, - i = 1, - range = [0, 1]; - - function scale(x) { - return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; - } - - scale.domain = function(x) { - if (!arguments.length) return [x0, x1]; - x0 = x[0]; - x1 = x[1]; - kx = range.length / (x1 - x0); - return scale; - }; - - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - kx = range.length / (x1 - x0); - i = range.length - 1; - return scale; - }; - - return scale; -}; -d3.svg = {}; -d3.svg.arc = function() { - var innerRadius = d3_svg_arcInnerRadius, - outerRadius = d3_svg_arcOuterRadius, - startAngle = d3_svg_arcStartAngle, - endAngle = d3_svg_arcEndAngle; - - function arc() { - var r0 = innerRadius.apply(this, arguments), - r1 = outerRadius.apply(this, arguments), - a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, - a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, - da = a1 - a0, - df = da < Math.PI ? "0" : "1", - c0 = Math.cos(a0), - s0 = Math.sin(a0), - c1 = Math.cos(a1), - s1 = Math.sin(a1); - return da >= d3_svg_arcMax - ? (r0 - ? "M0," + r1 - + "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1) - + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 - + "M0," + r0 - + "A" + r0 + "," + r0 + " 0 1,1 0," + (-r0) - + "A" + r0 + "," + r0 + " 0 1,1 0," + r0 - + "Z" - : "M0," + r1 - + "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1) - + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 - + "Z") - : (r0 - ? "M" + r1 * c0 + "," + r1 * s0 - + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 - + "L" + r0 * c1 + "," + r0 * s1 - + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 - + "Z" - : "M" + r1 * c0 + "," + r1 * s0 - + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 - + "L0,0" - + "Z"); - } - - arc.innerRadius = function(v) { - if (!arguments.length) return innerRadius; - innerRadius = d3.functor(v); - return arc; - }; - - arc.outerRadius = function(v) { - if (!arguments.length) return outerRadius; - outerRadius = d3.functor(v); - return arc; - }; - - arc.startAngle = function(v) { - if (!arguments.length) return startAngle; - startAngle = d3.functor(v); - return arc; - }; - - arc.endAngle = function(v) { - if (!arguments.length) return endAngle; - endAngle = d3.functor(v); - return arc; - }; - - arc.centroid = function() { - var r = (innerRadius.apply(this, arguments) - + outerRadius.apply(this, arguments)) / 2, - a = (startAngle.apply(this, arguments) - + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset; - return [Math.cos(a) * r, Math.sin(a) * r]; - }; - - return arc; -}; - -var d3_svg_arcOffset = -Math.PI / 2, - d3_svg_arcMax = 2 * Math.PI - 1e-6; - -function d3_svg_arcInnerRadius(d) { - return d.innerRadius; -} - -function d3_svg_arcOuterRadius(d) { - return d.outerRadius; -} - -function d3_svg_arcStartAngle(d) { - return d.startAngle; -} - -function d3_svg_arcEndAngle(d) { - return d.endAngle; -} -function d3_svg_line(projection) { - var x = d3_svg_lineX, - y = d3_svg_lineY, - interpolate = "linear", - interpolator = d3_svg_lineInterpolators[interpolate], - tension = .7; - - function line(d) { - return d.length < 1 ? null : "M" + interpolator(projection(d3_svg_linePoints(this, d, x, y)), tension); - } - - line.x = function(v) { - if (!arguments.length) return x; - x = v; - return line; - }; - - line.y = function(v) { - if (!arguments.length) return y; - y = v; - return line; - }; - - line.interpolate = function(v) { - if (!arguments.length) return interpolate; - interpolator = d3_svg_lineInterpolators[interpolate = v]; - return line; - }; - - line.tension = function(v) { - if (!arguments.length) return tension; - tension = v; - return line; - }; - - return line; -} - -d3.svg.line = function() { - return d3_svg_line(Object); -}; - -// Converts the specified array of data into an array of points -// (x-y tuples), by evaluating the specified `x` and `y` functions on each -// data point. The `this` context of the evaluated functions is the specified -// "self" object; each function is passed the current datum and index. -function d3_svg_linePoints(self, d, x, y) { - var points = [], - i = -1, - n = d.length, - fx = typeof x === "function", - fy = typeof y === "function", - value; - if (fx && fy) { - while (++i < n) points.push([ - x.call(self, value = d[i], i), - y.call(self, value, i) - ]); - } else if (fx) { - while (++i < n) points.push([x.call(self, d[i], i), y]); - } else if (fy) { - while (++i < n) points.push([x, y.call(self, d[i], i)]); - } else { - while (++i < n) points.push([x, y]); - } - return points; -} - -// The default `x` property, which references d[0]. -function d3_svg_lineX(d) { - return d[0]; -} - -// The default `y` property, which references d[1]. -function d3_svg_lineY(d) { - return d[1]; -} - -// The various interpolators supported by the `line` class. -var d3_svg_lineInterpolators = { - "linear": d3_svg_lineLinear, - "step-before": d3_svg_lineStepBefore, - "step-after": d3_svg_lineStepAfter, - "basis": d3_svg_lineBasis, - "basis-open": d3_svg_lineBasisOpen, - "basis-closed": d3_svg_lineBasisClosed, - "bundle": d3_svg_lineBundle, - "cardinal": d3_svg_lineCardinal, - "cardinal-open": d3_svg_lineCardinalOpen, - "cardinal-closed": d3_svg_lineCardinalClosed, - "monotone": d3_svg_lineMonotone -}; - -// Linear interpolation; generates "L" commands. -function d3_svg_lineLinear(points) { - var path = [], - i = 0, - n = points.length, - p = points[0]; - path.push(p[0], ",", p[1]); - while (++i < n) path.push("L", (p = points[i])[0], ",", p[1]); - return path.join(""); -} - -// Step interpolation; generates "H" and "V" commands. -function d3_svg_lineStepBefore(points) { - var path = [], - i = 0, - n = points.length, - p = points[0]; - path.push(p[0], ",", p[1]); - while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); - return path.join(""); -} - -// Step interpolation; generates "H" and "V" commands. -function d3_svg_lineStepAfter(points) { - var path = [], - i = 0, - n = points.length, - p = points[0]; - path.push(p[0], ",", p[1]); - while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); - return path.join(""); -} - -// Open cardinal spline interpolation; generates "C" commands. -function d3_svg_lineCardinalOpen(points, tension) { - return points.length < 4 - ? d3_svg_lineLinear(points) - : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), - d3_svg_lineCardinalTangents(points, tension)); -} - -// Closed cardinal spline interpolation; generates "C" commands. -function d3_svg_lineCardinalClosed(points, tension) { - return points.length < 3 - ? d3_svg_lineLinear(points) - : points[0] + d3_svg_lineHermite((points.push(points[0]), points), - d3_svg_lineCardinalTangents([points[points.length - 2]] - .concat(points, [points[1]]), tension)); -} - -// Cardinal spline interpolation; generates "C" commands. -function d3_svg_lineCardinal(points, tension, closed) { - return points.length < 3 - ? d3_svg_lineLinear(points) - : points[0] + d3_svg_lineHermite(points, - d3_svg_lineCardinalTangents(points, tension)); -} - -// Hermite spline construction; generates "C" commands. -function d3_svg_lineHermite(points, tangents) { - if (tangents.length < 1 - || (points.length != tangents.length - && points.length != tangents.length + 2)) { - return d3_svg_lineLinear(points); - } - - var quad = points.length != tangents.length, - path = "", - p0 = points[0], - p = points[1], - t0 = tangents[0], - t = t0, - pi = 1; - - if (quad) { - path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) - + "," + p[0] + "," + p[1]; - p0 = points[1]; - pi = 2; - } - - if (tangents.length > 1) { - t = tangents[1]; - p = points[pi]; - pi++; - path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) - + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) - + "," + p[0] + "," + p[1]; - for (var i = 2; i < tangents.length; i++, pi++) { - p = points[pi]; - t = tangents[i]; - path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) - + "," + p[0] + "," + p[1]; - } - } - - if (quad) { - var lp = points[pi]; - path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) - + "," + lp[0] + "," + lp[1]; - } - - return path; -} - -// Generates tangents for a cardinal spline. -function d3_svg_lineCardinalTangents(points, tension) { - var tangents = [], - a = (1 - tension) / 2, - p0, - p1 = points[0], - p2 = points[1], - i = 1, - n = points.length; - while (++i < n) { - p0 = p1; - p1 = p2; - p2 = points[i]; - tangents.push([a * (p2[0] - p0[0]), a * (p2[1] - p0[1])]); - } - return tangents; -} - -// B-spline interpolation; generates "C" commands. -function d3_svg_lineBasis(points) { - if (points.length < 3) return d3_svg_lineLinear(points); - var path = [], - i = 1, - n = points.length, - pi = points[0], - x0 = pi[0], - y0 = pi[1], - px = [x0, x0, x0, (pi = points[1])[0]], - py = [y0, y0, y0, pi[1]]; - path.push(x0, ",", y0); - d3_svg_lineBasisBezier(path, px, py); - while (++i < n) { - pi = points[i]; - px.shift(); px.push(pi[0]); - py.shift(); py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - i = -1; - while (++i < 2) { - px.shift(); px.push(pi[0]); - py.shift(); py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - return path.join(""); -} - -// Open B-spline interpolation; generates "C" commands. -function d3_svg_lineBasisOpen(points) { - if (points.length < 4) return d3_svg_lineLinear(points); - var path = [], - i = -1, - n = points.length, - pi, - px = [0], - py = [0]; - while (++i < 3) { - pi = points[i]; - px.push(pi[0]); - py.push(pi[1]); - } - path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) - + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); - --i; while (++i < n) { - pi = points[i]; - px.shift(); px.push(pi[0]); - py.shift(); py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - return path.join(""); -} - -// Closed B-spline interpolation; generates "C" commands. -function d3_svg_lineBasisClosed(points) { - var path, - i = -1, - n = points.length, - m = n + 4, - pi, - px = [], - py = []; - while (++i < 4) { - pi = points[i % n]; - px.push(pi[0]); - py.push(pi[1]); - } - path = [ - d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", - d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) - ]; - --i; while (++i < m) { - pi = points[i % n]; - px.shift(); px.push(pi[0]); - py.shift(); py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - return path.join(""); -} - -function d3_svg_lineBundle(points, tension) { - var n = points.length - 1, - x0 = points[0][0], - y0 = points[0][1], - dx = points[n][0] - x0, - dy = points[n][1] - y0, - i = -1, - p, - t; - while (++i <= n) { - p = points[i]; - t = i / n; - p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); - p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); - } - return d3_svg_lineBasis(points); -} - -// Returns the dot product of the given four-element vectors. -function d3_svg_lineDot4(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; -} - -// Matrix to transform basis (b-spline) control points to bezier -// control points. Derived from FvD 11.2.8. -var d3_svg_lineBasisBezier1 = [0, 2/3, 1/3, 0], - d3_svg_lineBasisBezier2 = [0, 1/3, 2/3, 0], - d3_svg_lineBasisBezier3 = [0, 1/6, 2/3, 1/6]; - -// Pushes a "C" Bézier curve onto the specified path array, given the -// two specified four-element arrays which define the control points. -function d3_svg_lineBasisBezier(path, x, y) { - path.push( - "C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), - ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), - ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), - ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), - ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), - ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); -} - -// Computes the slope from points p0 to p1. -function d3_svg_lineSlope(p0, p1) { - return (p1[1] - p0[1]) / (p1[0] - p0[0]); -} - -// Compute three-point differences for the given points. -// http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference -function d3_svg_lineFiniteDifferences(points) { - var i = 0, - j = points.length - 1, - m = [], - p0 = points[0], - p1 = points[1], - d = m[0] = d3_svg_lineSlope(p0, p1); - while (++i < j) { - m[i] = d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1])); - } - m[i] = d; - return m; -} - -// Interpolates the given points using Fritsch-Carlson Monotone cubic Hermite -// interpolation. Returns an array of tangent vectors. For details, see -// http://en.wikipedia.org/wiki/Monotone_cubic_interpolation -function d3_svg_lineMonotoneTangents(points) { - var tangents = [], - d, - a, - b, - s, - m = d3_svg_lineFiniteDifferences(points), - i = -1, - j = points.length - 1; - - // The first two steps are done by computing finite-differences: - // 1. Compute the slopes of the secant lines between successive points. - // 2. Initialize the tangents at every point as the average of the secants. - - // Then, for each segment… - while (++i < j) { - d = d3_svg_lineSlope(points[i], points[i + 1]); - - // 3. If two successive yk = y{k + 1} are equal (i.e., d is zero), then set - // mk = m{k + 1} = 0 as the spline connecting these points must be flat to - // preserve monotonicity. Ignore step 4 and 5 for those k. - - if (Math.abs(d) < 1e-6) { - m[i] = m[i + 1] = 0; - } else { - // 4. Let ak = mk / dk and bk = m{k + 1} / dk. - a = m[i] / d; - b = m[i + 1] / d; - - // 5. Prevent overshoot and ensure monotonicity by restricting the - // magnitude of vector to a circle of radius 3. - s = a * a + b * b; - if (s > 9) { - s = d * 3 / Math.sqrt(s); - m[i] = s * a; - m[i + 1] = s * b; - } - } - } - - // Compute the normalized tangent vector from the slopes. Note that if x is - // not monotonic, it's possible that the slope will be infinite, so we protect - // against NaN by setting the coordinate to zero. - i = -1; while (++i <= j) { - s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) - / (6 * (1 + m[i] * m[i])); - tangents.push([s || 0, m[i] * s || 0]); - } - - return tangents; -} - -function d3_svg_lineMonotone(points) { - return points.length < 3 - ? d3_svg_lineLinear(points) - : points[0] + - d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); -} -d3.svg.line.radial = function() { - var line = d3_svg_line(d3_svg_lineRadial); - line.radius = line.x, delete line.x; - line.angle = line.y, delete line.y; - return line; -}; - -function d3_svg_lineRadial(points) { - var point, - i = -1, - n = points.length, - r, - a; - while (++i < n) { - point = points[i]; - r = point[0]; - a = point[1] + d3_svg_arcOffset; - point[0] = r * Math.cos(a); - point[1] = r * Math.sin(a); - } - return points; -} -function d3_svg_area(projection) { - var x0 = d3_svg_lineX, - x1 = d3_svg_lineX, - y0 = 0, - y1 = d3_svg_lineY, - interpolate = "linear", - interpolator = d3_svg_lineInterpolators[interpolate], - tension = .7; - - function area(d) { - if (d.length < 1) return null; - var points0 = d3_svg_linePoints(this, d, x0, y0), - points1 = d3_svg_linePoints(this, d, x0 === x1 ? d3_svg_areaX(points0) : x1, y0 === y1 ? d3_svg_areaY(points0) : y1); - return "M" + interpolator(projection(points1), tension) - + "L" + interpolator(projection(points0.reverse()), tension) - + "Z"; - } - - area.x = function(x) { - if (!arguments.length) return x1; - x0 = x1 = x; - return area; - }; - - area.x0 = function(x) { - if (!arguments.length) return x0; - x0 = x; - return area; - }; - - area.x1 = function(x) { - if (!arguments.length) return x1; - x1 = x; - return area; - }; - - area.y = function(y) { - if (!arguments.length) return y1; - y0 = y1 = y; - return area; - }; - - area.y0 = function(y) { - if (!arguments.length) return y0; - y0 = y; - return area; - }; - - area.y1 = function(y) { - if (!arguments.length) return y1; - y1 = y; - return area; - }; - - area.interpolate = function(x) { - if (!arguments.length) return interpolate; - interpolator = d3_svg_lineInterpolators[interpolate = x]; - return area; - }; - - area.tension = function(x) { - if (!arguments.length) return tension; - tension = x; - return area; - }; - - return area; -} - -d3.svg.area = function() { - return d3_svg_area(Object); -}; - -function d3_svg_areaX(points) { - return function(d, i) { - return points[i][0]; - }; -} - -function d3_svg_areaY(points) { - return function(d, i) { - return points[i][1]; - }; -} -d3.svg.area.radial = function() { - var area = d3_svg_area(d3_svg_lineRadial); - area.radius = area.x, delete area.x; - area.innerRadius = area.x0, delete area.x0; - area.outerRadius = area.x1, delete area.x1; - area.angle = area.y, delete area.y; - area.startAngle = area.y0, delete area.y0; - area.endAngle = area.y1, delete area.y1; - return area; -}; -d3.svg.chord = function() { - var source = d3_svg_chordSource, - target = d3_svg_chordTarget, - radius = d3_svg_chordRadius, - startAngle = d3_svg_arcStartAngle, - endAngle = d3_svg_arcEndAngle; - - // TODO Allow control point to be customized. - - function chord(d, i) { - var s = subgroup(this, source, d, i), - t = subgroup(this, target, d, i); - return "M" + s.p0 - + arc(s.r, s.p1) + (equals(s, t) - ? curve(s.r, s.p1, s.r, s.p0) - : curve(s.r, s.p1, t.r, t.p0) - + arc(t.r, t.p1) - + curve(t.r, t.p1, s.r, s.p0)) - + "Z"; - } - - function subgroup(self, f, d, i) { - var subgroup = f.call(self, d, i), - r = radius.call(self, subgroup, i), - a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, - a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset; - return { - r: r, - a0: a0, - a1: a1, - p0: [r * Math.cos(a0), r * Math.sin(a0)], - p1: [r * Math.cos(a1), r * Math.sin(a1)] - }; - } - - function equals(a, b) { - return a.a0 == b.a0 && a.a1 == b.a1; - } - - function arc(r, p) { - return "A" + r + "," + r + " 0 0,1 " + p; - } - - function curve(r0, p0, r1, p1) { - return "Q 0,0 " + p1; - } - - chord.radius = function(v) { - if (!arguments.length) return radius; - radius = d3.functor(v); - return chord; - }; - - chord.source = function(v) { - if (!arguments.length) return source; - source = d3.functor(v); - return chord; - }; - - chord.target = function(v) { - if (!arguments.length) return target; - target = d3.functor(v); - return chord; - }; - - chord.startAngle = function(v) { - if (!arguments.length) return startAngle; - startAngle = d3.functor(v); - return chord; - }; - - chord.endAngle = function(v) { - if (!arguments.length) return endAngle; - endAngle = d3.functor(v); - return chord; - }; - - return chord; -}; - -function d3_svg_chordSource(d) { - return d.source; -} - -function d3_svg_chordTarget(d) { - return d.target; -} - -function d3_svg_chordRadius(d) { - return d.radius; -} - -function d3_svg_chordStartAngle(d) { - return d.startAngle; -} - -function d3_svg_chordEndAngle(d) { - return d.endAngle; -} -d3.svg.diagonal = function() { - var source = d3_svg_chordSource, - target = d3_svg_chordTarget, - projection = d3_svg_diagonalProjection; - - function diagonal(d, i) { - var p0 = source.call(this, d, i), - p3 = target.call(this, d, i), - m = (p0.y + p3.y) / 2, - p = [p0, {x: p0.x, y: m}, {x: p3.x, y: m}, p3]; - p = p.map(projection); - return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; - } - - diagonal.source = function(x) { - if (!arguments.length) return source; - source = d3.functor(x); - return diagonal; - }; - - diagonal.target = function(x) { - if (!arguments.length) return target; - target = d3.functor(x); - return diagonal; - }; - - diagonal.projection = function(x) { - if (!arguments.length) return projection; - projection = x; - return diagonal; - }; - - return diagonal; -}; - -function d3_svg_diagonalProjection(d) { - return [d.x, d.y]; -} -d3.svg.diagonal.radial = function() { - var diagonal = d3.svg.diagonal(), - projection = d3_svg_diagonalProjection, - projection_ = diagonal.projection; - - diagonal.projection = function(x) { - return arguments.length - ? projection_(d3_svg_diagonalRadialProjection(projection = x)) - : projection; - }; - - return diagonal; -}; - -function d3_svg_diagonalRadialProjection(projection) { - return function() { - var d = projection.apply(this, arguments), - r = d[0], - a = d[1] + d3_svg_arcOffset; - return [r * Math.cos(a), r * Math.sin(a)]; - }; -} -d3.svg.mouse = function(container) { - return d3_svg_mousePoint(container, d3.event); -}; - -// https://bugs.webkit.org/show_bug.cgi?id=44083 -var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0; - -function d3_svg_mousePoint(container, e) { - var point = (container.ownerSVGElement || container).createSVGPoint(); - if ((d3_mouse_bug44083 < 0) && (window.scrollX || window.scrollY)) { - var svg = d3.select(document.body) - .append("svg:svg") - .style("position", "absolute") - .style("top", 0) - .style("left", 0); - var ctm = svg[0][0].getScreenCTM(); - d3_mouse_bug44083 = !(ctm.f || ctm.e); - svg.remove(); - } - if (d3_mouse_bug44083) { - point.x = e.pageX; - point.y = e.pageY; - } else { - point.x = e.clientX; - point.y = e.clientY; - } - point = point.matrixTransform(container.getScreenCTM().inverse()); - return [point.x, point.y]; -}; -d3.svg.touches = function(container) { - var touches = d3.event.touches; - return touches ? d3_array(touches).map(function(touch) { - var point = d3_svg_mousePoint(container, touch); - point.identifier = touch.identifier; - return point; - }) : []; -}; -d3.svg.symbol = function() { - var type = d3_svg_symbolType, - size = d3_svg_symbolSize; - - function symbol(d, i) { - return (d3_svg_symbols[type.call(this, d, i)] - || d3_svg_symbols.circle) - (size.call(this, d, i)); - } - - symbol.type = function(x) { - if (!arguments.length) return type; - type = d3.functor(x); - return symbol; - }; - - // size of symbol in square pixels - symbol.size = function(x) { - if (!arguments.length) return size; - size = d3.functor(x); - return symbol; - }; - - return symbol; -}; - -function d3_svg_symbolSize() { - return 64; -} - -function d3_svg_symbolType() { - return "circle"; -} - -// TODO cross-diagonal? -var d3_svg_symbols = { - "circle": function(size) { - var r = Math.sqrt(size / Math.PI); - return "M0," + r - + "A" + r + "," + r + " 0 1,1 0," + (-r) - + "A" + r + "," + r + " 0 1,1 0," + r - + "Z"; - }, - "cross": function(size) { - var r = Math.sqrt(size / 5) / 2; - return "M" + -3 * r + "," + -r - + "H" + -r - + "V" + -3 * r - + "H" + r - + "V" + -r - + "H" + 3 * r - + "V" + r - + "H" + r - + "V" + 3 * r - + "H" + -r - + "V" + r - + "H" + -3 * r - + "Z"; - }, - "diamond": function(size) { - var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), - rx = ry * d3_svg_symbolTan30; - return "M0," + -ry - + "L" + rx + ",0" - + " 0," + ry - + " " + -rx + ",0" - + "Z"; - }, - "square": function(size) { - var r = Math.sqrt(size) / 2; - return "M" + -r + "," + -r - + "L" + r + "," + -r - + " " + r + "," + r - + " " + -r + "," + r - + "Z"; - }, - "triangle-down": function(size) { - var rx = Math.sqrt(size / d3_svg_symbolSqrt3), - ry = rx * d3_svg_symbolSqrt3 / 2; - return "M0," + ry - + "L" + rx +"," + -ry - + " " + -rx + "," + -ry - + "Z"; - }, - "triangle-up": function(size) { - var rx = Math.sqrt(size / d3_svg_symbolSqrt3), - ry = rx * d3_svg_symbolSqrt3 / 2; - return "M0," + -ry - + "L" + rx +"," + ry - + " " + -rx + "," + ry - + "Z"; - } -}; - -d3.svg.symbolTypes = d3.keys(d3_svg_symbols); - -var d3_svg_symbolSqrt3 = Math.sqrt(3), - d3_svg_symbolTan30 = Math.tan(30 * Math.PI / 180); -})(); diff --git a/client/js/d3/d3.layout.js b/client/js/d3/d3.layout.js deleted file mode 100755 index 3d854ed6..00000000 --- a/client/js/d3/d3.layout.js +++ /dev/null @@ -1,1923 +0,0 @@ -(function(){d3.layout = {}; -// Implements hierarchical edge bundling using Holten's algorithm. For each -// input link, a path is computed that travels through the tree, up the parent -// hierarchy to the least common ancestor, and then back down to the destination -// node. Each path is simply an array of nodes. -d3.layout.bundle = function() { - return function(links) { - var paths = [], - i = -1, - n = links.length; - while (++i < n) paths.push(d3_layout_bundlePath(links[i])); - return paths; - }; -}; - -function d3_layout_bundlePath(link) { - var start = link.source, - end = link.target, - lca = d3_layout_bundleLeastCommonAncestor(start, end), - points = [start]; - while (start !== lca) { - start = start.parent; - points.push(start); - } - var k = points.length; - while (end !== lca) { - points.splice(k, 0, end); - end = end.parent; - } - return points; -} - -function d3_layout_bundleAncestors(node) { - var ancestors = [], - parent = node.parent; - while (parent != null) { - ancestors.push(node); - node = parent; - parent = parent.parent; - } - ancestors.push(node); - return ancestors; -} - -function d3_layout_bundleLeastCommonAncestor(a, b) { - if (a === b) return a; - var aNodes = d3_layout_bundleAncestors(a), - bNodes = d3_layout_bundleAncestors(b), - aNode = aNodes.pop(), - bNode = bNodes.pop(), - sharedNode = null; - while (aNode === bNode) { - sharedNode = aNode; - aNode = aNodes.pop(); - bNode = bNodes.pop(); - } - return sharedNode; -} -d3.layout.chord = function() { - var chord = {}, - chords, - groups, - matrix, - n, - padding = 0, - sortGroups, - sortSubgroups, - sortChords; - - function relayout() { - var subgroups = {}, - groupSums = [], - groupIndex = d3.range(n), - subgroupIndex = [], - k, - x, - x0, - i, - j; - - chords = []; - groups = []; - - // Compute the sum. - k = 0, i = -1; while (++i < n) { - x = 0, j = -1; while (++j < n) { - x += matrix[i][j]; - } - groupSums.push(x); - subgroupIndex.push(d3.range(n)); - k += x; - } - - // Sort groups… - if (sortGroups) { - groupIndex.sort(function(a, b) { - return sortGroups(groupSums[a], groupSums[b]); - }); - } - - // Sort subgroups… - if (sortSubgroups) { - subgroupIndex.forEach(function(d, i) { - d.sort(function(a, b) { - return sortSubgroups(matrix[i][a], matrix[i][b]); - }); - }); - } - - // Convert the sum to scaling factor for [0, 2pi]. - // TODO Allow start and end angle to be specified. - // TODO Allow padding to be specified as percentage? - k = (2 * Math.PI - padding * n) / k; - - // Compute the start and end angle for each group and subgroup. - x = 0, i = -1; while (++i < n) { - x0 = x, j = -1; while (++j < n) { - var di = groupIndex[i], - dj = subgroupIndex[i][j], - v = matrix[di][dj]; - subgroups[di + "-" + dj] = { - index: di, - subindex: dj, - startAngle: x, - endAngle: x += v * k, - value: v - }; - } - groups.push({ - index: di, - startAngle: x0, - endAngle: x, - value: (x - x0) / k - }); - x += padding; - } - - // Generate chords for each (non-empty) subgroup-subgroup link. - i = -1; while (++i < n) { - j = i - 1; while (++j < n) { - var source = subgroups[i + "-" + j], - target = subgroups[j + "-" + i]; - if (source.value || target.value) { - chords.push(source.value < target.value - ? {source: target, target: source} - : {source: source, target: target}) - } - } - } - - if (sortChords) resort(); - } - - function resort() { - chords.sort(function(a, b) { - return sortChords(a.target.value, b.target.value); - }); - } - - chord.matrix = function(x) { - if (!arguments.length) return matrix; - n = (matrix = x) && matrix.length; - chords = groups = null; - return chord; - }; - - chord.padding = function(x) { - if (!arguments.length) return padding; - padding = x; - chords = groups = null; - return chord; - }; - - chord.sortGroups = function(x) { - if (!arguments.length) return sortGroups; - sortGroups = x; - chords = groups = null; - return chord; - }; - - chord.sortSubgroups = function(x) { - if (!arguments.length) return sortSubgroups; - sortSubgroups = x; - chords = null; - return chord; - }; - - chord.sortChords = function(x) { - if (!arguments.length) return sortChords; - sortChords = x; - if (chords) resort(); - return chord; - }; - - chord.chords = function() { - if (!chords) relayout(); - return chords; - }; - - chord.groups = function() { - if (!groups) relayout(); - return groups; - }; - - return chord; -}; -// A rudimentary force layout using Gauss-Seidel. -d3.layout.force = function() { - var force = {}, - event = d3.dispatch("tick"), - size = [1, 1], - alpha, - friction = .9, - linkDistance = d3_layout_forceLinkDistance, - linkStrength = d3_layout_forceLinkStrength, - charge = -30, - gravity = .1, - theta = .8, - interval, - nodes = [], - links = [], - distances, - strengths; - - function repulse(node, kc) { - return function(quad, x1, y1, x2, y2) { - if (quad.point !== node) { - var dx = quad.cx - node.x, - dy = quad.cy - node.y, - dn = 1 / Math.sqrt(dx * dx + dy * dy); - - /* Barnes-Hut criterion. */ - if ((x2 - x1) * dn < theta) { - var k = kc * quad.count * dn * dn; - node.x += dx * k; - node.y += dy * k; - return true; - } - - if (quad.point && isFinite(dn)) { - var k = kc * dn * dn; - node.x += dx * k; - node.y += dy * k; - } - } - }; - } - - function tick() { - var n = nodes.length, - m = links.length, - q = d3.geom.quadtree(nodes), - i, // current index - o, // current object - s, // current source - t, // current target - l, // current distance - x, // x-distance - y; // y-distance - - // gauss-seidel relaxation for links - for (i = 0; i < m; ++i) { - o = links[i]; - s = o.source; - t = o.target; - x = t.x - s.x; - y = t.y - s.y; - if (l = (x * x + y * y)) { - l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; - x *= l; - y *= l; - t.x -= x; - t.y -= y; - s.x += x; - s.y += y; - } - } - - // apply gravity forces - var kg = alpha * gravity; - x = size[0] / 2; - y = size[1] / 2; - i = -1; while (++i < n) { - o = nodes[i]; - o.x += (x - o.x) * kg; - o.y += (y - o.y) * kg; - } - - // compute quadtree center of mass - d3_layout_forceAccumulate(q); - - // apply charge forces - var kc = alpha * charge; - i = -1; while (++i < n) { - q.visit(repulse(nodes[i], kc)); - } - - // position verlet integration - i = -1; while (++i < n) { - o = nodes[i]; - if (o.fixed) { - o.x = o.px; - o.y = o.py; - } else { - o.x -= (o.px - (o.px = o.x)) * friction; - o.y -= (o.py - (o.py = o.y)) * friction; - } - } - - event.tick.dispatch({type: "tick", alpha: alpha}); - - // simulated annealing, basically - return (alpha *= .99) < .005; - } - - force.on = function(type, listener) { - event[type].add(listener); - return force; - }; - - force.nodes = function(x) { - if (!arguments.length) return nodes; - nodes = x; - return force; - }; - - force.links = function(x) { - if (!arguments.length) return links; - links = x; - return force; - }; - - force.size = function(x) { - if (!arguments.length) return size; - size = x; - return force; - }; - - force.linkDistance = function(x) { - if (!arguments.length) return linkDistance; - linkDistance = d3.functor(x); - return force; - }; - - // For backwards-compatibility. - force.distance = force.linkDistance; - - force.linkStrength = function(x) { - if (!arguments.length) return linkStrength; - linkStrength = d3.functor(x); - return force; - }; - - force.friction = function(x) { - if (!arguments.length) return friction; - friction = x; - return force; - }; - - force.charge = function(x) { - if (!arguments.length) return charge; - charge = x; - return force; - }; - - force.gravity = function(x) { - if (!arguments.length) return gravity; - gravity = x; - return force; - }; - - force.theta = function(x) { - if (!arguments.length) return theta; - theta = x; - return force; - }; - - force.start = function() { - var i, - j, - n = nodes.length, - m = links.length, - w = size[0], - h = size[1], - neighbors, - o; - - for (i = 0; i < n; ++i) { - (o = nodes[i]).index = i; - } - - distances = []; - strengths = []; - for (i = 0; i < m; ++i) { - o = links[i]; - if (typeof o.source == "number") o.source = nodes[o.source]; - if (typeof o.target == "number") o.target = nodes[o.target]; - distances[i] = linkDistance.call(this, o, i); - strengths[i] = linkStrength.call(this, o, i); - } - - for (i = 0; i < n; ++i) { - o = nodes[i]; - if (isNaN(o.x)) o.x = position("x", w); - if (isNaN(o.y)) o.y = position("y", h); - if (isNaN(o.px)) o.px = o.x; - if (isNaN(o.py)) o.py = o.y; - } - - // initialize node position based on first neighbor - function position(dimension, size) { - var neighbors = neighbor(i), - j = -1, - m = neighbors.length, - x; - while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x; - return Math.random() * size; - } - - // initialize neighbors lazily - function neighbor() { - if (!neighbors) { - neighbors = []; - for (j = 0; j < n; ++j) { - neighbors[j] = []; - } - for (j = 0; j < m; ++j) { - var o = links[j]; - neighbors[o.source.index].push(o.target); - neighbors[o.target.index].push(o.source); - } - } - return neighbors[i]; - } - - return force.resume(); - }; - - force.resume = function() { - alpha = .1; - d3.timer(tick); - return force; - }; - - force.stop = function() { - alpha = 0; - return force; - }; - - // use `node.call(force.drag)` to make nodes draggable - force.drag = function() { - - this - .on("mouseover.force", d3_layout_forceDragOver) - .on("mouseout.force", d3_layout_forceDragOut) - .on("mousedown.force", dragdown) - .on("touchstart.force", dragdown); - - d3.select(window) - .on("mousemove.force", d3_layout_forceDragMove) - .on("touchmove.force", d3_layout_forceDragMove) - .on("mouseup.force", d3_layout_forceDragUp, true) - .on("touchend.force", d3_layout_forceDragUp, true) - .on("click.force", d3_layout_forceDragClick, true); - - return force; - }; - - function dragdown(d, i) { - var m = d3_layout_forcePoint(this.parentNode); - (d3_layout_forceDragNode = d).fixed = true; - d3_layout_forceDragMoved = false; - d3_layout_forceDragElement = this; - d3_layout_forceDragForce = force; - d3_layout_forceDragOffset = [m[0] - d.x, m[1] - d.y]; - d3_layout_forceCancel(); - } - - return force; -}; - -var d3_layout_forceDragForce, - d3_layout_forceDragNode, - d3_layout_forceDragMoved, - d3_layout_forceDragOffset, - d3_layout_forceStopClick, - d3_layout_forceDragElement; - -function d3_layout_forceDragOver(d) { - d.fixed = true; -} - -function d3_layout_forceDragOut(d) { - if (d !== d3_layout_forceDragNode) { - d.fixed = false; - } -} - -function d3_layout_forcePoint(container) { - return d3.event.touches - ? d3.svg.touches(container)[0] - : d3.svg.mouse(container); -} - -function d3_layout_forceDragMove() { - if (!d3_layout_forceDragNode) return; - var parent = d3_layout_forceDragElement.parentNode; - - // O NOES! The drag element was removed from the DOM. - if (!parent) { - d3_layout_forceDragNode.fixed = false; - d3_layout_forceDragOffset = d3_layout_forceDragNode = d3_layout_forceDragElement = null; - return; - } - - var m = d3_layout_forcePoint(parent); - d3_layout_forceDragMoved = true; - d3_layout_forceDragNode.px = m[0] - d3_layout_forceDragOffset[0]; - d3_layout_forceDragNode.py = m[1] - d3_layout_forceDragOffset[1]; - d3_layout_forceCancel(); - d3_layout_forceDragForce.resume(); // restart annealing -} - -function d3_layout_forceDragUp() { - if (!d3_layout_forceDragNode) return; - - // If the node was moved, prevent the mouseup from propagating. - // Also prevent the subsequent click from propagating (e.g., for anchors). - if (d3_layout_forceDragMoved) { - d3_layout_forceStopClick = true; - d3_layout_forceCancel(); - } - - // Don't trigger this for touchend. - if (d3.event.type === "mouseup") { - d3_layout_forceDragMove(); - } - - d3_layout_forceDragNode.fixed = false; - d3_layout_forceDragForce = - d3_layout_forceDragOffset = - d3_layout_forceDragNode = - d3_layout_forceDragElement = null; -} - -function d3_layout_forceDragClick() { - if (d3_layout_forceStopClick) { - d3_layout_forceCancel(); - d3_layout_forceStopClick = false; - } -} - -function d3_layout_forceCancel() { - d3.event.stopPropagation(); - d3.event.preventDefault(); -} - -function d3_layout_forceAccumulate(quad) { - var cx = 0, - cy = 0; - quad.count = 0; - if (!quad.leaf) { - var nodes = quad.nodes, - n = nodes.length, - i = -1, - c; - while (++i < n) { - c = nodes[i]; - if (c == null) continue; - d3_layout_forceAccumulate(c); - quad.count += c.count; - cx += c.count * c.cx; - cy += c.count * c.cy; - } - } - if (quad.point) { - // jitter internal nodes that are coincident - if (!quad.leaf) { - quad.point.x += Math.random() - .5; - quad.point.y += Math.random() - .5; - } - quad.count++; - cx += quad.point.x; - cy += quad.point.y; - } - quad.cx = cx / quad.count; - quad.cy = cy / quad.count; -} - -function d3_layout_forceLinkDistance(link) { - return 20; -} - -function d3_layout_forceLinkStrength(link) { - return 1; -} -d3.layout.partition = function() { - var hierarchy = d3.layout.hierarchy(), - size = [1, 1]; // width, height - - function position(node, x, dx, dy) { - var children = node.children; - node.x = x; - node.y = node.depth * dy; - node.dx = dx; - node.dy = dy; - if (children) { - var i = -1, - n = children.length, - c, - d; - dx = node.value ? dx / node.value : 0; - while (++i < n) { - position(c = children[i], x, d = c.value * dx, dy); - x += d; - } - } - } - - function depth(node) { - var children = node.children, - d = 0; - if (children) { - var i = -1, - n = children.length; - while (++i < n) d = Math.max(d, depth(children[i])); - } - return 1 + d; - } - - function partition(d, i) { - var nodes = hierarchy.call(this, d, i); - position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); - return nodes; - } - - partition.size = function(x) { - if (!arguments.length) return size; - size = x; - return partition; - }; - - return d3_layout_hierarchyRebind(partition, hierarchy); -}; -d3.layout.pie = function() { - var value = Number, - sort = null, - startAngle = 0, - endAngle = 2 * Math.PI; - - function pie(data, i) { - - // Compute the start angle. - var a = +(typeof startAngle === "function" - ? startAngle.apply(this, arguments) - : startAngle); - - // Compute the angular range (end - start). - var k = (typeof endAngle === "function" - ? endAngle.apply(this, arguments) - : endAngle) - startAngle; - - // Optionally sort the data. - var index = d3.range(data.length); - if (sort != null) index.sort(function(i, j) { - return sort(data[i], data[j]); - }); - - // Compute the numeric values for each data element. - var values = data.map(value); - - // Convert k into a scale factor from value to angle, using the sum. - k /= values.reduce(function(p, d) { return p + d; }, 0); - - // Compute the arcs! - var arcs = index.map(function(i) { - return { - data: data[i], - value: d = values[i], - startAngle: a, - endAngle: a += d * k - }; - }); - - // Return the arcs in the original data's order. - return data.map(function(d, i) { - return arcs[index[i]]; - }); - } - - /** - * Specifies the value function *x*, which returns a nonnegative numeric value - * for each datum. The default value function is `Number`. The value function - * is passed two arguments: the current datum and the current index. - */ - pie.value = function(x) { - if (!arguments.length) return value; - value = x; - return pie; - }; - - /** - * Specifies a sort comparison operator *x*. The comparator is passed two data - * elements from the data array, a and b; it returns a negative value if a is - * less than b, a positive value if a is greater than b, and zero if a equals - * b. - */ - pie.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return pie; - }; - - /** - * Specifies the overall start angle of the pie chart. Defaults to 0. The - * start angle can be specified either as a constant or as a function; in the - * case of a function, it is evaluated once per array (as opposed to per - * element). - */ - pie.startAngle = function(x) { - if (!arguments.length) return startAngle; - startAngle = x; - return pie; - }; - - /** - * Specifies the overall end angle of the pie chart. Defaults to 2π. The - * end angle can be specified either as a constant or as a function; in the - * case of a function, it is evaluated once per array (as opposed to per - * element). - */ - pie.endAngle = function(x) { - if (!arguments.length) return endAngle; - endAngle = x; - return pie; - }; - - return pie; -}; -// data is two-dimensional array of x,y; we populate y0 -d3.layout.stack = function() { - var values = Object, - order = d3_layout_stackOrders["default"], - offset = d3_layout_stackOffsets["zero"], - out = d3_layout_stackOut, - x = d3_layout_stackX, - y = d3_layout_stackY; - - function stack(data, index) { - - // Convert series to canonical two-dimensional representation. - var series = data.map(function(d, i) { - return values.call(stack, d, i); - }); - - // Convert each series to canonical [[x,y]] representation. - var points = series.map(function(d, i) { - return d.map(function(v, i) { - return [x.call(stack, v, i), y.call(stack, v, i)]; - }); - }); - - // Compute the order of series, and permute them. - var orders = order.call(stack, points, index); - series = d3.permute(series, orders); - points = d3.permute(points, orders); - - // Compute the baseline… - var offsets = offset.call(stack, points, index); - - // And propagate it to other series. - var n = series.length, - m = series[0].length, - i, - j, - o; - for (j = 0; j < m; ++j) { - out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); - for (i = 1; i < n; ++i) { - out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); - } - } - - return data; - } - - stack.values = function(x) { - if (!arguments.length) return values; - values = x; - return stack; - }; - - stack.order = function(x) { - if (!arguments.length) return order; - order = typeof x === "function" ? x : d3_layout_stackOrders[x]; - return stack; - }; - - stack.offset = function(x) { - if (!arguments.length) return offset; - offset = typeof x === "function" ? x : d3_layout_stackOffsets[x]; - return stack; - }; - - stack.x = function(z) { - if (!arguments.length) return x; - x = z; - return stack; - }; - - stack.y = function(z) { - if (!arguments.length) return y; - y = z; - return stack; - }; - - stack.out = function(z) { - if (!arguments.length) return out; - out = z; - return stack; - }; - - return stack; -} - -function d3_layout_stackX(d) { - return d.x; -} - -function d3_layout_stackY(d) { - return d.y; -} - -function d3_layout_stackOut(d, y0, y) { - d.y0 = y0; - d.y = y; -} - -var d3_layout_stackOrders = { - - "inside-out": function(data) { - var n = data.length, - i, - j, - max = data.map(d3_layout_stackMaxIndex), - sums = data.map(d3_layout_stackReduceSum), - index = d3.range(n).sort(function(a, b) { return max[a] - max[b]; }), - top = 0, - bottom = 0, - tops = [], - bottoms = []; - for (i = 0; i < n; ++i) { - j = index[i]; - if (top < bottom) { - top += sums[j]; - tops.push(j); - } else { - bottom += sums[j]; - bottoms.push(j); - } - } - return bottoms.reverse().concat(tops); - }, - - "reverse": function(data) { - return d3.range(data.length).reverse(); - }, - - "default": function(data) { - return d3.range(data.length); - } - -}; - -var d3_layout_stackOffsets = { - - "silhouette": function(data) { - var n = data.length, - m = data[0].length, - sums = [], - max = 0, - i, - j, - o, - y0 = []; - for (j = 0; j < m; ++j) { - for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; - if (o > max) max = o; - sums.push(o); - } - for (j = 0; j < m; ++j) { - y0[j] = (max - sums[j]) / 2; - } - return y0; - }, - - "wiggle": function(data) { - var n = data.length, - x = data[0], - m = x.length, - max = 0, - i, - j, - k, - s1, - s2, - s3, - dx, - o, - o0, - y0 = []; - y0[0] = o = o0 = 0; - for (j = 1; j < m; ++j) { - for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; - for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { - for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { - s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; - } - s2 += s3 * data[i][j][1]; - } - y0[j] = o -= s1 ? s2 / s1 * dx : 0; - if (o < o0) o0 = o; - } - for (j = 0; j < m; ++j) y0[j] -= o0; - return y0; - }, - - "expand": function(data) { - var n = data.length, - m = data[0].length, - k = 1 / n, - i, - j, - o, - y0 = []; - for (j = 0; j < m; ++j) { - for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; - if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; - else for (i = 0; i < n; i++) data[i][j][1] = k; - } - for (j = 0; j < m; ++j) y0[j] = 0; - return y0; - }, - - "zero": function(data) { - var j = -1, - m = data[0].length, - y0 = []; - while (++j < m) y0[j] = 0; - return y0; - } - -}; - -function d3_layout_stackMaxIndex(array) { - var i = 1, - j = 0, - v = array[0][1], - k, - n = array.length; - for (; i < n; ++i) { - if ((k = array[i][1]) > v) { - j = i; - v = k; - } - } - return j; -} - -function d3_layout_stackReduceSum(d) { - return d.reduce(d3_layout_stackSum, 0); -} - -function d3_layout_stackSum(p, d) { - return p + d[1]; -} -d3.layout.histogram = function() { - var frequency = true, - valuer = Number, - ranger = d3_layout_histogramRange, - binner = d3_layout_histogramBinSturges; - - function histogram(data, i) { - var bins = [], - values = data.map(valuer, this), - range = ranger.call(this, values, i), - thresholds = binner.call(this, range, values, i), - bin, - i = -1, - n = values.length, - m = thresholds.length - 1, - k = frequency ? 1 : 1 / n, - x; - - // Initialize the bins. - while (++i < m) { - bin = bins[i] = []; - bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); - bin.y = 0; - } - - // Fill the bins, ignoring values outside the range. - i = -1; while(++i < n) { - x = values[i]; - if ((x >= range[0]) && (x <= range[1])) { - bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; - bin.y += k; - bin.push(data[i]); - } - } - - return bins; - } - - // Specifies how to extract a value from the associated data. The default - // value function is `Number`, which is equivalent to the identity function. - histogram.value = function(x) { - if (!arguments.length) return valuer; - valuer = x; - return histogram; - }; - - // Specifies the range of the histogram. Values outside the specified range - // will be ignored. The argument `x` may be specified either as a two-element - // array representing the minimum and maximum value of the range, or as a - // function that returns the range given the array of values and the current - // index `i`. The default range is the extent (minimum and maximum) of the - // values. - histogram.range = function(x) { - if (!arguments.length) return ranger; - ranger = d3.functor(x); - return histogram; - }; - - // Specifies how to bin values in the histogram. The argument `x` may be - // specified as a number, in which case the range of values will be split - // uniformly into the given number of bins. Or, `x` may be an array of - // threshold values, defining the bins; the specified array must contain the - // rightmost (upper) value, thus specifying n + 1 values for n bins. Or, `x` - // may be a function which is evaluated, being passed the range, the array of - // values, and the current index `i`, returning an array of thresholds. The - // default bin function will divide the values into uniform bins using - // Sturges' formula. - histogram.bins = function(x) { - if (!arguments.length) return binner; - binner = typeof x === "number" - ? function(range) { return d3_layout_histogramBinFixed(range, x); } - : d3.functor(x); - return histogram; - }; - - // Specifies whether the histogram's `y` value is a count (frequency) or a - // probability (density). The default value is true. - histogram.frequency = function(x) { - if (!arguments.length) return frequency; - frequency = !!x; - return histogram; - }; - - return histogram; -}; - -function d3_layout_histogramBinSturges(range, values) { - return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); -} - -function d3_layout_histogramBinFixed(range, n) { - var x = -1, - b = +range[0], - m = (range[1] - b) / n, - f = []; - while (++x <= n) f[x] = m * x + b; - return f; -} - -function d3_layout_histogramRange(values) { - return [d3.min(values), d3.max(values)]; -} -d3.layout.hierarchy = function() { - var sort = d3_layout_hierarchySort, - children = d3_layout_hierarchyChildren, - value = d3_layout_hierarchyValue; - - // Recursively compute the node depth and value. - // Also converts the data representation into a standard hierarchy structure. - function recurse(data, depth, nodes) { - var childs = children.call(hierarchy, data, depth), - node = d3_layout_hierarchyInline ? data : {data: data}; - node.depth = depth; - nodes.push(node); - if (childs) { - var i = -1, - n = childs.length, - c = node.children = [], - v = 0, - j = depth + 1; - while (++i < n) { - d = recurse(childs[i], j, nodes); - d.parent = node; - c.push(d); - v += d.value; - } - if (sort) c.sort(sort); - if (value) node.value = v; - } else if (value) { - node.value = +value.call(hierarchy, data, depth) || 0; - } - return node; - } - - // Recursively re-evaluates the node value. - function revalue(node, depth) { - var children = node.children, - v = 0; - if (children) { - var i = -1, - n = children.length, - j = depth + 1; - while (++i < n) v += revalue(children[i], j); - } else if (value) { - v = +value.call(hierarchy, d3_layout_hierarchyInline ? node : node.data, depth) || 0; - } - if (value) node.value = v; - return v; - } - - function hierarchy(d) { - var nodes = []; - recurse(d, 0, nodes); - return nodes; - } - - hierarchy.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return hierarchy; - }; - - hierarchy.children = function(x) { - if (!arguments.length) return children; - children = x; - return hierarchy; - }; - - hierarchy.value = function(x) { - if (!arguments.length) return value; - value = x; - return hierarchy; - }; - - // Re-evaluates the `value` property for the specified hierarchy. - hierarchy.revalue = function(root) { - revalue(root, 0); - return root; - }; - - return hierarchy; -}; - -// A method assignment helper for hierarchy subclasses. -function d3_layout_hierarchyRebind(object, hierarchy) { - object.sort = d3.rebind(object, hierarchy.sort); - object.children = d3.rebind(object, hierarchy.children); - object.links = d3_layout_hierarchyLinks; - object.value = d3.rebind(object, hierarchy.value); - - // If the new API is used, enabling inlining. - object.nodes = function(d) { - d3_layout_hierarchyInline = true; - return (object.nodes = object)(d); - }; - - return object; -} - -function d3_layout_hierarchyChildren(d) { - return d.children; -} - -function d3_layout_hierarchyValue(d) { - return d.value; -} - -function d3_layout_hierarchySort(a, b) { - return b.value - a.value; -} - -// Returns an array source+target objects for the specified nodes. -function d3_layout_hierarchyLinks(nodes) { - return d3.merge(nodes.map(function(parent) { - return (parent.children || []).map(function(child) { - return {source: parent, target: child}; - }); - })); -} - -// For backwards-compatibility, don't enable inlining by default. -var d3_layout_hierarchyInline = false; -d3.layout.pack = function() { - var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), - size = [1, 1]; - - function pack(d, i) { - var nodes = hierarchy.call(this, d, i), - root = nodes[0]; - - // Recursively compute the layout. - root.x = 0; - root.y = 0; - d3_layout_packTree(root); - - // Scale the layout to fit the requested size. - var w = size[0], - h = size[1], - k = 1 / Math.max(2 * root.r / w, 2 * root.r / h); - d3_layout_packTransform(root, w / 2, h / 2, k); - - return nodes; - } - - pack.size = function(x) { - if (!arguments.length) return size; - size = x; - return pack; - }; - - return d3_layout_hierarchyRebind(pack, hierarchy); -}; - -function d3_layout_packSort(a, b) { - return a.value - b.value; -} - -function d3_layout_packInsert(a, b) { - var c = a._pack_next; - a._pack_next = b; - b._pack_prev = a; - b._pack_next = c; - c._pack_prev = b; -} - -function d3_layout_packSplice(a, b) { - a._pack_next = b; - b._pack_prev = a; -} - -function d3_layout_packIntersects(a, b) { - var dx = b.x - a.x, - dy = b.y - a.y, - dr = a.r + b.r; - return (dr * dr - dx * dx - dy * dy) > .001; // within epsilon -} - -function d3_layout_packCircle(nodes) { - var xMin = Infinity, - xMax = -Infinity, - yMin = Infinity, - yMax = -Infinity, - n = nodes.length, - a, b, c, j, k; - - function bound(node) { - xMin = Math.min(node.x - node.r, xMin); - xMax = Math.max(node.x + node.r, xMax); - yMin = Math.min(node.y - node.r, yMin); - yMax = Math.max(node.y + node.r, yMax); - } - - // Create node links. - nodes.forEach(d3_layout_packLink); - - // Create first node. - a = nodes[0]; - a.x = -a.r; - a.y = 0; - bound(a); - - // Create second node. - if (n > 1) { - b = nodes[1]; - b.x = b.r; - b.y = 0; - bound(b); - - // Create third node and build chain. - if (n > 2) { - c = nodes[2]; - d3_layout_packPlace(a, b, c); - bound(c); - d3_layout_packInsert(a, c); - a._pack_prev = c; - d3_layout_packInsert(c, b); - b = a._pack_next; - - // Now iterate through the rest. - for (var i = 3; i < n; i++) { - d3_layout_packPlace(a, b, c = nodes[i]); - - // Search for the closest intersection. - var isect = 0, s1 = 1, s2 = 1; - for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { - if (d3_layout_packIntersects(j, c)) { - isect = 1; - break; - } - } - if (isect == 1) { - for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { - if (d3_layout_packIntersects(k, c)) { - if (s2 < s1) { - isect = -1; - j = k; - } - break; - } - } - } - - // Update node chain. - if (isect == 0) { - d3_layout_packInsert(a, c); - b = c; - bound(c); - } else if (isect > 0) { - d3_layout_packSplice(a, j); - b = j; - i--; - } else { // isect < 0 - d3_layout_packSplice(j, b); - a = j; - i--; - } - } - } - } - - // Re-center the circles and return the encompassing radius. - var cx = (xMin + xMax) / 2, - cy = (yMin + yMax) / 2, - cr = 0; - for (var i = 0; i < n; i++) { - var node = nodes[i]; - node.x -= cx; - node.y -= cy; - cr = Math.max(cr, node.r + Math.sqrt(node.x * node.x + node.y * node.y)); - } - - // Remove node links. - nodes.forEach(d3_layout_packUnlink); - - return cr; -} - -function d3_layout_packLink(node) { - node._pack_next = node._pack_prev = node; -} - -function d3_layout_packUnlink(node) { - delete node._pack_next; - delete node._pack_prev; -} - -function d3_layout_packTree(node) { - var children = node.children; - if (children) { - children.forEach(d3_layout_packTree); - node.r = d3_layout_packCircle(children); - } else { - node.r = Math.sqrt(node.value); - } -} - -function d3_layout_packTransform(node, x, y, k) { - var children = node.children; - node.x = (x += k * node.x); - node.y = (y += k * node.y); - node.r *= k; - if (children) { - var i = -1, n = children.length; - while (++i < n) d3_layout_packTransform(children[i], x, y, k); - } -} - -function d3_layout_packPlace(a, b, c) { - var da = b.r + c.r, - db = a.r + c.r, - dx = b.x - a.x, - dy = b.y - a.y, - dc = Math.sqrt(dx * dx + dy * dy), - cos = (db * db + dc * dc - da * da) / (2 * db * dc), - theta = Math.acos(cos), - x = cos * db, - h = Math.sin(theta) * db; - dx /= dc; - dy /= dc; - c.x = a.x + x * dx + h * dy; - c.y = a.y + x * dy - h * dx; -} -// Implements a hierarchical layout using the cluster (or dendogram) algorithm. -d3.layout.cluster = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), - separation = d3_layout_treeSeparation, - size = [1, 1]; // width, height - - function cluster(d, i) { - var nodes = hierarchy.call(this, d, i), - root = nodes[0], - previousNode, - x = 0, - kx, - ky; - - // First walk, computing the initial x & y values. - d3_layout_treeVisitAfter(root, function(node) { - if (node.children) { - node.x = d3_layout_clusterX(node.children); - node.y = d3_layout_clusterY(node.children); - } else { - node.x = previousNode ? x += separation(node, previousNode) : 0; - node.y = 0; - previousNode = node; - } - }); - - // Compute the left-most, right-most, and depth-most nodes for extents. - var left = d3_layout_clusterLeft(root), - right = d3_layout_clusterRight(root), - x0 = left.x - separation(left, right) / 2, - x1 = right.x + separation(right, left) / 2; - - // Second walk, normalizing x & y to the desired size. - d3_layout_treeVisitAfter(root, function(node) { - node.x = (node.x - x0) / (x1 - x0) * size[0]; - node.y = (1 - node.y / root.y) * size[1]; - }); - - return nodes; - } - - cluster.separation = function(x) { - if (!arguments.length) return separation; - separation = x; - return cluster; - }; - - cluster.size = function(x) { - if (!arguments.length) return size; - size = x; - return cluster; - }; - - return d3_layout_hierarchyRebind(cluster, hierarchy); -}; - -function d3_layout_clusterY(children) { - return 1 + d3.max(children, function(child) { - return child.y; - }); -} - -function d3_layout_clusterX(children) { - return children.reduce(function(x, child) { - return x + child.x; - }, 0) / children.length; -} - -function d3_layout_clusterLeft(node) { - var children = node.children; - return children ? d3_layout_clusterLeft(children[0]) : node; -} - -function d3_layout_clusterRight(node) { - var children = node.children; - return children ? d3_layout_clusterRight(children[children.length - 1]) : node; -} -// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm -d3.layout.tree = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), - separation = d3_layout_treeSeparation, - size = [1, 1]; // width, height - - function tree(d, i) { - var nodes = hierarchy.call(this, d, i), - root = nodes[0]; - - function firstWalk(node, previousSibling) { - var children = node.children, - layout = node._tree; - if (children) { - var n = children.length, - firstChild = children[0], - previousChild, - ancestor = firstChild, - child, - i = -1; - while (++i < n) { - child = children[i]; - firstWalk(child, previousChild); - ancestor = apportion(child, previousChild, ancestor); - previousChild = child; - } - d3_layout_treeShift(node); - var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim); - if (previousSibling) { - layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); - layout.mod = layout.prelim - midpoint; - } else { - layout.prelim = midpoint; - } - } else { - if (previousSibling) { - layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); - } - } - } - - function secondWalk(node, x) { - node.x = node._tree.prelim + x; - var children = node.children; - if (children) { - var i = -1, - n = children.length; - x += node._tree.mod; - while (++i < n) { - secondWalk(children[i], x); - } - } - } - - function apportion(node, previousSibling, ancestor) { - if (previousSibling) { - var vip = node, - vop = node, - vim = previousSibling, - vom = node.parent.children[0], - sip = vip._tree.mod, - sop = vop._tree.mod, - sim = vim._tree.mod, - som = vom._tree.mod, - shift; - while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { - vom = d3_layout_treeLeft(vom); - vop = d3_layout_treeRight(vop); - vop._tree.ancestor = node; - shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip); - if (shift > 0) { - d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift); - sip += shift; - sop += shift; - } - sim += vim._tree.mod; - sip += vip._tree.mod; - som += vom._tree.mod; - sop += vop._tree.mod; - } - if (vim && !d3_layout_treeRight(vop)) { - vop._tree.thread = vim; - vop._tree.mod += sim - sop; - } - if (vip && !d3_layout_treeLeft(vom)) { - vom._tree.thread = vip; - vom._tree.mod += sip - som; - ancestor = node; - } - } - return ancestor; - } - - // Initialize temporary layout variables. - d3_layout_treeVisitAfter(root, function(node, previousSibling) { - node._tree = { - ancestor: node, - prelim: 0, - mod: 0, - change: 0, - shift: 0, - number: previousSibling ? previousSibling._tree.number + 1 : 0 - }; - }); - - // Compute the layout using Buchheim et al.'s algorithm. - firstWalk(root); - secondWalk(root, -root._tree.prelim); - - // Compute the left-most, right-most, and depth-most nodes for extents. - var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), - right = d3_layout_treeSearch(root, d3_layout_treeRightmost), - deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), - x0 = left.x - separation(left, right) / 2, - x1 = right.x + separation(right, left) / 2, - y1 = deep.depth || 1; - - // Clear temporary layout variables; transform x and y. - d3_layout_treeVisitAfter(root, function(node) { - node.x = (node.x - x0) / (x1 - x0) * size[0]; - node.y = node.depth / y1 * size[1]; - delete node._tree; - }); - - return nodes; - } - - tree.separation = function(x) { - if (!arguments.length) return separation; - separation = x; - return tree; - }; - - tree.size = function(x) { - if (!arguments.length) return size; - size = x; - return tree; - }; - - return d3_layout_hierarchyRebind(tree, hierarchy); -}; - -function d3_layout_treeSeparation(a, b) { - return a.parent == b.parent ? 1 : 2; -} - -// function d3_layout_treeSeparationRadial(a, b) { -// return (a.parent == b.parent ? 1 : 2) / a.depth; -// } - -function d3_layout_treeLeft(node) { - return node.children ? node.children[0] : node._tree.thread; -} - -function d3_layout_treeRight(node) { - return node.children ? node.children[node.children.length - 1] : node._tree.thread; -} - -function d3_layout_treeSearch(node, compare) { - var children = node.children; - if (children) { - var child, - n = children.length, - i = -1; - while (++i < n) { - if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) { - node = child; - } - } - } - return node; -} - -function d3_layout_treeRightmost(a, b) { - return a.x - b.x; -} - -function d3_layout_treeLeftmost(a, b) { - return b.x - a.x; -} - -function d3_layout_treeDeepest(a, b) { - return a.depth - b.depth; -} - -function d3_layout_treeVisitAfter(node, callback) { - function visit(node, previousSibling) { - var children = node.children; - if (children) { - var child, - previousChild = null, - i = -1, - n = children.length; - while (++i < n) { - child = children[i]; - visit(child, previousChild); - previousChild = child; - } - } - callback(node, previousSibling); - } - visit(node, null); -} - -function d3_layout_treeShift(node) { - var shift = 0, - change = 0, - children = node.children, - i = children.length, - child; - while (--i >= 0) { - child = children[i]._tree; - child.prelim += shift; - child.mod += shift; - shift += child.shift + (change += child.change); - } -} - -function d3_layout_treeMove(ancestor, node, shift) { - ancestor = ancestor._tree; - node = node._tree; - var change = shift / (node.number - ancestor.number); - ancestor.change += change; - node.change -= change; - node.shift += shift; - node.prelim += shift; - node.mod += shift; -} - -function d3_layout_treeAncestor(vim, node, ancestor) { - return vim._tree.ancestor.parent == node.parent - ? vim._tree.ancestor - : ancestor; -} -// Squarified Treemaps by Mark Bruls, Kees Huizing, and Jarke J. van Wijk -// Modified to support a target aspect ratio by Jeff Heer -d3.layout.treemap = function() { - var hierarchy = d3.layout.hierarchy(), - round = Math.round, - size = [1, 1], // width, height - padding = null, - pad = d3_layout_treemapPadNull, - sticky = false, - stickies, - ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio - - // Compute the area for each child based on value & scale. - function scale(children, k) { - var i = -1, - n = children.length, - child, - area; - while (++i < n) { - area = (child = children[i]).value * (k < 0 ? 0 : k); - child.area = isNaN(area) || area <= 0 ? 0 : area; - } - } - - // Recursively arranges the specified node's children into squarified rows. - function squarify(node) { - if (!node.children) return; - var rect = pad(node), - row = [], - children = node.children.slice(), // copy-on-write - child, - best = Infinity, // the best row score so far - score, // the current row score - u = Math.min(rect.dx, rect.dy), // initial orientation - n; - scale(children, rect.dx * rect.dy / node.value); - row.area = 0; - while ((n = children.length) > 0) { - row.push(child = children[n - 1]); - row.area += child.area; - if ((score = worst(row, u)) <= best) { // continue with this orientation - children.pop(); - best = score; - } else { // abort, and try a different orientation - row.area -= row.pop().area; - position(row, u, rect, false); - u = Math.min(rect.dx, rect.dy); - row.length = row.area = 0; - best = Infinity; - } - } - if (row.length) { - position(row, u, rect, true); - row.length = row.area = 0; - } - node.children.forEach(squarify); - } - - // Recursively resizes the specified node's children into existing rows. - // Preserves the existing layout! - function stickify(node) { - if (!node.children) return; - var rect = pad(node), - children = node.children.slice(), // copy-on-write - child, - row = []; - scale(children, rect.dx * rect.dy / node.value); - row.area = 0; - while (child = children.pop()) { - row.push(child); - row.area += child.area; - if (child.z != null) { - position(row, child.z ? rect.dx : rect.dy, rect, !children.length); - row.length = row.area = 0; - } - } - node.children.forEach(stickify); - } - - // Computes the score for the specified row, as the worst aspect ratio. - function worst(row, u) { - var s = row.area, - r, - rmax = 0, - rmin = Infinity, - i = -1, - n = row.length; - while (++i < n) { - if (!(r = row[i].area)) continue; - if (r < rmin) rmin = r; - if (r > rmax) rmax = r; - } - s *= s; - u *= u; - return s - ? Math.max((u * rmax * ratio) / s, s / (u * rmin * ratio)) - : Infinity; - } - - // Positions the specified row of nodes. Modifies `rect`. - function position(row, u, rect, flush) { - var i = -1, - n = row.length, - x = rect.x, - y = rect.y, - v = u ? round(row.area / u) : 0, - o; - if (u == rect.dx) { // horizontal subdivision - if (flush || v > rect.dy) v = rect.dy; // over+underflow - while (++i < n) { - o = row[i]; - o.x = x; - o.y = y; - o.dy = v; - x += o.dx = v ? round(o.area / v) : 0; - } - o.z = true; - o.dx += rect.x + rect.dx - x; // rounding error - rect.y += v; - rect.dy -= v; - } else { // vertical subdivision - if (flush || v > rect.dx) v = rect.dx; // over+underflow - while (++i < n) { - o = row[i]; - o.x = x; - o.y = y; - o.dx = v; - y += o.dy = v ? round(o.area / v) : 0; - } - o.z = false; - o.dy += rect.y + rect.dy - y; // rounding error - rect.x += v; - rect.dx -= v; - } - } - - function treemap(d) { - var nodes = stickies || hierarchy(d), - root = nodes[0]; - root.x = 0; - root.y = 0; - root.dx = size[0]; - root.dy = size[1]; - if (stickies) hierarchy.revalue(root); - scale([root], root.dx * root.dy / root.value); - (stickies ? stickify : squarify)(root); - if (sticky) stickies = nodes; - return nodes; - } - - treemap.size = function(x) { - if (!arguments.length) return size; - size = x; - return treemap; - }; - - treemap.padding = function(x) { - if (!arguments.length) return padding; - - function padFunction(node) { - var p = x.call(treemap, node, node.depth); - return p == null - ? d3_layout_treemapPadNull(node) - : d3_layout_treemapPad(node, typeof p === "number" ? [p, p, p, p] : p); - } - - function padConstant(node) { - return d3_layout_treemapPad(node, x); - } - - var type; - pad = (padding = x) == null ? d3_layout_treemapPadNull - : (type = typeof x) === "function" ? padFunction - : type === "number" ? (x = [x, x, x, x], padConstant) - : padConstant; - return treemap; - }; - - treemap.round = function(x) { - if (!arguments.length) return round != Number; - round = x ? Math.round : Number; - return treemap; - }; - - treemap.sticky = function(x) { - if (!arguments.length) return sticky; - sticky = x; - stickies = null; - return treemap; - }; - - treemap.ratio = function(x) { - if (!arguments.length) return ratio; - ratio = x; - return treemap; - }; - - return d3_layout_hierarchyRebind(treemap, hierarchy); -}; - -function d3_layout_treemapPadNull(node) { - return {x: node.x, y: node.y, dx: node.dx, dy: node.dy}; -} - -function d3_layout_treemapPad(node, padding) { - var x = node.x + padding[3], - y = node.y + padding[0], - dx = node.dx - padding[1] - padding[3], - dy = node.dy - padding[0] - padding[2]; - if (dx < 0) { x += dx / 2; dx = 0; } - if (dy < 0) { y += dy / 2; dy = 0; } - return {x: x, y: y, dx: dx, dy: dy}; -} -})(); diff --git a/client/js/d3/d3.time.js b/client/js/d3/d3.time.js deleted file mode 100755 index 3a3409fa..00000000 --- a/client/js/d3/d3.time.js +++ /dev/null @@ -1,660 +0,0 @@ -(function(){d3.time = {}; - -var d3_time = Date; -d3.time.format = function(template) { - var n = template.length; - - function format(date) { - var string = [], - i = -1, - j = 0, - c, - f; - while (++i < n) { - if (template.charCodeAt(i) == 37) { - string.push( - template.substring(j, i), - (f = d3_time_formats[c = template.charAt(++i)]) - ? f(date) : c); - j = i + 1; - } - } - string.push(template.substring(j, i)); - return string.join(""); - } - - format.parse = function(string) { - var date = new d3_time(1900, 0, 1), - i = d3_time_parse(date, template, string, 0); - if (i != string.length) return null; - if (date.hour12) { - var hours = date.getHours() % 12; - date.setHours(date.hour12pm ? hours + 12 : hours); - } - delete date.hour12; - delete date.hour12pm; - return date; - }; - - format.toString = function() { - return template; - }; - - return format; -}; - -function d3_time_parse(date, template, string, j) { - var c, - p, - i = 0, - n = template.length, - m = string.length; - while (i < n) { - if (j >= m) return -1; - c = template.charCodeAt(i++); - if (c == 37) { - p = d3_time_parsers[template.charAt(i++)]; - if (!p || ((j = p(date, string, j)) < 0)) return -1; - } else if (c != string.charCodeAt(j++)) { - return -1; - } - } - return j; -} - -var d3_time_zfill2 = d3.format("02d"), - d3_time_zfill3 = d3.format("03d"), - d3_time_zfill4 = d3.format("04d"), - d3_time_sfill2 = d3.format("2d"); - -var d3_time_formats = { - a: function(d) { return d3_time_weekdays[d.getDay()].substring(0, 3); }, - A: function(d) { return d3_time_weekdays[d.getDay()]; }, - b: function(d) { return d3_time_months[d.getMonth()].substring(0, 3); }, - B: function(d) { return d3_time_months[d.getMonth()]; }, - c: d3.time.format("%a %b %e %H:%M:%S %Y"), - d: function(d) { return d3_time_zfill2(d.getDate()); }, - e: function(d) { return d3_time_sfill2(d.getDate()); }, - H: function(d) { return d3_time_zfill2(d.getHours()); }, - I: function(d) { return d3_time_zfill2(d.getHours() % 12 || 12); }, - j: d3_time_dayOfYear, - m: function(d) { return d3_time_zfill2(d.getMonth() + 1); }, - M: function(d) { return d3_time_zfill2(d.getMinutes()); }, - p: function(d) { return d.getHours() >= 12 ? "PM" : "AM"; }, - S: function(d) { return d3_time_zfill2(d.getSeconds()); }, - U: d3_time_weekNumberSunday, - w: function(d) { return d.getDay(); }, - W: d3_time_weekNumberMonday, - x: d3.time.format("%m/%d/%y"), - X: d3.time.format("%H:%M:%S"), - y: function(d) { return d3_time_zfill2(d.getFullYear() % 100); }, - Y: function(d) { return d3_time_zfill4(d.getFullYear() % 10000); }, - Z: d3_time_zone, - "%": function(d) { return "%"; } -}; - -var d3_time_parsers = { - a: d3_time_parseWeekdayAbbrev, - A: d3_time_parseWeekday, - b: d3_time_parseMonthAbbrev, - B: d3_time_parseMonth, - c: d3_time_parseLocaleFull, - d: d3_time_parseDay, - e: d3_time_parseDay, - H: d3_time_parseHour24, - I: d3_time_parseHour12, - // j: function(d, s, i) { /*TODO day of year [001,366] */ return i; }, - m: d3_time_parseMonthNumber, - M: d3_time_parseMinutes, - p: d3_time_parseAmPm, - S: d3_time_parseSeconds, - // U: function(d, s, i) { /*TODO week number (sunday) [00,53] */ return i; }, - // w: function(d, s, i) { /*TODO weekday [0,6] */ return i; }, - // W: function(d, s, i) { /*TODO week number (monday) [00,53] */ return i; }, - x: d3_time_parseLocaleDate, - X: d3_time_parseLocaleTime, - y: d3_time_parseYear, - Y: d3_time_parseFullYear - // , - // Z: function(d, s, i) { /*TODO time zone */ return i; }, - // "%": function(d, s, i) { /*TODO literal % */ return i; } -}; - -// Note: weekday is validated, but does not set the date. -function d3_time_parseWeekdayAbbrev(date, string, i) { - return string.substring(i, i += 3).toLowerCase() in d3_time_weekdayAbbrevLookup ? i : -1; -} - -var d3_time_weekdayAbbrevLookup = { - sun: 3, - mon: 3, - tue: 3, - wed: 3, - thu: 3, - fri: 3, - sat: 3 -}; - -// Note: weekday is validated, but does not set the date. -function d3_time_parseWeekday(date, string, i) { - d3_time_weekdayRe.lastIndex = 0; - var n = d3_time_weekdayRe.exec(string.substring(i, i + 10)); - return n ? i += n[0].length : -1; -} - -var d3_time_weekdayRe = /^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/ig; - -var d3_time_weekdays = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday" -]; - -function d3_time_parseMonthAbbrev(date, string, i) { - var n = d3_time_monthAbbrevLookup[string.substring(i, i += 3).toLowerCase()]; - return n == null ? -1 : (date.setMonth(n), i); -} - -var d3_time_monthAbbrevLookup = { - jan: 0, - feb: 1, - mar: 2, - apr: 3, - may: 4, - jun: 5, - jul: 6, - aug: 7, - sep: 8, - oct: 9, - nov: 10, - dec: 11 -}; - -function d3_time_parseMonth(date, string, i) { - d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.substring(i, i + 12)); - return n ? (date.setMonth(d3_time_monthLookup[n[0].toLowerCase()]), i += n[0].length) : -1; -} - -var d3_time_monthRe = /^(?:January|February|March|April|May|June|July|August|September|October|November|December)/ig; - -var d3_time_monthLookup = { - january: 0, - february: 1, - march: 2, - april: 3, - may: 4, - june: 5, - july: 6, - august: 7, - september: 8, - october: 9, - november: 10, - december: 11 -}; - -var d3_time_months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" -]; - -function d3_time_parseLocaleFull(date, string, i) { - return d3_time_parse(date, d3_time_formats.c.toString(), string, i); -} - -function d3_time_parseLocaleDate(date, string, i) { - return d3_time_parse(date, d3_time_formats.x.toString(), string, i); -} - -function d3_time_parseLocaleTime(date, string, i) { - return d3_time_parse(date, d3_time_formats.X.toString(), string, i); -} - -function d3_time_parseFullYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 4)); - return n ? (date.setFullYear(n[0]), i += n[0].length) : -1; -} - -function d3_time_parseYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setFullYear(d3_time_century() + +n[0]), i += n[0].length) : -1; -} - -function d3_time_century() { - return ~~(new Date().getFullYear() / 1000) * 1000; -} - -function d3_time_parseMonthNumber(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setMonth(n[0] - 1), i += n[0].length) : -1; -} - -function d3_time_parseDay(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setDate(+n[0]), i += n[0].length) : -1; -} - -// Note: we don't validate that the hour is in the range [0,23]. -function d3_time_parseHour24(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setHours(+n[0]), i += n[0].length) : -1; -} - -// Note: we don't validate that the hour is in the range [1,12]. -function d3_time_parseHour12(date, string, i) { - date.hour12 = true; - return d3_time_parseHour24(date, string, i); -} - -function d3_time_parseMinutes(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setMinutes(+n[0]), i += n[0].length) : -1; -} - -function d3_time_parseSeconds(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.setSeconds(+n[0]), i += n[0].length) : -1; -} - -// Note: we don't look at the next directive. -var d3_time_numberRe = /\s*\d+/; - -function d3_time_parseAmPm(date, string, i) { - var n = d3_time_amPmLookup[string.substring(i, i += 2).toLowerCase()]; - return n == null ? -1 : (date.hour12pm = n, i); -} - -var d3_time_amPmLookup = { - am: 0, - pm: 1 -}; - -function d3_time_year(d) { - return new d3_time(d.getFullYear(), 0, 1); -} - -function d3_time_dayOfYear(d) { - return d3_time_zfill3(1 + ~~((d - d3_time_year(d)) / 864e5)); -} - -function d3_time_weekNumberSunday(d) { - var d0 = d3_time_year(d); - return d3_time_zfill2(~~(((d - d0) / 864e5 + d0.getDay()) / 7)); -} - -function d3_time_weekNumberMonday(d) { - var d0 = d3_time_year(d); - return d3_time_zfill2(~~(((d - d0) / 864e5 + (d0.getDay() + 6) % 7) / 7)); -} - -// TODO table of time zone offset names? -function d3_time_zone(d) { - var z = d.getTimezoneOffset(), - zs = z > 0 ? "-" : "+", - zh = ~~(Math.abs(z) / 60), - zm = Math.abs(z) % 60; - return zs + d3_time_zfill2(zh) + d3_time_zfill2(zm); -} -d3.time.format.utc = function(template) { - var local = d3.time.format(template); - - function format(date) { - var utc = new d3_time_format_utc(); - utc._ = date; - return local(utc); - } - - format.parse = function(string) { - try { - d3_time = d3_time_format_utc; - var date = local.parse(string); - return date && date._; - } finally { - d3_time = Date; - } - }; - - format.toString = local.toString; - - return format; -}; - -function d3_time_format_utc() { - this._ = new Date(Date.UTC.apply(this, arguments)); -} - -d3_time_format_utc.prototype = { - getDate: function() { return this._.getUTCDate(); }, - getDay: function() { return this._.getUTCDay(); }, - getFullYear: function() { return this._.getUTCFullYear(); }, - getHours: function() { return this._.getUTCHours(); }, - getMilliseconds: function() { return this._.getUTCMilliseconds(); }, - getMinutes: function() { return this._.getUTCMinutes(); }, - getMonth: function() { return this._.getUTCMonth(); }, - getSeconds: function() { return this._.getUTCSeconds(); }, - getTimezoneOffset: function() { return 0; }, - valueOf: function() { return this._.getTime(); }, - setDate: function(x) { this._.setUTCDate(x); }, - setDay: function(x) { this._.setUTCDay(x); }, - setFullYear: function(x) { this._.setUTCFullYear(x); }, - setHours: function(x) { this._.setUTCHours(x); }, - setMilliseconds: function(x) { this._.setUTCMilliseconds(x); }, - setMinutes: function(x) { this._.setUTCMinutes(x); }, - setMonth: function(x) { this._.setUTCMonth(x); }, - setSeconds: function(x) { this._.setUTCSeconds(x); } -}; -d3.time.format.iso = d3.time.format.utc("%Y-%m-%dT%H:%M:%SZ"); -function d3_time_range(floor, step, number) { - return function(t0, t1, dt) { - var time = floor(t0), times = []; - if (time < t0) step(time); - if (dt > 1) { - while (time < t1) { - var date = new Date(+time); - if (!(number(date) % dt)) times.push(date); - step(time); - } - } else { - while (time < t1) times.push(new Date(+time)), step(time); - } - return times; - }; -} -d3.time.second = function(date) { - return new Date(~~(date / 1e3) * 1e3); -}; - -d3.time.second.utc = d3.time.second; -d3.time.seconds = d3_time_range(d3.time.second, function(date) { - date.setTime(date.getTime() + 1e3); -}, function(date) { - return date.getSeconds(); -}); - -d3.time.seconds.utc = d3.time.seconds; -d3.time.minute = function(date) { - return new Date(~~(date / 6e4) * 6e4); -}; - -d3.time.minute.utc = d3.time.minute;d3.time.minutes = d3_time_range(d3.time.minute, d3_time_minutesStep, function(date) { - return date.getMinutes(); -}); - -d3.time.minutes.utc = d3_time_range(d3.time.minute, d3_time_minutesStep, function(date) { - return date.getUTCMinutes(); -}); - -function d3_time_minutesStep(date) { - date.setTime(date.getTime() + 6e4); // assumes no leap seconds -} -d3.time.hour = function(date) { - var offset = date.getTimezoneOffset() / 60; - return new Date((~~(date / 36e5 - offset) + offset) * 36e5); -}; - -d3.time.hour.utc = function(date) { - return new Date(~~(date / 36e5) * 36e5); -}; -d3.time.hours = d3_time_range(d3.time.hour, d3_time_hoursStep, function(date) { - return date.getHours(); -}); - -d3.time.hours.utc = d3_time_range(d3.time.hour.utc, d3_time_hoursStep, function(date) { - return date.getUTCHours(); -}); - -function d3_time_hoursStep(date) { - date.setTime(date.getTime() + 36e5); -} -d3.time.day = function(date) { - return new Date(date.getFullYear(), date.getMonth(), date.getDate()); -}; - -d3.time.day.utc = function(date) { - return new Date(~~(date / 864e5) * 864e5); -}; -d3.time.days = d3_time_range(d3.time.day, function(date) { - date.setDate(date.getDate() + 1); -}, function(date) { - return date.getDate() - 1; -}); - -d3.time.days.utc = d3_time_range(d3.time.day.utc, function(date) { - date.setUTCDate(date.getUTCDate() + 1); -}, function(date) { - return date.getUTCDate() - 1; -}); -d3.time.week = function(date) { - (date = d3.time.day(date)).setDate(date.getDate() - date.getDay()); - return date; -}; - -d3.time.week.utc = function(date) { - (date = d3.time.day.utc(date)).setUTCDate(date.getUTCDate() - date.getUTCDay()); - return date; -}; -d3.time.weeks = d3_time_range(d3.time.week, function(date) { - date.setDate(date.getDate() + 7); -}, function(date) { - return ~~((date - new Date(date.getFullYear(), 0, 1)) / 6048e5); -}); - -d3.time.weeks.utc = d3_time_range(d3.time.week.utc, function(date) { - date.setUTCDate(date.getUTCDate() + 7); -}, function(date) { - return ~~((date - Date.UTC(date.getUTCFullYear(), 0, 1)) / 6048e5); -}); -d3.time.month = function(date) { - return new Date(date.getFullYear(), date.getMonth(), 1); -}; - -d3.time.month.utc = function(date) { - return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1)); -}; -d3.time.months = d3_time_range(d3.time.month, function(date) { - date.setMonth(date.getMonth() + 1); -}, function(date) { - return date.getMonth(); -}); - -d3.time.months.utc = d3_time_range(d3.time.month.utc, function(date) { - date.setUTCMonth(date.getUTCMonth() + 1); -}, function(date) { - return date.getUTCMonth(); -}); -d3.time.year = function(date) { - return new Date(date.getFullYear(), 0, 1); -}; - -d3.time.year.utc = function(date) { - return new Date(Date.UTC(date.getUTCFullYear(), 0, 1)); -}; -d3.time.years = d3_time_range(d3.time.year, function(date) { - date.setFullYear(date.getFullYear() + 1); -}, function(date) { - return date.getFullYear(); -}); - -d3.time.years.utc = d3_time_range(d3.time.year.utc, function(date) { - date.setUTCFullYear(date.getUTCFullYear() + 1); -}, function(date) { - return date.getUTCFullYear(); -}); -// TODO nice -function d3_time_scale(methods, format) { - var linear = d3.scale.linear(); - - function scale(x) { - return linear(x); - } - - scale.invert = function(x) { - return d3_time_scaleDate(linear.invert(x)); - }; - - scale.domain = function(x) { - if (!arguments.length) return linear.domain().map(d3_time_scaleDate); - linear.domain(x); - return scale; - }; - - scale.ticks = function(m, k) { - var extent = d3_time_scaleExtent(scale.domain()); - if (typeof m !== "function") { - var span = extent[1] - extent[0], - target = span / m, - i = d3.bisect(d3_time_scaleSteps, target, 1, d3_time_scaleSteps.length - 1); - if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i; - m = methods[i]; - k = m[1]; - m = m[0]; - } - return m(extent[0], extent[1], k); - }; - - scale.tickFormat = function() { - return format; - }; - - // TOOD expose d3_scale_linear_rebind? - scale.range = d3.rebind(scale, linear.range); - scale.rangeRound = d3.rebind(scale, linear.rangeRound); - scale.interpolate = d3.rebind(scale, linear.interpolate); - scale.clamp = d3.rebind(scale, linear.clamp); - - return scale; -} - -// TODO expose d3_scaleExtent? -function d3_time_scaleExtent(domain) { - var start = domain[0], stop = domain[domain.length - 1]; - return start < stop ? [start, stop] : [stop, start]; -} - -function d3_time_scaleDate(t) { - return new Date(t); -} - -function d3_time_scaleFormat(formats) { - return function(date) { - var i = formats.length - 1, f = formats[i]; - while (!f[1](date)) f = formats[--i]; - return f[0](date); - }; -} - -var d3_time_scaleSteps = [ - 1e3, // 1-second - 5e3, // 5-second - 15e3, // 15-second - 3e4, // 30-second - 6e4, // 1-minute - 3e5, // 5-minute - 9e5, // 15-minute - 18e5, // 30-minute - 36e5, // 1-hour - 108e5, // 3-hour - 216e5, // 6-hour - 432e5, // 12-hour - 864e5, // 1-day - 1728e5, // 2-day - 6048e5, // 1-week - 1728e6, // 1-month - 7776e6, // 3-month - 31536e6 // 1-year -]; - -var d3_time_scaleLocalMethods = [ - [d3.time.seconds, 1], - [d3.time.seconds, 5], - [d3.time.seconds, 15], - [d3.time.seconds, 30], - [d3.time.minutes, 1], - [d3.time.minutes, 5], - [d3.time.minutes, 15], - [d3.time.minutes, 30], - [d3.time.hours, 1], - [d3.time.hours, 3], - [d3.time.hours, 6], - [d3.time.hours, 12], - [d3.time.days, 1], - [d3.time.days, 2], - [d3.time.weeks, 1], - [d3.time.months, 1], - [d3.time.months, 3], - [d3.time.years, 1] -]; - -var d3_time_scaleLocalFormats = [ - [d3.time.format("%Y"), function(d) { return true; }], - [d3.time.format("%B"), function(d) { return d.getMonth(); }], - [d3.time.format("%b %d"), function(d) { return d.getDate() != 1; }], - [d3.time.format("%a %d"), function(d) { return d.getDay() && d.getDate() != 1; }], - [d3.time.format("%I %p"), function(d) { return d.getHours(); }], - [d3.time.format("%I:%M"), function(d) { return d.getMinutes(); }], - [d3.time.format(":%S"), function(d) { return d.getSeconds() || d.getMilliseconds(); }] -]; - -var d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats); - -d3.time.scale = function() { - return d3_time_scale(d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); -}; -var d3_time_scaleUTCMethods = [ - [d3.time.seconds.utc, 1], - [d3.time.seconds.utc, 5], - [d3.time.seconds.utc, 15], - [d3.time.seconds.utc, 30], - [d3.time.minutes.utc, 1], - [d3.time.minutes.utc, 5], - [d3.time.minutes.utc, 15], - [d3.time.minutes.utc, 30], - [d3.time.hours.utc, 1], - [d3.time.hours.utc, 3], - [d3.time.hours.utc, 6], - [d3.time.hours.utc, 12], - [d3.time.days.utc, 1], - [d3.time.days.utc, 2], - [d3.time.weeks.utc, 1], - [d3.time.months.utc, 1], - [d3.time.months.utc, 3], - [d3.time.years.utc, 1] -]; - -var d3_time_scaleUTCFormats = [ - [d3.time.format.utc("%Y"), function(d) { return true; }], - [d3.time.format.utc("%B"), function(d) { return d.getUTCMonth(); }], - [d3.time.format.utc("%b %d"), function(d) { return d.getUTCDate() != 1; }], - [d3.time.format.utc("%a %d"), function(d) { return d.getUTCDay() && d.getUTCDate() != 1; }], - [d3.time.format.utc("%I %p"), function(d) { return d.getUTCHours(); }], - [d3.time.format.utc("%I:%M"), function(d) { return d.getUTCMinutes(); }], - [d3.time.format.utc(":%S"), function(d) { return d.getUTCSeconds() || d.getUTCMilliseconds(); }] -]; - -var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats); - -d3.time.scale.utc = function() { - return d3_time_scale(d3_time_scaleUTCMethods, d3_time_scaleUTCFormat); -}; -})(); diff --git a/client/js/images/ui-bg_glass_65_ffffff_1x400.png b/client/js/images/ui-bg_glass_65_ffffff_1x400.png deleted file mode 100755 index 0dc2feb7..00000000 Binary files a/client/js/images/ui-bg_glass_65_ffffff_1x400.png and /dev/null differ diff --git a/client/js/images/ui-bg_glass_75_dadada_1x400.png b/client/js/images/ui-bg_glass_75_dadada_1x400.png deleted file mode 100644 index 5a46b47c..00000000 Binary files a/client/js/images/ui-bg_glass_75_dadada_1x400.png and /dev/null differ diff --git a/client/js/images/ui-bg_glass_75_e6e6e6_1x400.png b/client/js/images/ui-bg_glass_75_e6e6e6_1x400.png deleted file mode 100644 index 86c2baa6..00000000 Binary files a/client/js/images/ui-bg_glass_75_e6e6e6_1x400.png and /dev/null differ diff --git a/client/js/images/ui-icons_222222_256x240.png b/client/js/images/ui-icons_222222_256x240.png deleted file mode 100755 index 43bf16eb..00000000 Binary files a/client/js/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/client/js/images/ui-icons_454545_256x240.png b/client/js/images/ui-icons_454545_256x240.png deleted file mode 100644 index 7ec70d11..00000000 Binary files a/client/js/images/ui-icons_454545_256x240.png and /dev/null differ diff --git a/client/js/images/ui-icons_888888_256x240.png b/client/js/images/ui-icons_888888_256x240.png deleted file mode 100644 index 5ba708c3..00000000 Binary files a/client/js/images/ui-icons_888888_256x240.png and /dev/null differ diff --git a/client/js/jquery-1.9.1.min.js b/client/js/jquery-1.9.1.min.js deleted file mode 100644 index 006e9531..00000000 --- a/client/js/jquery-1.9.1.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license -//@ sourceMappingURL=jquery.min.map -*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
t
",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; -return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) -}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("