Benutzer:Shadowtweaker/Vorlage:AtkTable: Unterschied zwischen den Versionen

Aus PokéWiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
== Toggle + JavaScript ==
== Toggle + JavaScript ==
<pre>
<pre>
/* initialize generation and position labels */
/* initialize generation labels and level sorting across generations */
$(".at").each(function() {
$(".at").each(function() {
coltogen = $(this).find("thead tr:nth-child(2) th").toArray().map((x, i) => [x.dataset.gen, x.dataset.gen].slice(0, x.colSpan).join(",")).join(",").split(",");
coltogen = $(this).find("thead tr:nth-child(2) th").toArray().map((x, i) => [x.dataset.gen, x.dataset.gen].slice(0, x.colSpan).join(",")).join(",").split(",");
Zeile 8: Zeile 8:
});
});
});
});
$(".at tbody tr").each((a, b) => b.setAttribute("data-pos", a));
$(".at_l tbody tr td:nth-child(1)").each((i, x) => x.innerHTML = "" + i);
$(".at_l").each(function() {
id = $(this).find("thead tr:nth-child(1) th:nth-child(1)")[0];
level = $(this).find("thead tr:nth-child(1) th:nth-child(2)")[0];
id2 = document.createElement("th");
id2.rowSpan = id.rowSpan;
$(this).find("thead tr:nth-child(1)")[0].insertBefore(id2, id);
id.colSpan = level.colSpan;
id.rowSpan = level.rowSpan;
level.style.display = "none";
});


/* initialize toggle buttons */
/* initialize toggle buttons */
Zeile 36: Zeile 46:
$(this)[0].style.display = "none";
$(this)[0].style.display = "none";
});
});
/* sort rows by level */
/* adjust level header */
/*$(".at_l").each(function() {
$(".at_l").each(function() {
rows = [];
id = $(this).find("thead tr:nth-child(1) th:nth-child(2)")[0];
$(this).find("tbody tr").each((a, b) => rows.push(b));
level = $(this).find("thead tr:nth-child(1) th:nth-child(3)")[0];
if (gen == 0)
if (gen == 0) {
rows = rows.sort((a, b) => a.getAttribute("data-pos") - b.getAttribute("data-pos"));
id.colSpan = level.colSpan;
else
id.rowSpan = 1;
rows = rows.sort((a, b) => parseInt($(a).find("td:nth-child(" + gen + ")")[0].innerText.replace("—", "101")) - parseInt($(b).find("td:nth-child(" + gen + ")")[0].innerText.replace("", "101")));
id.innerHTML = '<a href="/Level">Level</a> nach Generation';
$(this).find("tbody")[0].innerHTML = rows.map(x => x.outerHTML).join("");
}
});*/
else {
id.colSpan = $(this).find("thead tr:nth-child(2) th").toArray().filter(x => x.dataset.gen == gen)[0].colSpan;
id.rowSpan = $(this).find("thead tr:nth-child(2) th").toArray().filter(x => x.dataset.gen == gen)[0].rowSpan + 1;
id.innerHTML = '<a href="/Level">Level</a>';
}
$(this).find("thead tr:nth-child(2)")[0].style.display = (gen == 0 ? "" : "none");
});
}
}
</pre>
</pre>

Version vom 13. Februar 2018, 22:47 Uhr

Toggle + JavaScript

/* initialize generation labels and level sorting across generations */
$(".at").each(function() {
	coltogen = $(this).find("thead tr:nth-child(2) th").toArray().map((x, i) => [x.dataset.gen, x.dataset.gen].slice(0, x.colSpan).join(",")).join(",").split(",");
	$(this).find("tbody tr").each(function() {
		$(this).find("td").toArray().slice(0, coltogen.length).forEach((x, i) => x.dataset.gen = coltogen[i]);
	});
});
$(".at_l tbody tr td:nth-child(1)").each((i, x) => x.innerHTML = "" + i);
$(".at_l").each(function() {
	id = $(this).find("thead tr:nth-child(1) th:nth-child(1)")[0];
	level = $(this).find("thead tr:nth-child(1) th:nth-child(2)")[0];
	id2 = document.createElement("th");
	id2.rowSpan = id.rowSpan;
	$(this).find("thead tr:nth-child(1)")[0].insertBefore(id2, id);
	id.colSpan = level.colSpan;
	id.rowSpan = level.rowSpan;
	level.style.display = "none";
});

/* initialize toggle buttons */
$(".at_toggle").each(function(index, object) {
	var toggle = document.createElement("a");
	toggle.className = 'at_togglerlink';
	toggle.setAttribute('href', 'javascript:at_toggle("' + object.getAttribute("data-for") + '");');
	var child = object.firstChild;
	object.removeChild(child);
	toggle.appendChild(child);
	object.insertBefore(toggle, object.firstChild);
});

/* toggler function */
function at_toggle(gen) {
	/* general toggling of generation-specific data */
	$("*[data-gen]").each(function() {
		if (this.dataset.gen == "-0") this.style.display = (gen == 0 ? "" : "none");
		else if (gen != 0 && Math.abs(this.dataset.gen) != gen) this.style.display = "none";
		else if (gen == 0 && this.dataset.gen < 0) this.style.display = "none";
		else this.style.display = "";
	});
	/* toggle rows that are irrelevant for this generation */
	$(".at tbody tr").each(function() {
		$(this)[0].style.display = "";
		if (gen != 0 && !$(this).find("td").toArray().filter(x => x.dataset.gen == gen).map(x => x.innerText != "—").reduce((acc, cv) => acc || cv, false))
			$(this)[0].style.display = "none";
	});
	/* adjust level header */
	$(".at_l").each(function() {
		id = $(this).find("thead tr:nth-child(1) th:nth-child(2)")[0];
		level = $(this).find("thead tr:nth-child(1) th:nth-child(3)")[0];
		if (gen == 0) {
			id.colSpan = level.colSpan;
			id.rowSpan = 1;
			id.innerHTML = '<a href="/Level">Level</a> nach Generation';
		}
		else {
			id.colSpan = $(this).find("thead tr:nth-child(2) th").toArray().filter(x => x.dataset.gen == gen)[0].colSpan;
			id.rowSpan = $(this).find("thead tr:nth-child(2) th").toArray().filter(x => x.dataset.gen == gen)[0].rowSpan + 1;
			id.innerHTML = '<a href="/Level">Level</a>';
		}
		$(this).find("thead tr:nth-child(2)")[0].style.display = (gen == 0 ? "" : "none");
	});
}
Welche Generationen sollen angezeigt werden?
1. Gen. 2. Gen. 3. Gen. 4. Gen. 5. Gen. 6. Gen. 7. Gen. alle

Attacken

Durch Levelaufstieg

Vorlage:AtkTable/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkRow/Level Vorlage:AtkTable/Footer

Durch TM/VM

Vorlage:AtkTable/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkRow/TMVM Vorlage:AtkTable/Footer

Vererbbarkeit

Vorlage:AtkTable/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkRow/Zucht Vorlage:AtkTable/Footer

Durch Attacken-Lehrer

Vorlage:AtkTable/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkRow/Lehrer Vorlage:AtkTable/Footer