Open main menu

MediaWiki:Common.js

Revision as of 13:46, 17 November 2024 by Guaka (talk | contribs) (JavaScript parse error: Parse error: Missing ) in parenthetical in file 'MediaWiki:Common.js' on line 15)

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.
/* Any JavaScript here will be loaded for all users on every page load. */

/* https://github.com/Hitchwiki/hitchwiki/issues/23 */
if ($('body.mw-special-Block').length) { 
  $('#mw-input-wpDisableEmail').click();
  $('#mw-input-wpHardBlock').click();
  $('#mw-input-wpExpiry')[0].value = 'infinite';
}

/** doesn't work yet,
 * JavaScript parse error: Parse error: Missing ) in parenthetical in file 'MediaWiki:Common.js' on line 15

document.addEventListener("DOMContentLoaded", function() {
    // Find all map elements in the document
    const mapElements = document.querySelectorAll("map[lat][lng][zoom]");

    mapElements.forEach((mapElement) => {
        // Extract the map attributes
        const lat = parseFloat(mapElement.getAttribute("lat"));
        const lon = parseFloat(mapElement.getAttribute("lng"));
        const zoom = parseInt(mapElement.getAttribute("zoom"), 10);
        const width = 300; // Set width for the static map display
        const height = 300; // Set height for the static map display
        
        // Create a container div for the static map
        const mapContainer = document.createElement("div");

        // Call the function to create the static map inside the container
        createStaticMap(mapContainer, lat, lon, zoom, width, height);

        // Create an anchor element that wraps the map container
        const mapLink = document.createElement("a");
        mapLink.href = `https://hitchmap.com/#location,${lat},${lon},${zoom}`;
        mapLink.appendChild(mapContainer);

        // Replace the original <map> element with the link containing the map container
        mapElement.replaceWith(mapLink);
    });
});

**/