Color Coding for Planets.nu

Color codes planets and ships by race on Planets.nu map

  1. // ==UserScript==
  2. // @name Color Coding for Planets.nu
  3. // @description Color codes planets and ships by race on Planets.nu map
  4. // @include http://play.planets.nu/*
  5. // @include http://test.planets.nu/*
  6. // @include http://planets.nu/*
  7. // @version 2.3.6
  8. // @namespace https://greasyfork.org/users/2860
  9. // ==/UserScript==
  10.  
  11. // 1. Color codes planets and ships by race on Planets.nu map
  12. // 2. v0.5 - now activates or deactivates from Settings screen!
  13. // 3. v0.7 - now activates or deactivates default color for user from Settings screen
  14. // 4. v0.81 - now saves settings for the user to a cookie, when changed from the Settings Screen
  15. // 5. v0.90 - First 11 race colors, unknown planets, and unoccupied planets now configurable from Settings Screen!
  16. // 6. v1.0 - Fully functional! Uses color gradient for all planets. Displays color gradiant on Settings Screen (FF only, will tackle Chrome later)
  17. // 7. v1.1 - Chrome and FF color preview. Gradient colors for standard game races, info, and unknown
  18. // 8. v1.2 - Redraws colors on maps after any setting changes. Different sized circles around planets for Own Ships, Ally, and Enemy. Own ships will always have correct color
  19. // 9. v1.3 - rewrote Settings changes to play nicely with other mods.
  20. // 10.v1.4 - added in support for users changing colors beyond race 11 (settings page does not refresh, so hit the settings button again to see the changes).
  21. // 11.v1.5,1.51 - added support for new play.planets.nu client
  22. // 12.v1.6 - New note colors that match the mod.
  23. // 13.v1.61 - added support for new planets urls
  24. // 14.v1.7 - Adds planets v3 API support
  25. // 15.v1.81 - Now shows ship names with explosions (formerly a separate script). Fixed colors in the diplomacy screen color picker (if you ever want to use this with the mod).
  26. // 16.v1.9 - Graphics change for cloaked ships on map
  27. // 17.v2.0 - Split from codebase for original planets.nu implementation
  28. // 18.v2.1 - Fixes multiple bugs. Minefields laid in other races name are displayed with the Unknown Owner color (previously would not work with color mod).
  29. // 19.v2.11 - Fixes bug which results in allied ships not appearing properly around planets
  30. // 20.v2.12 - Imports performance improving changes from planets.nu UI - should fix misc bugs and improve performance
  31. // 21.v2.2 - Option to use Color Picker colors. New button to reset note colors to blank.
  32. // 22.v2.21 - changed include so doesn't run on old client
  33. // 23.v2.22,v.2.24 - updated to work with Sphere
  34. // 24.v2.3 - Modifies mouse-over text for minefields so you can tell if web or regular minefield
  35. // 25.v2.3.1 - Minor fixes
  36. // 26.v2.3.2 - fixes compatibility issues with new planets.nu features
  37. // 27.v2.3.3 - adds compability with new planets.nu features from December 2016
  38. // 28.v2.3.4 - adds compability with new planets.nu features from April 2017
  39. // 29.v2.3.5 - fixes problem where wrong colors are rendered for enemy/allied ships around planets when zoomed out.
  40. // 30.v2.3.6 - added support for wormholes
  41.  
  42. function wrapper () { // wrapper for injection
  43. //var colors = ["white", "Green", "Crimson", "HotPink", "Lime", "Magenta", "Yellow", "Purple", "Gray", "Cyan", "Blue", "mediumslateblue", "sienna", "skyblue", "tomato","wheat", "lightcoral", "darkslategray", "teal", "firebrick", "olive", "mediumpurple", "lime", "indigo", "tan", "yellowgreen", "goldenrod", "aliceblue", "olivedrab", "orangered"];
  44.  
  45. var colorsA =["#F0F8FF","#32CD32","#CD5C5C","#FFC0CB","#98FB98","#C0C0C0","#FFFF00","#EE82EE","#D3D3D3","#B0E0E6","#87CEFA","#7B68EE","#F4A460","#D2B48C","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  46. var colorsA2 =["#FFFFFF","#006400","#FF0000","#FF69B4","#00FA9A","#6A5ACD","#FFD700","#9400D3","#808080","#00CED1","#4169E1","#7B68EE","#A0522D","#87CEEB","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  47.  
  48. var modInfo="#F4A460";//chocolate
  49. var modInfo2="#D2691E";//chocolate
  50.  
  51. var modUnknown="#FFF8DC"; //Tan
  52. var modUnknown2="#D2B48C"; //Tan
  53. var modRace=12;
  54. var useColorPicker=0;
  55.  
  56. // Fed - White
  57. // Lizard - Green
  58. // Birds - Crimson
  59. // Fascists - Pink
  60. // Privateers - Lime
  61. // Cyborg - Magenta
  62. // Crystals - Yellow
  63. // Empire - Purple
  64. // Robots - Gray
  65. // Rebels - Aqua
  66. // Colonies - Blue
  67.  
  68. var activeColorMod=null;//default true
  69. var defaultMyColor=null;//default true
  70. var useCustomColor=false;//have we checked Cookie
  71. var firstLoad=true;
  72.  
  73.  
  74. var oldShow = geoSimpleColorPicker.prototype.show;
  75.  
  76.  
  77. geoSimpleColorPicker.prototype.show = function (targetId, callback) {
  78. if (activeColorMod==false)
  79. {
  80. oldShow.apply(this,arguments);
  81. }
  82. else
  83. {
  84. this.picker = $("<div style='position:absolute;background-color:#000;padding:4px;z-index:999;'></div>").hide().appendTo("body");
  85. this.target = $("#" + targetId);
  86. this.callback = callback;
  87. //colors table
  88. var objX = new Array('00', '33', '66', '99', 'CC', 'FF');
  89. html = '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  90. var br = 1;
  91. for (o = 0; o < 6; o++) {
  92. html += '</tr><tr>';
  93. for (y = 0; y < 6; y++) {
  94. if (y == 3) { html += '</tr><tr>'; }
  95. for (x = 0; x < 6; x++) {
  96. var grid = objX[o] + objX[y] + objX[x];
  97. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  98. }
  99. }
  100. }
  101. html += '</tr></table>';
  102.  
  103. //greys table
  104. var objX = new Array('0', '3', '6', '9', 'C', 'F');
  105. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  106. var br = 0;
  107. for (y = 0; y < 6; y++) {
  108. for (x = 0; x < 6; x++) {
  109. if (br == 18) {
  110. br = 0;
  111. html += '</tr><tr>';
  112. }
  113. br++;
  114. var grid = objX[y] + objX[x] + objX[y] + objX[x] + objX[y] + objX[x];
  115. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  116. }
  117. }
  118. html += "</tr></table>";
  119. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  120. var br = 0;
  121. for (y = 0; y < 2; y++) {
  122. for (x = 0; x < 10; x++) {
  123. if (br == 10) {
  124. br = 0;
  125. html += '</tr><tr>';
  126. }
  127. br++;
  128. var grid;
  129. if (y==0)
  130. {
  131. if (colorsA[x].charAt(0)=='#')
  132. grid = colorsA[x].substring(1,colorsA.length);
  133. else
  134. grid = colorsA[x];
  135. }
  136. else
  137. {
  138. if (colorsA2[x].charAt(0)=='#')
  139. grid = colorsA2[x].substring(1,colorsA2.length);
  140. else
  141. grid = colorsA2[x];
  142. }
  143. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  144. }
  145. }
  146. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  147. html += '<td><div title="clear" onclick="colorPicker.selectColor(\'clear\');" style="cursor:pointer;margin: 1px;width:80px;height:20px;text-align:center;border: solid 1px #fff;color: #fff;">CLEAR</div></td>';
  148. html += "</tr></table>";
  149. this.picker.css("left", this.target.offset().left);
  150. this.picker.css("top", this.target.offset().top + this.target.height() + 10);
  151. this.picker.html(html);
  152. if (vgaPlanets.prototype.version>=3)
  153. $(".cpselect").tclick(function () { colorPicker.selectColor($(this).data("color")); });
  154. this.picker.show();
  155. }
  156. };
  157.  
  158. // vgap3.js functions
  159.  
  160.  
  161. var oldDraw = vgapMap.prototype.draw;
  162.  
  163. vgapMap.prototype.draw = function (fast, ctx, skipUserContent, secondCanvas) {
  164.  
  165. //check Color Mod Settings
  166. checkColorModSettings();
  167. if (activeColorMod==false)
  168. {
  169. oldDraw.apply(this,arguments);
  170. }
  171. else
  172. {
  173. if (drawing)
  174. return;
  175. //remove planet names (and re-add at the end)
  176. $(".PlanetName").remove();
  177. $(".Pin").remove();
  178. this.startdrawtime = new Date;
  179.  
  180. if (!ctx && fast) {
  181. this.drawFromSecond();
  182.  
  183. if (vgap.accountsettings.livemeasuretool && this.measure && this.measures.length > 0) {
  184. var measure = this.measures[this.measures.length - 1];
  185. this.ctx.beginPath();
  186. this.drawLine(this.ctx, this.screenX(measure.x1), this.screenY(measure.y1), this.screenX(this.x), this.screenY(this.y), "cyan", 2);
  187.  
  188. var dist = Math.dist(measure.x1, measure.y1, this.x, this.y);
  189. this.drawCircle(this.ctx, this.screenX(measure.x1), this.screenY(measure.y1), dist * this.zoom, colorToRGBA("#00FFFF", 0.4), 1);
  190.  
  191.  
  192.  
  193. var txtX = this.x + Math.ceil(15 / this.zoom);
  194. if (this.x < measure.x1)
  195. txtX = this.x - Math.ceil(15 / this.zoom);
  196.  
  197. var txtY = this.y + Math.ceil(15 / this.zoom);
  198. if (this.y < measure.y1)
  199. txtY = this.y - Math.ceil(15 / this.zoom);
  200.  
  201. var txt = dist.toFixed(1);
  202. //if (totalDist > dist)
  203. // txt += " - " + totalDist.toFixed(1);
  204.  
  205. this.ctx.textBaseline = "middle";
  206. this.ctx.textAlign = "center";
  207. this.ctx.fillStyle = "#ffffff";
  208. this.ctx.fillText(txt, this.screenX(txtX), this.screenY(txtY));
  209. }
  210. this.showDrawTime(fast);
  211. return;
  212. }
  213.  
  214. //if (!ctx && fast && this.spritecache().tiles) {
  215. // this.drawFromTiles();
  216. // this.showDrawTime(fast);
  217. // return;
  218. //}
  219.  
  220. var drawing = true;
  221.  
  222. var fullrender = true;
  223. if (fast)
  224. fullrender = false;
  225.  
  226. var sets = vgap.accountsettings;
  227. var drawUserContent = true;
  228. if (skipUserContent)
  229. drawUserContent = false;
  230.  
  231. if (!ctx)
  232. ctx = this.ctx;
  233.  
  234. ctx.fillStyle = "#000000";
  235. ctx.clearRect(0, 0, vgap.map.canvas.width, vgap.map.canvas.height);
  236. if (vgap.settings.isacademy) {
  237. var x = this.screenX(2000);
  238. var y = this.screenY(2000);
  239. var r = Math.ceil(vgap.settings.mapwidth) * this.zoom;
  240. var grad = ctx.createRadialGradient(x, y, 0, x, y, r);
  241. var a = (5 - Math.sqrt(Math.sqrt(this.zoom))) / 5;
  242. grad.addColorStop(0, "rgba(50, 25, 25, " + a + ")");
  243. grad.addColorStop(1, "rgba(50, 50, 25, 0)");
  244. ctx.fillStyle = grad;
  245.  
  246. ctx.beginPath();
  247. ctx.arc(x, y, r, 0, Math.PI * 2, false);
  248. ctx.closePath();
  249. ctx.fill();
  250. //console.log(a);
  251. }
  252. if (this.activeShip) {
  253. vgap.shipScreen.predraw();
  254. }
  255. //Debris Disk stroke
  256. if (vgap.map.zoom >= 5 && fullrender) {
  257. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  258.  
  259. var planet = vgap.debrisdisks[i];
  260. var rad = planet.debrisdisk * vgap.map.zoom;
  261.  
  262. var visible = this.isVisible(planet.x, planet.y, planet.debrisdisk);
  263.  
  264. //if on this canvas
  265. if (visible) {
  266.  
  267. //draw rings
  268. var screenX = this.screenX(planet.x);
  269. var screenY = this.screenY(planet.y);
  270.  
  271. var color = "#ffffff";
  272. ctx.strokeStyle = colorToRGBA(color, 0.1);
  273. ctx.lineWidth = 2;
  274.  
  275. ctx.beginPath();
  276. ctx.arc(screenX, screenY, rad, 0, Math.PI * 2, false);
  277. ctx.closePath();
  278. ctx.stroke();
  279. }
  280. }
  281. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  282. var planet = vgap.debrisdisks[i];
  283. var rad = planet.debrisdisk * vgap.map.zoom - 2;
  284.  
  285. var visible = this.isVisible(planet.x, planet.y, planet.debrisdisk);
  286.  
  287. //if on this canvas
  288. if (visible) {
  289.  
  290. //draw centers
  291. var screenX = this.screenX(planet.x);
  292. var screenY = this.screenY(planet.y);
  293.  
  294. //blank centers (for overlapping circles)
  295. ctx.fillStyle = "#111111";
  296. ctx.beginPath();
  297. ctx.arc(screenX, screenY, rad, 0, Math.PI * 2, false);
  298. ctx.closePath();
  299. ctx.fill();
  300. }
  301. }
  302. }
  303.  
  304. //draw full detail grid
  305. var drawgrid = vgap.map.zoom >= 40;
  306. if (vgap.settings.isacademy)
  307. drawgrid = vgap.map.zoom >= 30;
  308. if (drawgrid && fullrender) {
  309.  
  310. ctx.strokeStyle = "#222";
  311. ctx.lineWidth = 1;
  312.  
  313. var gridsize = vgap.map.canvas.width / vgap.map.canvas.mapwidth;
  314. var srad = gridsize / 2;
  315. var x = Math.floor(vgap.map.canvas.x);
  316. for (var i = 0; i <= (vgap.map.canvas.mapwidth + 1) ; i++) {
  317. var y = Math.floor(vgap.map.canvas.y);
  318. for (var j = 0; j <= (vgap.map.canvas.mapheight + 1) ; j++) {
  319. var screenX = this.screenX(x);
  320. var screenY = this.screenY(y);
  321. ctx.strokeRect(screenX - srad, screenY - srad, srad * 2, srad * 2);
  322. ctx.strokeRect(screenX - 1, screenY - 1, 2, 2);
  323. y++;
  324. }
  325. x++;
  326. }
  327. }
  328.  
  329. if (vgap.settings.sphere && vgap.accountsettings.sphereborder)
  330. {
  331. ctx.strokeStyle = "#222";
  332. ctx.lineWidth = 1;
  333. ctx.strokeRect(this.screenX(2000 - vgap.settings.mapwidth/2 - 10), this.screenY(2000 + vgap.settings.mapheight/2 + 10), (vgap.settings.mapwidth + 20) * this.zoom, (vgap.settings.mapheight + 20) * this.zoom);
  334. }
  335. //nebulas
  336. if (vgap.nebulas && fullrender) {
  337.  
  338. for (var i = 0; i < vgap.nebulas.length; i++) {
  339. var neb = vgap.nebulas[i];
  340.  
  341. //var rad = neb.radius * vgap.map.zoom;
  342. var visible = this.isVisible(neb.x, neb.y, neb.radius);
  343.  
  344. //if on this canvas
  345. if (visible) {
  346. var screenX = this.screenX(neb.x);
  347. var screenY = this.screenY(neb.y);
  348. this.drawNebula(screenX, screenY, neb, ctx);
  349. }
  350. }
  351. }
  352.  
  353. //stars
  354. if (vgap.stars && fullrender) {
  355. for (var i = 0; i < vgap.stars.length; i++) {
  356. var star = vgap.stars[i];
  357.  
  358. //var rad = Math.sqrt(star.mass) * vgap.map.zoom;
  359. var visible = this.isVisible(star.x, star.y, Math.sqrt(star.mass));
  360.  
  361. if (visible) {
  362. var screenX = this.screenX(star.x);
  363. var screenY = this.screenY(star.y);
  364. this.drawStar(screenX, screenY, star, ctx);
  365. }
  366. }
  367. }
  368.  
  369. //minefields
  370. if (fullrender) {
  371. for (var i = 0; i < vgap.minefields.length; i++) {
  372. var minefield = vgap.minefields[i];
  373. var rad = minefield.radius * vgap.map.zoom;
  374. var visible = this.isVisible(minefield.x, minefield.y, minefield.radius);
  375.  
  376. //if on this canvas
  377. if (visible) {
  378.  
  379. var screenX = this.screenX(minefield.x);
  380. var screenY = this.screenY(minefield.y);
  381. this.drawMinefield(screenX, screenY, minefield.color, rad, ctx, minefield.isweb,minefield.ownercolor);
  382. }
  383. }
  384. }
  385.  
  386. //ions
  387. if (fullrender) {
  388. for (var i = 0; i < vgap.ionstorms.length; i++) {
  389. var storm = vgap.ionstorms[i];
  390.  
  391. var rad = storm.radius * vgap.map.zoom;
  392. var visible = this.isVisible(storm.x, storm.y, storm.radius);
  393.  
  394. //if on this canvas
  395. if (visible) {
  396. var screenX = this.screenX(storm.x);
  397. var screenY = this.screenY(storm.y);
  398. this.drawIon(screenX, screenY, storm.voltage, rad, ctx, storm);
  399. }
  400. }
  401. }
  402.  
  403. //wormholes
  404. if (fullrender && vgap.wormholes) {
  405. for (var i = 0; i < vgap.wormholes.length; i++) {
  406. var wormhole = vgap.wormholes[i];
  407.  
  408. var rad = this.planetRad(wormhole);
  409.  
  410. var hasEntrance = (wormhole.x != 0 && wormhole.y != 0);
  411. var hasExit = (wormhole.targetx != 0 && wormhole.targety != 0);
  412.  
  413. if (hasEntrance) {
  414.  
  415. var x = wormhole.x;
  416. var y = wormhole.y;
  417.  
  418. var visible = this.isVisible(x, y, 3);
  419.  
  420. //if on this canvas
  421. if (visible) {
  422. var screenX = this.screenX(x);
  423. var screenY = this.screenY(y);
  424. this.drawWormHole(screenX, screenY, rad, false, wormhole, ctx);
  425. }
  426. }
  427.  
  428. if (hasExit) {
  429.  
  430. var x = wormhole.targetx;
  431. var y = wormhole.targety;
  432.  
  433. var visible = this.isVisible(x, y, 3);
  434.  
  435. //if on this canvas
  436. if (visible) {
  437. var screenX = this.screenX(x);
  438. var screenY = this.screenY(y);
  439. this.drawWormHole(screenX, screenY, rad, true, wormhole, ctx);
  440. }
  441. }
  442.  
  443. if (hasEntrance && hasExit) {
  444. ctx.beginPath();
  445. this.drawLine(ctx, this.screenX(wormhole.x), this.screenY(wormhole.y), this.screenX(wormhole.targetx), this.screenY(wormhole.targety), colorToRGBA("#f69704", 0.2), 1);
  446. }
  447. }
  448. }
  449. //planets
  450. for (var i = 0; i < vgap.planets.length; i++) {
  451.  
  452. var planet = vgap.planets[i];
  453.  
  454. var skip = false;
  455.  
  456. if (!skip) {
  457. var rad = this.planetRad(planet);
  458. var visible = this.isVisible(planet.x, planet.y, rad + 8);
  459.  
  460. //if on this canvas
  461. if (visible) {
  462.  
  463. var screenX = this.screenX(planet.x);
  464. var screenY = this.screenY(planet.y);
  465.  
  466. //draw warp well
  467. if (vgap.map.zoom >= 10 && planet.debrisdisk == 0 && fullrender && !vgap.settings.isacademy) {
  468.  
  469. ctx.fillStyle = "#000000";
  470. ctx.strokeStyle = "#555555";
  471. ctx.lineWidth = 1;
  472. for (var x = (planet.x - 3) ; x <= planet.x + 3; x++) {
  473. for (var y = (planet.y - 3) ; y <= planet.y + 3; y++) {
  474. if (Math.dist(x, y, planet.x, planet.y) <= 3) {
  475. var mX = this.screenX(x);
  476. var mY = this.screenY(y);
  477. var srad = vgap.map.zoom / 2;
  478. ctx.fillRect(mX - srad, mY - srad, srad * 2, srad * 2);
  479. ctx.strokeRect(mX - srad, mY - srad, srad * 2, srad * 2);
  480. }
  481. }
  482. }
  483. }
  484. this.drawPlanet(planet, ctx, fullrender);
  485. }
  486. }
  487. }
  488. //Debris Disk Fill
  489. if (fullrender) {
  490. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  491. var planet = vgap.debrisdisks[i];
  492. var rad = planet.debrisdisk * vgap.map.zoom;
  493.  
  494. var visible = this.isVisible(planet.x, planet.y, rad);
  495.  
  496. //if on this canvas
  497. if (visible) {
  498.  
  499. //draw centers
  500. var screenX = this.screenX(planet.x);
  501. var screenY = this.screenY(planet.y);
  502. this.drawDebris(screenX, screenY, rad, ctx);
  503. }
  504. }
  505. }
  506. if (fullrender) {
  507. if (this.zoom > 40) {
  508.  
  509. //ships in space only
  510. for (var i = 0; i < vgap.ships.length; i++) {
  511. var ship = vgap.ships[i];
  512. var rad = this.shipRad(ship);
  513. var visible = this.isVisible(ship.x, ship.y, rad);
  514.  
  515. if (visible)
  516. this.drawShip(ship, ctx);
  517.  
  518. }
  519. }
  520. else {
  521. //ships in space only
  522. for (var i = 0; i < vgap.inspace.length; i++) {
  523. var ship = vgap.inspace[i];
  524. var rad = this.shipRad(ship);
  525. var visible = this.isVisible(ship.x, ship.y, rad);
  526.  
  527. if (visible)
  528. this.drawShip(ship, ctx);
  529. }
  530. }
  531. }
  532. //Explosions
  533. if (fullrender) {
  534. for (var i = 0; i < vgap.explosions.length; i++) {
  535. var message = vgap.explosions[i];
  536. var screenX = this.screenX(message.x);
  537. var screenY = this.screenY(message.y);
  538. var rad = 4;
  539. if (message.fatal)
  540. rad = 6;
  541.  
  542. // Stroked X
  543. ctx.beginPath();
  544. ctx.moveTo(screenX - rad, screenY - rad);
  545. ctx.lineTo(screenX + rad, screenY + rad);
  546. ctx.moveTo(screenX + rad, screenY - rad);
  547. ctx.lineTo(screenX - rad, screenY + rad);
  548. ctx.closePath();
  549.  
  550. ctx.strokeStyle = message.color;
  551. ctx.lineWidth = 2;
  552. ctx.stroke();
  553. if (message.messagetype == 10)
  554. ctx.fillText( message.body.substr(message.body.indexOf("the name of the ship was:")+"the name of the ship was:".length),screenX+20,screenY+14);
  555. }
  556. }
  557. //event callout for user scripts
  558. if (fullrender)
  559. vgap.callPlugins("draw");
  560.  
  561. //user content
  562. if (drawUserContent && fullrender)
  563. this.drawUserChangeable(ctx);
  564.  
  565.  
  566. //if (fast) {
  567. // if (vgap.map.drawtimer)
  568. // clearTimeout(vgap.map.drawtimer);
  569. // vgap.map.drawtimer = setTimeout(function () { vgap.map.draw(); }, 200);
  570. //}
  571.  
  572. //copy to second canvas for slow panning
  573. vgap.map.ctx2.clearRect(0, 0, vgap.map.canvas.width, vgap.map.canvas.height);
  574. vgap.map.ctx2.drawImage(vgap.map.canvas, 0, 0);
  575. vgap.map.canvas2.x = vgap.map.canvas.x;
  576. vgap.map.canvas2.y = vgap.map.canvas.y;
  577. vgap.map.canvas2.zoom = vgap.map.zoom;
  578. vgap.map.canvas2.centerX = vgap.map.centerX;
  579. vgap.map.canvas2.centerY = vgap.map.centerY;
  580.  
  581.  
  582. drawing = false;
  583. this.showDrawTime(fast);
  584. }
  585. };
  586. var oldSetMineColors = vgaPlanets.prototype.setMineColors;
  587.  
  588. vgaPlanets.prototype.setMineColors = function (minefield) {
  589. checkColorModSettings();
  590. var sets = vgap.accountsettings;
  591. if (activeColorMod==false)
  592. {
  593. oldSetMineColors.apply(this,arguments);
  594. }
  595.  
  596. else if (vgaPlanets.prototype.version>=3)
  597. {
  598. if ((defaultMyColor==true)&&(minefield.ownerid == vgap.player.id))
  599. minefield.color = sets.mymines;
  600. else //use new colors
  601. {
  602. if (minefield.ownerid>0)
  603. minefield.color=colorsA2[minefield.ownerid-1];
  604. else minefield.color=modUnknown2;
  605. if (useColorPicker>0)
  606. {
  607. var relation = vgap.getRelation(minefield.ownerid);
  608. if (relation != null && relation.color && relation.color != "")
  609. minefield.color = "#" + relation.color;
  610. }
  611. }
  612. }
  613.  
  614. };
  615.  
  616. var oldDrawPlanet = vgapMap.prototype.drawPlanet;
  617.  
  618. vgapMap.prototype.drawPlanet = function(planet, ctx,fullrender)
  619. {
  620. if (activeColorMod==false)
  621. {
  622. oldDrawPlanet.apply(this,arguments);
  623. }
  624. else
  625. {
  626. var x = this.screenX(planet.x);
  627. var y = this.screenY(planet.y);
  628. var rad = this.planetRad(planet);
  629.  
  630. var from = planet.colorfrom;
  631. var to = planet.colorto;
  632.  
  633. var bg = colorToRGBA(to, 0.2);
  634. if (vgap.godmode) {
  635. if (planet.flag == 1) {
  636. from = "#ffffff";
  637. to = "#0000ff";
  638. if (this.putHypCircle) {
  639. //this.hypcircles = [];
  640. this.hypcircles.push({ x: planet.x, y: planet.y });
  641. }
  642. } else if (planet.flag == 2) {
  643. from = "#ffffff";
  644. to = "#00ff00";
  645. }
  646. }
  647. if (planet.id < 0) {
  648. from = colorToRGBA(from, 0.5);
  649. to = colorToRGBA(to, 0.5);
  650. }
  651.  
  652. if (vgap.settings.isacademy) {
  653. ctx.fillStyle = bg;
  654. ctx.fillRect(this.screenX(planet.x - 0.5), this.screenY(planet.y + 0.5), this.zoom, this.zoom);
  655. }
  656. //on first draw create a sprite
  657. var spritekey = "planet" + from.substring(1) + to.substring(1) + planet.isbase + (planet.debrisdisk > 0) + (planet.id < 0);
  658. this.drawPlanetSprite(spritekey, rad, from, to, planet.isbase);
  659.  
  660. var grad = ctx.createLinearGradient(x - rad, y - rad, x + rad, y + rad);
  661. grad.addColorStop(0, from);
  662. grad.addColorStop(1, to);
  663. ctx.fillStyle = grad;
  664.  
  665. if (((this.zoom > 20 && planet.debrisdisk == 0) || (this.zoom > 100 && planet.debrisdisk > 0)) && vgap.animations && fullrender && vgap.map.fastrendering) {
  666.  
  667. if (planet.scale)
  668. rad *= planet.scale;
  669.  
  670. //draw the image of the planet
  671. if (!planet.imgObj) {
  672. planet.imgObj = new Image();
  673. planet.imgObj.onload = function () { vgap.map.draw(); };
  674. planet.imgObj.src = planet.img;
  675. if (planet.debrisdisk > 0) {
  676. planet.rotation = Math.random() * Math.PI;
  677. planet.scale = Math.random() * 0.5 + 0.5;
  678. }
  679. }
  680. else {
  681. if (planet.rotation > 0) {
  682. //draw rotated version
  683. ctx.save();
  684. ctx.translate(x, y);
  685. ctx.rotate(planet.rotation);
  686. ctx.drawImage(planet.imgObj, -rad, -rad, rad * 2, rad * 2);
  687. ctx.restore();
  688. }
  689. else
  690. ctx.drawImage(planet.imgObj, x - rad, y - rad, rad * 2, rad * 2);
  691.  
  692. }
  693.  
  694. if (planet.isbase) {
  695. var sb = vgap.getStarbase(planet.id);
  696. ctx.drawImage(vgap.sbimg[sb.starbasetype], x+(rad/3), y-rad, rad/1.5, rad/1.5);
  697. }
  698. }
  699. else if (vgap.map.zoom <= 2) {
  700. this.drawSprite(ctx, spritekey, x, y, rad + 1);
  701. }
  702. else {
  703. if (planet.isbase) {
  704. ctx.fillRect(x - rad, y - rad, rad * 2, rad * 2);
  705. }
  706. else {
  707. ctx.beginPath();
  708. ctx.arc(x, y, rad, 0, Math.PI * 2, false);
  709. ctx.closePath();
  710. ctx.fill();
  711. }
  712. }
  713. //stroke the planet appropriately
  714. if (this.zoom < 40 && fullrender)
  715. {
  716. //this should result with multiple rings of different colors for your ships, an allied ship, and an enemy ship.
  717. var sets = vgap.accountsettings;
  718.  
  719. var color;
  720. var shipsAt = vgap.shipsAt(planet.x, planet.y);
  721. for (var j = 0; j < shipsAt.length; j++)
  722. {
  723. var number=shipsAt[j].ownerid;
  724. color=colorsA2[number-1];
  725. if (shipsAt[j].ownerid == vgap.player.id)
  726. planet.myShip = true;
  727. else
  728. {
  729. var relation = vgap.getRelation(shipsAt[j].ownerid)
  730. if (relation != null && relation.color && relation.color != "")
  731. planet.colorShip = relation.color;
  732. else if (vgap.allied(shipsAt[j].ownerid))
  733. planet.allyShip = true;
  734. else
  735. planet.enemyShip = true;
  736. }
  737. }
  738.  
  739. if (planet.myShip) {
  740. if (defaultMyColor==true)
  741. ctx.strokeStyle = sets.myshipfrom;
  742. else
  743. ctx.strokeStyle =colorsA2[vgap.player.id-1];
  744. this.drawPlanetStrokeSprite("myplanetship", 12, colorsA2[vgap.player.id-1]);
  745. ctx.lineWidth = 1;
  746. ctx.beginPath();
  747. ctx.arc(x, y, rad + 2, 0, Math.PI * 2, false);
  748. ctx.closePath();
  749. ctx.stroke();
  750. }
  751. if (planet.allyShip||planet.colorShip) {
  752.  
  753. this.drawPlanetStrokeSprite("enemyplanetship", 10, color);
  754.  
  755. //if (vgap.map.zoom <= 2)
  756. // this.drawSprite(ctx, "enemyplanetship", x, y, rad + 5);
  757. //else {
  758.  
  759. ctx.strokeStyle = color;
  760. ctx.lineWidth = 1;
  761. ctx.beginPath();
  762. ctx.arc(x, y, rad + 4, 0, Math.PI * 2, false);
  763. ctx.closePath();
  764. ctx.stroke();
  765. //}
  766. }
  767. if (planet.enemyShip) {
  768. this.drawPlanetStrokeSprite("enemyplanetship", 14, color);
  769. // if (vgap.map.zoom <= 2) {
  770. // this.drawSprite(ctx, "enemyplanetship", x, y, rad + 5);
  771. // }
  772. // else {
  773. ctx.strokeStyle = color;
  774. ctx.lineWidth = 1;
  775. ctx.beginPath();
  776. ctx.arc(x, y, rad + 6, 0, Math.PI * 2, false);
  777. ctx.closePath();
  778. ctx.stroke();
  779. // }
  780. }
  781. }
  782. if (planet.note && planet.note.body.length > 0 && fullrender) {
  783. ctx.strokeStyle = "#FFFF00";
  784. ctx.lineWidth = 1;
  785. ctx.strokeRect(x - rad - 1, y - rad - 1, (rad + 1) * 2, (rad + 1) * 2);
  786. }
  787. }
  788. };
  789.  
  790. var oldDrawMinefield = vgapMap.prototype.drawMinefield;
  791.  
  792. vgapMap.prototype.drawMinefield = function (x, y, color, rad, ctx,isweb,bordercolor)
  793. {
  794. if (activeColorMod==false)
  795. {
  796. oldDrawMinefield.apply(this,arguments);
  797. }
  798. else
  799. {
  800. var grad = ctx.createRadialGradient(x, y, 0, x, y, rad);
  801. var spritekey = "mine" + color.substring(1);
  802. if (!vgap.map.sprites[spritekey]) {
  803. sctx = vgap.map.spritectx;
  804. var soffset = vgap.map.spriteindex * vgap.map.spritewidth;
  805. var srad = 24;
  806. var sx = soffset + srad+1;
  807. var sy = srad+1;
  808.  
  809. var grad = sctx.createRadialGradient(sx, sy, 0, sx, sy, srad);
  810. if (isweb==false)
  811. {
  812. grad.addColorStop(0, colorToRGBA(color, 0.4));
  813. grad.addColorStop(1, colorToRGBA(color, 0.2));
  814. }
  815. else
  816. {
  817. grad.addColorStop(0.9, colorToRGBA(color, 0.15));
  818. grad.addColorStop(1, colorToRGBA(color, 0.3));
  819. }
  820. sctx.fillStyle = grad;
  821.  
  822. sctx.beginPath();
  823. sctx.arc(sx, sy, srad, 0, Math.PI * 2, false);
  824. sctx.closePath();
  825. sctx.fill();
  826.  
  827. vgap.map.sprites[spritekey] = { key: spritekey, offset: soffset, width: (srad * 2 + 2) };
  828. vgap.map.spriteindex++;
  829. }
  830. if (vgap.map.zoom <= 1 && !vgap.map.fastrendering) {
  831. this.drawSprite(ctx, spritekey, x, y, rad + 1);
  832. }
  833. else{
  834. if (isweb==false)
  835. {
  836. grad.addColorStop(0, colorToRGBA(color, 0.4));
  837. grad.addColorStop(1, colorToRGBA(color, 0.2));
  838. }
  839. else
  840. {
  841. grad.addColorStop(0.9, colorToRGBA(color, 0.15));
  842. grad.addColorStop(1, colorToRGBA(color, 0.3));
  843. }
  844. ctx.fillStyle = grad;
  845.  
  846. if (bordercolor)
  847. ctx.strokeStyle = colorToRGBA(bordercolor, 0.2);
  848. ctx.lineWidth = 2;
  849. ctx.beginPath();
  850. ctx.arc(x, y, rad, 0, Math.PI * 2, false);
  851. ctx.closePath();
  852. ctx.fill();
  853. if (bordercolor)
  854. ctx.stroke();
  855.  
  856. //centerpoint
  857. ctx.beginPath();
  858. ctx.arc(x, y, 1, 0, Math.PI * 2, false);
  859. ctx.closePath();
  860. ctx.fill();
  861. }
  862. }
  863. };
  864.  
  865. var oldSetShipColors = vgaPlanets.prototype.setShipColors;
  866.  
  867. vgaPlanets.prototype.setShipColors = function (ship)
  868. {
  869. var sets = vgap.accountsettings;
  870. if (activeColorMod==false)
  871. {
  872. oldSetShipColors.apply(this,arguments);
  873. }
  874. else
  875. {
  876. if ((defaultMyColor==true)&&(ship.ownerid == vgap.player.id))
  877. {
  878. ship.colorfrom = sets.myshipfrom;
  879. ship.colorto = sets.myshipto;
  880. if (ship.hullid >= 200 && ship.hullid <= 300) {
  881. ship.colorfrom = "#7a7a3e";
  882. ship.colorto = "#717131";
  883. }
  884.  
  885. if (ship.hullid == 205) {
  886. ship.colorfrom = sets.myplanetfrom;
  887. ship.colorto = sets.myplanetto;
  888. }
  889. return;
  890. }
  891. if(useColorPicker>0)
  892. {
  893. var relation = vgap.getRelation(ship.ownerid);
  894. if (relation != null && relation.color != "") {
  895. ship.colorfrom = "#" + shadeColor(relation.color, 100);
  896. ship.colorto = "#" + shadeColor(relation.color, -100);
  897. return;
  898. }
  899. }
  900. if ((ship.ownerid>0)&&(ship.ownerid<30))
  901. {
  902. ship.colorfrom = colorsA[ship.ownerid-1];
  903. ship.colorto = colorsA2[ship.ownerid-1];
  904. return;
  905. }
  906. //weird, but seems it can happen
  907. ship.colorfrom = modUnknown;
  908. ship.colorto = modUnknown2;
  909. }
  910. };
  911.  
  912. var oldSetPlanetColors = vgaPlanets.prototype.setPlanetColors;
  913.  
  914. vgaPlanets.prototype.setPlanetColors = function (planet) {
  915. var sets = vgap.accountsettings;
  916. if (activeColorMod==false)
  917. {
  918. oldSetPlanetColors.apply(this,arguments);
  919. }
  920.  
  921. else
  922. {
  923. //determine rings required
  924. var shipsAt = vgap.shipsAt(planet.x, planet.y);
  925. for (var j = 0; j < shipsAt.length; j++) {
  926. if (shipsAt[j].ownerid == vgap.player.id)
  927. planet.myShip = true;
  928. else {
  929. var relation = vgap.getRelation(shipsAt[j].ownerid)
  930. var number=shipsAt[j].ownerid;
  931. color=colorsA2[number-1];
  932. if (relation != null && relation.color && relation.color != "")
  933. planet.colorShip = color;
  934. else if (vgap.allied(shipsAt[j].ownerid))
  935. planet.allyShip = true;
  936. else
  937. planet.enemyShip = true;
  938. }
  939. }
  940.  
  941. var sets = vgap.accountsettings;
  942. if (planet.note && planet.note.color != "") {
  943. planet.colorfrom = "#" + shadeColor(planet.note.color, 100);
  944. planet.colorto = "#" + shadeColor(planet.note.color, -100);
  945. return;
  946. }
  947. if ((defaultMyColor==true)&&(planet.ownerid == vgap.player.id))
  948. {
  949. planet.colorfrom = sets.myplanetfrom;
  950. planet.colorto = sets.myplanetto;
  951. return;
  952. }
  953.  
  954. if(planet.ownerid==0&&planet.infoturn>0)
  955. {
  956. planet.colorfrom=modInfo;
  957. planet.colorto=modInfo2;
  958. return
  959. }
  960. if(planet.ownerid==0)
  961. {
  962. planet.colorfrom=modUnknown;
  963. planet.colorto=modUnknown2;
  964. return
  965. }
  966. if(useColorPicker>0)
  967. {
  968. var relation = vgap.getRelation(planet.ownerid);
  969. if (relation != null && relation.color != "") {
  970. planet.colorfrom = "#" + shadeColor(relation.color, 100);
  971. planet.colorto = "#" + shadeColor(relation.color, -100);
  972. return;
  973. }
  974. }
  975. planet.colorfrom=colorsA[planet.ownerid-1];
  976. planet.colorto=colorsA2[planet.ownerid-1]
  977. }
  978. };
  979.  
  980.  
  981.  
  982. var oldLoadWaypoints = vgaPlanets.prototype.loadWaypoints;
  983.  
  984. vgaPlanets.prototype.loadWaypoints = function () {
  985. if (activeColorMod==false)
  986. {
  987. oldLoadWaypoints.apply(this,arguments);
  988. }
  989. else
  990. {
  991.  
  992. var sets = vgap.accountsettings;
  993.  
  994. this.waypoints = new Array();
  995. for (var i = 0; i < vgap.ships.length; i++) {
  996. //waypoint
  997. var ship = vgap.ships[i];
  998. if (ship.ownerid != vgap.player.id) {
  999. if (ship.heading != -1 && ship.warp != 0) {
  1000.  
  1001. var relation = vgap.getRelation(ship.ownerid);
  1002.  
  1003. var color = colorsA2[ship.ownerid-1];
  1004.  
  1005. var speed = vgap.getSpeed(ship.warp, ship.hullid);
  1006.  
  1007. var x2 = ship.x + Math.round(Math.sin(Math.toRad(ship.heading)) * speed);
  1008. var y2 = ship.y + Math.round(Math.cos(Math.toRad(ship.heading)) * speed);
  1009. ship.targetx = x2;
  1010. ship.targety = y2;
  1011. if (useColorPicker>0)
  1012. if (relation.color && relation.color != "")
  1013. color = "#" + relation.color;
  1014. this.waypoints.push({ id: ship.id, x1: ship.x, y1: ship.y, x2: x2, y2: y2, color: color });
  1015.  
  1016. //this.waypoints.push(this.paper.path("M" + this.screenX(ship.x) + " " + this.screenY(ship.y) + "L" + this.screenX(x2) + " " + this.screenY(y2)).attr({ stroke: color, "stroke-width": "2", "stroke-opacity": 0.5 }));
  1017. }
  1018. }
  1019. else {
  1020.  
  1021. if (vgap.isChunnelling(ship)) {
  1022.  
  1023. var x = ship.x;
  1024. var y = ship.y;
  1025.  
  1026. //we are initiating a chunnel at warp speed inside a matrix
  1027. if (ship.warp > 0 && (ship.targetx != ship.x || ship.targety != ship.y)) {
  1028.  
  1029.  
  1030. var dasharray = null;
  1031. var color = sets.myshipto;
  1032.  
  1033. var next = vgap.getNextLoc(ship);
  1034.  
  1035. var waypoint = { id: ship.id, x1: x, y1: y, x2: next.x, y2: next.y, color: color, dasharray: dasharray };
  1036. this.waypoints.push(waypoint);
  1037. ship.lastwaypoint = waypoint;
  1038.  
  1039. x = next.x;
  1040. y = next.y;
  1041. }
  1042.  
  1043. var targetId = parseInt(ship.friendlycode, 10);
  1044. var target = vgap.getShipClosestCopy(targetId, ship.x, ship.y);
  1045. var dasharray = [9, 4];
  1046. var color = "#00FFFF";
  1047. if (ship.id < 0)
  1048. color = "rgba(0, 255, 255, 0.15)";
  1049. var linewidth = 2;
  1050. if (ship.hullid != 56 && ship.hullid != 114) {
  1051. dasharray = [5, 2];
  1052. color = "#009999";
  1053. }
  1054. if (vgap.multiChunnel(ship.x, ship.y, target.x, target.y)) {
  1055. linewidth = 6;
  1056. dasharray = [6,6];
  1057. }
  1058.  
  1059. this.waypoints.push({ id: ship.id, x1: x, y1: y, x2: target.x, y2: target.y, color: color, dasharray: dasharray, linewidth: linewidth });
  1060. }
  1061. else if (vgap.isTemporalLancing(ship)) {
  1062.  
  1063. var x = ship.x;
  1064. var y = ship.y;
  1065.  
  1066. var target = vgap.getTemporalLanceEndPoint(ship);
  1067. var dasharray = [9, 4];
  1068. var color = "#FF00FF";
  1069. var linewidth = 2;
  1070.  
  1071. this.waypoints.push({ id: ship.id, x1: x, y1: y, x2: target.x, y2: target.y, color: color, dasharray: dasharray, linewidth: linewidth });
  1072. }
  1073. else {
  1074.  
  1075. var dasharray = null;
  1076. var color;
  1077. if (defaultMyColor==true)
  1078. color = sets.myshipto;
  1079. else
  1080. {
  1081. color = colorsA2[ship.ownerid-1];
  1082. }
  1083. var path = vgap.getPath(ship);
  1084. if (vgap.isHyping(ship)) {
  1085. color = "#F5F5DC";
  1086. dasharray = [2, 2];
  1087.  
  1088. if (path.length > 0) {
  1089. var first = path[0];
  1090. var dist = Math.dist(first.x1, first.y1, first.x2, first.y2);
  1091. var mindist = 339.95;
  1092. var maxdist = 360.05;
  1093. var middist = 350;
  1094. if (vgap.settings.isacademy) {
  1095. mindist = 8;
  1096. maxdist = 9;
  1097. middist = 8.5;
  1098. }
  1099. if (dist < mindist || dist > maxdist) {
  1100. //now we just fly exactly 350
  1101. color = "#FF0000";
  1102. ship.heading = vgap.getHeading(first.x1, first.y1, first.x2, first.y2);
  1103. first.x2 = ship.x + Math.round(Math.sin(Math.toRad(ship.heading)) * middist);
  1104. first.y2 = ship.y + Math.round(Math.cos(Math.toRad(ship.heading)) * middist);
  1105. }
  1106. }
  1107. }
  1108. //use tower path
  1109. var tower = vgap.isTowTarget(ship.id);
  1110. if (tower != null)
  1111. path = vgap.getPath(tower);
  1112.  
  1113. var startfuel = ship.neutronium;
  1114. for (var j = 0; j < path.length; j++) {
  1115. if (vgap.isHyping(ship) && j > 0)
  1116. break;
  1117. //change color for fuel shortage
  1118. var fuel = vgap.getFuelUsage(path[j].x1, path[j].y1, path[j].x2, path[j].y2, ship);
  1119. if (fuel > startfuel && tower == null)
  1120. color = "#ff6600";
  1121. //pod color
  1122. if (ship.hullid >= 200 && ship.hullid < 300)
  1123. color = colorToRGBA("#7a7a3e", 0.1);
  1124. startfuel -= fuel;
  1125.  
  1126. var waypoint = { id: ship.id, x1: path[j].x1, y1: path[j].y1, x2: path[j].x2, y2: path[j].y2, color: color, dasharray: dasharray };
  1127. this.waypoints.push(waypoint);
  1128. // this.waypoints.push(this.paper.path("M" + this.screenX(path[j].x1) + " " + this.screenY(path[j].y1) + "L" + this.screenX(path[j].x2) + " " + this.screenY(path[j].y2)).attr(params));
  1129. ship.lastwaypoint = waypoint;
  1130. }
  1131. }
  1132. }
  1133. }
  1134. for (var i = 0; i < vgap.ionstorms.length; i++) {
  1135. var storm = vgap.ionstorms[i];
  1136. if (storm.parentid == 0) {
  1137.  
  1138. var x = storm.x;
  1139. var y = storm.y;
  1140. if (storm.centroid) {
  1141. x = storm.centroid.x;
  1142. y = storm.centroid.y;
  1143. }
  1144.  
  1145. var x2 = x + Math.round(Math.sin(Math.toRad(storm.heading)) * storm.warp * storm.warp);
  1146. var y2 = y + Math.round(Math.cos(Math.toRad(storm.heading)) * storm.warp * storm.warp);
  1147.  
  1148. //add 1000 to id to make sure it doesnt' match up with ship ids
  1149. this.waypoints.push({ id: 1000 + storm.id, x1: x, y1: y, x2: x2, y2: y2, color: colorToRGBA("#FFFF00", 0.1) });
  1150. }
  1151. }
  1152. if (vgap.player.raceid == 12) {
  1153. for (var i = 0; i < vgap.myplanets.length; i++) {
  1154. var planet = vgap.myplanets[i];
  1155. if (planet.podhullid > 0) {
  1156.  
  1157. if (planet.builtdefense > 0 && vgap.player.raceid == 12) {
  1158.  
  1159. var podTarget = vgap.getShip(planet.builtdefense);
  1160.  
  1161. if (podTarget != null) {
  1162. //bounce off accellerator
  1163. this.waypoints.push({ id: planet.id, x1: planet.x, y1: planet.y, x2: podTarget.x, y2: podTarget.y, color: colorToRGBA("#7a7a3e", 0.5) });
  1164. this.waypoints.push({ id: planet.id, x1: podTarget.x, y1: podTarget.y, x2: planet.targetx, y2: planet.targety, color: colorToRGBA("#7a7a3e", 0.5) });
  1165. }
  1166.  
  1167. }
  1168. else
  1169. this.waypoints.push({ id: planet.id, x1: planet.x, y1: planet.y, x2: planet.targetx, y2: planet.targety, color: colorToRGBA("#7a7a3e", 0.5) });
  1170. }
  1171. }
  1172. }
  1173. }//mod is true
  1174. };
  1175.  
  1176. var oldMineText = vgapMap.prototype.mineText;
  1177.  
  1178. vgapMap.prototype.mineText = function (x, y) {
  1179. if ((activeColorMod==false))
  1180. oldMineText.apply(this,arguments);
  1181. else
  1182. {
  1183. var txt = "";
  1184. for (var i = 0; i < vgap.minefields.length; i++) {
  1185. var minefield = vgap.minefields[i];
  1186. if (Math.dist(minefield.x, minefield.y, x, y) <= minefield.radius) {
  1187. txt += "<div class='ItemSelectionBox minCorrection'><span>";
  1188. if (minefield.ownerid == vgap.player.id)
  1189. if (minefield.isweb)
  1190. txt += "Your Web Minefield ";
  1191. else
  1192. txt += "Your Minefield ";
  1193. else {
  1194. var player = vgap.getPlayer(minefield.ownerid);
  1195. var race = vgap.getRace(player.raceid);
  1196. if (minefield.isweb)
  1197. txt += race.adjective + " (" + player.username + ") Web Minefield ";
  1198. else
  1199. txt += race.adjective + " (" + player.username + ") Minefield ";
  1200. }
  1201. txt += "Id:" + minefield.id + "</span>";
  1202. txt += "<table class='CleanTable' style='width:100%;'>";
  1203. txt += "<tr><td>Mines: </td><td> " + gsv(minefield.units) + " </td><td>&nbsp;Radius: </td><td> " + gsv(minefield.radius) + " </td></tr>";
  1204. var lastscanned = vgap.game.turn - minefield.infoturn + " turns ago";
  1205. if (minefield.infoturn == vgap.game.turn)
  1206. lastscanned = "this turn";
  1207.  
  1208. if (vgap.settings.isacademy)
  1209. txt += "<tr><td colspan = 4> Scanned: " + lastscanned + "</td></tr>";
  1210. else
  1211. txt += "<tr><td>Scanned: </td><td> " + lastscanned + "</td><td>&nbsp;Friendly: </td><td> " + gsv(minefield.friendlycode) + " </td></tr>";
  1212. txt += "</table></div>";
  1213. }
  1214. }
  1215. return txt;
  1216. }
  1217. };
  1218.  
  1219. var oldShowSettings = vgapDashboard.prototype.showSettings;
  1220.  
  1221. vgapDashboard.prototype.showSettings = function () {
  1222.  
  1223.  
  1224. var new_html="";
  1225. new_html += "<div id='ResetTurnButton' class='BasicFlatButton' onclick='vgapDashboard.prototype.resetNotes();'>Reset all note colors to blank</div><hr>";
  1226. new_html += "<br><h3>Custom Settings for Color Mod</h3>";
  1227. new_html += "<div style='width:250px;'></div>";
  1228. new_html += "<div id='Test'><table>";
  1229. new_html += "<tr><td><div id='LaunchSim' onclick='vgapDashboard.prototype.resetColorModColors();' title='Default is: Active.'>Reset all custom color settings </div></td>";
  1230. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeDefaultMyColor();' title='Default is: Active.'>Use default colors for My Race Only</div></td>";
  1231. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeColorMod();' title='Default is: Active.'>Activate or Deactivate Color Mod</div></td>";
  1232. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeColorPicker();' title='Default is: InActive.'>Set Diplomatic Color Picker</div></td></tr></table>";
  1233.  
  1234. new_html += "<div id='AccountSettings2'><table>";
  1235. new_html += "<tr><th>Color Settings</th></tr>";
  1236.  
  1237. //html += this.renderSetColorMod("Race 1", "test");
  1238. new_html += "<tr><td>" + "Race 1" + "</td><td><input type='text' id='Race1' onchange='SaveRace();' value='" + colorsA[0] + "'/></td><td><input type='text' id='Race1A' onchange='SaveRace();' value='" + colorsA2[0] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[0] + "), color-stop(1, " + colorsA2[0] + ")); background: -moz-linear-gradient(top left," + colorsA[0] + " 0%, " + colorsA2[0] + " 100%)' type='text' id='IgnoreRace1' value=' '/></td></tr>";
  1239. new_html += "<tr><td>" + "Race 2" + "</td><td><input type='text' id='Race2' onchange='SaveRace();' value='" + colorsA[1] + "'/></td><td><input type='text' id='Race2A' onchange='SaveRace();' value='" + colorsA2[1] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[1] + "), color-stop(1, " + colorsA2[1] + ")); background: -moz-linear-gradient(top left," + colorsA[1] + " 0%, " + colorsA2[1] + " 100%)' type='text' id='IgnoreRace1' value=' '/></td></tr>";
  1240. new_html += "<tr><td>" + "Race 3" + "</td><td><input type='text' id='Race3' onchange='SaveRace();' value='" + colorsA[2] + "'/></td><td><input type='text' id='Race3A' onchange='SaveRace();' value='" + colorsA2[2] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[2] + "), color-stop(1, " + colorsA2[2] + ")); background: -moz-linear-gradient(top left," + colorsA[2] + " 0%, " + colorsA2[2] + " 100%)' type='text' id='IgnoreRace3' value=' '/></td></tr>";
  1241. new_html += "<tr><td>" + "Race 4" + "</td><td><input type='text' id='Race4' onchange='SaveRace();' value='" + colorsA[3] + "'/></td><td><input type='text' id='Race4A' onchange='SaveRace();' value='" + colorsA2[3] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[3] + "), color-stop(1, " + colorsA2[3] + ")); background: -moz-linear-gradient(top left," + colorsA[3] + " 0%, " + colorsA2[3] + " 100%)' type='text' id='IgnoreRace4 value=' '/></td></tr>";
  1242. new_html += "<tr><td>" + "Race 5" + "</td><td><input type='text' id='Race5' onchange='SaveRace();' value='" + colorsA[4] + "'/></td><td><input type='text' id='Race5A' onchange='SaveRace();' value='" + colorsA2[4] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[4] + "), color-stop(1, " + colorsA2[4] + ")); background: -moz-linear-gradient(top left," + colorsA[4] + " 0%, " + colorsA2[4] + " 100%)' type='text' id='IgnoreRace5' value=' '/></td></tr>";
  1243. new_html += "<tr><td>" + "Race 6" + "</td><td><input type='text' id='Race6' onchange='SaveRace();' value='" + colorsA[5] + "'/></td><td><input type='text' id='Race6A' onchange='SaveRace();' value='" + colorsA2[5] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[5] + "), color-stop(1, " + colorsA2[5] + ")); background: -moz-linear-gradient(top left," + colorsA[5] + " 0%, " + colorsA2[5] + " 100%)' type='text' id='IgnoreRace6 value=' '/></td></tr>";
  1244. new_html += "<tr><td>" + "Race 7" + "</td><td><input type='text' id='Race7' onchange='SaveRace();' value='" + colorsA[6] + "'/></td><td><input type='text' id='Race7A' onchange='SaveRace();' value='" + colorsA2[6] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[6] + "), color-stop(1, " + colorsA2[6] + ")); background: -moz-linear-gradient(top left," + colorsA[6] + " 0%, " + colorsA2[6] + " 100%)' type='text' id='IgnoreRace7' value=' '/></td></tr>";
  1245. new_html += "<tr><td>" + "Race 8" + "</td><td><input type='text' id='Race8' onchange='SaveRace();' value='" + colorsA[7] + "'/></td><td><input type='text' id='Race8A' onchange='SaveRace();' value='" + colorsA2[7] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[7] + "), color-stop(1, " + colorsA2[7] + ")); background: -moz-linear-gradient(top left," + colorsA[7] + " 0%, " + colorsA2[7] + " 100%)' type='text' id='IgnoreRace8 value=' '/></td></tr>";
  1246. new_html += "<tr><td>" + "Race 9" + "</td><td><input type='text' id='Race9' onchange='SaveRace();' value='" + colorsA[8] + "'/></td><td><input type='text' id='Race9A' onchange='SaveRace();' value='" + colorsA2[8] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[8] + "), color-stop(1, " + colorsA2[8] + ")); background: -moz-linear-gradient(top left," + colorsA[8] + " 0%, " + colorsA2[8] + " 100%)' type='text' id='IgnoreRace9' value=' '/></td></tr>";
  1247. new_html += "<tr><td>" + "Race 10" + "</td><td><input type='text' id='Race10' onchange='SaveRace();' value='" + colorsA[9] + "'/></td><td><input type='text' id='Race10A' onchange='SaveRace();' value='" + colorsA2[9] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[9] + "), color-stop(1, " + colorsA2[9] + ")); background: -moz-linear-gradient(top left, " + colorsA[9] + " 0%, " + colorsA2[9] + " 100%)' type='text' id='IgnoreRace10 value=' '/></td></tr>";
  1248. new_html += "<tr><td>" + "Race 11" + "</td><td><input type='text' id='Race11' onchange='SaveRace();' value='" + colorsA[10] + "'/></td><td><input type='text' id='Race11A' onchange='SaveRace();' value='" + colorsA2[10] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[10] + "), color-stop(1, " + colorsA2[10] + ")); background: -moz-linear-gradient(top left, " + colorsA[10] + " 0%, " + colorsA2[10] + " 100%)' type='text' id='IgnoreRace11' value=' '/></td></tr>";
  1249. new_html += "<tr><td>" + "Unoccupied" + "</td><td><input type='text' id='ModInfo' onchange='SaveRace();' value='" + modInfo + "'/></td><td><input type='text' id='ModInfo2' onchange='SaveRace();' value='" + modInfo2 + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + modInfo + "), color-stop(1, " + modInfo2 + ")); background: -moz-linear-gradient(top left, " + modInfo + " 0%, " + modInfo2 + " 100%)' type='text' id='IgnoreInfo value=' '/></td></tr>";
  1250. new_html += "<tr><td>" + "Unknown" + "</td><td><input type='text' id='ModUnknown' onchange='SaveRace();' value='" + modUnknown + "'/></td><td><input type='text' id='ModUnknown2' onchange='SaveRace();' value='" + modUnknown2 + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + modUnknown + "), color-stop(1, " + modUnknown2 + ")); background: -moz-linear-gradient(top left, " + modUnknown + " 0%, " + modUnknown2 + " 100%)' type='text' id='IgnoreUnknown value=' '/></td></tr>";
  1251. new_html += "<tr><td><input type='text' id='ModRace' onchange='SaveRaceNum();' value='" + modRace + "'/></td><td><input type='text' id='ModRace2' onchange='SaveRace();' value='" + colorsA[modRace-1] + "'/></td><td><input type='text' id='ModRace3' onchange='SaveRace();' value='" + colorsA2[modRace-1] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[modRace-1] + "), color-stop(1, " + colorsA2[modRace-1] + ")); background: -moz-linear-gradient(top left, " + colorsA[modRace-1] + " 0%, " + colorsA2[modRace-1] + " 100%)' type='text' id='IgnoreRaceMod value=' '/></td></tr>";
  1252. //html += "<tr><td>Test</td>" + "<td>Test2</td>" + "<td><input style='background: -moz-linear-gradient(top left, #ccffff 0%, #00ffff 100%); background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff))' type='text' id='IgnoreMe2' value=' '/></tr></td>";
  1253. //html += "<tr><td>Test2</td>" + "<td>Test3</td>" + "<td><input style='background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff)) background: -moz-linear-gradient(top left, #ccffff 0%, #00ffff 100%)' type='text' id='IgnoreMe' value=' '/></tr></td>";
  1254. //html += "<tr><td>Test</td>" + "<td>Test2</td>" + "<td><input style='background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff))' type='text' id='IgnoreMe2' value=' '/></tr></td>";
  1255. //html += "<tr><td><input style='background: -webkit-gradient(linear, left top, right bottom, from(#ccc), to(#000)); background: -moz-linear-gradient(top, #ccc, #000);' type='text' id='IgnoreMe' value=' '</td></tr>";
  1256. //html += "<tr><td><input style='background: -moz-linear-gradient(top, #ccc, #000); background: -webkit-gradient(linear, left top, right bottom, from(#ccc), to(#000)); ' type='text' id='IgnoreMe' value=' '</td></tr>";
  1257.  
  1258. new_html += "</table></div>";
  1259. this.customSettingsContent.push(new_html);
  1260. oldShowSettings.apply(this,arguments);
  1261. this.customSettingsContent.pop();
  1262. };
  1263.  
  1264. vgapDashboard.prototype.resetNotes=function()
  1265. {
  1266. if (!confirm("This function will reset all planet note colors to blank. Confirm to continue."))
  1267. return;
  1268. for (var i = 0; i < vgap.planets.length; i++)
  1269. {
  1270.  
  1271. var planet = vgap.planets[i];
  1272. if (planet.note && planet.note.color != "")
  1273. planet.note.color="";
  1274. }
  1275. };
  1276.  
  1277. SaveRaceNum=function(){
  1278. modRace=$("#ModRace").val();//melee race specified
  1279. };
  1280.  
  1281. SaveRace=function(){
  1282.  
  1283. var i;
  1284. if (modRace>11)
  1285. {
  1286. colorsA[modRace-1]=$("#ModRace2").val();
  1287. colorsA2[modRace-1]=$("#ModRace3").val();
  1288. var String3="Race"+(modRace);
  1289. set_cookie(String3,colorsA[modRace-1],2029,1,1);
  1290. set_cookie(String3+"A",colorsA2[modRace-1],2029,1,1);
  1291. }
  1292. for (i=0;i<11;i++)
  1293. {
  1294. var String="#Race"+(i+1);
  1295. var String2="Race"+(i+1);
  1296. colorsA[i]= $(String).val();
  1297. set_cookie(String2,colorsA[i],2029,1,1);
  1298. colorsA2[i]=$(String+"A").val();
  1299. set_cookie(String2+"A",colorsA2[i],2029,1,1);
  1300. }
  1301. modInfo= $("#ModInfo").val();
  1302. modUnknown= $("#ModUnknown").val();
  1303. modInfo2= $("#ModInfo2").val();
  1304. modUnknown2= $("#ModUnknown2").val();
  1305.  
  1306.  
  1307. set_cookie("ModInfo",modInfo,2099,1,1);
  1308. set_cookie("ModUnknown",modUnknown,2029,1,1);
  1309.  
  1310. set_cookie("ModInfo2",modInfo2,2014,1,1);
  1311. set_cookie("ModUnknown2",modUnknown2,2029,1,1);
  1312. vgap.loadWaypoints();
  1313. vgap.map.draw();
  1314. };
  1315.  
  1316. set_cookie=function( name, value, exp_y, exp_m, exp_d, path, domain, secure )
  1317. //name=cookie name (required)
  1318. //value=cookie value (required)
  1319. //exp_y,M,d is expiration year, month, day (if blank cookie will delete when browser closes)
  1320. //path=path within site this applies to (can be blank)
  1321. //domain=apply only to websites in this domain (can be blank)
  1322. //secure=use SSL (leave blank)
  1323.  
  1324. {
  1325. var cookie_string = name + "=" + escape ( value );
  1326.  
  1327. if ( exp_y )
  1328. {
  1329. var expires = new Date ( exp_y, exp_m, exp_d );
  1330. cookie_string += "; expires=" + expires.toGMTString();
  1331. }
  1332.  
  1333. if ( path )
  1334. cookie_string += "; path=" + escape ( path );
  1335.  
  1336. if ( domain )
  1337. cookie_string += "; domain=" + escape ( domain );
  1338. if ( secure )
  1339. cookie_string += "; secure";
  1340. document.cookie = cookie_string;
  1341. };
  1342.  
  1343. get_cookie =function( cookie_name )
  1344. {
  1345. var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  1346.  
  1347. if ( results )
  1348. return ( unescape ( results[2] ) );
  1349. else
  1350. return null;
  1351. };
  1352.  
  1353. vgapDashboard.prototype.saveToCookie = function(){
  1354. //alert("In Function save");
  1355. // set a new cookie
  1356. if (defaultMyColor==true)
  1357. {
  1358. set_cookie("defaultMyColor",1,2029,1,1);
  1359. //alert("set to true!!");
  1360. }
  1361. else{
  1362. set_cookie("defaultMyColor",0,2029,1,1);
  1363. //alert("set to false!!");
  1364. }
  1365. if (activeColorMod==true)
  1366. set_cookie("activeColorMod",1,2029,1,1);
  1367. else
  1368. set_cookie("activeColorMod",0,2029,1,1);
  1369.  
  1370. if (useColorPicker==1)
  1371. set_cookie("ColorPicker",1,2029,1,1);
  1372. else
  1373. set_cookie("ColorPicker",0,2029,1,1);
  1374. };
  1375.  
  1376.  
  1377. vgapDashboard.prototype.changeColorMod = function(){
  1378. if (activeColorMod==true)
  1379. {
  1380. activeColorMod=false;
  1381. alert("The Race Specific Color Mod is now Deactived.");
  1382. }
  1383. else
  1384. {
  1385. activeColorMod=true;
  1386. alert("The Race Specific Color Mod is now Active.");
  1387. }
  1388. vgapDashboard.prototype.saveToCookie()
  1389. vgap.loadWaypoints();
  1390. vgap.map.draw();
  1391. };
  1392.  
  1393. vgapDashboard.prototype.changeColorPicker = function(){
  1394. if (useColorPicker==1)
  1395. {
  1396. useColorPicker=0;
  1397. alert("Ignore Diplomatic Color Picker colors.");
  1398. }
  1399. else
  1400. {
  1401. useColorPicker=1;
  1402. alert("Using Diplomatic Color Picker Colors");
  1403. }
  1404. vgapDashboard.prototype.saveToCookie()
  1405. vgap.loadWaypoints();
  1406. vgap.map.draw();
  1407. };
  1408.  
  1409. vgapDashboard.prototype.resetColorModColors = function(){
  1410. alert("Resetting all colors to Mod defaults");
  1411.  
  1412. colorsA =["#F0F8FF","#32CD32","#CD5C5C","#FFC0CB","#98FB98","#C0C0C0","#FFFF00","#EE82EE","#D3D3D3","#B0E0E6","#87CEFA","#7B68EE","#F4A460","#D2B48C","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  1413. colorsA2 =["#FFFFFF","#006400","#FF0000","#FF69B4","#00FA9A","#6A5ACD","#FFD700","#9400D3","#808080","#00CED1","#4169E1","#7B68EE","#A0522D","#87CEEB","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  1414. modInfo="#F4A460";//chocolate
  1415. modInfo2="#D2691E";//chocolate
  1416.  
  1417. modUnknown="#FFF8DC"; //Tan
  1418. modUnknown2="#D2B48C"; //Tan
  1419. vgapDashboard.prototype.saveToCookie();
  1420. vgap.loadWaypoints();
  1421. vgap.map.draw();
  1422. };
  1423.  
  1424. vgapDashboard.prototype.changeDefaultMyColor = function(){
  1425. if (defaultMyColor==true)
  1426. {
  1427. alert("Mod is no longer using Default colors for your race.");
  1428. defaultMyColor=false;
  1429. }
  1430. else
  1431. {
  1432. alert("Mod will now use Default color (aqua/green) for your race.");
  1433. defaultMyColor=true;
  1434. }
  1435. vgapDashboard.prototype.saveToCookie();
  1436. vgap.loadWaypoints();
  1437. vgap.map.draw();
  1438. };
  1439.  
  1440. checkColorModSettings = function(){
  1441. //Color Mod settings
  1442. //if null, then its unset - check the cookie
  1443. //if cookie doesn't exist, set to default.
  1444. if (activeColorMod==null)
  1445. {
  1446. var checkActive=null;
  1447. checkActive=get_cookie("activeColorMod");
  1448. if (checkActive==null)
  1449. {
  1450. activeColorMod=true;//no cookie, set to default
  1451. }
  1452. else if (checkActive==1)
  1453. {
  1454. activeColorMod=true;
  1455. }
  1456. else
  1457. {
  1458. activeColorMod=false;
  1459. }
  1460. }
  1461.  
  1462. var checkPicker=null;
  1463. checkPicker=get_cookie("ColorPicker");
  1464. if (checkPicker) useColorPicker=checkPicker;
  1465. if (defaultMyColor==null)
  1466. {
  1467. var checkColor=null;
  1468. checkColor=get_cookie("defaultMyColor");
  1469. if (checkColor==null)
  1470. {
  1471. defaultMyColor=true;//no cookie, set to default
  1472. }
  1473. else if (checkColor==1)
  1474. {
  1475. defaultMyColor=true;
  1476. }
  1477. else
  1478. {
  1479. defaultMyColor=false;
  1480. }
  1481. }
  1482.  
  1483. if (useCustomColor==false)
  1484. //have not checked cookies yet
  1485. {
  1486. var i;
  1487. var checkColor=null;
  1488.  
  1489. for (i=0;i<30;i++)
  1490. {
  1491. var String="Race"+(i+1);
  1492. checkColor=get_cookie(String);
  1493. if (checkColor)
  1494. colorsA[i]=checkColor;
  1495. checkColor=null;
  1496. checkColor=get_cookie(String+"A");
  1497. if (checkColor) colorsA2[i]=checkColor;
  1498. checkColor=null;
  1499. }
  1500. checkColor=get_cookie("ModInfo");
  1501. if (checkColor) modInfo=checkColor;
  1502. checkColor=null;
  1503. checkColor=get_cookie("ModUnknown");
  1504. if (checkColor) modUnknown=checkColor;
  1505. checkColor=null;
  1506.  
  1507. checkColor=get_cookie("ModInfo2");
  1508. if (checkColor) modInfo2=checkColor;
  1509. checkColor=null;
  1510. checkColor=get_cookie("ModUnknown2");
  1511. if (checkColor) modUnknown2=checkColor;
  1512. //set var so we know cookies have been checked
  1513. useCustomColor=true;
  1514. }
  1515. };
  1516.  
  1517.  
  1518. } //wrapper for injection
  1519.  
  1520.  
  1521.  
  1522.  
  1523. var script = document.createElement("script");
  1524. script.type = "application/javascript";
  1525. script.textContent = "(" + wrapper + ")();";
  1526.  
  1527. document.body.appendChild(script);