From 186971d0031e2147c994f9a6a2cfb53d9092e473 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Mon, 15 Dec 2014 23:24:37 +0000 Subject: [PATCH] draw-tools plugin: add basic support for exporting as a stock intel URL, now that stock supports basic drawing import to be done... --- plugins/draw-tools.user.js | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/plugins/draw-tools.user.js b/plugins/draw-tools.user.js index 7b31a386..01fed201 100644 --- a/plugins/draw-tools.user.js +++ b/plugins/draw-tools.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-draw-tools@breunigs // @name IITC plugin: draw tools // @category Layer -// @version 0.6.6.@@DATETIMEVERSION@@ +// @version 0.7.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -364,8 +364,53 @@ window.plugin.drawTools.optCopy = function() { if (typeof android !== 'undefined' && android && android.shareString) { android.shareString(localStorage['plugin-draw-tools-layer']); } else { + var stockWarnings = {}; + var stockLinks = []; + window.plugin.drawTools.drawnItems.eachLayer( function(layer) { + if (layer instanceof L.GeodesicCircle || layer instanceof L.Circle) { + stockWarnings.noCircle = true; + return; //.eachLayer 'continue' + } else if (layer instanceof L.GeodesicPolygon || layer instanceof L.Polygon) { + stockWarnings.polyAsLine = true; + // but we can export them + } else if (layer instanceof L.GeodesicPolyline || layer instanceof L.Polyline) { + // polylines are fine + } else if (layer instanceof L.Marker) { + stockWarnings.noMarker = true; + return; //.eachLayer 'continue' + } else { + stockWarnings.unknown = true; //should never happen + return; //.eachLayer 'continue' + } + // only polygons and polylines make it through to here + var latLngs = layer.getLatLngs(); + // stock only handles one line segment at a time + for (var i=0; i40) stockWarnTexts.push('Warning: Stock intel may not work with more than 40 line segments - there are '+stockLinks.length); + if (stockWarnings.noCircle) stockWarnTexts.push('Warning: Circles cannot be exported to stock intel'); + if (stockWarnings.noMarker) stockWarnTexts.push('Warning: Markers cannot be exported to stock intel'); + if (stockWarnings.unknown) stockWarnTexts.push('Warning: UNKNOWN ITEM TYPE'); + + var html = '

Select all and press CTRL+C to copy it.

' + +'' + +'

or, export as a link for the standard intel map (for non IITC users)

' + +''; + if (stockWarnTexts.length>0) { + html += ''; + } + dialog({ - html: '

Select all and press CTRL+C to copy it.

', + html: html, width: 600, dialogClass: 'ui-dialog-drawtoolsSet-copy', title: 'Draw Tools Export'