User:Sinthorion/common.js

// Auto-signs each post alert("v up2"); $(".replyButton").click(function(e) {   var sign = ("~".repeat(3));    var editframe = $("#cke_contents_WikiaEditor-0 iframe, #cke_contents_WikiaEditor-1 iframe");    var inner = editframe.contents.find("#bodyContent");    inner.html(inner.html+sign); });

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 = 'http://vignette1.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) { alert("Single click at client position "+e.clientX+"|"+e.clientY); var x = Math.floor(e.clientX - (map.offX / map.zoom)); var y = Math.floor(e.clientY - (map.offY / map.zoom)); 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 500% if (map.zoom > 5.0) { map.zoom = 5.0; return false; }       var sizeX = 3200 * map.zoom; var sizeY = 4000 * map.zoom; var newsize = "" + sizeX + "px " + sizeY + "px"; map.style.backgroundSize = newsize; var diff = map.zoom - old_zoom; var xrat = e.clientX - map.clientWidth; var yrat = e.clientY - map.clientHeight; map.offX += xrat * delta * diff; map.offY += yrat * delta * diff; map.offX *= map.zoom / old_zoom; map.offY *= map.zoom / old_zoom; //map.offX += map.zoom * delta * (e.clientX - (map.clientWidth / 2)); //map.offY += 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); }