ФЭНДОМ


Замечание. Возможно, после сохранения вам придётся очистить кэш своего браузера, чтобы увидеть изменения.

  • Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить, или нажмите Ctrl-F5 или Ctrl-R (⌘-R на Mac)
  • Google Chrome + Яндекс.Браузер: Нажмите Ctrl-Shift-R (⌘-Shift-R на Mac)
  • Internet Explorer: Удерживая Ctrl, нажмите Обновить, или нажмите Ctrl-F5
  • Konqueror: Нажмите Обновить или F5
  • Opera: Выберите очистку кэша в меню Инструменты → Настройки.
/* Any JavaScript here will be loaded for all users on every page load. */
 
//TODO: Organise names, maybe collect all names in an array to reduce code redundancy
 
  //***************************************************\\
 //***Admin Post Colours for Forums and Message Walls***\\
//*******************************************************\\
(function() {
    var border_admin = "6px double ";//+color
    var background_admin = "rgba(216, 180, 88, 0.85) url('https://images.wikia.nocookie.net/__cb20140625215453/lotrminecraftmod/images/0/03/Admin1_120.png') bottom center no-repeat";
    var admins = [
        {name: "TreebeardOfFangorn", color:"#A7B200"},
        {name: "Maykroft", color:"#DC143C"},
        {name: "Shtormhold", color:"#006400"},
        {name: "Sinthorion", color:"#FF7F00"},
        {name: "Areades", color:"#81BEF7"},
        {name: "Beijing1000", color:"#136613"},
        {name: "Glflegolas", color:"#387C44"},
        {name: "Quipp", color:"#00CCFF"},
        {name: "SamwiseFilmore", color:"#D07130"},
        {name: "Glaerdir", color:"#F962A5"},
        {name: "Thorin_Stonehelm", color:"#0078FF"},
        {name: "EpicSpacePanda", color:"#0EC79F"}
    ];
 
    var border_mod = "2px solid ";//+color
    var background_mod = "rgba(214, 188, 136, 0.85) url('https://images.wikia.nocookie.net/__cb20141205133613/lotrminecraftmod/images/d/d1/Mod.png') bottom center no-repeat";
    var mods = [
 
        {name: "Danvintius_Bookix ", color:"#4AA02C"},
        {name: "AlteOgre", color:"#669900"},
        {name: "High_King_Ithilion", color:"#3F00FF"}
    ];
 
    var background_tempmod = "rgba(205, 192, 176, 0.66) url('https://vignette.wikia.nocookie.net/lotrminecraftmod/images/b/b2/Temp_mod_tag_3.png/revision/latest?cb=20150605193955') bottom center no-repeat";
    var tempmods = [
        {name:"TomtheBom"},
        {name:"Rocket_Engineer"},
        {name:"Recneps"},
        {name:"Dinopizzagamer"},
        {name:"GimliBurper"}
    ];
 
    function get_filter(profile) {
        return eval("(function() {return $(this).has(\"a[href$=':"+profile.name+"']\").length;})");
    }
 
    var avatars = $('.speech-bubble-avatar');
 
    (function(){
        var mevans = {name: "LOTRMod", color:"#B55A15"};
        avatars.filter(get_filter(mevans)).next().css({
            background: "rgb(216, 180, 88) url('https://images.wikia.nocookie.net/__cb20141225003527/lotrminecraftmod/images/thumb/4/4e/Modcreator.png/250px-Modcreator.png') bottom center no-repeat",
            padding: '10px',
            border: border_admin+mevans.color
        });
    })();
 
    var i;
    for (i in admins) {
        var admin = admins[i];
        avatars.filter(get_filter(admin)).next().css({
            background: background_admin,
            padding: '10px',
            border: border_admin+admin.color
        });
    }
    for (i in mods) {
        var mod = mods[i];
        avatars.filter(get_filter(mod)).next().css({
            background: background_mod,
            padding: '10px',
            border: border_mod+mod.color
        });
    }
    for (i in tempmods) {
        var tempmod = tempmods[i];
        avatars.filter(get_filter(tempmod)).next().css({
            background: background_tempmod,
            padding: '10px',
        });
    }
})();
 
// OTHER CODE //
 
/* Makes all quotes collapsible by default, excluding the first line.
 */
var quote = $('.quote:not(.customquote)');
quote.addClass("mw-collapsible mw-collapsed");
quote.each(function() {
    $(this).html(
        $(this).html().replace(
            /^(.* wrote:(?:\n|<br>))([\s\S]*)$/m,
            // [\s\S] = whitespace or non-whitespace = match all ~= [.\n]
            '$1<span class="mw-collapsible-content">$2</span>'
        )
    );
});
 
/* Username replace feature
 * Inserts viewing user's name into <span class="insertusername"></span>
 * Put text inside the spans to be viewed by logged out users
 * Originally by [[wikia:User:Splarka|Splarka]], then by [[User:Spang|Spang]],
 * This (jQuery) version by [[wikia:User:Joeyaa]], written to be backwards compatible
 */
 
if (wgUserName != 'null') {
	$('.insertusername').html(wgUserName);
}
 
  //********************************************\\
 //** Worldmap (Template:MiddleEarthMap) [WIP] **\\
