MediaWiki:Common.js: Difference between revisions
From Business Heroes Food Truck Simulation
Wikiworks743 (talk | contribs) No edit summary |
Wikiworks743 (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
const classes = ['im-marketing', 'im-finance', 'im-operations', 'im-planning', 'im-hr', 'im-accounting']; | const classes = ['im-marketing', 'im-finance', 'im-operations', 'im-planning', 'im-hr', 'im-accounting']; | ||
getActiveButton(); | |||
$('.im-icon') | $('.im-icon') | ||
Line 23: | Line 21: | ||
} | } | ||
}); | }); | ||
function getActiveButton(){ | |||
var getactive = localStorage.getItem('active'); | |||
$('.im-icon.' + getactive + '').click(); | |||
$('.im-icon.' + getactive + '').parent().addClass('im-active'); | |||
} | |||
function getActiveCategory(){ | |||
if($('a[title="Category:Planning"]').length) { | |||
$('.im-planning').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-planning' ); | |||
} else if($('a[title="Category:Finance"]').length) { | |||
$('.im-finance').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-finance' ); | |||
} else if($('a[title="Category:Marketing"]').length) { | |||
$('.im-marketing').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-marketing' ); | |||
} else if($('a[title="Category:Operations"]').length) { | |||
$('.im-operations').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-operations' ); | |||
} else if($('a[title="Category:HR"]').length) { | |||
$('.im-hr').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-hr' ); | |||
} else if($('a[title="Category:Accounting"]').length) { | |||
$('.im-accounting').parent().addClass('im-active'); | |||
localStorage.setItem('active', 'im-accounting' ); | |||
} else { | |||
getActiveButton(); | |||
} | |||
} |
Revision as of 23:24, 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']; getActiveButton(); $('.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++) { prefix = "/index.php/"; page = decodeURIComponent($(this).attr('href').replace(prefix,'')); $(this).attr('title', page); } }); function getActiveButton(){ var getactive = localStorage.getItem('active'); $('.im-icon.' + getactive + '').click(); $('.im-icon.' + getactive + '').parent().addClass('im-active'); } function getActiveCategory(){ if($('a[title="Category:Planning"]').length) { $('.im-planning').parent().addClass('im-active'); localStorage.setItem('active', 'im-planning' ); } else if($('a[title="Category:Finance"]').length) { $('.im-finance').parent().addClass('im-active'); localStorage.setItem('active', 'im-finance' ); } else if($('a[title="Category:Marketing"]').length) { $('.im-marketing').parent().addClass('im-active'); localStorage.setItem('active', 'im-marketing' ); } else if($('a[title="Category:Operations"]').length) { $('.im-operations').parent().addClass('im-active'); localStorage.setItem('active', 'im-operations' ); } else if($('a[title="Category:HR"]').length) { $('.im-hr').parent().addClass('im-active'); localStorage.setItem('active', 'im-hr' ); } else if($('a[title="Category:Accounting"]').length) { $('.im-accounting').parent().addClass('im-active'); localStorage.setItem('active', 'im-accounting' ); } else { getActiveButton(); } }