Skip to content

Commit

Permalink
Close #2. Add border display
Browse files Browse the repository at this point in the history
  • Loading branch information
untunt committed Nov 18, 2023
1 parent a42e971 commit 925ef67
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 20 deletions.
53 changes: 39 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,38 @@

th:nth-of-type(3),
td:nth-of-type(3),
#main:not(.combine) td.cell-diag+td {
#main:not(.combine) td.cell-diag+td,
th.dummy.add-border+th,
td.dummy.add-border+td {
border-left-width: 1px;
padding-left: 8px;
}

th.dummy.double-border+th,
td.dummy.double-border+td {
border-left-width: 3px;
border-left-style: double;
}

tr:nth-of-type(2) td,
#main:not(.combine) td.cell-diag {
#main:not(.combine) :not(.dummy)+td.cell-diag,
tr.dummy.add-border+tr td {
border-top-width: 1px;
padding-top: 8px;
}

.cell-f,
.cell-nan {
background: #fde9e9;
tr.dummy.double-border+tr td {
border-top-width: 3px;
border-top-style: double;
}

th.dummy.gray-border+th,
td:not(.cell-diag)+td.dummy.gray-border+td {
border-left-color: #ccc;
}

tr.dummy.gray-border+tr td:not(.cell-diag) {
border-top-color: #ccc;
}

.cell-t,
Expand All @@ -236,6 +254,11 @@
background: #eff;
}

.cell-f,
.cell-nan {
background: #fde9e9;
}

.cell-f-star {
background: #fcecfc;
}
Expand Down Expand Up @@ -334,11 +357,9 @@
-moz-appearance: textfield;
}

input#rhyme-check:checked~.count-total-line {
display: none;
}

input#rhyme-group-check:checked~.show-tf-check-line {
input#rhyme-check:checked~.count-total-line,
input#rhyme-group-check:checked~.show-tf-check-line,
.dummy {
display: none;
}

