-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.html
More file actions
86 lines (85 loc) · 1.88 KB
/
Copy pathprocess.html
File metadata and controls
86 lines (85 loc) · 1.88 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
77
78
79
80
81
82
83
84
85
86
<script>
var txt1 =
`@@{page1;learn}
@@[html]
<h2>Hello</h2>
<hr>
<button onclick="test()">Test</button>
@@[css]
h2{
color: redl
}
@@[js]
function test(){
alert("Hello!");
}
`;
function init(){
let el = document.getElementById("tx1");
el.value = txt1;
}
function process(){
let lines = [];
var el1;
lines = txt1.split("\n");
for(li in lines){
if(lines[li].substring(0,2) == "@@"){
if(lines[li].substring(2,3) == "{"){
let el = document.getElementById("in2");
el.value = lines[li].slice(3).split(";")[0];
let el2 = document.getElementById("in1");
el2.value = lines[li].slice(3).split(";")[1].split("}");
}
if(lines[li].substring(2,3) == "["){
if(lines[li].substring(3,5)=="ht"){
el1 = document.getElementById("tx2");
}
if(lines[li].substring(3,5)=="cs"){
el1 = document.getElementById("tx3");
}
if(lines[li].substring(3,5)=="js"){
el1 = document.getElementById("tx4");
}
}
}else{
if(el1!=null)
el1.value = el1.value + lines[li] + "\n";
}
}
}
</script>
<style>
#outer{
display: flex;
}
#left{
background-color: cyan;
flex: 1;
}
#right{
background-color: magenta;
flex: 1;
padding: 4px;
}
#tx2,#tx3, #tx4{
margin: 4px;
}
input, label, button{
margin: 4px;
}
</style>
<body onload="init()">
<div id="outer">
<div id="left">
<textarea id="tx1" cols="80" rows="25"></textarea>
</div>
<div id="right">
<label>Subject</label><input id="in1" type="text"></input>
<label>Page</label><input id="in2" type="text"></input>
<textarea id="tx2" cols="80" rows="5"></textarea>
<textarea id="tx3" cols="80" rows="5"></textarea>
<textarea id="tx4" cols="80" rows="5"></textarea>
</div>
</div> <!-- outer -->
<button onclick="process()">Process</button>
</body>