Jump to content

MediaWiki:Common.js: Difference between revisions

From Dogs Welcome (Isle of Man)
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


document.getElementById('linkNorth')?.addEventListener('click', function() {
var directions = ['North', 'East', 'West', 'South'];
    window.location.hash = 'North';
});


document.getElementById('linkWest')?.addEventListener('click', function() {
directions.forEach(function(direction) {
     window.location.hash = 'West';
     var linkElement = document.getElementById('link' + direction);
});
    var sectionElement = document.getElementById(direction);
 
   
document.getElementById('linkEast')?.addEventListener('click', function() {
    if (linkElement) {
    window.location.hash = 'East';
        linkElement.addEventListener('click', function() {
});
            window.location.hash = direction;
 
        });
document.getElementById('linkSouth')?.addEventListener('click', function() {
     }
     window.location.hash = 'South';
});
});

Latest revision as of 11:04, 17 March 2025

/* Any JavaScript here will be loaded for all users on every page load. */

var directions = ['North', 'East', 'West', 'South'];

directions.forEach(function(direction) {
    var linkElement = document.getElementById('link' + direction);
    var sectionElement = document.getElementById(direction);
    
    if (linkElement) {
        linkElement.addEventListener('click', function() {
            window.location.hash = direction;
        });
    }
});