-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
271 lines (209 loc) · 6.98 KB
/
script.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
window.onload = function(){
var slider_val = document.getElementById("slider").value;
console.log(slider_val);
};
//List CSS controls
function listToSquare(){
document.getElementById("list").style.listStyleType = "square";
listDisplayStyle("square");
}
function listToCircle(){
document.getElementById("list").style.listStyleType = "circle";
listDisplayStyle("circle");
}
function listToDisc(){
document.getElementById("list").style.listStyleType = "disc";
listDisplayStyle("disc");
}
function listDisplayStyle(newStyle){
document.getElementById("list-style").innerHTML = "list-style-type:" + newStyle + ";";
}
//Border CSS controls
var slider_val;
function getSliderVal(){
slider_val = document.getElementById("slider").value;
console.log("Test");
return slider_val;
}
var current_style = "solid";
function changeCurrentStyle(newType){
current_style = newType;
}
function getCurrentStyle(){
return current_style;
}
function updateBorder(){
var slider_val = getSliderVal();
document.getElementById("border-test").style.border = slider_val + "px " + getCurrentStyle() + " black";
document.getElementById("slider-val").innerHTML = slider_val + "px";
changeBorderCode();
}
function borderToSolid(){
changeCurrentStyle("solid");
document.getElementById("border-test").style.border = getSliderVal() + "px " + getCurrentStyle() + " black";
changeBorderCode();
}
function borderToDotted(){
changeCurrentStyle("dotted");
document.getElementById("border-test").style.border = getSliderVal() + "px " + getCurrentStyle() + " black";
changeBorderCode();
}
function borderToDashed(){
changeCurrentStyle("dashed");
document.getElementById("border-test").style.border = getSliderVal() + "px " + getCurrentStyle() + " black";
changeBorderCode();
}
function borderToDouble(){
changeCurrentStyle("double");
document.getElementById("border-test").style.border = getSliderVal() + "px " + getCurrentStyle() + " black";
changeBorderCode();
}
function changeBorderCode(){
document.getElementById("border-code").innerHTML = "border: " + getSliderVal() + "px " + getCurrentStyle() + " black;";
}
var margin_val;
function getMarginValue(){
margin_val = document.getElementById("m-slider").value;
return margin_val;
}
var padding_val;
function getPaddingValue(){
padding_val = document.getElementById("p-slider").value;
return padding_val;
}
var unit = "px";
function unitToPercent(){
unit = "%";
changeMargin();
changePadding();
}
function unitToPx(){
unit = "px";
changeMargin();
changePadding();
}
function unitToEm(){
unit = "em";
changeMargin();
changePadding();
}
function changeMarginVal(){
document.getElementById("margin-val").innerHTML = " " + getMarginValue() + unit;
changeMPText();
}
function changePaddingVal(){
document.getElementById("padding-val").innerHTML = " " +getPaddingValue() + unit;
changeMPText();
}
function changeMargin(){
document.getElementById("mp-test").style.margin = getMarginValue() + unit;
changeMarginVal();
}
function changePadding(){
document.getElementById("mp-test").style.padding = getPaddingValue() + unit;
changePaddingVal();
}
function copy_text(){
var textValue = document.getElementById("list-style").innerHTML;
navigator.clipboard.writeText(textValue).then(function() {
console.log('Async: Copying to clipboard was successful!');
}, function(err) {
console.error('Async: Could not copy text: ', err);
});
console.log(textValue);
}
function clickFunction(){
console.log("test!");
}
function changeMPText(){
document.getElementById("mp-code").innerHTML = "margin:" + getMarginValue() + unit + ";" + " padding:" + getPaddingValue() + unit + ";";
}
var currentAlignment;
function textAlignLeft(){
currentAlignment = "left";
updateAlignText();
document.getElementById("text-align-para").style.textAlign = currentAlignment;
}
function textAlignRight(){
currentAlignment = "right";
updateAlignText();
document.getElementById("text-align-para").style.textAlign = "right";
}
function textAlignCenter(){
currentAlignment = "center";
updateAlignText();
document.getElementById("text-align-para").style.textAlign = "center";
}
function updateAlignText(){
document.getElementById("text-align-code").innerHTML = "text-align:" + currentAlignment + ";";
}
var currentColor;
function getColorValue(){
if(document.getElementById("color-box").value == ""){
return "#000000";
}else{
return document.getElementById("color-box").value;
}
}
function adjustColor(){
var color = getColorValue();
document.getElementById("color-tester").style.color = color;
adjustColorCode();
syncColorPicker(color);
}
function getBGColorValue(){
if(document.getElementById("BG-color-box").value == ""){
return "#ffffff";
}else{
return document.getElementById("BG-color-box").value;
}
}
function adjustBGColor(){
var color = getBGColorValue();
document.getElementById("color-tester").style.backgroundColor = color;
adjustColorCode();
syncBGColorPicker(color);
}
function getColorPickerVal(){
return document.getElementById("favcolor").value;
}
function getColorPickerBGVal(){
return document.getElementById("favcolorBG").value;
}
function adjustText(){
document.getElementById("color-box").value = getColorPickerVal();
adjustColor();
}
function adjustBGText(){
document.getElementById("BG-color-box").value = getColorPickerBGVal();
adjustBGColor();
}
function syncColorPicker(color){
document.getElementById("favcolor").value = color;
}
function syncBGColorPicker(color){
document.getElementById("favcolorBG").value = color;
}
function adjustColorCode(){
document.getElementById("tc-code").innerHTML = "color:" + getColorValue() + ";" + " background-color:" + getBGColorValue() + ";";
}
function changeHyperCode(state){
document.getElementById("hyper-code").innerHTML = "text-decoration:" + state + ";";
}
function checkCheckBox(){
if(document.getElementById("hyperlink-none").checked == false){
var a = document.getElementById("links").childNodes;
a[1].style.textDecoration = "none";
a[3].style.textDecoration = "none";
a[5].style.textDecoration = "none";
a[7].style.textDecoration = "none";
changeHyperCode("none");
} else{
var a = document.getElementById("links").childNodes;
a[1].style.textDecoration = "underline";
a[3].style.textDecoration = "underline";
a[5].style.textDecoration = "underline";
a[7].style.textDecoration = "underline";
changeHyperCode("underline");
}
}