Tag linking

This commit is contained in:
Jim Shepich III 2026-02-02 00:19:40 -05:00
parent de6a8973e6
commit b24256a59e
11 changed files with 14 additions and 708 deletions

View File

@ -0,0 +1,11 @@
function selectTagByUrlQuery(){
query = new URLSearchParams(window.location.search);
tag = query.get('tag');
if(tag){
document.querySelector(`#tag-selector-${tag}`).checked = true;
}
}
document.addEventListener('load', selectTagByUrlQuery);
selectTagByUrlQuery();

View File

@ -1,177 +0,0 @@
if(document.getElementsByName("keywords")[0].content.indexOf("player")>-1){
main();
}
function main(){
var tables = document.getElementsByTagName("table");
var abilities = {"-":0};
var skills = {};
var stats = {};
var features = {};
var masteries = [];
var EXP = {};
for(i=0;i<tables.length;i++){
var header_names = "";
var header_row = tables[i].children[0].children[0];
//Iterate over the thead -> tr -> th elements
for(k=0;k<header_row.children.length;k++){
header_names += header_row.children[k].innerHTML.trim();
}
if(checkheaders(header_names,["Ability","Score","Modifier"])==3){
abilities.DOM = tables[i];
} else if(checkheaders(header_names,["Ability","Skill","Bonus","EXP"])==4){
skills.DOM = tables[i];
} else if(checkheaders(header_names,["Stat","Value"])==2){
stats.DOM = tables[i];
} else if(checkheaders(header_names,["Feature","EXP","Description"])==3){
features.DOM = tables[i];
} else if(checkheaders(header_names,["Mastery","EXP","Requirements","Type","Description"])==5){
masteries.push({"DOM":tables[i]});
}
}
function checkheaders(string, keywords){
var output = 0;
for(j=0;j<keywords.length;j++){
if(string.indexOf(keywords[j])>-1){
output += 1;
}
}
return output;
}
function align(cell,how="center"){
cell.className = cell.className.replace("leftalign","");
cell.className = cell.className.replace("rightalign","");
cell.className = cell.className.replace("centeralign","");
cell.className += " "+how+"align";
}
for(i=0;i<abilities.DOM.children[1].children.length;i++){
//Iterate over the rows of the abilities table
var row = abilities.DOM.children[1].children[i];
var ability = row.children[0].innerHTML.trim();
abilities[ability] = parseInt(row.children[2].innerHTML.trim());
}
var row_modifier = "";
for(i=0;i<skills.DOM.children[1].children.length;i++){
//Iterate over rows of the skills table.
var row = skills.DOM.children[1].children[i];
var bonus;
var exp;
if(row.children[0].innerHTML.trim() in abilities){
row_modifier = row.children[0].innerHTML.trim();
skill = row.children[1];
bonus = row.children[2];
exp = row.children[3];
} else {
skill = row.children[0];
bonus = row.children[1];
exp = row.children[2];
}
if(isNaN(parseInt(exp.innerHTML.trim()))){
exp.innerHTML = "0";
}
align(exp);
align(bonus);
EXP[skill.innerHTML.trim()] = parseInt(exp.innerHTML.trim());
var skill_bonus = Math.floor(parseInt(exp.innerHTML.trim())/2) + abilities[row_modifier];
bonus.innerHTML = " "+skill_bonus+" ";
skills[skill.innerHTML.trim()] = skill_bonus;
}
for(i=0;i<stats.DOM.children[1].children.length;i++){
var row = stats.DOM.children[1].children[i];
var stat = row.children[0];
var value = row.children[1];
var exp = row.children[2];
align(value);
align(exp);
stats[stat.innerHTML.trim()] = value;
var exp_value = exp.innerHTML.trim();
if(isNaN(exp_value)){
if(exp_value=="-"){
exp_value = 0;
} else if(exp_value.indexOf("d")>-1) {
stats["HD Improvement"] = parseInt(exp_value.substring(exp_value.indexOf("d")+1,exp_value.length));
stats["HD Increase"] = parseInt(exp_value.substring(0,exp_value.indexOf("d")));
exp_value = stats["HD Improvement"]+stats["HD Increase"];
} else {
exp_value = 0;
exp.innerHTML = "0";
}
}
EXP[stat.innerHTML.trim()] = exp_value;
}
for(i=0;i<features.DOM.children[1].children.length;i++){
var row = features.DOM.children[1].children[i];
var feature = row.children[0];
var exp_str = row.children[1].innerHTML.trim();
var exp = parseInt(exp_str.substring(0,exp_str.indexOf("/")));
features[feature.innerHTML.trim()] = parseInt(exp_str.substring(exp_str.indexOf("/")+1,exp_str.length));
EXP[feature.innerHTML.trim()] = exp;
}
for(j=0;j<masteries.length;j++){
var mastery = masteries[j];
for(i=0;i<mastery.DOM.children[1].children.length;i++){
var row = mastery.DOM.children[1].children[i];
var feature = row.children[0];
var exp_str = row.children[1].innerHTML.trim();
var exp = 0;
if(exp_str.indexOf("/")>-1){
exp = parseInt(exp_str.substring(0,exp_str.indexOf("/")));
} else {
exp = parseInt(exp_str);
}
EXP[feature.innerHTML.trim()] = exp;
}
}
var HP = 1 + Math.floor((skills["Persistence"]+skills["Toughness"])/2);
if(HP<1){
HP = 1;
}
for(h=1;h<=EXP["HP"];h++){
if(h%5==0 && abilities["CON"]>=1){
HP += abilities["CON"];
} else {
HP += 1;
}
}
stats["HP"].innerHTML = " "+HP+" ";
if(!("HD Increase" in stats) && !("HD Improvement" in stats)){
stats["HD Increase"] = 0;
stats["HD Improvement"] = 0;
}
var hd = [Math.floor(stats["HD Increase"]/2)+1];
hd.push(4+2*Math.floor(stats["HD Improvement"]/2));
stats["Hit Dice"].innerHTML = hd[0]+"d"+hd[1];
var AC = 8 + Math.ceil(skills["Toughness"]/3) + Math.ceil(skills["Evasion"]/3);
stats["AC"].innerHTML = " "+AC+" ";
var exp_total = [0,parseInt(stats["EXP Total"].innerHTML.trim())];
for(key in EXP){
var temp_exp = parseInt(EXP[key]);
if(!isNaN(temp_exp)){
exp_total[0] += temp_exp;
}
}
stats["EXP Total"].innerHTML = (exp_total[1]-exp_total[0])+"/"+exp_total[1];
}

