You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
3.3 KiB
145 lines
3.3 KiB
3 months ago
|
/**
|
||
|
**-
|
||
|
* JavaScript providing functions for
|
||
|
* generating the HTML elements
|
||
|
* required by an article
|
||
|
*
|
||
|
* Author - Philip Osztromok
|
||
|
*
|
||
|
* 27 March 2022
|
||
|
*+
|
||
|
*/
|
||
|
|
||
|
const addBanner = function (link, lecturer, episode) {
|
||
|
const newBanner = document.createElement("div")
|
||
|
newBanner.classList.add("banner")
|
||
|
newBanner.innerHTML =`
|
||
|
<h1 class="courselink">${link}</h1>
|
||
|
<h2 class="lecturer">${lecturer}</h2>
|
||
|
<h2 class="episodetitle">${episode}</h2>
|
||
|
`
|
||
|
return newBanner
|
||
|
}
|
||
|
|
||
|
function addArticle() {
|
||
|
const newArticle = document.createElement("Article")
|
||
|
return newArticle
|
||
|
}
|
||
|
|
||
|
function addChapterTitle(section) {
|
||
|
const newHeader = document.createElement("h2")
|
||
|
newHeader.classList.add("chaptertitle")
|
||
|
newHeader.innerHTML = `${section}`
|
||
|
return newHeader
|
||
|
|
||
|
}
|
||
|
function addTitle(title) {
|
||
|
const newTitle = document.createElement("h1")
|
||
|
newTitle.classList.add("top_title")
|
||
|
newTitle.innerHTML = `${title}`
|
||
|
return newTitle
|
||
|
}
|
||
|
|
||
|
function addHeader(section) {
|
||
|
const newHeader = document.createElement("h2")
|
||
|
newHeader.classList.add("sectiontitle")
|
||
|
newHeader.innerHTML = `${section}`
|
||
|
return newHeader
|
||
|
}
|
||
|
|
||
|
function addSubHeader(subsection) {
|
||
|
const newSubHeader = document.createElement("h3")
|
||
|
newSubHeader.classList.add("subsectiontitle")
|
||
|
newSubHeader.innerHTML = `${subsection}`
|
||
|
return newSubHeader
|
||
|
}
|
||
|
|
||
|
function addSmallHeader(bit) {
|
||
|
const newSmallHeader = document.createElement("h4")
|
||
|
newSmallHeader.classList.add("bit")
|
||
|
newSmallHeader.innerHTML = `${bit}`;
|
||
|
return newSmallHeader
|
||
|
}
|
||
|
|
||
|
function addParagraph(paragraph) {
|
||
|
const newParagraph = document.createElement("p")
|
||
|
newParagraph.innerHTML = `${paragraph}`
|
||
|
return newParagraph
|
||
|
}
|
||
|
|
||
|
function addClassParagraph(paragraph, newClass) {
|
||
|
const newParagraph = document.createElement("p")
|
||
|
newParagraph.classList.add(newClass)
|
||
|
newParagraph.innerHTML = `${paragraph}`
|
||
|
return newParagraph
|
||
|
}
|
||
|
|
||
|
function addCaption(caption) {
|
||
|
const newCaption = document.createElement("figcaption")
|
||
|
newCaption.innerHTML = `${caption}`
|
||
|
return newCaption
|
||
|
}
|
||
|
|
||
|
function addQuote (quote, caption) {
|
||
|
const newBlockQuote = document.createElement("blockquote");
|
||
|
const newParagraph = addParagraph(quote);
|
||
|
const newCaption = addCaption(caption);
|
||
|
newBlockQuote.append(newParagraph, newCaption);
|
||
|
newParagraph.classList.add("p_quotation");
|
||
|
return newBlockQuote;
|
||
|
}
|
||
|
|
||
|
function addUnorderedList (list) {
|
||
|
|
||
|
const newList = document.createElement("ul");
|
||
|
|
||
|
for (let item of list) {
|
||
|
let li = document.createElement("li");
|
||
|
li.innerText = item;
|
||
|
newList.appendChild(li);
|
||
|
}
|
||
|
|
||
|
console.log(list);
|
||
|
|
||
|
return newList;
|
||
|
}
|
||
|
|
||
|
function addOrderedList (list) {
|
||
|
|
||
|
const newList = document.createElement("ol");
|
||
|
|
||
|
for (let item of list) {
|
||
|
let li = document.createElement("li");
|
||
|
li.innerText = item;
|
||
|
newList.appendChild(li);
|
||
|
}
|
||
|
|
||
|
console.log(list);
|
||
|
|
||
|
return newList;
|
||
|
}
|
||
|
|
||
|
function addBlockquote (quote, citation) {
|
||
|
let newBlockquote = document.createElement("blockquote");
|
||
|
let newQuote = document.createElement("p");
|
||
|
let newCitation = document.createElement("cite");
|
||
|
|
||
|
newQuote.innerText = quote;
|
||
|
newCitation.innerText = citation;
|
||
|
|
||
|
newBlockquote.appendChild(newQuote);
|
||
|
newBlockquote.appendChild(newCitation);
|
||
|
|
||
|
return newBlockquote;
|
||
|
}
|
||
|
export { addBanner, addArticle, addChapterTitle, addTitle, addHeader, addSubHeader, addSmallHeader, addParagraph, addClassParagraph, addCaption, addQuote, addOrderedList, addUnorderedList, addBlockquote }
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
*
|
||
|
* helper functions
|
||
|
*
|
||
|
*/
|
||
|
|