User:Scormus/sandbox

 <!-- Begin var worldDX = 0; var worldDY = 0; var worldScaleX = 1.; var worldScaleY = 1.; var yLocationAtZero = 0; var params = {}; var defaultMap = "default"; var defaultMapVersion = "full";

function getMapImageData(mapCode, mapVersion) { if (mapCode == "mil") { var mapData = new Object; mapData["imageURL"] = "http://images1.wikia.nocookie.net/__cb20100413230531/championsonline/images/5/55/Millennium_City_Full_Map.png"; mapData["worldGridPoints"]= ["1169 66 1920", "10061 198 -2712"]; mapData["imageGridPoints"] = ["345,123", "1421,687"]; return mapData; }

return getDefaultMapImageData; }

function getDefaultMapImageData { var mapData = new Object; mapData["imageURL"] = "http://images1.wikia.nocookie.net/__cb20100413230531/championsonline/images/5/55/Millennium_City_Full_Map.png"; mapData["worldGridPoints"]= ["1169 66 1920", "10061 198 -2712"]; mapData["imageGridPoints"] = ["374,100", "1263,564"]; return mapData; }

function getMapNotationData(notationCode, mapVersion) { if (notationCode == "circle") { var notationData = new Object; notationData["imageURL"] = "http://images2.wikia.nocookie.net/__cb20100413235557/championsonline/images/7/7e/Map_location_highlight_green_circle_30x30.png"; notationData["notationSize"] = "30,30"; return notationData; } return getDefaultNotationData; }

function getDefaultNotationData { var notationData = new Object; notationData["imageURL"] = "http://images2.wikia.nocookie.net/__cb20100413235557/championsonline/images/7/7e/Map_location_highlight_green_circle_30x30.png"; notationData["notationSize"] = "10,10"; return notationData; }

function getMapImageURL(mapCode, mapVersion) { var mapData = getMapImageData(mapCode, mapVersion); return mapData["imageURL"]; }

function getMapWorldGridPoints(mapCode, mapVersion) { var mapData = getMapImageData(mapCode, mapVersion); return mapData["worldGridPoints"]; }

function getMapImageGridPoints(mapCode, mapVersion) { var mapData = getMapImageData(mapCode, mapVersion); return mapData["imageGridPoints"]; }

function getMapNotationURL(notationCode, mapVersion) { var notationData = getMapNotationData(notationCode, mapVersion); return notationData["imageURL"]; }

function getMapNotationSize(notationCode, mapVersion) { var notationData = getMapNotationData(notationCode, mapVersion); return notationData["notationSize"]; }

function setParams { var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { var hash = hashes[i].split('='); var name = decodeURI(hash[0]); var value = decodeURI(hash[1]); params[name] = value; }

if (typeof(params["location"]) == "undefined") { params["location"] = decodeURI(location.search).substr(1); } if (typeof(params["map"]) == "undefined") { params["map"] = defaultMap; } if (typeof(params["mapVersion"]) == "undefined") { params["mapVersion"] = defaultMapVersion; } }

function getLocationFromSearch { var co_location = decodeURI(location.search).substr(1); return co_location; }

function getYFromLocationString(str) { var lastCommaIndex = str.lastIndexOf(","); if (lastCommaIndex > 0) { return str.substr(lastCommaIndex + 1); }

var lastSpaceIndex = str.lastIndexOf(" "); if (lastSpaceIndex > 0) { return str.substr(lastSpaceIndex + 1); } return str; }

function getXFromLocationString(str) { var firstCommaIndex = str.indexOf(","); if (firstCommaIndex > 0) { return str.substr(0, firstCommaIndex); }

var firstSpaceIndex = str.indexOf(" "); if (firstSpaceIndex > 0) { return str.substr(0, firstSpaceIndex); } return str; }

function writeAllNotations { setParams; var mapCode = params["map"]; var mapVersion = params["mapVersion"];

setScale(mapCode, mapVersion); writeBackgroundMap(mapCode, mapVersion); writeNotation(params['location'], "circle", mapVersion); writeNotation("1169 66 1920", "circle", mapVersion); writeNotation("10061 198 -2712", "circle", mapVersion); }

function setScale(mapCode, mapVersion) { var worldGridPoints = getMapWorldGridPoints(mapCode, mapVersion); var imageGridPoints = getMapImageGridPoints(mapCode, mapVersion);

var worldGridPoint1 = worldGridPoints[0]; var imageGridPoint1 = imageGridPoints[0]; var xLocation1 = getXFromLocationString(imageGridPoint1); var yLocation1 = getYFromLocationString(imageGridPoint1); var xLocationWorld1 = getXFromLocationString(worldGridPoint1); var yLocationWorld1 = getYFromLocationString(worldGridPoint1);

var worldGridPoint2 = worldGridPoints[1]; var imageGridPoint2 = imageGridPoints[1]; var xLocation2 = getXFromLocationString(imageGridPoint2); var yLocation2 = getYFromLocationString(imageGridPoint2); var xLocationWorld2 = getXFromLocationString(worldGridPoint2); var yLocationWorld2 = getYFromLocationString(worldGridPoint2);

var xLocationAtZero = ((xLocationWorld1 * xLocation2) - (xLocationWorld2 * xLocation1)) / (xLocationWorld1 - xLocationWorld2); var yLocationAtZero = ((yLocationWorld1 * yLocation2) - (yLocationWorld2 * yLocation1)) / (yLocationWorld1 - yLocationWorld2);

worldDX = xLocationAtZero; worldDY = yLocationAtZero; if (xLocation1 != worldDX) { worldScaleX = xLocationWorld1 / (xLocation1 - worldDX); } else { worldScaleX = xLocationWorld2 / (xLocation2 - worldDX); } if (yLocation1 != worldDY)  { worldScaleY = yLocationWorld1 / (yLocation1 - worldDY); } else { worldScaleY = yLocationWorld2 / (yLocation2 - worldDY); }	}

function getScreenXFromLocationString(locationString) { var worldX = getXFromLocationString(locationString); return (worldX / worldScaleX) + worldDX; }

function getScreenYFromLocationString(locationString) { var worldY = getYFromLocationString(locationString); return (worldY / worldScaleY) + worldDY; }

function writeBackgroundMap(mapCode, mapVersion) { var mapImageURL = getMapImageURL(mapCode, mapVersion); document.write(" "); }

function writeNotation(locationString, notationCode, mapVersion) { var mapNotationURL = getMapNotationURL(notationCode, mapVersion); var notationImageSize = getMapNotationSize(notationCode, mapVersion);

var notationImageHeight =getXFromLocationString(notationImageSize); var notationImageWidth = getYFromLocationString(notationImageSize);

var newX = getScreenXFromLocationString(locationString); newX = newX - notationImageWidth / 2 ; newX = Math.round(newX);

var newY = getScreenYFromLocationString(locationString); newY = newY - notationImageHeight / 2 ; newY = Math.round(newY);

document.write(" "); } // End -->

 writeAllNotations;