Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function animate() {
- var flights = {
- 100: ["travel-svo", "travel-svo"],
- 600: ["travel-fra", "travel-fra", "travel-fra", "travel-fra", "travel-fra",
- "travel-fra", "travel-fra", "travel-nap"],
- 620: ["travel-ams", "travel-ams"],
- 700: ["travel-lhr", "travel-lhr", "travel-lhr", "travel-lhr", "travel-lhr"],
- 710: ["travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg"],
- 805: ["travel-gva"],
- 810: ["travel-vie", "travel-vie", "travel-vie", "travel-vie"],
- 850: ["travel-ams", "travel-ams", "travel-ams"],
- 855: ["travel-svo"],
- 930: ["travel-beg", "travel-beg"],
- 935: ["travel-muc", "travel-muc", "travel-muc"],
- 945: ["travel-sof", "travel-sof"],
- 950: ["travel-fco"],
- 955: ["travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg",
- "travel-cdg", "travel-cdg"],
- 1010: ["travel-mad", "travel-mad", "travel-mad", "travel-mad", "travel-mad"],
- 1015: ["travel-svo", "travel-svo"],
- 1025: ["travel-zrh"],
- 1030: ["travel-dxb", "travel-dxb", "travel-arn"],
- 1035: ["travel-fra", "travel-fra", "travel-fra", "travel-fra", "travel-fra",
- "travel-fra"],
- 1040: ["travel-led", "travel-led"]
- };
- var circle = function(coef, flight_id) {
- var svgns = "http://www.w3.org/2000/svg";
- var svgDocument =document;
- var motion = svgDocument.createElementNS(svgns,"animateMotion");
- var shape = svgDocument.createElementNS(svgns, "circle");
- motion.setAttribute("begin", "path_ani.end");
- motion.setAttribute("dur", "10s");
- motion.setAttribute("path", document.getElementById(flight_id).getAttributeNS(null, "d"));
- motion.setAttribute("xlink:href", "#" + flight_id);
- shape.setAttributeNS(null, "r", 1*coef);
- shape.setAttributeNS(null, "fill", "1f78b4");
- shape.setAttributeNS(null, "stroke", "1f78b4");
- shape.setAttribute("id", "airplane-" + flight_id);
- shape.appendChild(motion);
- document.getElementById("airplanes").appendChild(shape);
- }
- setTimeout(function() {
- var time = 100;
- var interval = setInterval(function() {
- var f = flights[time];
- var counts = {};
- if (f) {
- // count unique items
- for(var i = 0; i < f.length; i += 1) {
- var num = f[i];
- counts[num] = counts[num] ? counts[num]+1 : 1;
- }
- for (var flight in counts) {
- circle(counts[flight], flight);
- }
- }
- time += 5;
- // stop
- if (time > 1040) {
- clearInterval(interval);
- }
- }, 50);
- }, 12000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement