forked from xzhhbx/jsbox_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
underline_text.js
105 lines (100 loc) · 3.44 KB
/
underline_text.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
const underline = '꯭'
function decorateText(input) {
let outputText = underline
for (let i=0;i<input.length;i++) {
outputText += input[i] + underline
}
return outputText
}
$ui.render({
props: {
title: "文字下划线"
},
views: [{
type: "view",
props: {
id: "mainView"
},
layout: (make, view) => {
make.width.equalTo(view.super)
make.height.equalTo(view.super)
make.center.equalTo(view.super)
},
views: [
{
type: "input",
props: {
id: "inputView",
text: '',
placeholder: "需转换内容,回车键转换",
autoFontSize: true,
},
layout: (make, view) => {
make.width.equalTo(view.super).offset(-40)
make.height.equalTo(40)
make.centerX.equalTo(view.super)
make.top.equalTo(view.super).offset(10)
},
events: {
returned: sender => {
$("inputView").text = decorateText($("inputView").text)
$("inputView").blur()
}
}
},{
type: "button",
props: {
id: "speechButton",
title: "语音"
},
layout: (make, view)=> {
make.top.equalTo($("inputView").bottom).offset(10)
make.width.equalTo($("inputView").width).dividedBy(3).offset(-10)
make.left.equalTo($("inputView").left)
},
events: {
tapped: sender => {
$input.speech( {
handler: text => {
$("inputView").text = decorateText(text)
}
})
}
}
},{
type: "button",
props: {
id: "clipButton",
title: "剪贴板"
},
layout: (make, view) => {
make.top.equalTo($("inputView").bottom).offset(10)
make.width.equalTo($("inputView").width).dividedBy(3).offset(-10)
make.centerX.equalTo(view.super)
},
events: {
tapped: sender => {
$("inputView").text = decorateText($clipboard.text)
}
}
},{
type: "button",
props: {
id: "copyButton",
title: "复制"
},
layout: (make, view) => {
make.top.equalTo($("inputView").bottom).offset(10)
make.width.equalTo($("inputView").width).dividedBy(3).offset(-10)
make.right.equalTo($("inputView").right)
},
events: {
tapped: sender => {
$clipboard.text = $("inputView").text
$("inputView").blur()
}
}
}
]
}]
})