-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStyleToObject.html
More file actions
76 lines (58 loc) · 1.3 KB
/
StyleToObject.html
File metadata and controls
76 lines (58 loc) · 1.3 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
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
/*
Made by Krotkikh Andrey 25.10.2018
*/
var result;
var str = `
position: absolute;
top: -999px;
left: 0px;
right: auto;
bottom: auto;
border: 0px;
box-sizing: content-box;
word-wrap: break-word;
overflow: hidden;
height: 0px !important;
min-height: 0px !important;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
font-weight: 400;
font-style: normal;
letter-spacing: 0px;
text-transform: none;
word-spacing-new: 0px;
text-indent: 0px;
line-height: 20px;
width: 191px;
`;
function splitColon(string) {
return string.split(":");
}
function trimTab(string) {
return string.trim();
}
function styleToObject(string) {
var arrayOfProps;
var objectResult = {};
arrayOfProps = string.split(";");
arrayOfProps = arrayOfProps.map(trimTab);
arrayOfProps = arrayOfProps.map(splitColon);
for (var i = 0; i < arrayOfProps.length; i++) {
objectResult[arrayOfProps[i][0]] = arrayOfProps[i][1];
}
return(objectResult);
};
result = styleToObject(str);
for (var key in result) {
alert( "Ключ: " + key + " значение: " + result[key] );
}
</script>
</body>
</html>