View File

@ -1,63 +0,0 @@
function extract_data(){
var data = document.getElementsByTagName("tr");
var master = {};
var header = null;
for(row of data){
if(row.className == "row0"){
continue;
//Skip table headers
} else if (row.className == "row1"){
header = row.parentElement.parentElement.parentElement.parentElement.previousElementSibling.innerText;
//If we're at a new table, then we have to go up the DOM tree until we
//find that section's header.
master[header] = [];
//And create a new list for that header in the master object.
}
var row_object = {};
row_object["link"] = row.children[0].children[0].href;
//The link can be found in the anchor element in the first cell of the
//row.
var text = row.children[0].children[0].innerText;
//Get the text of the link.
row_object["song"] = text.substring(0,text.indexOf("(")-1);
//The name of the song is the start of the text until the space before
//the parenthesis. I've made sure to use hyphens in place of parentheses in
//song titles.
row_object["source"] = text.substring(text.indexOf("(")+1, text.indexOf(")"));
//The work that the song is from is indicated between the parentheses.
row_object["vibes"] = row.children[1].innerText.split(", ")
//The vibes are in the second column, delimited by a comma-space.
master[header].push(row_object);
}
return master;
}
function download(filename, text) {
//Borrowed shamelessly from:
//https://ourcodeworld.com/articles/read/189/how-to-create-a-file-and-generate-a-download-with-javascript-in-the-browser-without-a-server
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
var button = document.getElementById("download-JSON");
button.addEventListener("click",function(){
var json_data = JSON.stringify(extract_data(),null,2);
download("epics_bgm.json",json_data);
});

View File

@ -1,385 +0,0 @@
//Variale `list` is imported from JSON with query_handler.php.
//var lists = JSON.parse(document.getElementById("lists-json").innerText);
var list_id = document.getElementById("query-list").innerText;
//Get list id from <var> tag created in query-handler.php.
var selected_list = null;
if(lists.hasOwnProperty(list_id)){
selected_list = lists[list_id];
} else {
selected_list = lists["master"];
//If the list id in the query is invalid, go back to the main list.
}
function gen_list_html(list){
//This function creates HTML from a list's JSON object by iterativel calling the gen_item_html function to convert individual items. This design paradigm facilitates the construction of nested lists or lists with sections.
var html = "";
if(!list.hasOwnProperty("type")){
list.type = "default";
}
if(!list.hasOwnProperty("subtype")){
list.subtype = "default";
}
var list_type = list.type;
if(list.hasOwnProperty("sections")){
list_type = "sectioned";
//Lists that have separate sections require special handling involving recursion.
}
switch(list_type){
case "master":
for(id in lists){
html += gen_item_html(id,type="list-id");
}
html = `<ul>${html}</ul>`;
break;
case "quotes":
html += "<hr />";
for(quote of list.list){
html += gen_item_html(quote,type="quote");
}
break;
case "key-value":
for(pair of list.list){
html += gen_item_html(pair,type="kv-pair");
}
html = (list.hasOwnProperty("ordered") && list.ordered) ? `<ol>${html}</ol>` : `<ul>${html}</ul>`;
//Create an ordered list if list has the property "ordered".
break;
case "gallery":
document.getElementById("lists").style.textAlign="center";
//Center the rows of exhibits on the page.
if(!list.hasOwnProperty("subtype")){
list.subtype="default";
}
for(exhibit of list.list){
html += gen_item_html(exhibit,type="exhibit",subtype=list.subtype);
}
break;
case "external":
//This branch will only run if someone manually enters the list name into the query; clicking an external-type list from the Master List will just open the link in a new tab.
setTimeout(function(){location.assign(list["link"])}, 600);
//If the list specified in the query has the external property, then redirect to the external link. I use setTimeout in order to allow the rest of the code to run.
list.title = `Redirecting to List of ${list.title}...`;
list.list = [];
//It takes a second to redirect, so put some filler on the page while the reader waits.
break;
case "sectioned":
if(!list.hasOwnProperty("section-level")||list["section-level"]==null){
list["section-level"] = 1;
//Section-level defines the heading level of the section. Top level is 1.
}
if(!list.hasOwnProperty("dropdown")||list.dropdown==null){
list.dropdown = true;
//By default, sections ARE in details/summary tags.
}
if(!list.hasOwnProperty("dropdown-open")||list["dropdown-open"]==null){
list["dropdown-open"] = false;
//By default, sections are collapsed.
}
for(section of list.sections){
var section_html = "";
var level = list["section-level"] + 1;
section["section-level"] = level;
//Nested secions are of lower levels.
if(!section.hasOwnProperty("type")||section.type==undefined){
section.type = list.type;
//This branch transfers the list type down from higher levels. By default, the bottom-level lists will inherit the type of the top-level object unless otherwise specified.
}
if(!section.hasOwnProperty("subtype")||section.subtype==undefined){
section.subtype = list.subtype;
//Sections should also inherit subtypes.
}
if(!section.hasOwnProperty("dropdown")||section.dropdown==undefined){
section.dropdown = list.dropdown;
//Inherit dropdown-ness unless otherwise specified.
}
if(!section.hasOwnProperty("dropdown-open")||section["dropdown-open"]==undefined){
section["dropdown-open"] = list["dropdown-open"];
//Inherit whether the dropdown should be collapsed or open.
}
var description = (section.hasOwnProperty("description")) ? `<p>${section.description}</p>` : "";
//Sections can have their own descriptions.
var title = `<h${level}>${section.title}</h${level}>`;
//Wrap the section title in a header tag.
if(section.hasOwnProperty("dropdown") && section.dropdown){
//If the section is marked with the "dropdown" attribute, then nest the section's data in a details/summary tag.
var open = (section["dropdown-open"]) ? "open":"";
section_html = `<details class="heading" ${open}><summary class="heading">${title}</summary>${description}${gen_list_html(section)}</details>`;
} else {
section_html = `${title}${description}${gen_list_html(section)}`;
}
//Sectioned
html += `<section id="${section.title}">${section_html}</section>`;
//Assigning ids allows for the possibility of fragment linking.
}
break;
default:
for(item of list.list){
html += gen_item_html(item);
}
html = (list.hasOwnProperty("ordered") && list.ordered) ? `<ol>${html}</ol>` : `<ul>${html}</ul>`;
//Create an ordered list if list has the property "ordered".
}
return html;
}
function gen_item_html(item,type="default",subtype=null){
var item_html = "";
switch(type){
case "list-id":
if(lists[item].hasOwnProperty("hidden") && lists[item].hidden){
return "";
//Lists marked with the "hidden" attribute are in-development and should not be displayed on the Master List.
}
if(!lists[item].hasOwnProperty("title")){
lists[item].title = item;
//If a title is not set for the list, then just use its id.
}
var tooltip = "";
if(lists[item].hasOwnProperty("description")){
tooltip=lists[item]["description"];
//When hovering over a list in the directory, display its description as a tooltip.
}
var link = `href='index.php?page=lists&list=${item}' target='_self'`;
//By default, lists have internal links that change the query value to that list's title. Internal links should open in the same tab.
if(lists[id].hasOwnProperty("type") && lists[item].type=="external"){
link = `href='${lists[item]["link"]}' target='_blank'`;
//For external lists, use their link instead of an internal link. External links should open in a new tab.
}
item_html = `<li title="${tooltip}"><a ${link}>${lists[item].title}</a></li>`;
//The Master List contains a link to every other list in the JSON file.
break;
case "quote":
//Format quotes like they are formatted on Goodreads.
if(!item.hasOwnProperty("quote")){
//If the quote is blank, then things are going to get real weird. Most likely, this will be caused by a typo, so this branch is a safeguard against any resulting errors.
return "";
}
item_html = "<p>";
if(item.hasOwnProperty("title")){
item_html += `<b>${item.title}</b><br />`;
//Add a title if the quote has one (e.g. "The Litany Against Fear").
}
item_html += `&ldquo;${item.quote}&rdquo;<br>`;
//Add the text of the quote.
if(item.hasOwnProperty("card") && !item.hasOwnProperty("quotee")){
item.quotee="";
//If a flavor text doesn't have a quotee, don't write "Unknown".
}
item_html += `&nbsp;&mdash; ${item.hasOwnProperty("quotee") ? item.quotee : "Unknown"}`;
//Add the quotee's name, or "Unknown" if one is not specified.
if(item.hasOwnProperty("source")){
if(item.hasOwnProperty("quotee") && item.quotee!=""){
item_html += ", ";
//Unless there is no quotee, separate the quotee from the source with ", "
}
item_html += item.source;
//Add the source if the quote has one.
}
if(item.hasOwnProperty("card")){
if(item.quotee!=""||item.hasOwnProperty("source")){
item_html += `, `;
//Separate quotee or source from card title with ", "
}
item_html += `<a target='_blank' href='https://gatherer.wizards.com/pages/card/Details.aspx?multiverseid=${item.multiverseid}'>${item.card}</a> (Magic: the Gathering)`;
}
item_html += "</p><hr />";
//Delimit the quotes with a horizontal rule.
break;
case "kv-pair":
if(!(item.hasOwnProperty("k")&&item.hasOwnProperty("v"))||Object.keys(item).length==1){
var key = Object.keys(item)[0];
item["k"] = key;
item["v"] = item[key];
//If the item is an object containing a single key-value pair, then use that pair as the k and v for displaying.
}
if(item.hasOwnProperty("link")){
item_html = `<span class="list-key"><a href="${item.link}" target="_blank">${item["k"]}</a></span>`;
} else {
item_html = `<span class="list-key">${item["k"]}</span>`;
}
item_html += ` &mdash; ${item["v"]}`;
if(item.hasOwnProperty("list") && Array.isArray(item.list)){
//Sublist time, baby!
var temp = {
"title":item_html,
"list":item.list,
"ordered": (item.hasOwnProperty("ordered")) ? item.ordered:undefined,
"dropdown": (item.hasOwnProperty("dropdown")) ? item.dropdown:undefined,
"dropdown-open": (item.hasOwnProperty("dropdown-open")) ? item["dropdown-open"]:undefined
};
//If a key-value pair has a list key with an array attribute, then reformat it as a sublist whose title is the kv pair and whose list is the array.
item_html = gen_item_html(temp,type="sublist")
} else {
item_html = `<li>${item_html}</li>`;
}
break;
case "exhibit":
var tooltip, alt, text, img_src, image;
tooltip = text = img_src = image = "";
classes = {"div":[],"img":[],"a":[]}
switch(subtype){
case "album":
tooltip = `${item.title} (${item.year}) - ${item.artist}`;
alt = tooltip;
img_src = item.cover;
text = `${item.title}<br />${item.artist}<br />(${item.year})`;
break;
case "movie":
tooltip = `${item.title} (${item.year})`;
alt = tooltip;
img_src = item.poster;
text = `${item.title}<br />(${item.year})`;
break;
case "mtg-card":
var gatherer_link = "https://gatherer.wizards.com/pages/card/Details.aspx?multiverseid=";
var gatherer_image = "https://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=";
if(item.hasOwnProperty("multiverseid")&&!item.hasOwnProperty("link")){
if(Array.isArray(item.multiverseid)){
//If the multiverseid is an array, treat it as a transform card and link to the Gatherer page for the front half.
item.link = gatherer_link+item.multiverseid[0];
} else {
item.link = gatherer_link+item.multiverseid;
}
//If there's no alternate link specified, then use the multiverseid to generate the Gatherer link.
}
if(item.hasOwnProperty("multiverseid")&&!item.hasOwnProperty("image")){
if(Array.isArray(item.multiverseid)){
img_src = [];
for(id of item.multiverseid){
img_src.push(gatherer_image+id+"&type=card")
}
//If there are multiple (two) multiverseids, make a link src for each of them for convenience.
} else {
img_src = gatherer_image+item.multiverseid+"&type=card";
}
//If there's no alternate link specified, then use the multiverseid to generate the Gatherer link for the image.
} else {
if(Array.isArray(item.image)){
img_src=[];
for(src of item.image){
img_src.push(src);
}
//If multiple (two) image sources are specified, create an array of both.
} else {
img_src = item.image;
}
}
if(item.hasOwnProperty("name")){
alt = tooltip = item.name;
}
if(Array.isArray(img_src)){
image = `<img title="${tooltip}" alt="${tooltip}" src="${img_src[0]}" class="gallery exhibit-${subtype} card-front ${classes.img.join(" ")}" /><img title="${tooltip}" alt="${tooltip}" src="${img_src[1]}" class="gallery exhibit-${subtype} card-back ${classes.img.join(" ")}" />`
//Two srcs are to be treated as those of a transform card, which switches on hover.
classes.div.push("card-transform");
}
break;
default:
}
if(image==""||!image){
image = image = `<img title="${tooltip}" alt="${tooltip}" src="${img_src}" class="gallery exhibit-${subtype} ${classes.img.join(" ")}" />`;
//If the image variable is not already defined, then generate it.
}
//Gallery items must have an image.
if(item.hasOwnProperty("link")){
image = `<a href='${item.link}' target='_blank' class="${classes.a.join(" ")}">${image}</a>`;
//If there's a link associated with the exhibit, put it on the image.
}
item_html = (text=="") ? image : `${image}<br />${text}`;
//If there's no text, then there's no need for a line break.
item_html = `<div class="gallery exhibit-${subtype} ${classes.div.join(" ")}">${item_html}</div>`
break;
case "sublist":
//Sublists can be any type (most likely default or key-value), so the best way to deal with them is recursion.
if(item.hasOwnProperty("dropdown") && item.dropdown){
var open = (item.hasOwnProperty("dropdown-open")&&item["dropdown-open"])?"open":"";
item_html = `<li><details ${open}><summary>${item.title}</summary>${gen_list_html(item)}</details></li>`;
} else {
item_html = `<li>${item.title}${gen_list_html(item)}</li>`;
}
break;
default:
if(["string","number"].includes(typeof item)){
item_html = `<li>${item}</li>`;
//If the element is a simple string or number, then we don't need to do any special formatting.
} else if (typeof item === "object"){
var keys = Object.keys(item);
if(keys.length == 1){
if (Array.isArray(item[keys[0]])){
//An item that is a dictionary only containing a list is probably a sublist. Format it as such, and pass it back through this switch statement.
var temp = {
"title":keys[0],
"type":"default",
"list":item[keys[0]]
};
item_html = gen_item_html(temp,"sublist");
} else {
item_html = gen_item_html(item,"kv-pair");
//A item that is dictionary with one key, whose value is not a list, is to be treated as a term-explanation type key-value pair.
}
} else {
item_html = gen_item_html(item,"sublist");
//At this point, if there is no other specification, an item that's an object is probably a sublist.
}
}
}
return item_html;
}
function str2html(md){
//This function replaces escapes commands and Markdown with their HTML equivalents.
html = md.replaceAll("\n","<br />");
return html;
}
document.getElementById("list-title").innerHTML = selected_list.title;
if(selected_list.hasOwnProperty("description")){
document.getElementById("list-description").innerHTML = selected_list.description;
} else {
document.getElementById("list-description").style.display = "none";
//If the list has no description, hide the element to remove the awkward space from the padding.
}
//Generate the article header from the list's title and description.
document.getElementById("list-container").innerHTML += str2html(gen_list_html(selected_list));
//Call the gen_list_html function to convert the list from a JSON object to sophisticated HTML.
if(list_id != "master"){
document.getElementById("lists").innerHTML += "<br /><p><a id='list-return-link' href='index.php?page=lists&list=master'>Return to Master List &#8617;</a></p>";
//Add a return link to the bottom of the article.
}

View File

@ -1 +0,0 @@
//$("#main-header").css({"font-size":$("#main-header").height()+"px"})

File diff suppressed because one or more lines are too long

View File

@ -1,11 +0,0 @@
<?php
$socials_string = file_get_contents(__DIR__ ."/../data/socials.json",true);
//__DIR__ constant specifies the path to the script
$socials = json_decode($socials_string);
foreach($socials as $s){
echo "<a class='social' href='" . $s->link . "'><span class='fa-brands fa-" . $s->icon . "' title='".$s->platform."'></span></a>";
}
echo "<br /><span class='copyright'>Copyright &copy; 2021-".date("Y")." Jim Shepich</span>";
?>

View File

@ -1,44 +0,0 @@
<?php
function page_comparator($a,$b){
//This function is the sorting criterion for the later call of usort, which will sort the page objects
//from pages.json in increasing order of their "index" value.
return $a->index <=> $b->index;
//For some reason, PHP8 requires the spaceship operator (<=>)
//instead of a greater than symbol.
}
function gen_nav_element($page){
$iframe = false;
//By default, echo the contents of a file instead of embedding it in an iframe.
if(isset($page->file)){
$href = "index.php?page=".$page->query_value;
$target = "_self";
//If the page is associated with a file, then point the navibar href to the file's query value.
$iframe = (isset($page->iframe)) ? true : false;
//If the page has the iframe attribute, then keep track of that.
} elseif(isset($page->link)) {
$href = $page->link;
$target = "_blank";
//If instead the page is associated with an external link, then point the navibar href there and make it open in a new window.
}
echo "<a href='".$href."' target='".$target."'><div class='nav-tab'><span class='nav-text'>".$page->name."</span></div></a>";
}
$page_array = get_object_vars($pages);
//Convert $pages from object to an associative array of [key=>val, key=>val]
//where the keys are the names of the page objects from the JSON file and the
//vals are the page objects themselves.
usort($page_array,"page_comparator");
//Sort the pages in order of increasing "index" value.
foreach($page_array as $key=>$p){
if($p->index>-1){
gen_nav_element($p);
//Pages with indices less than 0 are hidden from the navibar.
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
//__DIR__ points to scripts folder.
$pages = json_decode(file_get_contents(__DIR__ ."/../data/pages.json"));
//Load dictionary of site pages from pages.json file.
$query_page = (isset($_REQUEST['page']) && !empty($_REQUEST['page'])) ? $_GET['page'] : "home";
//Get value of "page" query key; default is "home".
$page = (isset($pages->$query_page)) ? $pages->$query_page : $pages->{404};
//If the query value ($query_page) is not in the dictionary ($pages), then load the 404 page instead.
echo "<var id='query-page'>".$query_page."</var>";
//Store the page id in a var tag in case we need to access it with JavaScript.
$list = (isset($_REQUEST['list']) && !empty($_REQUEST['list'])) ? $_GET['list'] : "master";
//Get the value of "list" from the query key; default is "master" (the master list).
echo "<var id='query-list'>".$list."</var>";
//Store the list id in a var tag so that we can easily figure out what list to generate with list.js.
if($query_page=="lists"){
$lists_json = json_decode(file_get_contents(__DIR__ ."/../data/lists.json"));
echo "<script id='lists-json'>var lists=".json_encode($lists_json)."</script>";
//Copy the data from lists.json and paste it into a script tag, saving it as a variable called `list` to be accessed by later JavaScript code (i.e. lists.js).
//I would have stored it in a var tag, but there was a weird bug with some of the <u> tags leaking out and making my title underlined, and this seemed to avoid that (and it's probably more efficient too).
}
?>

View File

@ -6,4 +6,5 @@
<br /> <br />
<h2>Post History</h2> <h2>Post History</h2>
{content} {content}
</article> </article>
<script src="/assets/js/blog_archive_query.js"></script>

View File

@ -1 +1 @@
<a class='blog-tag' data='{tag_name}'' href='{site.base_url}/tags/{tag_name}.html'>{tag_name}</a> <a class='blog-tag' data='{tag_name}'' href='{site.base_url}/archive.html?tag={tag_name}'>{tag_name}</a>