User:Lirmont/monaco.js

function include(filename) {	var head = document.getElementsByTagName('head')[0]; script = document.createElement('script'); script.src = filename; script.type = 'text/javascript'; head.appendChild(script) }

function addEventHandler(target, eventType, handler) {   if (target.addEventListener) { target.addEventListener(eventType, handler, false); } else if (target.attachEvent) { target.attachEvent("on" + eventType, handler); } else { target["on" + eventType] = handler; } }

function includeFiles {   include('/index.php?title=User:Anthoron/prototype.js&action=raw&ctype=text/javascript'); include('/index.php?title=User:Lirmont/tooltip.js&action=raw&ctype=text/javascript'); }

var codeLines=new Array; var points=new Array; var map; //put in by displayForm var lines = 0; var frameWidth = 0; var frameHeight = 0; var currentPoint = -1; //put in by handler var currentPointIndex = -1;

function showCoordinates(event) { var element = Event.element(event); var el = element.offsetParent; var x = 0, y = 0;

while (el) {		x += el.offsetLeft; y += el.offsetTop; el = el.offsetParent; }	var xPos = (100*((event.pageX-x-5)/element.getWidth)); //5 is an offset to match image var yPos = (100*((event.pageY-y-5)/element.getHeight)); $('xPosField').innerHTML = String(xPos).substr(0,5)+"%"; $('yPosField').innerHTML = String(yPos).substr(0,5)+"%"; }

function setDelete(id) { currentPoint = id; $('pointButton').innerHTML = "Delete Point"; }

/* Example



function addDeletePoint {

if($('pointButton').innerHTML=="Add Point") { codeLines[0]=""; } else if($('pointButton').innerHTML=="Delete Point") { alert("Delete Point entry point."); for(i=0;i<=lines-1;i++) { alert("id("+i+"): "+points[i][5]+" Current ID:"+currentPoint); if(points[i].indexOf(currentPoint)>-1) currentPointIndex=i; }		if(currentPointIndex!=-1) { var child = $(parseString(currentPoint)); var prnt = $('iFrame'); alert(child.innerHTML+" "+prnt.innerHTML); prnt.removeChild(child); }			}

for (i=0;i<=lines+1;i++) { if(i==0) { $('showCode').innerHTML = codeLines[i]; } else { $('showCode').innerHTML += codeLines[i]; } if(i!=(lines+1)) { $('showCode').innerHTML += "\n"; } } }

function displayForm {	$('pointName').innerHTML=' ' +'' +'Show Name Zone Name: '; $('symbolHolder').innerHTML= 'blip '                                   + 'check '                                   + 'text ' + ''; $('buttonHolder').innerHTML='Add Point '; $('textareaHolder').innerHTML=' ';

map = $('pictureFrame').getElementsByTagName('a')[0].title; frameWidth = $('pictureFrame').getElementsByTagName('img')[0].width; frameHeight = $('pictureFrame').getElementsByTagName('img')[0].height; var frameSrc = $('pictureFrame').getElementsByTagName('img')[0].src; $('pictureFrame').innerHTML=' '; }

addEventHandler(window, "load", includeFiles); addEventHandler(window, "load", displayForm);