-
Notifications
You must be signed in to change notification settings - Fork 0
/
styleTweeksLabels.js
63 lines (53 loc) · 2.13 KB
/
styleTweeksLabels.js
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
var s_btnlabelsz = document.getElementById('btnLabelSz');
var s_btnlabelfnt = document.getElementById('btnLabelFnt');
var s_btnlabelcase = document.getElementById('btnLabelCase');
var fontKeyPrefix = "actorQP4.";
s_btnlabelsz.addEventListener('change', function() { setLabelStyles(); saveFontSettings();});
s_btnlabelfnt.addEventListener('change', function() { setLabelStyles(); saveFontSettings();});
s_btnlabelcase.addEventListener('change', function() { setLabelStyles(); saveFontSettings();});
window.addEventListener("load", function(event) {
getFontSettings();
});
function getFontSettings() {
let fntSzIx = localStorage.getItem(fontKeyPrefix +"fntSzIx");
let fntCaseIx = localStorage.getItem(fontKeyPrefix + "fntCaseIx");
let fntFamIx = localStorage.getItem(fontKeyPrefix + "fntFamIx");
if (fntSzIx >= 0){
s_btnlabelsz.selectedIndex = fntSzIx;
}
if (fntCaseIx >= 0){
s_btnlabelcase.selectedIndex = fntCaseIx;
}
if (fntFamIx >= 0){
s_btnlabelfnt.selectedIndex = fntFamIx;
}
setLabelStyles();
}
function saveFontSettings() {
localStorage.setItem(fontKeyPrefix + "fntSzIx", s_btnlabelsz.selectedIndex );
localStorage.setItem(fontKeyPrefix + "fntCaseIx", s_btnlabelcase.selectedIndex );
localStorage.setItem(fontKeyPrefix + "fntFamIx", s_btnlabelfnt.selectedIndex );
}
function setLabelStyles() {
let labelz = document.querySelectorAll('.actorLabel');
let fntSz = s_btnlabelsz.value;
let fntCase = s_btnlabelcase.value;
let fntFamily = s_btnlabelfnt.value;
labelz.forEach(function(userItem) {
userItem.style.fontSize = fntSz;
userItem.style.textTransform = fntCase;
userItem.style.fontFamily = fntFamily;
});
}
function resetLabelStyles() {
let labelz = document.querySelectorAll('.actorLabel');
labelz.forEach(function(userItem) {
userItem.style.fontSize = "";
userItem.style.textTransform = "";
userItem.style.fontFamily = "";
});
s_btnlabelsz.selectedIndex = 0;
s_btnlabelcase.selectedIndex = 0;
s_btnlabelfnt.selectedIndex = 0;
saveFontSettings();
}