Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync050 #403

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b10183e
First commit
c-schmitz Apr 2, 2016
48480ae
Fixed linebreaks
c-schmitz Apr 2, 2016
4bbc74d
Create README.md
c-schmitz Apr 2, 2016
84aaf3c
-Added import - will never delete, only update portals
c-schmitz Apr 3, 2016
d1ea5cb
Updated README
c-schmitz Apr 3, 2016
d05ef19
Fixed include/match header lines for the new Intel URL. (#1)
koljanowak Nov 1, 2018
42bff39
Code updated for V0.30
MysticJay Jan 16, 2020
726c7ba
Sync only Default
MysticJay Jan 17, 2020
d07a5eb
Typos
MysticJay Jan 18, 2020
18a6a52
fixed sync
MysticJay Feb 13, 2020
cbff2b2
Syntax correction
modos189 Feb 14, 2020
5419cdf
Delete font-awesome plugin
modos189 Feb 14, 2020
23facfd
Merge branch 'master' of github.com:IITC-CE/ingress-intel-total-conve…
modos189 Jul 13, 2020
679939c
Merge Draws
MysticJay Jul 16, 2020
9224f27
merge for import
MysticJay Jul 16, 2020
86890ea
UI fix
MysticJay Jul 16, 2020
89750ee
Introducing KEY_STORAGE
MysticJay Jul 17, 2020
02c7eb1
Code for Empty Drawn Fields (EDF) added
MysticJay Jul 20, 2020
7c2401c
Copy Dialog
MysticJay Jul 20, 2020
50a610f
Adding support for scouted and droned portals
MysticJay Jul 21, 2020
23037ab
Highlighters
MysticJay Jul 27, 2020
12ae44b
sorting portalslist fixed
MysticJay Jul 29, 2020
7c8da52
sorting uniques fixed
MysticJay Jul 29, 2020
add5b7e
Add 'plugins/uniques-export/' from commit 'd05ef190c6381ce07401c1427f…
MysticJay Aug 7, 2020
e636cda
Uniques-Export
MysticJay Aug 7, 2020
f7afca2
findPortalGuidByCacheE6
MysticJay Aug 7, 2020
ad88cca
0.3.9 beta 1
MysticJay Aug 14, 2020
3a9b203
Removing merged sources
MysticJay Aug 14, 2020
d543121
Issues #364 & hook for Alerts
MysticJay Aug 14, 2020
0ab2a94
UNIQUES 0.3.9beta2
MysticJay Aug 16, 2020
c9fbdf2
UNIQUES 0.3.9rc1
MysticJay Aug 19, 2020
5377809
Cleanup
MysticJay Aug 20, 2020
e7f3956
PortalList-Dialog fixed
MysticJay Aug 26, 2020
64f7727
Typo fix
MysticJay Aug 31, 2020
54c6ad6
abandoned dialog
MysticJay Aug 31, 2020
7d11d2e
Update uniques.js
MysticJay Sep 10, 2020
a6aeaa9
Merge branch 'Multi-Project-Extension' into SYNC50
MysticJay Sep 19, 2020
aae5c17
Merge branch 'Draw-Tools-Merge' into SYNC50
MysticJay Sep 19, 2020
94f1636
Merge branch 'EDF' into SYNC50
MysticJay Sep 19, 2020
d3f63a3
Merge branch 'uniques040' into SYNC50
MysticJay Sep 19, 2020
89dae80
Comments 1
MysticJay Oct 15, 2020
743f71e
Comments 2
MysticJay Nov 19, 2020
deee9f7
Conflict detection
MysticJay Nov 21, 2020
29a5164
Merge branch 'master' of github.com:IITC-CE/ingress-intel-total-conve…
modos189 Dec 6, 2020
ccc4f6d
Resolving Conflicts
MysticJay Dec 6, 2020
3125a7d
Merge branch 'master' into SYNC050
MysticJay Dec 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions plugins/cache-portals-on-map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @author jonatkins
// @name Cache viewed portals on map
// @category Cache
// @version 0.1.0
// @version 0.2.0
// @description Cache the details of recently viewed portals and use this to populate the map when possible


Expand Down Expand Up @@ -31,8 +31,8 @@ window.plugin.cachePortalDetailsOnMap.entityInject = function(data) {
};

// extend portal's GUID lookup to search in cached portals as well
window.cachePortalDetailsOnMap.findPortalGuidByCacheE6 = function(latE6, lngE6) {
let guid = window.cachePortalDetailsOnMap.findPortalGuidByPositionE6old(latE6, lngE6);
window.plugin.cachePortalDetailsOnMap.findPortalGuidByCacheE6 = function(latE6, lngE6) {
let guid = window.plugin.cachePortalDetailsOnMap.findPortalGuidByPositionE6old(latE6, lngE6);

// PLUGIN: cache > cache
if (guid == null) {
Expand All @@ -41,25 +41,26 @@ window.cachePortalDetailsOnMap.findPortalGuidByCacheE6 = function(latE6, lngE6)
for (let g in cache.cache) {
let p = cache.cache[g];
if (latE6 == p.ent[2][2] && lngE6 == p.ent[2][3]) {
// console.log("newFindPortalGuidByPositionE6 matched in cache! %s %s -> [%s] = %o", latE6, lngE6, g, p);
console.log("findPortalGuidByCacheE6 matched in cache! %s %s -> [%s] = %o", latE6, lngE6, g, p);
guid = g;
break;
}
}
}
}
return guid;
};
}

