-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
146 lines (127 loc) · 3.65 KB
/
test.html
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
<html>
<head>
<meta charset="UTF-8">
<title>Test cv.json themes</title>
<style>
/*iframe {border: 5px solid red;}*/
#wrap {padding: 0; overflow: hidden;border: 5px solid red;}
#wrap.pc { width: 600px; height: 450px;}
#wrap.pc iframe { width: 800px; height: 600px; }
#wrap.pc iframe {
-moz-transform: scale(0.75); -moz-transform-origin: 0 0;
transform: scale(0.75); transform-origin: 0 0;
}
#wrap.mbl { width: 320px; height: 480px;}
#wrap.mbl iframe { width: 320px; height: 480px;}
#wrap.mbl iframe {
-moz-transform: scale(1); -moz-transform-origin: 0 0;
transform: scale(1); transform-origin: 0 0;
}
</style>
<script>
var $ = function(id){return document.getElementById(id)};
var _ = function(e){return e.options[e.selectedIndex]};
var s = {
"default": ["violet", "black", "vertical", "colorful"],
"title_first": ["violet", "black", "vertical", "colorful", "dark"],
"carousel": ["violet", "dark", "dos"],
"layer": ["flat", "paged"]
};
var page = `
<html>
<head>
<meta charset="UTF-8">
<title>Test CV<\/title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text\/javascript" src="cv.json.js" ><\/script>
<\/head>
<body>
<script>
@{script}
<\/script>
<\/body>
<\/html>
`;
function device(){
var dev = _($("dev")).value;
document.getElementById("wrap").className = dev;
}
var curStyle = "violet";
function ctheme(){
fillStyles();
var doc = $("if").contentWindow.document;
doc.open();
var code = page.replace("@{script}", getCode());
doc.write(code);
doc.close();
}
function getCode(){
var thm = _($("thm")).text;
var stl = _($("stl")).text;
var scr = `
CVJson.setRelativePath("./")
.setThemesPath("themes/")
.setThemeName("@{theme}")
.setStyleName("@{style}")
.setFooter("info/footer.htm")
.process("cv.json");
`;
scr = scr.replace("@{theme}", thm);
scr = scr.replace("@{style}", stl);
$("code").value = scr;
return scr;
}
function cstyle(){
var innerWin = $("if").contentWindow;
var stl = _($("stl")).text;
innerWin.CVJson.loadStyle(stl);
curStyle = stl;
getCode();
}
function fillStyles(){
var sl = s[_($("thm")).text];
var stl = $("stl");
var i;
for(i = stl.options.length - 1 ; i >= 0 ; i--){
stl.remove(i);
}
sl.forEach(function(element, index, array){
var option = document.createElement("option");
option.text = element;
stl.add(option);
});
i = sl.indexOf(curStyle);
if(i > -1){
stl.selectedIndex = i;
} else {
stl.selectedIndex = 0;
curStyle = stl.text;
}
}
</script>
</head>
<body>
Device:
<select id="dev" onchange="device()">
<option value="pc">800X600</option>
<option value="mbl">320X480</option>
</select>
Theme:
<select id="thm" onchange="ctheme()">
<option selected>default</option>
<option>title_first</option>
<option>carousel</option>
<option>layer</option>
</select>
<select id="stl" onchange="cstyle()">
</select>
<br>
<div id="wrap" class="pc">
<iframe id="if" ></iframe>
</div>
<textarea id="code" style="width:600px; height:100px;"></textarea>
<script>
ctheme();
</script>
</body>
</html>