MediaWiki:Skin/Adventure2.0.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K (klickidiklack (noch seeeehr rudimentär, aber schon mal ein Ansatz))
 
K (Text ein bisserl länger einblenden)
Zeile 71: Zeile 71:
 
gametext.innerHTML += '<div style="position:absolute; top:200px; left:200px"' +
 
gametext.innerHTML += '<div style="position:absolute; top:200px; left:200px"' +
 
      'id="' + textid + '" + class="gametext">' + text + '</div>'
 
      'id="' + textid + '" + class="gametext">' + text + '</div>'
window.setTimeout("hidetext('" + textid + "')", text.length * 50);
+
window.setTimeout("hidetext('" + textid + "')", text.length * 70);
 
}
 
}
  

Version vom 6. September 2009, 00:05 Uhr

window.onload = function() {
	var actions = document.getElementById('action-table').getElementsByTagName('td');
	for(var i = 0; i < actions.length; i++) {
		actions[i].setAttribute("onclick", "unselect(), " + 
						   "this.className = 'selectedaction', " + 
						   "selectedaction = this.id.replace(/action-/, ''), " +
						   "newtitles(), " +
						   "newclicks()");
		}
	klickable      = new Array();
	originaltitles = new Array();
	var i = document.getElementById('gamefield').getElementsByTagName('*');
	var k = 0;
	for(var j = 0; j < i.length; j++) {
		if(i[j].className == 'klickable') {
			klickable[k] = i[j];
			originaltitles[k] = i[j].title;
			k++;
			}
		}
	}

function unselect() {
	var actions = document.getElementById('action-table').getElementsByTagName('td');
	for(var i = 0; i < actions.length; i++) {
		actions[i].className = "";
		}
	for(var i = 0; i < klickable.length; i++) {
		klickable[i].title = originaltitles[i];
		}
	}

function newtitles() {
	for(var i = 0; i < klickable.length; i++) {
		switch(selectedaction) {
			case "view":
				klickable[i].title = 'Sieh ' + originaltitles[i] + ' an';
				break;
			case "take":
				klickable[i].title = 'Nimm ' + originaltitles[i];
				break;
			case "use":
				klickable[i].title = 'Benutze ' + originaltitles[i];
				break;
			case "talk":
				klickable[i].title = 'Rede mit ' + originaltitles[i];
				break;
			case "give":
				klickable[i].title = 'Gib an ' + originaltitles[i];
				break;
			default:
				originaltitles[i];
				break;
			}
		}
	}

function newclicks() {
	for(var i = 0; i < klickable.length; i++) {
		var j = klickable[i].getElementsByTagName('*');
		for(var k = 0; k < j.length; k++) {
			if(j[k].className == selectedaction) {
				klickable[i].setAttribute("onclick", j[k].innerHTML);
				}
			}
		}
	}

function showtext(textid, text) {
	var gametext = document.getElementById('gametext');
	gametext.innerHTML += '<div style="position:absolute; top:200px; left:200px"' +
			      'id="' + textid + '" + class="gametext">' + text + '</div>'
	window.setTimeout("hidetext('" + textid + "')", text.length * 70);
	}

function hidetext(textid) {
	var gametext = document.getElementById('gametext');
	var text = document.getElementById(textid);
	hide = gametext.removeChild(text);
	}