Expand Down Expand Up @@ -385,7 +406,7 @@ <h1>韻段離合指數統計工具</h1>
<div>
<p>⑤ 要在結果中顯示的韻類(留空則顯示所有韻類):</p>
<textarea id="rime-names" style="height: 1.5em;" placeholder="輸入要在結果中顯示的韻類……"
onblur="this.value=this.value.replace(/[\t\n ]+/g, ' ').trim()"></textarea>
onblur="this.value=this.value.replace(/[\t\n ]+/g, ' ').replace(/ \|\\ /g, ' | \\ ').trim()"></textarea>
</div>
<div>
<p>⑥ 韻類名中要縮小字號的字符:</p>
Expand Down Expand Up @@ -422,7 +443,8 @@ <h1>韻段離合指數統計工具</h1>
<div><input type="checkbox" id="hide-half-bkgd-check" onclick="gen();"><label
for="hide-half-bkgd-check">不合併時,隱藏對角線左下的背景顏色</label>
</div>
<div><input type="checkbox" id="hide-zero-check" onclick="gen();"><label for="hide-zero-check">不合併時,押韻次數爲 0
<div><input type="checkbox" id="hide-zero-check" onclick="gen();" checked><label
for="hide-zero-check">不合併時,押韻次數爲 0
則省略</label>
</div>
<div><input type="checkbox" id="hide-all-bkgd-check" onclick="gen();"><label
Expand Down Expand Up @@ -503,7 +525,9 @@ <h4>使用說明</h4>
href="https://nk2028.shn.hk/qieyun-autoderiver/">切韻音系自動推導器</a>所用的推導方案代碼格式</span><span
class="show-if-pinyin">外部傳入的參數爲 <code>漢語拼音</code>,內含 3
個屬性:<code>聲母</code><code>韻母</code><code>聲調</code></span>,代碼返回韻類名</p>
<p class="indent">⑤:韻類之間用空格分隔(輸入製表符會自動替換爲空格)</p>
<p class="indent">⑤:韻類之間用空格分隔(輸入製表符會自動替換爲空格),也可輸入下列符號用於添加框線:<br>
<code>|</code> 黑色單線、<code>|_</code> 灰色單線、<code>||</code> 黑色雙線
</p>
<p class="hide-if-rime-name-only">若標注已經是韻類名,則會自動跳過④的推導,如此可以直接指定一些字的韻類。<span
class="show-if-phono-desc">標注音韻地位(描述或編碼)的格式應與 <a
href="https://nk2028.shn.hk/qieyun-js/classes/____.html">qieyun-js</a> 相同。</span><span
Expand All @@ -514,7 +538,8 @@ <h4>使用說明</h4>
推導,匯出的結果可直接加入③中。</span></p>
<p class="hide-if-rime-name-only">實際上大多數字只需在③中標注,但對於韻母有多讀的多音字,應在①中指定讀音。當然,也可在①中爲所有字標注而不使用③④,此時③④可以留空。</p>
<p>本頁面不使用緩存,各文本框中輸入的資料請在本地妥善保存!</p>
<p>本頁面原始碼公開於 <a href="https://github.com/nk2028/rhyme-stat">GitHub</a>。示例材料來自沈約作品中所有押梗攝的韻段;示例材料僅適用於「標注:音韻地位」模式。</p>
<p>本頁面原始碼公開於 <a href="https://github.com/nk2028/rhyme-stat">GitHub</a>。示例材料來自沈約作品中所有押梗攝的韻段;示例材料僅適用於「標注:音韻地位」模式。
</p>
</div>
</div>
<script>
Expand Down
31 changes: 25 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,38 @@ function genTable(checks) {
table.innerHTML = '';
main.classList.add('table-valid');

function addDummyClassesAndClearIfDummy(element, rime) {
addedClasses = {
'|': ['dummy', 'add-border'],
'|_': ['dummy', 'add-border', 'gray-border'],
'||': ['dummy', 'add-border', 'double-border'],
}[rime];
if (addedClasses) {
element.classList.add(...addedClasses);
element.innerHTML = '';
}
}
// 生成表格
let headRow = document.createElement('tr');
table.appendChild(headRow);
headRow.appendChild(getCell('', true));
headRow.appendChild(getCell('字次', true));
table.appendChild(headRow);

rimeNames.some((rime1, i) => {
if (rime1 === '\\') return true;
let cell = getCellRimeName(rime1, true);
addDummyClassesAndClearIfDummy(cell, rime1);
headRow.appendChild(cell);
});
rimeNames.forEach((rime1, i) => {
headRow.appendChild(getCellRimeName(rime1, true));
if (rime1 === '\\') return;
let count1 = rimeCounts[rime1] || 0;
let row = document.createElement('tr');
addDummyClassesAndClearIfDummy(row, rime1);
table.appendChild(row);
row.appendChild(getCellRimeName(rime1));
row.appendChild(getCellValue(count1));
rimeNames.forEach((rime2, j) => {
rimeNames.some((rime2, j) => {
if (rime2 === '\\') return true;
let count2 = rimeCounts[rime2] || 0;
let count11 = pairCounts[getPair(rime1, rime1)] || 0;
let count12 = pairCounts[getPair(rime1, rime2)] || 0;
Expand Down Expand Up @@ -270,9 +289,9 @@ function genTable(checks) {
if (i === j) {
cell.classList.add('cell-diag');
}
addDummyClassesAndClearIfDummy(cell, rime2);
row.appendChild(cell);
});
table.appendChild(row);
});
}

Expand Down Expand Up @@ -340,7 +359,7 @@ function writeSampleData(rimeNamesMiniOnly = false, noDictionary = false) {
'□;。◎‖',
noDictionary ? '' : '衡(匣開二庚平)\n横(匣合二庚平)\n亨(曉開二庚平)\n客(溪開二庚入)\n陌(明二庚入)\n泽(澄開二庚入)\n鳠(匣合二耕入)\n頟(疑開二庚入)\n白(並二庚入)\n宅(澄開二庚入)\n形(匣開四青平)\n灵(來開四青平)\n冥(明四青平)\n龄(來開四青平)\n声(書開三清平)\n英(影開三庚平)\n诚(常開三清平)\n明(明三庚平)\n牲(生開三庚平)\n缨(影開三清平)\n盈(以開三清平)\n并(幫三清平)\n精(精開三清平)\n清(清開三清平)\n平(並三庚平)\n城(常開三清平)\n鸣(明三庚平)\n生(生開三庚平)\n成(常開三清平)\n岭(來開三清上)\n秉(幫三庚上)\n景(見開三庚上)\n永(云合三庚上)\n聘(滂三清去)\n请(清開三清上)\n圣(書開三清去)\n命(明三庚去)\n碧(幫三庚入)\n石(常開三清入)\n辟(幫三清入)\n籍(從開三清入)\n役(以合三清入)\n积(精開三清入)\n脊(精開三清入)\n适(書開三清入)\n尺(昌開三清入)\n迹(精開三清入)\n嵉(定開四青平)\n星(心開四青平)\n经(見開四青平)\n垧(見合四青平)\n萦(影合三清平)\n青(清開四青平)\n情(從開三清平)\n茎(匣開二耕平)\n莺(影開二耕平)\n惊(見開三庚平)\n摘(知開二耕入)\n襞(幫三清入)\n射(船開三清入)\n隙(溪開三庚入)\n席(邪開三清入)\n惜(心開三清入)',
noDictionary ? '' : "return 音韻地位.判斷([\n ['庚韻 莊組', '庚莊'],\n ['庚韻', '庚' + 音韻地位.等],\n ['', 音韻地位.韻], // 其餘韻母\n]);",
'青 清 庚莊 庚三 耕 庚二',
'青 清 庚莊 庚三 耕 |_ 庚二',
'一二三四五六七八九十等 1234567890 ABCD 開开合洪細细撮口呼 內内外輕重紐纽鈕钮類类 幫帮非端知來来精莊庄章日照見见影喻云以 脣唇齒齿舌牙喉 銳鋭锐鈍钝 平上去入仄陰',
];
const countTotalSample = 1000;
Expand Down

0 comments on commit 925ef67

Please sign in to comment.