').append(svg).html()
264 | return svg_html
265 | }
266 |
267 | function createIcons() {
268 | var LEVEL_TO_RADIUS = [7, 7, 7, 7, 8, 8, 9, 10, 11];
269 | window.plugin.upcv.iconCaptured = {};
270 | window.plugin.upcv.iconVisited = {};
271 | window.plugin.upcv.iconScouted = {};
272 |
273 | const parts = window.plugin.upcv.settings.showVisited + window.plugin.upcv.settings.showScouted;
274 |
275 | LEVEL_TO_RADIUS.forEach((el, idx) => {
276 | let size = el * 2 + 8;
277 | let offset = 0;
278 | if (window.plugin.upcv.settings.showVisited) {
279 | window.plugin.upcv.iconVisited[idx] = svgToIcon(getSVGString(size, window.plugin.upcv.settings.upv_color, parts, offset), size + 4);
280 | window.plugin.upcv.iconCaptured[idx] = svgToIcon(getSVGString(size, window.plugin.upcv.settings.upc_color, parts, offset), size + 4);
281 | offset++;
282 | } else {
283 | window.plugin.upcv.iconVisited[idx] = svgToIcon(getSVGString(size, 'transparent', parts, offset), size + 4);
284 | window.plugin.upcv.iconCaptured[idx] = svgToIcon(getSVGString(size, 'transparent', parts, offset), size + 4);
285 | }
286 | if (window.plugin.upcv.settings.showScouted) {
287 | window.plugin.upcv.iconScouted[idx] = svgToIcon(getSVGString(size, window.plugin.upcv.settings.scouted_color, parts, offset), size + 4);
288 | } else {
289 | window.plugin.upcv.iconScouted[idx] = svgToIcon(getSVGString(size, 'transparent', parts, offset), size + 4);
290 | }
291 | });
292 | }
293 |
294 | window.plugin.upcv.removePortalFromMap = function (data) {
295 | if (!data.portal._historyLayer) {
296 | return;
297 | }
298 | window.plugin.upcv.layerGroup.removeLayer(data.portal._historyLayer);
299 | }
300 |
301 | window.plugin.upcv.addToPortalMap = function (data) {
302 | var type = data.portal.options.ent[2][18];
303 | var portal_level = data.portal.options.data.level;
304 | if (portal_level == undefined) return;
305 | var tileParams = window.getCurrentZoomTileParameters ? window.getCurrentZoomTileParameters() : window.getMapZoomTileParameters();
306 | if (tileParams.level === 0) {
307 | drawPortalFlags(data.portal);
308 | } else {
309 | window.plugin.upcv.removePortalFromMap(data);
310 | }
311 | }
312 |
313 | window.plugin.upcv.toggleDisplayMode = function () {
314 | var portals_state = count_portals_stat()
315 |
316 | var svg_html = make_state_piesvg(portals_state)
317 |
318 | var dialog_html = `
319 |
320 |
321 | | Uniques count in view |
322 | | Toral: | ${portals_state.total} |
323 | | UPV: | ${portals_state.upv} |
324 | | UPC: | ${portals_state.upc} |
325 | | Scouted: | ${portals_state.scouted} |
326 |
327 | ${svg_html}
328 |
329 |
374 |
375 | `
376 | dialog({
377 | html: dialog_html,
378 | title: 'Portal Visited',
379 | id: 'plugin-portal-visited',
380 | width: '300px',
381 | closeCallback: function () {
382 | const elMode = document.getElementById('portal-visited-settings-display-missing');
383 | const elVisited = document.getElementById('portal-visited-settings--show-visited');
384 | const elScouted = document.getElementById('portal-visited-settings--show-scouted');
385 |
386 | window.plugin.upcv.settings.drawMissing = elMode.checked;
387 | window.plugin.upcv.settings.showVisited = elVisited.checked;
388 | window.plugin.upcv.settings.showScouted = elScouted.checked;
389 |
390 | try {
391 | if (upv_pallete) {upv_pallete.destroy();}
392 | } catch (e) {
393 | console.log("destroy got upv")
394 | }
395 | try {
396 | if (upc_pallete) {upc_pallete.destroy();}
397 | } catch (e) {
398 | console.log("destroy got upc")
399 | }
400 | try {
401 | if (scouted_pallete) {scouted_pallete.destroy();}
402 | } catch (e) {
403 | console.log("destroy got scout")
404 | }
405 |
406 | localStorage[KEY_SETTINGS] = JSON.stringify(window.plugin.upcv.settings);
407 | createIcons();
408 | drawAllFlags();
409 | }
410 | });
411 |
412 | var upv_pallete = new XNColorPicker({
413 | color: window.plugin.upcv.settings.upv_color,
414 | selector: "#portal-visited-settings--color-visited",
415 | showprecolor: true,
416 | prevcolors: null,
417 | showhistorycolor: false,
418 | format: 'hex',
419 | showPalette:true,
420 | show:false,
421 | lang:'en',
422 | colorTypeOption:'single',
423 | onError: function (e) {
424 | },
425 | onCancel:function(color){
426 | },
427 | onChange:function(color){
428 | },
429 | onConfirm:function(color){
430 | window.plugin.upcv.settings.upv_color = color.color.hex;
431 | $("#portal-visited-pie")[0].outerHTML = make_state_piesvg(portals_state)
432 | }
433 | })
434 | var upc_pallete = new XNColorPicker({
435 | color: window.plugin.upcv.settings.upc_color,
436 | selector: "#portal-visited-settings--color-captured",
437 | showprecolor: true,
438 | prevcolors: null,
439 | showhistorycolor: false,
440 | format: 'hex',
441 | showPalette:true,
442 | show:false,
443 | lang:'en',
444 | colorTypeOption:'single,linear-gradient,radial-gradient',
445 | onError: function (e) {
446 | },
447 | onCancel:function(color){
448 | },
449 | onChange:function(color){
450 | },
451 | onConfirm:function(color){
452 | window.plugin.upcv.settings.upc_color = color.color.hex;
453 | $("#portal-visited-pie")[0].outerHTML = make_state_piesvg(portals_state)
454 | }
455 | })
456 | var scouted_pallete = new XNColorPicker({
457 | color: window.plugin.upcv.settings.scouted_color,
458 | selector: "#portal-visited-settings--color-scouted",
459 | showprecolor: true,
460 | prevcolors: null,
461 | showhistorycolor: false,
462 | format: 'hex',
463 | showPalette:true,
464 | show:false,
465 | lang:'en',
466 | colorTypeOption:'single,linear-gradient,radial-gradient',
467 | onError: function (e) {
468 | },
469 | onCancel:function(color){
470 | },
471 | onChange:function(color){
472 | },
473 | onConfirm:function(color){
474 | window.plugin.upcv.settings.scouted_color = color.color.hex;
475 | $("#portal-visited-pie")[0].outerHTML = make_state_piesvg(portals_state)
476 | }
477 | })
478 | }
479 | ///////////////////////////////////////////////////////////////////////////////
480 |
481 | window.plugin.upcv.upcv = function(data) {
482 | var type = data.portal.options.ent[2][18];
483 | var portal_level = data.portal.options.data.level;
484 | if (portal_level == undefined) return;
485 | if(type & UPC_FLAG){
486 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.upc_color, fillOpacity: 1 });
487 | }else if(type & UPV_FLAG){
488 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.upv_color,fillOpacity: 1 });
489 | }
490 | }
491 | window.plugin.upcv.not_upcv = function(data) {
492 | var type = data.portal.options.ent[2][18];
493 | var portal_level = data.portal.options.data.level;
494 | if (portal_level == undefined) return;
495 | if(type&UPC_FLAG){
496 | return
497 | }
498 | if(type&UPV_FLAG){
499 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.upv_color,fillOpacity: 1 });
500 | }
501 | else{
502 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.upc_color, fillOpacity: 1 });
503 | }
504 |
505 | }
506 | window.plugin.upcv.scouted = function(data) {
507 | var type = data.portal.options.ent[2][18];
508 | var portal_level = data.portal.options.data.level;
509 | if (portal_level == undefined) return;
510 | if(type & SCOUT_FLAG){
511 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.scouted_color, fillOpacity: 1});
512 | }
513 | }
514 | window.plugin.upcv.not_scouted = function(data) {
515 | var type = data.portal.options.ent[2][18];
516 | var portal_level = data.portal.options.data.level;
517 | if (portal_level == undefined) return;
518 | if(!(type & SCOUT_FLAG)){
519 | data.portal.setStyle({fillColor: window.plugin.upcv.settings.scouted_color, fillOpacity: 1 });
520 | }
521 | }
522 |
523 | var setup = function() {
524 | try {
525 | window.plugin.upcv.settings = JSON.parse(localStorage[KEY_SETTINGS]);
526 | } catch (e) {
527 | window.plugin.upcv.settings = {
528 | drawMissing: false,
529 | showVisited: true,
530 | showScouted: false,
531 | upv_color: UPV_COLOR,
532 | upc_color: UPC_COLOR,
533 | scouted_color: SCOUT_COLOR,
534 | };
535 | }
536 | createIcons()
537 | window.plugin.upcv.layerGroup = new L.LayerGroup();
538 | window.addLayerGroup('Portal Visited', window.plugin.upcv.layerGroup, false);
539 |
540 | window.addHook('portalAdded', window.plugin.upcv.addToPortalMap);
541 | window.addHook('portalRemoved', window.plugin.upcv.removePortalFromMap);
542 | window.map.on('zoom', drawAllFlags);
543 | $('#toolbox').append('
Portal Visited');
544 |
545 | window.addPortalHighlighter('Portal UPC/V', window.plugin.upcv.upcv);
546 | window.addPortalHighlighter('Portal not UPC/V', window.plugin.upcv.not_upcv);
547 | window.addPortalHighlighter('Portal Scouted', window.plugin.upcv.scouted);
548 | window.addPortalHighlighter('Portal not Scouted', window.plugin.upcv.not_scouted);
549 | }
550 | // PLUGIN END //////////////////////////////////////////////////////////
551 | setup.info = plugin_info;
552 | if(!window.bootPlugins) window.bootPlugins = [];
553 | window.bootPlugins.push(setup);
554 | if(window.iitcLoaded && typeof setup === 'function') setup();
555 | }
556 | var script = document.createElement('script');
557 | var info = {};
558 | if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
559 | script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
560 | (document.body || document.head || document.documentElement).appendChild(script);
561 |
--------------------------------------------------------------------------------