MediaWiki:Common.js: Difference between revisions

From Business Heroes Food Truck Simulation
No edit summary
No edit summary
Line 18: Line 18:
.each(function(){
.each(function(){
     for(var i = 0, j = classes.length; i < j; i++) {
     for(var i = 0, j = classes.length; i < j; i++) {
        $(this).attr('title', $(this).attr('href'));
    page = $(this).attr('href');
    prefix = "/index.php/";
    page = decodeURIComponent(page.replace(prefix,''));
        $(this).attr('title', page);
     }
     }
});
});

Revision as of 22:40, 17 December 2022

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

const classes = ['im-marketing', 'im-finance', 'im-operations', 'im-planning', 'im-hr', 'im-accounting'];

var getactive = localStorage.getItem('active');
$('.im-icon.' + getactive + '').click();
$('.im-icon.' + getactive + '').parent().addClass('im-active');

$('.im-icon')
    .click(function(){
		for(var i = 0, j = classes.length; i < j; i++) {
    		if($(this).hasClass('' + classes[i] + '')) {
        		localStorage.setItem('active', '' + classes[i] + '');
        		break;
    		}
		}
	})
	.each(function(){
    	for(var i = 0, j = classes.length; i < j; i++) {
    		page = $(this).attr('href');
    		prefix = "/index.php/";
    		page = decodeURIComponent(page.replace(prefix,''));
        	$(this).attr('title', page);
    	}
	});


var thispageurl = window.location.href;
$("#top-panel").find('.nav-link').each(function(){
	if (this.href === thispageurl) {
    	$(this).closest('.nav-item, .mw-list-item').addClass('show');
	}
});