-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhamletFootnotes_txt.js
More file actions
52 lines (46 loc) · 1.64 KB
/
Copy pathhamletFootnotes_txt.js
File metadata and controls
52 lines (46 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use strict";
/*
Author: Kylie Drawdy
Date: 09/16/24
*/
// Node list of phrases that are associated with footnotes
let phrases = document.querySelectorAll("article blockquote dfn");
// for loop to loop through phrases
for ( let i = 0; i < phrases.length; i++) {
// create anonymous function that runs on click
phrases[i].onclick = function() {
// create phrases variable
let phrase = document.createElement("h1");
// set value of textContent
phrase.textContent = this.textContent;
// create footnote variable
let footnote = document.createElement("p");
// set value of text content
footnote.textContent = footnotes[i];
// apply style rules
footnote.style = "font-style: italic; font-size: 1.2em;"
// create close Button
let closeButton = document.createElement("input");
// set buttons type attribute
closeButton.type = "button";
// set closeButton value
closeButton.value = "Close Footnote";
// Apply styles
closeButton.style = "display: block; margin: 10px auto;"
// create popup window
let popup = window.open("", "footnote", "width=300, height=200, top=100, left=100");
// apply styles
popup.document.body.style = "background-color: ivory; font-size: 16px; padding: 10px;"
// append phrase to popup.document.body.style
popup.document.body.appendChild(phrase);
// append footnote to popup.document.body.style
popup.document.body.appendChild(footnote);
// append closeButton to popup.document.body.style
popup.document.body.appendChild(closeButton);
// run anonymous function on click of closeButton
closeButton.onclick = function() {
//close popup window
popup.close();
}
}
}