window.cachePortalDetailsOnMap.searchInit = function () {
window.cachePortalDetailsOnMap.findPortalGuidByPositionE6old = window.findPortalGuidByPositionE6;
window.findPortalGuidByPositionE6 = window.cachePortalDetailsOnMap.findPortalGuidByCacheE6;
};
window.plugin.cachePortalDetailsOnMap.searchInit = function () {
window.plugin.cachePortalDetailsOnMap.findPortalGuidByPositionE6old = window.findPortalGuidByPositionE6;
window.findPortalGuidByPositionE6 = window.plugin.cachePortalDetailsOnMap.findPortalGuidByCacheE6;
console.log ("findPortalGuidByCacheE6 code injected");
}

window.plugin.cachePortalDetailsOnMap.setup = function() {

window.plugin.cachePortalDetailsOnMap.cache = {};
window.plugin.cachePortaldetailsOnMap.searchInit;
window.plugin.cachePortalDetailsOnMap.searchInit ();

addHook('portalDetailLoaded', window.plugin.cachePortalDetailsOnMap.portalDetailLoaded);
addHook('mapDataEntityInject', window.plugin.cachePortalDetailsOnMap.entityInject);
Expand Down
180 changes: 167 additions & 13 deletions plugins/draw-tools.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @author breunigs
// @name Draw tools
// @category Draw
// @version 0.8.0
// @description Allow drawing things onto the current map so you may plan your next move. Supports Multi-Project-Extension.

// @version 0.8.2
// @description Allow drawing things onto the current map so you may plan your next move. Supports Multi-Project-Extension and Empty Drawn Fields (EDF)

// HOOK: pluginDrawTools
// custom hook for draw tools to share it's activity with other plugins
Expand All @@ -13,6 +12,14 @@ window.plugin.drawTools = function() {};

window.plugin.drawTools.KEY_STORAGE = 'plugin-draw-tools-layer';

window.plugin.drawTools.merge = {};
window.plugin.drawTools.merge.status = true;
window.plugin.drawTools.merge.toggle() = function() {
var status = window.plugin.drawTools.merge.status;
status = Boolean(!status);
window.plugin.drawTools.merge.status = status;
}

window.plugin.drawTools.getMarkerIcon = function(color) {
if (!color) {
console.warn('Color is not set (default #a24ac3 will be used)');
Expand Down Expand Up @@ -258,21 +265,35 @@ window.plugin.drawTools.import = function(data) {


//Draw Tools Options

// Manual import, export and reset data
window.plugin.drawTools.manualOpt = function() {
var mergeStatusCheck = '';
if(!window.plugin.drawTools.merge.status){
mergeStatusCheck = 'checked';
}

var edfStatusCheck = '';
if(!window.plugin.drawTools.edf.obj.status){
edfStatusCheck = 'checked';
}

var html = '<div class="drawtoolsStyles">'
+ '<input type="color" name="drawColor" id="drawtools_color"></input>'
//TODO: add line style choosers: thickness, maybe dash styles?
+ '</div>'
+ '<div class="drawtoolsSetbox">'
+ '<a onclick="window.plugin.drawTools.optCopy();" tabindex="0">Copy Drawn Items</a>'
+ '<center><label id="MergeToggle"><input type="checkbox" '+mergeStatusCheck+' name="merge" '
+ 'onchange="window.plugin.drawTools.merge.toggle();return false;" />Reset draws before paste or import</label></center>'
//+ '<center><input type="checkbox" name="merge" id="drawtools_merge"></input> Do not overwrite, merge!</center>'
+ '<a onclick="window.plugin.drawTools.optPaste();return false;" tabindex="0">Paste Drawn Items</a>'
+ '<a onclick="window.plugin.drawTools.optImport();return false;" tabindex="0">Import Drawn Items</a>'
+ '<a onclick="window.plugin.drawTools.optExport();return false;" tabindex="0">Export Drawn Items</a>'
+ '<a onclick="window.plugin.drawTools.optReset();return false;" tabindex="0">Reset Drawn Items</a>'
+ '<a onclick="window.plugin.drawTools.snapToPortals();return false;" tabindex="0">Snap to portals</a>'
+ '<center><label id="edfToggle" style="color: #ffce00; cursor:pointer; display:block;">'
+ '<input type="checkbox" '+edfStatusCheck+' name="edf"'
+ 'onchange="window.plugin.drawTools.edf.action.toggle();return false;" />Fill the polygon(s)</label></center>'
+ '</div>';

dialog({
Expand Down Expand Up @@ -359,11 +380,30 @@ window.plugin.drawTools.optCopy = function() {
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 = '<p><a onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea\').select();">Select all</a> and press CTRL+C to copy it.</p>'
+'<textarea readonly onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea\').select();">'+window.localStorage[window.plugin.drawTools.KEY_STORAGE]+'</textarea>'
+'<p>or, export as a link for the standard intel map (for non IITC users)</p>'
+'<input onclick="event.target.select();" type="text" size="90" value="'+stockUrl+'"/>';
*/
// Export Normal draw
var html = ''
+'<p style="margin:0 0 6px;">Normal export:</p>'
+'<p style="margin:0 0 6px;"><a onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea#copyNorm\').select();">Select all</a> and press CTRL+C to copy it.</p>'
+'<textarea id="copyNorm" readonly onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea#copyNorm\').select();">'+localStorage[window.plugin.drawTools.KEY_STORAGE]+'</textarea>';

// Export draw (polygons as lines)
html += '<hr/>'
+'<p style="margin:0 0 6px;">or export with polygons as lines (not filled):</p>'
+'<p style="margin:0 0 6px;"><a onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea#copyEDF\').select();">Select all</a> and press CTRL+C to copy it.</p>'
+'<textarea id="copyEDF" readonly onclick="$(\'.ui-dialog-drawtoolsSet-copy textarea#copyEDF\').select();">'+window.plugin.drawTools.getDrawAsLines()+'</textarea>';

// Export for intel stock URL (only lines)
html += '<hr/>'
+'<p style="margin:0 0 6px;">or export as a link for the standard intel map (for non IITC users):</p>'
+'<p style="margin:0 0 6px;"><a onclick="$(this).parent().next(\'input\').select();">Select all</a> and press CTRL+C to copy it.</p>'
+'<input onclick="event.target.select();" type="text" size="49" value="'+stockUrl+'"/>';

if (stockWarnTexts.length>0) {
html += '<ul><li>'+stockWarnTexts.join('</li><li>')+'</li></ul>';
}
Expand All @@ -388,6 +428,7 @@ window.plugin.drawTools.optExport = function() {
}

window.plugin.drawTools.optPaste = function() {
// if (merge === undefined) merge = true; //default to true
var promptAction = prompt('Press CTRL+V to paste (draw-tools data or stock intel URL).', '');
promptAction = promptAction && promptAction.trim();
if (promptAction) {
Expand Down Expand Up @@ -428,17 +469,26 @@ window.plugin.drawTools.optPaste = function() {
}

// all parsed OK - clear and insert
window.plugin.drawTools.drawnItems.clearLayers();
if (!window.plugin.drawTools.merge.status) {
window.plugin.drawTools.drawnItems.clearLayers();
}
for (var i=0; i<newLines.length; i++) {
window.plugin.drawTools.drawnItems.addLayer(newLines[i]);
}
runHooks('pluginDrawTools', {event: 'import'});

console.log('DRAWTOOLS: reset and imported drawn items from stock URL');
console.log('DRAWTOOLS: '+(window.plugin.drawTools.merge.status?'':'reset and ')+'pasted drawn items from stock URL');
window.plugin.drawTools.optAlert('Import Successful.');


} else {
if (window.plugin.drawTools.merge.status) {
promptAction = (typeof(
window.localStorage[window.plugin.drawTools.KEY_STORAGE]) !== 'undefined' &&
window.localStorage[window.plugin.drawTools.KEY_STORAGE].length > 4
? window.localStorage[window.plugin.drawTools.KEY_STORAGE].slice(0,-1) + ',' + promptAction.slice(1)
: promptAction);
}
var data;
try{
data = JSON.parse(promptAction);
Expand All @@ -455,7 +505,7 @@ window.plugin.drawTools.optPaste = function() {
}
window.plugin.drawTools.drawnItems.clearLayers();
window.plugin.drawTools.import(data);
console.log('DRAWTOOLS: reset and imported drawn items');
console.log('DRAWTOOLS: '+(window.plugin.drawTools.merge.status?'':'reset and ')+'pasted drawn items');
window.plugin.drawTools.optAlert('Import Successful.');
}

Expand All @@ -473,9 +523,11 @@ window.plugin.drawTools.optImport = function() {
.on('load',function (e) {
try {
var data = JSON.parse(e.reader.result);
window.plugin.drawTools.drawnItems.clearLayers();
if (!window.plugin.drawTools.merge.status) {
window.plugin.drawTools.drawnItems.clearLayers();
}
window.plugin.drawTools.import(data);
console.log('DRAWTOOLS: reset and imported drawn tiems');
console.log('DRAWTOOLS: '+(window.plugin.drawTools.merge.status?'':'reset and ')+'imported drawn items');
window.plugin.drawTools.optAlert('Import Successful.');

// to write back the data to localStorage
Expand Down Expand Up @@ -654,7 +706,7 @@ window.plugin.drawTools.boot = function() {

$('head').append('<style>' +
'.drawtoolsSetbox > a { display:block; color:#ffce00; border:1px solid #ffce00; padding:3px 0; margin:10px auto; width:80%; text-align:center; background:rgba(8,48,78,.9); }'+
'.ui-dialog-drawtoolsSet-copy textarea { width:96%; height:250px; resize:vertical; }'+
'.ui-dialog-drawtoolsSet-copy textarea { width:96%; height:100px; resize:vertical; }'+
'</style>');

}
Expand Down Expand Up @@ -710,9 +762,111 @@ window.plugin.drawTools.mpe.initMPE = function(){
});
}

// EXPORT (POLYS AS LINES)
// ---------------------------------------------------------------------------------
window.plugin.drawTools.getDrawAsLines = function(){
var rawDraw = JSON.parse(window.localStorage[window.plugin.drawTools.KEY_STORAGE]);
var draw = [];

for(i in rawDraw){
var elemDraw = rawDraw[i];

if(elemDraw.type === 'polygon'){
var convElemDraw = {};
convElemDraw.color = elemDraw.color;
convElemDraw.type = 'polyline';
convElemDraw.latLngs = [];

var v = elemDraw.latLngs.length;
for(j in elemDraw.latLngs){
var ll = elemDraw.latLngs[j];
convElemDraw.latLngs.push(ll);
}
convElemDraw.latLngs.push(elemDraw.latLngs[0]);

draw.push(convElemDraw);
}else{
draw.push(elemDraw);
}
}

return JSON.stringify(draw);
}

// ---------------------------------------------------------------------------------
// EMPTY POLYGONS (EMPTY DRAWN FIELDS)
// ---------------------------------------------------------------------------------
window.plugin.drawTools.edf = {};
window.plugin.drawTools.edf.storage = {};
window.plugin.drawTools.edf.draw = {};
window.plugin.drawTools.edf.obj = {};
window.plugin.drawTools.edf.action = {};
window.plugin.drawTools.edf.ui = {};

window.plugin.drawTools.edf.boot = function(){
window.addHook('pluginDrawTools', window.plugin.drawTools.edf.hookManagement);
window.addHook('iitcLoaded', function(){
if(window.plugin.drawTools.edf.obj.status){
window.plugin.drawTools.edf.draw.toggleOpacityOpt();
window.plugin.drawTools.edf.draw.clearAndDraw();
}
});
};

window.plugin.drawTools.edf.obj.status = false;
window.plugin.drawTools.edf.obj.toggle = function(){
var status = window.plugin.drawTools.edf.obj.status;
status = Boolean(!status);
window.plugin.drawTools.edf.obj.status = status;
}
window.plugin.drawTools.edf.draw.toggleOpacityOpt = function(){
if(window.plugin.drawTools.edf.obj.status){
window.plugin.drawTools.polygonOptions.fillOpacity = 0.0;
}else{
window.plugin.drawTools.polygonOptions.fillOpacity = 0.2;
}
}
window.plugin.drawTools.edf.draw.clearAndDraw = function(){
window.plugin.drawTools.drawnItems.clearLayers();
window.plugin.drawTools.load();
console.log('DRAWTOOLS: reset all drawn items');
}

window.plugin.drawTools.edf.action.toggle = function(){
window.plugin.drawTools.edf.obj.toggle();
window.plugin.drawTools.edf.draw.toggleOpacityOpt();
window.plugin.drawTools.edf.draw.clearAndDraw();
}

window.plugin.drawTools.edf.hookManagement = function(data){
if(data.event === 'openOpt'){
}else if(data.event == 'layerCreated'){
if(window.plugin.drawTools.edf.obj.status){
// window.plugin.drawTools.edf.draw.toggleOpacityOpt(); // disabled by Zaso
window.plugin.drawTools.edf.draw.clearAndDraw();
}
}
}

window.plugin.drawTools.setupCSS = function(){
$("<style>").prop("type", "text/css").html(''
+'.leaflet-bar{box-shadow:0 1px 5px rgba(0,0,0,.65);}'
+'.leaflet-draw .leaflet-draw-section .leaflet-bar{box-shadow:none;}'
+'.leaflet-draw{box-shadow:0 1px 5px rgba(0,0,0,.65);border-radius:4px;}'

+'.leaflet-draw .leaflet-draw-section .leaflet-bar.leaflet-draw-toolbar-top a:last-child{border-bottom:2px solid #999;}'
+'.leaflet-draw .leaflet-draw-section .leaflet-bar a{border-radius:0;}'

+'.leaflet-draw .leaflet-draw-section .leaflet-bar{border-radius:0 0 4px 4px;overflow:hidden;margin-top:0;}'
+'.leaflet-draw .leaflet-draw-section .leaflet-bar.leaflet-draw-toolbar-top{border-radius:4px 4px 0 0;}'
).appendTo("head");
}

function setup () {
loadExternals(); // initialize leaflet
window.plugin.drawTools.boot(); // initialize drawtools
loadExternals();
window.plugin.drawTools.boot();
window.plugin.drawTools.setupCSS();
window.plugin.drawTools.edf.boot();
window.plugin.drawTools.mpe.boot(); // register to MPE if available
}

Expand Down
Loading