-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
66 lines (54 loc) · 2.44 KB
/
script.js
File metadata and controls
66 lines (54 loc) · 2.44 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
document.addEventListener("DOMContentLoaded", () => {
const form = document.querySelector("form");
const autofill = document.querySelector("button.autofill");
const reset = document.querySelector("button[type='reset']");
const fontName = document.querySelector("#fontName");
const fontWeight = document.querySelector("#fontWeight");
const fontStyle = document.querySelector("#fontStyle");
const loadStyle = document.querySelector("#loadStyle");
const fontURL = document.querySelector("#fontURL");
const resultsArea = document.querySelector(".results-area");
/*-------- AUTOFILL BTN --------*/
autofill.addEventListener("click", e => {
e.preventDefault();
fontName.value = "Instrument Sans";
fontWeight.value = 400;
fontStyle.value = "normal";
loadStyle.value = "swap";
fontURL.value = "https://file.garden/ZRt8jW_MomIqlrfn/fonts/InstrumentSans-Regular.ttf";
})
/*-------- RESET BTN --------*/
reset.addEventListener("click", () => {
resultsArea.matches(".show") ? resultsArea.classList.remove("show") : null;
})
/*-------- GO BTN --------*/
form.addEventListener("submit", e => {
e.preventDefault();
resultsArea.matches(".show") ? null : resultsArea.classList.add("show");
let fw = fontWeight.value == 400 ? "" : fontWeight.value.toString();
let fs = fontStyle.value == "auto" || fontStyle.value == "normal" ? "" : fontStyle.value.toString();
let ls = loadStyle.value == "auto" ? "" : loadStyle.value.toString();
const res = `@font-face { font-family: "${fontName.value}";${fw !== "" ? " font-weight: " + fw + ";" : ""}${fs !== "" ? " font-style: " + fs + ";" : ""}${ls !== "" ? " font-display: " + ls + ";" : ""} src: url("${fontURL.value}"); }`
let y = resultsArea.querySelector(".y");
y ? y.textContent = res : null;
let a = 350;
let b = Date.now();
let c = setInterval(() => {
if(Date.now() - b > 350){
clearInterval(c)
} else {
window.scrollTo(0, document.body.scrollHeight);
}
},0)
})
})//end loaded
popify({
button: ".crd button",
popup_selector: ".popup",
fade_speed: 400,
exit_options: {
exit_button: ".close-popup",
click_outside_to_exit: true,
escape_key_to_exit: true
}
})