Kamel:J*/Ka-Mel-Oh/Testgelände.js

addJS("Kamel:J*/Ka-Mel-Oh/Prototype.js");

/* --- helper stuff --- */

function card_info (number) {   var table = document.getElementById("card_info_table"); table.style.display = "table"; document.getElementById("card_info_cell").innerHTML = ""; table.onclick = function { this.style.display = "none"; };

x = new Ajax.Request("http://kamelopedia.mormo.org/api.php?action=parse&text=&format=json",		{			method:'get',			onSuccess: function(transport){				document.getElementById("card_info_cell").innerHTML = transport.responseJSON.parse.text["*"];			}		});

}

function fix_magic {

var deleters = document.getElementsByClassName("card_delete"); for (var i=0; i < deleters.length; i++) {		//var card = getDraggable(deleters[i]); deleters[i].onclick = function {d = getDraggable(this); d.parentNode.removeChild(d); }; deleters[i].style.cursor = "pointer"; }

var infos = document.getElementsByClassName("card_info"); for (var i=0; i < infos.length; i++) {		infos[i].onclick = function {d = getDraggable(this); card_info(d.childNodes[0].innerHTML); }; infos[i].style.cursor = "pointer"; }     }

function create_card (number, additional_css) {	if (number == "R") {		x = new Ajax.Request("http://kamelopedia.mormo.org/api.php?action=parse&text=&format=json",		{			method:'get',			onSuccess: function(transport){				document.getElementById("new_card_slot").innerHTML += transport.responseJSON.parse.text["*"];				fix_magic;			}		}); }	else {		x = new Ajax.Request("http://kamelopedia.mormo.org/api.php?action=parse&text=&format=json",		{			method:'get',			onSuccess: function(transport){				document.getElementById("new_card_slot").innerHTML += transport.responseJSON.parse.text["*"];				fix_magic;			}		}); } }

/* --- create card form --- */

addOnloadHook( function {	// forms	document.getElementById("card_create_form").innerHTML="  ";	document.getElementById("back_create_form").innerHTML=" ";

// onsubmit document.getElementById("card_create_form").childNodes[0].onsubmit = function { create_card(this.number.value,""); return false; }; document.getElementById("back_create_form").childNodes[0].onsubmit = function { create_card("R",""); return false; }; });

/* --- create permalink form --- */

addOnloadHook( function {	document.getElementById("perma_link").innerHTML="   ";

document.getElementById("perma_link").childNodes[0].onsubmit = function { var hints = document.getElementsByClassName("hint"); var out = []; for (var i = 0; i < hints.length; i ++) {			var s = ""; s += hints[i].innerHTML + ","; s += parseInt(hints[i].parentNode.style.left) + ","; s += parseInt(hints[i].parentNode.style.top) + ","; s += (parseInt(hints[i].parentNode.style.zIndex) - 1000); out.push(s); }		this.link.value = location.protocol+"//"+location.hostname+location.pathname+(location.search+"?").split("?")[0] + "?zIndex="+(dragobject.z -1000)+"&cards=" + out.join(";"); return false; }; });

/* --- init --- */

addOnloadHook( function {	var argstrings = (location.search+"?").split("?")[1].split("&");	var args = {}; // page parameters	for (var i=0; i<argstrings.length; i++)	{		var parts = (argstrings[i]+"==").split("=");		args[parts[0]]=parts[1];	}	if (! args.cards) return;	var cards = args.cards.split(";");       if (args.zIndex) dragobject.z = parseInt(args.zIndex) + 1000;		for (var i=0; i < cards.length; i ++)		{			var props = cards[i].split(",")				create_card(props[0],"left:"+props[1]+"px; top:"+props[2]+"px; z-index:"+(parseInt(props[3])+1000)+";");		} });