Atlas Tools.js

Revision as of 21:55, 20 October 2020 by BrianFreud (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Flash icons on hover. */
$('#UOLinksList').on('mouseover', 'span', function() {
        $('.pin a img').addClass('pin-not_circle');
        $('#' + $(this).data('pair') + ' a img').addClass('pin-circle').removeClass('pin-not_circle');
    })
    .on('mouseout', 'span', function() {
        $('.pin a img').removeClass('pin-not_circle');
        $('#' + $(this).data('pair') + ' a img').removeClass('pin-circle');
    });

/* Highlight map region on hover. */
document.removeHighlights = () => {
    $('.mapgrid').css('visibility', 'hidden');
    $('.roundTL,.roundTR,.roundBL,.roundBR').removeClass('roundTL roundTR roundBL roundBR');
};
$('body').on('mouseover', '.overlayhighlighter', function() {
        let getEles = (num) => [...$(this).find(`span:eq(${num})`).text().split(',')].map((x) => {
            return `.grid${x}`;
        }).join(', ');
        document.removeHighlights();
        $(getEles(0)).css('visibility', 'visible');
        $(getEles(1)).addClass('roundTL');
        $(getEles(2)).addClass('roundTR');
        $(getEles(3)).addClass('roundBL');
        $(getEles(4)).addClass('roundBR');
    })
    .on('mouseout', '.overlayhighlighter', function() {
        document.removeHighlights();
    });

/* Dev tool hotkeys for map highlighter. */
document.onkeydown = function(e) {
    if (e.ctrlKey) {
        switch (e.which) {
            case 38: // up
                $('.overlaygrid').css('fontSize', parseInt($('.overlaygrid').css('fontSize')) + 1 + 'px');
                break;

            case 40: // down
                $('.overlaygrid').css('fontSize', parseInt($('.overlaygrid').css('fontSize')) - 1 + 'px');
                break;

            case 66: // "b"
                $('.mapgrid').css({
                    background: 'red'
                });
                break;

            case 79: // "o"
                $('.mapInnerDiv:eq(2)').css('z-index', 1000);
                $('.mapgrid').css({
                    visibility: 'visible',
                });
                $('.hideoverlaytext').removeClass('hideoverlaytext');
                $('.overlaygrid').css({
                    opacity: '100%',
                    fontSize: '9px'
                });
                if (!$('#gridText').length) {
                    $('.mapOuterDiv').before(`
                        <input type="button" id="gridBtn" value="List" style="float: right;">
                        <textarea id="gridText" style="width:50%;float:right;height:10em;background:black;color:white;"></textarea>
                        <label for="gridTL">TL <input type="radio" id="gridTL" name="gridcorners" value="TL"></label>
                        <label for="gridTR">TR <input type="radio" id="gridTR" name="gridcorners" value="TR"></label>
                        <br>
                        <label for="gridBL">BL <input type="radio" id="gridBL" name="gridcorners" value="BL"></label>
                        <label for="gridBR">BR <input type="radio" id="gridBR" name="gridcorners" value="BR"></label>
                        <br>
                        <label for="gridNone">None <input type="radio" id="gridNone" name="gridcorners" value="None" checked></label>
                    `);
                    $('.mapOuterDiv').on('click', '.mapgrid', function () {
                        switch ($('input[name=gridcorners]:checked').val()) {
                            case 'TL':
                                $(this).toggleClass('gridClickedTL');
                                break;
                            case 'TR':
                                $(this).toggleClass('gridClickedTR');
                                break;
                            case 'BL':
                                $(this).toggleClass('gridClickedBL');
                                break;
                            case 'BR':
                                $(this).toggleClass('gridClickedBR');
                                break;
                            default:
                                $(this).toggleClass('gridClicked');
                        }
                    });
                    $('#gridBtn').on('click', function () {
                        let list = [],
                            tl = [],
                            tr = [],
                            bl = [],
                            br = [];
                        $('.gridClicked').each(function () { list.push($(this).text()); });
                        $('.gridClickedTL').each(function () { tl.push($(this).text()); });
                        $('.gridClickedTR').each(function () { tr.push($(this).text()); });
                        $('.gridClickedBL').each(function () { bl.push($(this).text()); });
                        $('.gridClickedBR').each(function () { br.push($(this).text()); });
                        $('#gridText').val(`|highlight=${list}
|TL=${tl.join(',')}
|TR=${tr.join(',')}
|BL=${bl.join(',')}
|BR=${br.join(',')}`);
                    });
                }
                event.preventDefault();
                break;
            default:
                return; // exit this handler for other keys
        }
    }
};