File size: 1,499 Bytes
5bab31c
 
558f996
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5bab31c
 
 
 
 
 
 
 
 
 
 
 
 
558f996
 
 
 
 
 
 
 
 
5bab31c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use strict"

const common_fonts = [
	"Arial",
	"Times New Roman",
	"Courier New",
	"Verdana",
	"Georgia",
	"Palatino",
	"Bookman Old Style",
	"Tahoma",
	"Century Gothic",
	"Lucida Console",
	"Monaco",
	"Bradley Hand",
	"Calibri",
	"Cambria",
	"Candara",
	"Consolas",
	"Constantia",
	"Corbel",
	"Franklin Gothic Medium",
	"Gabriola"
];

document.addEventListener("DOMContentLoaded", () => {
	const forms = document.querySelectorAll("form");
	forms.forEach((form) => {
		form.style.display = "none";
	});

	const formsContainer = document.querySelector("#forms-container");
	const noChosenForm = document.createElement("span");
	noChosenForm.classList.add("error");
	noChosenForm.textContent = "No form chosen";
	formsContainer.appendChild(noChosenForm);
});

const fontsSelect = document.querySelectorAll("#font").forEach((fontSelect) => {
	common_fonts.forEach(font => {
		const option = document.createElement('option');
		option.value = font;
		option.text = font;
		fontSelect.add(option);
	});
});

document.querySelectorAll(".show-form").forEach((button) => {
	button.addEventListener("click", (event) => {
		showForm(event.target.dataset.formId);
	});
});

function showForm(formId) {
	const forms = document.querySelectorAll("#forms-container form");
	forms.forEach((form) => {
		if (form.id === formId) {
			form.style.display = "block";
			const noChosenForm = document.querySelector(".error");
			noChosenForm.style.display = "none";
		} else {
			form.style.display = "none";
		}
	});
}