Rosetta Code:Village Pump/tasks descriptions only: Difference between revisions

Content added Content deleted
(One approach)
(javascript/DOM approach)
Line 25: Line 25:


:I hope this helps. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 14:58, 27 March 2015 (UTC)
:I hope this helps. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 14:58, 27 March 2015 (UTC)


::I was just fiddling inside of my webbrowser and came up with the following javascript-ish pseudocode. A solution using JScript or VBScript inside (gasp) Internet Explorer would seem to be the go.

::<lang javascript>
pages = document.getElementById("mw-pages")
anchors = pages.getElementsByTagName("a")
document.location = anchors[0].href // each one

start = document.getElementsByClassName("infobox")[0]
cursor = start
desc = ""
while (cursor.tagName !== "TABLE") {
there = cursor;
desc = desc + there.innerText + "\n";
cursor = cursor.nextElementSibling
}
// desc contains the task description</lang>

::The while loop should handle the different amounts of text between the infobox markup and the beginning of the contents table. [[User:Axtens|Axtens]] ([[User talk:Axtens|talk]]) 09:53, 16 April 2015 (UTC)