//************************************************\\
 
// (better don't edit anything below here unless your name is Sinthorion)
 
/*
function GetPixel(x, y)
{
    var p = canvas.context.getImageData(x, y, 1, 1).data; 
    var hex = "#" + ("000000" + rgbToHex(p[0], p[1], p[2])).slice(-6);  
    return hex;
}
 
function rgbToHex(r, g, b) {
    if (r > 255 || g > 255 || b > 255)
        throw "Invalid color component";
    return ((r << 16) | (g << 8) | b).toString(16);
}
*/
 
var map = document.getElementById("worldmap");
// Run the following code only if there is a valid map on the page
if (map) {
  /*
    //This code does not work due to security restrictions when getting images from another server
    var img = document.createElement("img");
    img.src = 'https://vignette.wikia.nocookie.net/lotrminecraftmod/images/7/70/MiddleEarth.png/revision/latest?cb=20150605200727';
    img.style.visibility = "hidden";
//    document.body.appendChild(img);
 
    var canvas = document.createElement("canvas");
    canvas.id = "canvas";
    canvas.style.border = "2px solid red";
    canvas.width = img.width;
    canvas.height = img.height;
    canvas.style.visibility = "hidden";
    canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
    document.body.appendChild(canvas);
 
alert("debug:" + GetPixel(10, 10));
alert("sucess");
*/
 
    // The current background-position; usually negative
    map.offX = -500;
    map.offY = -500;
    // The position where the dragging was started
    map.dragX = 0;
    map.dragY = 0;
    // The position to which the background will be moved
    map.newX = 0;
    map.newY = 0;
    // The current zoom level. Higher zoom level means bigger map
    map.zoom = 1.0;
 
    // Called when the mouse cursor is pressed down inside the map
    var dragStart = function(e) {
        e.preventDefault();
        map.dragX = e.clientX;
        map.dragY = e.clientY;
        document.addEventListener("mouseup", dragEnd);
        document.addEventListener("mousemove", update);
        return false;
    }
    // Called when the cursor is released anywhere on the screen.
    // This event is only triggered after a call of dragStart. It stops the listeners for this event and the update event.
    var dragEnd = function(e) {
        e.preventDefault();
        // If the mouse has not moved, it's no drag but a simple click action
        if (map.dragX == e.clientX && map.dragY == e.clientY) {
            var x = Math.floor(e.clientX * map.zoom - map.offX);
            var y = Math.floor(e.clientY * map.zoom - map.offY);
            alert("Single click at position "+x+"|"+y);
            /* Link to biome page */
            document.removeEventListener("mousemove", update);
            document.removeEventListener("mouseup", dragEnd);
            return false;
        }
        map.offX = map.newX;
        map.offY = map.newY;
        document.removeEventListener("mousemove", update);
        document.removeEventListener("mouseup", dragEnd);
        return false;
    }
    // Called whenever the mouse moves while it is dragging the map
    var update = function(e) {
        map.newX = map.offX + e.clientX - map.dragX;
        map.newY = map.offY + e.clientY - map.dragY;
        var newpos = map.newX.toString() + "px " + map.newY.toString() + "px";
        map.style.backgroundPosition = newpos;
    }
    // Called whenever the mousewheel is scrolled while the cursor is inside the map
    var zoom = function(e) {
        e.preventDefault();
        // Delta always is a multiple of 3
        var delta = e.deltaY / 3;
        var old_zoom = map.zoom;
        map.zoom -= delta * (map.zoom / 15);
        // Apply zoom limits
        if (map.zoom < map.clientWidth / 3200 * 2) {
            map.zoom = map.clientWidth / 3200 * 2;
            return false;
        }
        if (map.zoom < map.clientHeight / 4000 * 2) {
            map.zoom = map.clientHeight / 4000 * 2;
            return false;
        }
        // Max zoom level is 300%
        if (map.zoom > 3.0) {
            map.zoom = 3.0;
            return false;
        }
        var sizeX = 3200 * map.zoom;
        var sizeY = 4000 * map.zoom;
        var newsize = "" + sizeX + "px " + sizeY + "px";
        map.style.backgroundSize = newsize;
        map.offX *= map.zoom / old_zoom;
        map.offY *= map.zoom / old_zoom;
        map.offX += 0.1 * map.zoom * delta * (e.clientX - (map.clientWidth / 2));
        map.offY += 0.1 * map.zoom * delta * (e.clientY - (map.clientHeight / 2));
        var newpos = "" + map.offX + "px " + map.offY + "px";
        map.style.backgroundPosition = newpos;
        return false;
    }
    // Start the initial event listeners
    map.addEventListener("mousedown", dragStart);
    map.addEventListener("wheel", zoom);
}
 
importArticles({
    type: "script",
    articles: [ 
 
        'MediaWiki:ColorComments.js',
  ]
});
 
 
//Trying to Upload File Deletion scripts...
importArticles({
    type: "script",
    articles: [
        "u:dev:ListFiles/code.js",
        "u:dev:AjaxBatchDelete/code.2.js"
    ]
});