MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
change indentation, fix smiley |
||
| Line 4: | Line 4: | ||
if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") { | if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") { | ||
var $license = $("#wpLicense"); | |||
if ($license.length) { | |||
if (!$license.val()) { | |||
$license.val("License None"); | |||
} | |||
mw.loader.using("mediawiki.special.upload", function() { | |||
setTimeout(function() { | |||
$license.change(); | |||
}); | |||
}); | |||
} | |||
} | } | ||
| Line 23: | Line 23: | ||
function randomizeUserSmiley() { | function randomizeUserSmiley() { | ||
const smileys = [ | |||
"f/fe/Smiley_smiley", | |||
"3/3a/002_grin", | |||
"e/e5/003_tounge", | |||
"e/e2/004_happy", | |||
"1/1d/005_annoyed", | |||
"4/42/006_sad", | |||
"3/31/007_crying", | |||
"8/8a/008_wink", | |||
"d/d7/009_frustrated", | |||
"9/9c/010_shades", | |||
"d/d2/011_devil", | |||
"6/60/012_inquisitive", | |||
"6/67/013_ninja", | |||
"f/f6/014_santa", | |||
"a/ad/015_worker", | |||
"e/ed/016_bigspender", | |||
"5/5a/017_superman", | |||
"0/03/018_surprised", | |||
"4/47/019_indifferent", | |||
"6/6e/020_girl", | |||
"0/07/020_newyears2010", | |||
"d/d1/022_coy", | |||
"c/c0/023_wizard", | |||
"5/5b/024_fan_boy", | |||
"6/6f/025_terminator", | |||
"0/0d/026_XD", | |||
"6/6c/027_bully", | |||
"4/4b/028_commando", | |||
"b/b7/029_kissing", | |||
"6/67/030_bird", | |||
"6/6b/031_bunny", | |||
"a/a2/032_diamond", | |||
"3/38/033_firewizard", | |||
"9/9e/034_XP", | |||
"8/8b/035_postman", | |||
"e/e1/036_templar", | |||
"9/9b/037_angel", | |||
"6/66/038_nurse", | |||
"3/3b/039_vampire", | |||
"5/58/040_ghost", | |||
"a/a9/041_frankenstein", | |||
"3/3d/042_witch", | |||
"5/58/043_indian", | |||
"8/85/044_pilgrim", | |||
"6/6e/045_pumpkin", | |||
"b/b3/046_litpumpkin", | |||
"b/bd/047_snowman", | |||
"8/86/048_reindeer", | |||
"3/30/049_grinch", | |||
"d/d0/050_maestro", | |||
"3/3c/051_DJ", | |||
"5/52/052_sigh", | |||
"0/02/053_robber", | |||
"e/e0/054_police", | |||
"8/87/055_purple_ghost", | |||
"e/e2/056_pirate", | |||
"f/fa/057_viking", | |||
"e/e5/058_karate", | |||
"7/73/059_cowboy", | |||
"6/60/060_diver", | |||
"6/62/061_tanned", | |||
"f/f6/062_propeller", | |||
"b/bc/063_hardhat", | |||
"2/24/064_gasmask", | |||
"8/8a/065_robot", | |||
"7/77/066_peasant", | |||
"a/a6/067_soldier", | |||
"0/09/068_blacksmith", | |||
"c/c0/069_LOL", | |||
"6/66/070_dog", | |||
"3/3e/071_alien", | |||
"8/80/072_astronaut", | |||
"f/fd/073_orangeparty", | |||
"5/5b/074_greenparty", | |||
"f/fb/075_blueparty", | |||
"5/5a/076_redparty", | |||
"8/85/077_daredevil", | |||
"6/6d/078_monster", | |||
"4/40/079_skeleton", | |||
"a/ae/080_madscientist", | |||
"b/be/081_headhunter", | |||
"8/8a/082_safari", | |||
"0/0d/083_archaeologist", | |||
"f/f7/084_newyears2013", | |||
"3/37/085_winter", | |||
"6/6e/086_firedemon", | |||
"a/a9/087_bishop", | |||
"8/8b/088_zombie", | |||
"e/ea/089_bruce", | |||
"9/99/090_unit", | |||
"4/4c/091_spartan", | |||
"3/33/092_lady", | |||
"0/00/093_cow", | |||
"9/94/094_scarecrow", | |||
"b/b3/095_darkwizard", | |||
"d/d9/096_kungfumaster", | |||
"0/04/097_fox", | |||
"7/7d/098_nightvision", | |||
"8/81/099_summergirl", | |||
"0/06/100_fan_boy_II", | |||
"8/8a/101_hologram", | |||
"5/51/102_gingerbread", | |||
"d/dc/103_caroler", | |||
"e/ec/104_elf", | |||
"3/32/105_nutcracker", | |||
"a/a2/106_blushing", | |||
"e/e9/107_artist", | |||
"3/33/108_princess", | |||
"b/b8/109_chef", | |||
"2/23/110_clown", | |||
"2/2f/111_redninja", | |||
"5/53/112_3d_glasses", | |||
"9/9e/113_sunburned", | |||
"d/da/114_tourist", | |||
"0/04/115_graduate", | |||
"1/1d/116_sombrero", | |||
"8/8f/117_cat", | |||
"a/ac/118_scared", | |||
"a/aa/119_ghoul", | |||
"9/9c/120_mummy", | |||
"9/90/121_bat", | |||
"a/aa/122_eyeball", | |||
"8/89/123_light_wizard", | |||
"1/13/124_hooded", | |||
"f/fa/125_earmuffs", | |||
"e/ec/126_penguin", | |||
"a/a9/127_gold_smiley", | |||
"3/33/128_gold_ninja", | |||
"c/ca/129_gold_robot", | |||
"2/29/130_gold_top_hat", | |||
"d/d8/131_sick", | |||
"b/b9/132_unsure", | |||
"9/91/133_goofy", | |||
"c/c5/134_raindrop", | |||
"5/5d/135_bee", | |||
"9/92/136_butterfly", | |||
"4/4e/137_sea_captain", | |||
"c/ce/138_soda_clerk", | |||
"c/c6/139_lifeguard", | |||
"0/04/140_aviator", | |||
"b/b4/141_sleepy", | |||
"5/5a/142_seagull", | |||
"b/b3/143_werewolf", | |||
"d/dc/144_swamp_creature", | |||
"5/52/145_fairy", | |||
"b/be/146_fireman", | |||
"b/bb/147_spy", | |||
"b/b5/148_devil_skull", | |||
"4/4b/149_clockwork_robot", | |||
"c/cd/150_teddy_bear", | |||
"2/21/151_christmas_soldier", | |||
"0/0c/152_scrooge", | |||
"b/bc/153_boy", | |||
"b/bb/154_pigtails", | |||
"7/73/155_doctor", | |||
"f/f0/156_turban", | |||
"d/de/157_hazmat_suit", | |||
"b/b8/158_leprechaun", | |||
"a/a0/159_angry", | |||
"0/09/160_smirk", | |||
"f/ff/161_sweat", | |||
"0/07/162_countrysinger", | |||
"7/7e/163_thor", | |||
"1/1d/164_cowgirl", | |||
"b/bc/165_raccoon", | |||
"2/21/166_lion", | |||
"1/1c/167_laika", | |||
"4/46/168_fishbowl", | |||
"a/a4/169_slime", | |||
"a/a9/170_designer", | |||
"1/17/171_frozen", | |||
"f/ff/172_masquerade", | |||
"c/cf/173_polar_bear", | |||
"d/d8/174_baseball_cap", | |||
"8/8e/175_golfer", | |||
"d/da/176_platinum_spender", | |||
"2/29/177_green_dragon", | |||
"4/48/178_red_dragon", | |||
"1/1d/179_executioner", | |||
"f/ff/180_gargoyle", | |||
"a/a4/181_banshee", | |||
"7/7a/182_golem", | |||
"4/4d/183_frost_dragon", | |||
"4/4f/184_squirrel", | |||
"7/73/185_golden_dragon", | |||
"d/d0/186_robot_mk_ii", | |||
"3/38/187_black_dragon", | |||
"f/f4/188_silver_dragon", | |||
]; | |||
const randomSmiley = smileys[Math.floor(Math.random() * smileys.length)]; | |||
document.querySelector("#p-personal #pt-userpage a").style.backgroundImage = "url/images/"+randomSmiley+".png)"; | |||
} | } | ||
| Line 225: | Line 225: | ||
function processWorldLinks() { | function processWorldLinks() { | ||
document.querySelectorAll('a[href*="archive.offlinee.com/api/worlds/"]').forEach(attachWorldTooltip); | |||
} | } | ||
function attachWorldTooltip(link) { | function attachWorldTooltip(link) { | ||
var tooltip; | |||
var tooltipImage; | |||
link.onmouseenter = function () { | |||
const match = this.href.match(/\/download\/([^\/]+)/); | |||
if (!match) return; | |||
tooltip = document.createElement("div"); | |||
tooltip.className = "worldLink_tooltip"; | |||
tooltipImage = document.createElement("img"); | |||
tooltipImage.className = "worldLink_tooltipImage"; | |||
tooltipImage.src = "https://archive.offlinee.com/api/minimap/archivee/" + match[1]; | |||
if (!tooltipImage) return; | |||
tooltip.appendChild(tooltipImage); | |||
document.body.appendChild(tooltip); | |||
tooltipImage.onload = function () { | |||
positionWorldTooltip(link, tooltip); | |||
tooltip.style.visibility = "visible"; | |||
} | |||
tooltipImage.onerror = function () { | |||
tooltip.remove(); | |||
} | |||
} | |||
link.onmouseleave = function () { | |||
if (tooltip) { | |||
tooltip.remove(); | |||
} | |||
} | |||
} | } | ||
function positionWorldTooltip(link, tooltip) { | function positionWorldTooltip(link, tooltip) { | ||
const rect = link.getBoundingClientRect(); | |||
const width = tooltip.offsetWidth || 0; | |||
const height = tooltip.offsetHeight || 0; | |||
const margin = 8; | |||
// Prevent vertical overflow if possible | |||
var top = rect.bottom + margin; | |||
if (rect.bottom + height > window.innerHeight) { | |||
top = rect.top - height - margin; | |||
} | |||
// Prevent horizontal overflow if possible | |||
var left = rect.left; | |||
const maxLeft = window.innerWidth - width - margin; | |||
if (left > maxLeft) left = maxLeft; | |||
if (left < margin) left = margin; | |||
tooltip.style.left = left+"px"; | |||
tooltip.style.top = top+"px"; | |||
} | } | ||
processWorldLinks(); | processWorldLinks(); | ||
Revision as of 18:07, 1 November 2026
/* ========================================== */
/* Set Default License */
/* ========================================== */
if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") {
var $license = $("#wpLicense");
if ($license.length) {
if (!$license.val()) {
$license.val("License None");
}
mw.loader.using("mediawiki.special.upload", function() {
setTimeout(function() {
$license.change();
});
});
}
}
/* ========================================== */
/* User Smileys */
/* ========================================== */
function randomizeUserSmiley() {
const smileys = [
"f/fe/Smiley_smiley",
"3/3a/002_grin",
"e/e5/003_tounge",
"e/e2/004_happy",
"1/1d/005_annoyed",
"4/42/006_sad",
"3/31/007_crying",
"8/8a/008_wink",
"d/d7/009_frustrated",
"9/9c/010_shades",
"d/d2/011_devil",
"6/60/012_inquisitive",
"6/67/013_ninja",
"f/f6/014_santa",
"a/ad/015_worker",
"e/ed/016_bigspender",
"5/5a/017_superman",
"0/03/018_surprised",
"4/47/019_indifferent",
"6/6e/020_girl",
"0/07/020_newyears2010",
"d/d1/022_coy",
"c/c0/023_wizard",
"5/5b/024_fan_boy",
"6/6f/025_terminator",
"0/0d/026_XD",
"6/6c/027_bully",
"4/4b/028_commando",
"b/b7/029_kissing",
"6/67/030_bird",
"6/6b/031_bunny",
"a/a2/032_diamond",
"3/38/033_firewizard",
"9/9e/034_XP",
"8/8b/035_postman",
"e/e1/036_templar",
"9/9b/037_angel",
"6/66/038_nurse",
"3/3b/039_vampire",
"5/58/040_ghost",
"a/a9/041_frankenstein",
"3/3d/042_witch",
"5/58/043_indian",
"8/85/044_pilgrim",
"6/6e/045_pumpkin",
"b/b3/046_litpumpkin",
"b/bd/047_snowman",
"8/86/048_reindeer",
"3/30/049_grinch",
"d/d0/050_maestro",
"3/3c/051_DJ",
"5/52/052_sigh",
"0/02/053_robber",
"e/e0/054_police",
"8/87/055_purple_ghost",
"e/e2/056_pirate",
"f/fa/057_viking",
"e/e5/058_karate",
"7/73/059_cowboy",
"6/60/060_diver",
"6/62/061_tanned",
"f/f6/062_propeller",
"b/bc/063_hardhat",
"2/24/064_gasmask",
"8/8a/065_robot",
"7/77/066_peasant",
"a/a6/067_soldier",
"0/09/068_blacksmith",
"c/c0/069_LOL",
"6/66/070_dog",
"3/3e/071_alien",
"8/80/072_astronaut",
"f/fd/073_orangeparty",
"5/5b/074_greenparty",
"f/fb/075_blueparty",
"5/5a/076_redparty",
"8/85/077_daredevil",
"6/6d/078_monster",
"4/40/079_skeleton",
"a/ae/080_madscientist",
"b/be/081_headhunter",
"8/8a/082_safari",
"0/0d/083_archaeologist",
"f/f7/084_newyears2013",
"3/37/085_winter",
"6/6e/086_firedemon",
"a/a9/087_bishop",
"8/8b/088_zombie",
"e/ea/089_bruce",
"9/99/090_unit",
"4/4c/091_spartan",
"3/33/092_lady",
"0/00/093_cow",
"9/94/094_scarecrow",
"b/b3/095_darkwizard",
"d/d9/096_kungfumaster",
"0/04/097_fox",
"7/7d/098_nightvision",
"8/81/099_summergirl",
"0/06/100_fan_boy_II",
"8/8a/101_hologram",
"5/51/102_gingerbread",
"d/dc/103_caroler",
"e/ec/104_elf",
"3/32/105_nutcracker",
"a/a2/106_blushing",
"e/e9/107_artist",
"3/33/108_princess",
"b/b8/109_chef",
"2/23/110_clown",
"2/2f/111_redninja",
"5/53/112_3d_glasses",
"9/9e/113_sunburned",
"d/da/114_tourist",
"0/04/115_graduate",
"1/1d/116_sombrero",
"8/8f/117_cat",
"a/ac/118_scared",
"a/aa/119_ghoul",
"9/9c/120_mummy",
"9/90/121_bat",
"a/aa/122_eyeball",
"8/89/123_light_wizard",
"1/13/124_hooded",
"f/fa/125_earmuffs",
"e/ec/126_penguin",
"a/a9/127_gold_smiley",
"3/33/128_gold_ninja",
"c/ca/129_gold_robot",
"2/29/130_gold_top_hat",
"d/d8/131_sick",
"b/b9/132_unsure",
"9/91/133_goofy",
"c/c5/134_raindrop",
"5/5d/135_bee",
"9/92/136_butterfly",
"4/4e/137_sea_captain",
"c/ce/138_soda_clerk",
"c/c6/139_lifeguard",
"0/04/140_aviator",
"b/b4/141_sleepy",
"5/5a/142_seagull",
"b/b3/143_werewolf",
"d/dc/144_swamp_creature",
"5/52/145_fairy",
"b/be/146_fireman",
"b/bb/147_spy",
"b/b5/148_devil_skull",
"4/4b/149_clockwork_robot",
"c/cd/150_teddy_bear",
"2/21/151_christmas_soldier",
"0/0c/152_scrooge",
"b/bc/153_boy",
"b/bb/154_pigtails",
"7/73/155_doctor",
"f/f0/156_turban",
"d/de/157_hazmat_suit",
"b/b8/158_leprechaun",
"a/a0/159_angry",
"0/09/160_smirk",
"f/ff/161_sweat",
"0/07/162_countrysinger",
"7/7e/163_thor",
"1/1d/164_cowgirl",
"b/bc/165_raccoon",
"2/21/166_lion",
"1/1c/167_laika",
"4/46/168_fishbowl",
"a/a4/169_slime",
"a/a9/170_designer",
"1/17/171_frozen",
"f/ff/172_masquerade",
"c/cf/173_polar_bear",
"d/d8/174_baseball_cap",
"8/8e/175_golfer",
"d/da/176_platinum_spender",
"2/29/177_green_dragon",
"4/48/178_red_dragon",
"1/1d/179_executioner",
"f/ff/180_gargoyle",
"a/a4/181_banshee",
"7/7a/182_golem",
"4/4d/183_frost_dragon",
"4/4f/184_squirrel",
"7/73/185_golden_dragon",
"d/d0/186_robot_mk_ii",
"3/38/187_black_dragon",
"f/f4/188_silver_dragon",
];
const randomSmiley = smileys[Math.floor(Math.random() * smileys.length)];
document.querySelector("#p-personal #pt-userpage a").style.backgroundImage = "url/images/"+randomSmiley+".png)";
}
randomizeUserSmiley();
/* ========================================== */
/* Archive World Tooltips */
/* ========================================== */
function processWorldLinks() {
document.querySelectorAll('a[href*="archive.offlinee.com/api/worlds/"]').forEach(attachWorldTooltip);
}
function attachWorldTooltip(link) {
var tooltip;
var tooltipImage;
link.onmouseenter = function () {
const match = this.href.match(/\/download\/([^\/]+)/);
if (!match) return;
tooltip = document.createElement("div");
tooltip.className = "worldLink_tooltip";
tooltipImage = document.createElement("img");
tooltipImage.className = "worldLink_tooltipImage";
tooltipImage.src = "https://archive.offlinee.com/api/minimap/archivee/" + match[1];
if (!tooltipImage) return;
tooltip.appendChild(tooltipImage);
document.body.appendChild(tooltip);
tooltipImage.onload = function () {
positionWorldTooltip(link, tooltip);
tooltip.style.visibility = "visible";
}
tooltipImage.onerror = function () {
tooltip.remove();
}
}
link.onmouseleave = function () {
if (tooltip) {
tooltip.remove();
}
}
}
function positionWorldTooltip(link, tooltip) {
const rect = link.getBoundingClientRect();
const width = tooltip.offsetWidth || 0;
const height = tooltip.offsetHeight || 0;
const margin = 8;
// Prevent vertical overflow if possible
var top = rect.bottom + margin;
if (rect.bottom + height > window.innerHeight) {
top = rect.top - height - margin;
}
// Prevent horizontal overflow if possible
var left = rect.left;
const maxLeft = window.innerWidth - width - margin;
if (left > maxLeft) left = maxLeft;
if (left < margin) left = margin;
tooltip.style.left = left+"px";
tooltip.style.top = top+"px";
}
processWorldLinks();