var lists = JSON.parse(loadFile("data/lists.json")); //Load list data from lists.json file using vendor loadfile.js. var list_id = $("#query-list")[0].innerText; //Get list id from tag created in query-handler.php. var list = null; if(lists.hasOwnProperty(list_id)){ list = lists[list_id]; } else { list = lists["master"]; //If the list id in the query is invalid, go back to the main list. } $("#list-title")[0].innerText = list.title; if(list.hasOwnProperty("description")){ $("#list-description")[0].innerText = list.description; } if(list.hasOwnProperty("ordered") && list.ordered){ $("#list-container")[0].innerHTML += "
    "; //Create an ordered list of the list has attribute "ordered":true. } else { $("#list-container")[0].innerHTML += ""; //By default, lists are unordered. } $("#lists")[0].innerHTML += "
    Return to Master List ⮌"; //Add a return link to the bottom of the article. switch(list_id){ case "master": for(id in lists){ var item = `
  1. ${lists[id].title}
  2. `; $("#list")[0].innerHTML += item; //The Master List contains a link to every other list in the JSON file. } $("#list-return-link")[0].style.display="none"; //"Return to Master List" link is not needed on Master List itself. break; case "quotes": for(quote of list.list){ var item = "

    "; if(quote.hasOwnProperty("title")){ item += `${quote.title}
    `; //Add a title if the quote has one (e.g. "The Litany Against Fear"). } item += `"${quote.quote}"
    `; //Add the text of the quote. item += ` — ${quote.hasOwnProperty("quotee") ? quote.quotee : "Unknown"}`; //Add the quotee's name, or "Unknown" if one is not specified. if(quote.hasOwnProperty("source")){ item += `, ${quote.source}`; //Add the source if the quote has one. } item += "


    "; //Delimit the quotes with a horizontal rule. $("#list")[0].innerHTML += item; } break; default: for(item of list.list){ $("#list")[0].innerHTML += `
  3. ${item}
  4. `; } }