Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. function animate() {
  2. var flights = {
  3. 100: ["travel-svo", "travel-svo"],
  4. 600: ["travel-fra", "travel-fra", "travel-fra", "travel-fra", "travel-fra",
  5. "travel-fra", "travel-fra", "travel-nap"],
  6. 620: ["travel-ams", "travel-ams"],
  7. 700: ["travel-lhr", "travel-lhr", "travel-lhr", "travel-lhr", "travel-lhr"],
  8. 710: ["travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg"],
  9. 805: ["travel-gva"],
  10. 810: ["travel-vie", "travel-vie", "travel-vie", "travel-vie"],
  11. 850: ["travel-ams", "travel-ams", "travel-ams"],
  12. 855: ["travel-svo"],
  13. 930: ["travel-beg", "travel-beg"],
  14. 935: ["travel-muc", "travel-muc", "travel-muc"],
  15. 945: ["travel-sof", "travel-sof"],
  16. 950: ["travel-fco"],
  17. 955: ["travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg", "travel-cdg",
  18. "travel-cdg", "travel-cdg"],
  19. 1010: ["travel-mad", "travel-mad", "travel-mad", "travel-mad", "travel-mad"],
  20. 1015: ["travel-svo", "travel-svo"],
  21. 1025: ["travel-zrh"],
  22. 1030: ["travel-dxb", "travel-dxb", "travel-arn"],
  23. 1035: ["travel-fra", "travel-fra", "travel-fra", "travel-fra", "travel-fra",
  24. "travel-fra"],
  25. 1040: ["travel-led", "travel-led"]
  26. };
  27.  
  28. var circle = function(coef, flight_id) {
  29. var svgns = "http://www.w3.org/2000/svg";
  30. var svgDocument =document;
  31. var motion = svgDocument.createElementNS(svgns,"animateMotion");
  32. var shape = svgDocument.createElementNS(svgns, "circle");
  33.  
  34. motion.setAttribute("begin", "path_ani.end");
  35. motion.setAttribute("dur", "10s");
  36. motion.setAttribute("path", document.getElementById(flight_id).getAttributeNS(null, "d"));
  37. motion.setAttribute("xlink:href", "#" + flight_id);
  38.  
  39. shape.setAttributeNS(null, "r", 1*coef);
  40. shape.setAttributeNS(null, "fill", "1f78b4");
  41. shape.setAttributeNS(null, "stroke", "1f78b4");
  42. shape.setAttribute("id", "airplane-" + flight_id);
  43. shape.appendChild(motion);
  44. document.getElementById("airplanes").appendChild(shape);
  45. }
  46. setTimeout(function() {
  47. var time = 100;
  48.  
  49. var interval = setInterval(function() {
  50. var f = flights[time];
  51. var counts = {};
  52.  
  53. if (f) {
  54. // count unique items
  55. for(var i = 0; i < f.length; i += 1) {
  56. var num = f[i];
  57. counts[num] = counts[num] ? counts[num]+1 : 1;
  58. }
  59.  
  60. for (var flight in counts) {
  61. circle(counts[flight], flight);
  62. }
  63. }
  64. time += 5;
  65. // stop
  66. if (time > 1040) {
  67. clearInterval(interval);
  68. }
  69. }, 50);
  70. }, 12000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement