-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
126 lines (116 loc) · 3.23 KB
/
index.html
File metadata and controls
126 lines (116 loc) · 3.23 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>はいれつへんかん!</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" href="icon.png">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.10.3/brython.js"></script>
</head>
<body onload="brython()">
<header>
<h1 class="headline">
<a>はいれつへんかん!!!</a>
</h1>
</header>
<div id="a1">
<a1_h1 class="a1_headers">変換前データ</a1_h1>
<br>
</select>
<br>
<textarea id="b_convertText" rows="7" cols="80" placeholder="例: 011100101000111"></textarea>
<br>
<select id="cell">
</select>
<br>
<article class="data_options">
<div id="data_option0">
<input type="radio" name="data_option" id="dtop_none" value="0" checked>何も足さない 何も引かない
</div>
<div id="data_option1">
<input type="radio" name="data_option" id="dtop_wq" value="1">"で囲む
</div>
<div id="data_option2">
<input type="radio" name="data_option" id="dtop_q" value="2">'で囲む
</div>
</article>
<button type="button" id="convertButton">こんばーと!</button>
<br>
<br>
<a1_h2 class="a1_headers">変換後データ</a1_h2>
<br>
<br>
<textarea id="a_convertText" rows="7" cols="80" placeholder="完成例: { 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1 }"></textarea>
<script type="text/python">
from browser import document, alert
vals = ['C/C++/C#', 'Python/JavaScript']
cell = document["cell"]
bef = document["b_convertText"]
aft = document["a_convertText"]
def convertMain(e):
if bef.value == '':
alert("データを入力してください")
return
addC = ''
if document["dtop_none"].checked == True:
addC = ''
elif document["dtop_wq"].checked == True:
addC = '"'
elif document["dtop_q"].checked == True:
addC = "'"
nl = False
for c in bef.value:
if c == '\n':
nl = True
break
if cell.value == vals[0]:
aft.text = C4C(bef.value, addC, nl)
elif cell.value == vals[1]:
aft.text = C4Py(bef.value, addC, nl)
def C4C(data, addC, flag):
enc = '{'
if flag == True:
enc += '\n { '
for c in data:
if c == '\n':
enc = enc[:-2]
enc += ' },\n { '
else:
enc += addC + c + addC + ', '
enc = enc[:-2]
enc += ' }\n}'
elif flag == False:
enc += ' '
for c in data:
enc += addC + c + addC + ', '
enc = enc[:-2]
enc += ' }'
return enc
def C4Py(data, addC, flag):
enc = '['
if flag == True:
enc += '['
for c in data:
if c == '\n':
enc = enc[:-2]
enc += '], ['
else:
enc += addC + c + addC + ', '
enc = enc[:-2]
enc += ']]'
elif flag == False:
for c in data:
enc += addC + c + addC + ', '
enc = enc[:-2]
enc += ']'
return enc
convertButton = document["convertButton"]
convertButton.bind("click", convertMain)
for value in vals:
opt = document.createElement('option')
opt.text = str(value)
cell.appendChild(opt)
</script>
</div>
</body>
</html>