forked from bennyyip/Rime-See-Me
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
289 lines (285 loc) · 15 KB
/
index.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Rime 西米 for Squirrel</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script>
<script src="jscolor/jscolor.js"></script>
<script src="js/script.js"></script>
<script type="application/x-javascript" src="js/rw.js"></script>
</head>
<body>
<h1><span>RIME</span> <ruby>西<rt>See</rt></ruby><ruby>米<rt>Me</rt></ruby> - for <ruby>Squirrel<rt>鼠鬚管</rt></ruby></h1>
<table>
<tbody>
<tr>
<td id="effect">
<div id="box">
<div id="select"> <span id="text">穿搭</span><span id="hilited">pei se</span> <span
id="cursor">˰</span></div>
<div id="display">
<div id="n1"><span id="label1">1.</span><span id="word">配色</span><span
id="code1">(pei se)</span></div>
<div id="n2"><span id="label2">2.</span><span id="word">陪</span><span
id="code2">(pei)</span></div>
<div id="n3"><span id="label3">3.</span><span id="word">配</span><span
id="code3">(pei)</span></div>
<div id="n4"><span id="label4">4.</span><span id="word">賠</span><span
id="code4">(pei)</span></div>
<div id="n5"><span id="label5">5.</span><span id="word">培</span><span
id="code5">(pei)</span></div>
<div id="n6"><span id="label6">6.</span><span id="word">佩</span><span
id="code6">(pei)</span></div>
<div id="n7"><span id="label7">7.</span><span id="word">裴</span><span
id="code7">(pei)</span></div>
<div id="n8"><span id="label8">8.</span><span id="word">斐</span><span
id="code8">(pei)</span></div>
<div id="n9"><span id="label9">9.</span><span id="word">呸</span><span
id="code9">(pei)</span></div>
</div>
</div>
<br>
<div id="little_box"> <span id="tip">漢字 汉字 擴展 A</span> </div>
</td>
<td id="style_setting">
<form>
<fieldset> <legend>基本資訊</legend> <span>代<span class="em"></span>號</span><input
name="schema"
id="schema_input"
value="example"
onchange="writeIn(this.name,this.value+':');"
type="text"><br>
<span>名<span class="em"></span>稱</span><input name="name"
id="name_input"
value="名字"
onchange="writeIn(this.name,this.value);"
type="text"><br>
<span>作<span class="em"></span>者</span><input name="author"
id="author_input"
value="作者"
onchange="writeIn(this.name,this.value);"
type="text"><br>
</fieldset>
<fieldset> <legend>其他設定</legend> <span>候選數</span> <input
value="9"
min="1"
max="9"
name="number"
onchange="changeNumber(this.value)"
type="range"><br>
</fieldset>
<fieldset> <legend>環境參考背景</legend> <span>背景色</span><input
id="background"
class="color"
name="body"
value="F9F9F9"
onchange="document.getElementById('effect').style.backgroundColor = '#'+this.color"
type="text"> </fieldset>
<fieldset id="modEx"> <legend>BGR <> RGB</legend> <span>BGR</span><input
id="bgr"
value="77DDBB"
onchange="exMode('bgr','rgb',this.value);"
type="text"><br>
<span>RGB</span><input class="color {pickerPosition:'right'}"
id="rgb"
value="BBDD77"
onchange="exMode('rgb','bgr',this.value);"
type="text"><br>
</fieldset>
</form>
</td>
<td id="color_setting">
<form>
<fieldset> <legend>小視窗設定</legend> <span>背景</span><input
class="color {pickerPosition:'left'}"
name="back"
id="back_input"
value="FFFFFF"
onchange="changeColor('box','bg',this.name,this.color);changeColor('little_box','bg',this.name,this.color);"
type="text">
<!--鼠鬚管沒有邊框--> </fieldset>
<fieldset> <legend>組字區域</legend> <span>文字</span><input class="color {pickerPosition:'left'}"
name="text"
id="text_input"
value="000000"
onchange="changeColor('text','c',this.name,this.color);"
type="text"><br>
<span>編碼</span><input class="color {pickerPosition:'left'}"
name="hilited_text"
id="hilited_text_input"
value="000000"
onchange="changeColor('hilited','c',this.name,this.color);"
type="text"><br>
<span>背景</span><input class="color {pickerPosition:'left'}"
name="hilited_back"
id="hilited_back_input"
value="DDDDDD"
onchange="changeColor('hilited','bg',this.name,this.color);"
type="text"> </fieldset>
<fieldset> <legend>選定候選項</legend> <span>文字</span><input
class="color {pickerPosition:'left'}"
name="hilited_candidate_text"
id="hilited_candidate_text_input"
value="FFFFFF"
onchange="changeColor('n1','c',this.name,this.color);"
type="text"><br>
<span>背景</span><input class="color {pickerPosition:'left'}"
name="hilited_candidate_back"
id="hilited_candidate_back_input"
value="000000"
onchange="changeColor('n1','bg',this.name,this.color);"
type="text"><br>
<span>序號</span><input class="color {pickerPosition:'left'}"
name="hilited_candidate_label"
id="hilited_candidate_label_input"
value="FFFFFF"
onchange="changeColor('label1','c',this.name,this.color);"
type="text"> <br>
<span>提示</span><input class="color {pickerPosition:'left'}"
name="hilited_comment_text"
id="hilited_comment_text_input"
value="FFFFFF"
onchange="changeColor('code1','c',this.name,this.color);"
type="text"></fieldset>
<fieldset> <legend>其他候選項</legend> <span>文字</span><input
class="color {pickerPosition:'left'}"
name="candidate_text"
id="candidate_text_input"
value="000000"
onchange="changeColor('cursor','c',this.name,this.color);for(i=2;i<=9;i++) document.getElementById('n'+i).style.color = '#'+this.color;exConvert(this.name,this.color);"
type="text"><br><sub>(也會影響游標顏色)</sub><br>
<span>序號</span><input class="color {pickerPosition:'left'}"
name="label"
id="label_input"
value="000000"
onchange="for(i=2;i<=9;i++) document.getElementById('label'+i).style.color = '#'+this.color;exConvert(this.name,this.color);"
type="text"> <br>
<span>提示</span><input class="color {pickerPosition:'left'}"
name="comment_text"
id="comment_text_input"
value="DDDDDD"
onchange="changeColor('tip','c',this.name,this.color); for(i=2;i<=9;i++) document.getElementById('code'+i).style.color = '#'+this.color;exConvert(this.name,this.color);"
type="text"><br><sub>(也會影響狀態 tooltip 顏色)</sub> </fieldset>
</form>
</td>
<td id="code_generate">
<h2>產生設定碼</h2>
<div id="source_code">
<div>#Rime theme</div><br>
<div id="schema">example:</div>
<div> name: <span id="name">名字</span></div>
<div> author: <span id="author">作者</span></div>
<div> back_color: '<span id="back_color"></span>'</div>
<div> text_color: '<span id="text_color"></span>'</div>
<div> hilited_text_color: '<span
id="hilited_text_color"></span>'</div>
<div> hilited_back_color: '<span id="hilited_back_color"></span>'</div>
<div> hilited_candidate_text_color: '<span
id="hilited_candidate_text_color"></span>'</div>
<div> hilited_candidate_back_color: '<span
id="hilited_candidate_back_color"></span>'</div>
<div> hilited_candidate_label_color: '<span
id="hilited_candidate_label_color"></span>'</div>
<div> hilited_comment_text_color: '<span
id="hilited_comment_text_color"></span>'</div>
<div> candidate_text_color: '<span id="candidate_text_color"></span>'</div>
<div> label_color: '<span id="label_color"></span>'</div>
<div> comment_text_color: '<span id="comment_text_color"></span>'</div>
</div>
</td>
</tr>
</tbody>
</table>
<div>支援瀏覽器:Chrome 內核(Chrome、Vivaldi、……)或 Firefox 68、Waterfox 56 等(其餘瀏覽器可能也可正常運作,<a
href="https://github.com/GJRobert/Rime-See-Me-squirrel/issues/1"
target="_blank">歡迎回報</a>)</div>
<!--工作區-->
<div>選取已儲存之 YAML 主題設定檔<sup>*</sup>並載入:<input id="files" name="files[]"
multiple=""
type="file"> <output
id="list"></output>
<p> * 因程式功能所限,主題設定檔須符合一定格式,詳見<a href="https://github.com/GJRobert/Rime-See-Me-squirrel/blob/master/README.md#%E6%96%B0%E5%8A%9F%E8%83%BD%E8%AE%80%E5%85%A5%E7%8F%BE%E6%9C%89%E4%B8%BB%E9%A1%8C%E8%A8%AD%E5%AE%9A%E6%AA%94"
target="_blank">說明</a>。 </p>
</div>
<script>
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
// for (var i = 0, f; f = files[i]; i++) {
// output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
// f.size, ' bytes, last modified: ',
// f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
// '</li>');
//}
var f = files[0];
var reader = new FileReader();
// var yaml = new jsyaml();
reader.onload = function(e) {
// output.push(e.target.result);
output = jsyaml.safeLoad(e.target.result);
// document.getElementById('list').innerHTML = '<ul>' + output + '</ul>';
// console.dir(output);
var scheme = output[Object.keys(output)[0]];
//console.log(scheme.name);
console.dir(scheme);
// var back_color = scheme.back_color;
// var result = "";
for (var prop in scheme) {
// result += typeof(prop) + " " + prop + "\n";
// a=back_color.replace("0x","");
if (scheme[prop] === "") scheme[prop] = ' ' //continue;
if (prop.includes("color")) {
a = scheme[prop].replace("0x", "");
a = a[4] + a[5] + a[2] + a[3] + a[0] + a[1];
scheme[prop] = a.toLowerCase();
}
// result += scheme[prop] + "\n";
}
// console.log(result);
// back_color=a.toLowerCase();
// console.dir(scheme);
// changeColor('box','bg','back',back_color);
changeColor('box', 'bg', 'back', scheme.back_color);
changeColor('little_box', 'bg', 'back', scheme.back_color);
changeColor('code1', 'c', 'hilited_comment_text', scheme.hilited_comment_text_color);
changeColor('hilited', 'bg', 'hilited_back', scheme.hilited_back_color);
changeColor('hilited', 'c', 'hilited_text', scheme.hilited_text_color);
changeColor('label1', 'c', 'hilited_candidate_label', scheme.hilited_candidate_label_color);
changeColor('n1', 'bg', 'hilited_candidate_back', scheme.hilited_candidate_back_color);
changeColor('n1', 'c', 'hilited_candidate_text', scheme.hilited_candidate_text_color);
changeColor('text', 'c', 'text', scheme.text_color);
changeColor('tip', 'c', 'comment_text', scheme.comment_text_color);
for (i = 2; i <= 9; i++) document.getElementById('n' + i).style.color = '#' + scheme.candidate_text_color;
exConvert('candidate_text', scheme.candidate_text_color);
changeColor('cursor', 'c', 'candidate_text', scheme.candidate_text_color);
for (i = 2; i <= 9; i++) document.getElementById('label' + i).style.color = '#' + scheme.label_color;
exConvert('label', scheme.label_color);
for (i = 2; i <= 9; i++) document.getElementById('code' + i).style.color = '#' + scheme.comment_text_color;
exConvert('comment_text', scheme.comment_text_color);
for (var prop in scheme) {
// if (prop === "text") scheme[prop] = "text_color";
// var id = prop+'_input';
if (prop.includes("border")) continue;
if (prop.includes("color")) {
// console.log(prop+"\n");
var id = prop.replace("color", "input");
// console.log(id+"\n");
document.getElementById(id).style.backgroundColor = '#' + scheme[prop];
document.getElementById(id).value = scheme[prop].toUpperCase();
}
}
writeIn("name",scheme.name);
document.getElementById("name_input").value = scheme.name;
//schema.author = schema.author.replace("<","<");
//schema.author = schema.author.replace(">",">");
writeIn("author",scheme.author);
document.getElementById("author_input").value = scheme.author;
}
reader.readAsText(f);
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>
</body>
</html>