json not working

json not working

  1. <script>
  2. $("#clearPoints").click(function(){
  3. $(".point").remove();
  4. });
  5. function LoadFactions(){
  6. $("#actBox").hide();
  7. __t = -1;
  8. __f = -1;
  9. $("#factlist").empty();
  10. $("polygon").remove();
  11. $(".point").remove();
  12. $(".captionzzz").remove();
  13. $.post('engine.json.html', function(data){
  14. var f = jQuery.parseJSON(data);
  15. f.factions.forEach(function(faction){
  16. _factions[faction.id] = faction;
  17. $("#factlist").append("<li class=\"fact fact"+faction.id+"\"><div class=\"factSquare\" style=\"background-color: #" + faction.color + "\"></div> " + faction.name + "<span class=\"factid\">"+faction.id+"</span></li>");
  18. var i = 0;
  19. faction.turfs.forEach(function(points){
  20. var turfSVG = makeSVG('polygon', {'class': faction.id, 'name': i, 'points': points, stroke: 'white', 'stroke-width': 2, fill: '#' + faction.color, opacity: 0.3});
  21. var turf = $(turfSVG).appendTo("#_mapa"); 
  22. _factions[faction.id].turfPolygon[i] = turf;
  23. var fSize = 0.5;
  24. if(faction.dimensions[i][0] > 200){
  25. fSize = 1.1;
  26. }else if(faction.dimensions[i][0] > 90){
  27. fSize = 0.8;
  28. }
  29. $("<div>"+faction.name+"</div>").css({
  30. 'position': 'absolute',
  31. 'top': faction.turfcenter[i][1] - 10,
  32. 'left': faction.limits[i].minx + 'px',
  33. 'width': faction.limits[i].maxx - faction.limits[i].minx + 'px',
  34. 'text-align': 'center',
  35. 'font-size': fSize + 'em',
  36. 'font-weight': 'bold',
  37. 'color': 'white',
  38. 'text-transform': 'uppercase',
  39. 'font-family': 'tahoma',
  40. 'pointer-events': 'none'
  41. }).addClass('captionzzz').appendTo("#map_images");
  42. i++;
  43. });
  44. })
  45. }).done(function(){
  46. RefreshPolygonList();
  47. });
  48. }
  49. function RefreshPolygonList(){
  50. _factions.forEach(function(_f){
  51. $(".polylist_" + _f.id).remove();
  52. if(_f.turfPolygon.length > 0){
  53. $(".fact"+_f.id).after("<ul class=\"polylist polylist_"+_f.id+"\" style='display:none;'></ul>");
  54. var i = 0;
  55. _f.turfPolygon.forEach(function(poly){
  56. i++;
  57. $(".polylist_"+_f.id).append("<li class=\"turfinlist\">Turf #<span class=\"turfid\">" + i + "</span></li>");
  58. })
  59. }
  60. });
  61. }
  62. $(document).on("click", ".fact", function(){
  63. var fid = $(this).children(".factid").text();
  64. selectedFaction = fid;
  65. $(".fact").css("background-color", "black");
  66. $(this).css("background-color", "#555");
  67. });
  68. $("#addfact_color").keyup(function(){
  69. $("#previewCol").css("background-color", "#" + $(this).val());
  70. })
  71. LoadFactions();
  72. /*$("#_mapa").mousemove( function(event){
  73. $("#map_coords").text('Cursor position: X = ' + (($(this).offset().left + 3000) * (-1) + event.pageX) + ', Y = ' + ($(this).offset().top + 3000 - event.pageY));
  74. mX = ($(this).offset().left) * -1 + event.pageX;
  75. mY = ($(this).offset().top) * -1 + event.pageY;
  76. });*/
  77. $(function(){
  78. $(document).on("mouseenter", "polygon", function(){
  79. $(this).css({"opacity": "0.5", "cursor": "pointer"});
  80. }).on("mouseout", "polygon", function(){
  81. $(this).css({"opacity": "0.3", "cursor": "pointer"});
  82. });
  83. });
  84. $(document).on("click", ".turfinlist", function(){
  85. var _f = $(this).parent().prev().children(".factid").text();
  86. var _t = $(this).children(".turfid").text();
  87. scrMapTo(_factions[_f].turfcenter[_t - 1][0], _factions[_f].turfcenter[_t - 1][1]);
  88. })

  89. $(document).on("click", "polygon", function(e){
  90. var _f = $(this).attr('class');
  91. var _t = $(this).attr('name');
  92. __f = _f;
  93. __t = _t;
  94. if(_factions[_f].thread.length > 0){
  95. var _box = $("#actBox");
  96. _box.css({
  97. 'display': 'block',
  98. 'left': e.clientX - $("#_mapa").offset().left + 10 + 'px',
  99. 'top': e.clientY - $("#_mapa").offset().top + 'px'
  100. });
  101. $("#actShowThread").show();
  102. $("#actShowThread").attr('href', _factions[_f].thread);
  103. }
  104. });
  105. $("#_mapa").click(function(){
  106. if($("polygon:hover").length == 0){
  107. if($("#actBox").css('display') != 'none'){
  108. __t = -1;
  109. __f = -1;
  110. return $("#actBox").hide();
  111. }
  112. }
  113. });
  114. $(document).on("click", ".fact", function(e){
  115. $(this).next(".polylist:first").toggle();
  116. })
  117. </script>

Why this thing wouldnt work on my website?