bc.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. var map;
  2. function initMap () {
  3. index = 0
  4. stop_anim = false
  5. run_anim = false
  6. cables = L.tileLayer('http://{s}.tiles.mapbox.com/v3/rllfff.Test/{z}/{x}/{y}.png',{
  7. attribution: 'Cable data: <a href="http://cablemap.info/">cablemap.info</a>'
  8. })
  9. blank_map = L.tileLayer('http://{s}.tiles.mapbox.com/v3/rllfff.blank-populations/{z}/{x}/{y}.png')
  10. // osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  11. // attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  12. // })
  13. // osm_quest = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png')
  14. osm_sat = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png')
  15. // streets = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  16. // light = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.light/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  17. dark = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.dark/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  18. // comic = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.comic/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  19. // pirates = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.pirates/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  20. // high_contrast = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.high-contrast/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  21. // emerald = L.tileLayer('http://api.tiles.mapbox.com/v4/mapbox.emerald/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicmxsZmZmIiwiYSI6IkZyVmt4bUUifQ.R--ZDzdb-672Dx1E3suO9A')
  22. map = L.map('map',{
  23. minZoom: 2,
  24. maxZoom:6,
  25. zoomControl:false,
  26. layers: [blank_map]
  27. });
  28. if (typeof latlong !== 'undefined') {
  29. map.setView(latlong[index], 3)
  30. }
  31. blank_map.addTo(map)
  32. // osm_sat.addTo(map)
  33. var baseMaps = {
  34. "Submarine cables": cables,
  35. // "Streets": streets,
  36. // "Emerald": emerald,
  37. // "Light": light,
  38. // "High-Contrast": high_contrast,
  39. // "Comic": comic,
  40. // "Pirates": pirates,
  41. // "OSM Blank": osm,
  42. // "OSM Geopolitical": osm_quest,
  43. "OSM Satellite": osm_sat,
  44. "Dark": dark,
  45. "Blank map": blank_map
  46. }
  47. //setting the controls:
  48. new L.control.layers(baseMaps, null, {collapsed:false}).addTo(map)
  49. new L.Control.Zoom({position: 'topright'}).addTo(map)
  50. new L.Control.Attribution
  51. //custom markers:
  52. //the slider bar
  53. $('.info').hide()
  54. slide = 0
  55. $('#button').bind('click', function(){
  56. if (slide == 0){
  57. $('.bar').animate({"width": '300'})
  58. $('.info').show()
  59. $('#button').html('<')
  60. }
  61. slide += 1
  62. if (slide == 2){
  63. $('.bar').animate({"width": '20'})
  64. $('.info').hide()
  65. $('#button').html('>')
  66. slide = 0}
  67. })
  68. $('#attrib-content').hide()
  69. $('#about-content').hide()
  70. $('#contact-content').hide()
  71. $('#attrib').bind('click', function(){
  72. $('#attrib-content').toggle(400)
  73. })
  74. $('#legend').bind('click', function(){
  75. $('#legend-content').toggle(400)
  76. })
  77. $('#about').bind('click', function(){
  78. $('#about-content').toggle(400)
  79. })
  80. $('#contact').bind('click', function(){
  81. $('#contact-content').toggle(400)
  82. })
  83. $('#form-submit').bind('click',function(){
  84. // console.log("loading "+$('#form-host').val())
  85. $('#form-target').load('http://127.0.0.1:8080/ajax?hostname='+$('#form-host').val())
  86. })
  87. $('#form-stop-anim').bind('click',function(){
  88. // console.log("stopping animation ")
  89. bcHistory.stop()
  90. })
  91. // legend controls
  92. $('#home').bind('click', function(){
  93. $('#legend-text').html("This is the first hop on your journey, most probably the router of your provider for your neighbourhood or city.")
  94. })
  95. $('#hop').bind('click', function(){
  96. $('#legend-text').html("This represents a hop to either a server or router that you pass. Click on it to view it's metadata." )
  97. })
  98. $('#cluster').bind('click', function(){
  99. $('#legend-text').html('Server hops in the same country or location get automatically grouped into clusters. Click the clusters to see individual hops.')
  100. })
  101. $('#destination').bind('click', function(){
  102. $('#legend-text').html("The last hop on your journey. Ideally it is the machine that serves the destination website. More likeley however it is it's firewall")
  103. })
  104. $('#error').bind('click',function(){
  105. $('#error').html('')
  106. })
  107. if(cur_url !== ""){
  108. bcHistory.play(cur_url)
  109. map.addControl(bcControl)
  110. // add content :
  111. // $('.bc-custom-control').html("Hallo Welt")
  112. $('.bc-custom-control').hide();
  113. }
  114. }
  115. window.setInterval("watchUrl()",2000)
  116. function watchUrl(){
  117. $('#form-target').load('http://127.0.0.1:8080/ajax')
  118. }