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

Export bookmarked portals to a CSV lists #948

Closed
wants to merge 13 commits into from
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## What this fork is

This is me messing around with IITC.

Changes to Maxfield plugin:
- Display in console the names of the portals

Changes to Bookmarks plugin:
- Export to Tab Separated Values
- Export bookmarks to a list of URLS for http://www.ingress-maxfield.com/
- Export bookmarks to a list of URLS for http://www.ingressrouteplanner.com/

ingress intel total conversion (IITC)
=====================================

Expand Down
82 changes: 82 additions & 0 deletions plugins/bookmarks-by-zaso.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,85 @@
}
}

window.plugin.bookmarks.optMaxfield = function() {
if(typeof android !== 'undefined' && android && android.shareString) {
return android.shareString(localStorage[window.plugin.bookmarks.KEY_STORAGE]);
} else {

var portals = JSON.parse(localStorage['plugin-bookmarks']).portals,
output = '';

for (var key in portals) {
if (!portals.hasOwnProperty(key)) {
continue;
}
var bkmrk = portals[key].bkmrk;
for (var key in bkmrk) {
output += bkmrk[key].label + ';' + 'https://www.ingress.com/intel?ll=' + bkmrk[key].latlng + '&z=17&pll=' + bkmrk[key].latlng + ';0\n';
}
}

dialog({
html: '<p><a onclick="$(\'.ui-dialog-bkmrksSet-copy textarea\').select();">Select all</a> and press CTRL+C to copy it.</p><textarea readonly>'+output+'</textarea>',
dialogClass: 'ui-dialog-bkmrksSet-copy',
title: 'Ingress Maxfield'
});
}
}

window.plugin.bookmarks.optRoutePlanner = function() {
if(typeof android !== 'undefined' && android && android.shareString) {
return android.shareString(localStorage[window.plugin.bookmarks.KEY_STORAGE]);
} else {

var portals = JSON.parse(localStorage['plugin-bookmarks']).portals,
output = '';
for (var key in portals) {
if (!portals.hasOwnProperty(key)) {
continue;
}
var bkmrk = portals[key].bkmrk;
for (var key in bkmrk) {
output += 'https://www.ingress.com/intel?ll=' + bkmrk[key].latlng + '&z=17&pll=' + bkmrk[key].latlng + '\n';
}
}

dialog({
html: '<p><a onclick="$(\'.ui-dialog-bkmrksSet-copy textarea\').select();">Select all</a> and press CTRL+C to copy it.</p><textarea readonly>'+output+'</textarea>',
dialogClass: 'ui-dialog-bkmrksSet-copy',
title: 'Ingress Route Panner'
});
}
}

window.plugin.bookmarks.optCSV = function() {
if(typeof android !== 'undefined' && android && android.shareString) {
return android.shareString(localStorage[window.plugin.bookmarks.KEY_STORAGE]);
} else {

var portals = JSON.parse(localStorage['plugin-bookmarks']).portals,
output = '';
for (var key in portals) {
if (!portals.hasOwnProperty(key)) {
continue;
}
output += '\n\nFolder: ' + portals[key].label + '\n';
output += 'ID\tGUID\tName\tLatitude Longitude\tURL\n';

var bkmrk = portals[key].bkmrk;
for (var key in bkmrk) {
output += key+'\t'+bkmrk[key].guid + '\t' + bkmrk[key].label + '\t' + bkmrk[key].latlng +'\t'+ 'https://www.ingress.com/intel?ll=' + bkmrk[key].latlng + '&z=17&pll=' + bkmrk[key].latlng + '\n';
}
}

dialog({
html: '<p><a onclick="$(\'.ui-dialog-bkmrksSet-copy textarea\').select();">Select all</a> and press CTRL+C to copy it.</p><textarea readonly>'+output+'</textarea>',
dialogClass: 'ui-dialog-bkmrksSet-copy',
title: 'Ingress Route Panner'
});
}
}

window.plugin.bookmarks.optExport = function() {
if(typeof android !== 'undefined' && android && android.saveFile) {
android.saveFile("IITC-bookmarks.json", "application/json", localStorage[window.plugin.bookmarks.KEY_STORAGE]);
Expand Down Expand Up @@ -1208,6 +1287,9 @@
actions += '<a onclick="window.plugin.bookmarks.optReset();return false;">Reset bookmarks</a>';
actions += '<a onclick="window.plugin.bookmarks.optCopy();return false;">Copy bookmarks</a>';
actions += '<a onclick="window.plugin.bookmarks.optPaste();return false;">Paste bookmarks</a>';
actions += '<a onclick="window.plugin.bookmarks.optMaxfield();return false;">Bookmarks to Maxfield</a>';
actions += '<a onclick="window.plugin.bookmarks.optRoutePlanner();return false;">Bookmarks to Route Planner</a>';
actions += '<a onclick="window.plugin.bookmarks.optCSV();return false;">Bookmarks to CSV</a>';

if(plugin.bookmarks.isAndroid()) {
actions += '<a onclick="window.plugin.bookmarks.optImport();return false;">Import bookmarks</a>';
Expand Down
6 changes: 6 additions & 0 deletions plugins/max-links.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ window.plugin.maxLinks.updateLayer = function() {
window.plugin.maxLinks.layer.clearLayers();

var locations = [];
var myPortals = {};

var bounds = map.getBounds();
$.each(window.portals, function(guid, portal) {
var ll = portal.getLatLng();
if (bounds.contains(ll)) {
var p = map.project (portal.getLatLng(), window.plugin.maxLinks.PROJECT_ZOOM);
locations.push(p);
myPortals[(p.x+':'+p.y)] = {'x':p.x,'y':p.y,'title':portal.options.data.title,'guid':portal.options.guid};
if (locations.length > window.plugin.maxLinks.MAX_PORTALS_TO_LINK) return false; //$.each break
}
});
Expand All @@ -99,9 +101,12 @@ window.plugin.maxLinks.updateLayer = function() {
return [b,a];
}
var drawnLinks = {};
var drawnLog = '';

//draw a link, but only if it hasn't already been drawn
var drawLink = function(a,b) {
drawnLog+= (myPortals[a.x+':'+a.y].title+'\tto\t' + myPortals[b.x+':'+b.y].title+'\n');
drawnLog+= (myPortals[b.x+':'+b.y].title+'\tto\t' + myPortals[a.x+':'+a.y].title+'\n');
//order the points, so a pair of coordinates in any order is handled in one direction only
var points = orderedPoints(a,b);
a=points[0];
Expand Down Expand Up @@ -134,6 +139,7 @@ window.plugin.maxLinks.updateLayer = function() {
drawLink(triangle.b,triangle.c);
drawLink(triangle.c,triangle.a);
});
console.log(drawnLog);
}

window.plugin.maxLinks.setup = function() {
Expand Down