MediaWiki:Mobile.js
From Guild Wars Wiki 中文站
Jump to navigationJump to search
Note: After publishing, 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 / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for users using the mobile site */
(function updateMobileMenu() {
function getPageTitle() {
var url = new URL(window.location.href); // this is an API.
var c = url.searchParams.get("title");
if (c) {
return location.protocol + '//' + location.host + '/wiki/' + c;
} else {
return window.location.href.split('#')[0].split('?')[0];
}
}
var group0 = [
{
"name": "desktop-toggle",
"components": [
{
"text": "Desktop view toggle",
"href": getPageTitle() + "?mobileaction=toggle_view_desktop",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-noicon ",
}
]
},
{
"name": "purge",
"components": [
{
"text": "Purge",
"href": getPageTitle() + "?action=purge",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-noicon ",
}
]
}
];
var group1 = [
{
"name": "home",
"components": [
{
"text": "Main Page",
"href": "/wiki/Main_Page",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-home ",
"data-event-name": "home"
}
]
},
{
"name": "community",
"components": [
{
"text": "Community portal",
"href": "/wiki/Guild_Wars_Wiki:Community_portal",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-cp ",
"data-event-name": "recent-changes"
}
]
},
{
"name": "recent-changes",
"components": [
{
"text": "Recent changes",
"href": "/wiki/Special:RecentChanges",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-rc ",
"data-event-name": "recent-changes"
}
]
},
{
"name": "random",
"components": [
{
"text": "Random",
"href": "/wiki/Special:Random#/random",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-random ",
"id": "randomButton",
"data-event-name": "random"
}
]
}
];
var group2 = [
{
"name": "help-center",
"components": [
{
"text": "Help center",
"href": "/wiki/Help:Contents",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-hc ",
}
]
},
{
"name": "admin-noticeboard",
"components": [
{
"text": "Admin noticeboard",
"href": "/wiki/Guild_Wars_Wiki:Admin_noticeboard",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-an ",
}
]
},
{
"name": "report-bugs",
"components": [
{
"text": "Report a wiki bug",
"href": "/wiki/Guild_Wars_Wiki:Reporting_wiki_bugs",
"class": "mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-wb ",
}
]
}
];
// Insert before existing elements
var menuData = mw.config.get('wgMinervaMenuData');
menuData.groups.unshift(group2);
menuData.groups.unshift(group1);
menuData.groups.unshift(group0);
// Update settings object
mw.config.set('wgMinervaMenuData', menuData);
})();