forked from crimx/ext-saladict
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes crimx#252
- Loading branch information
Showing
11 changed files
with
6,656 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react' | ||
import { HjdictResult, HjdictResultLex, HjdictResultRelated } from './engine' | ||
import withStaticSpeaker from '@/components/withStaticSpeaker' | ||
import { ViewPorps } from '@/components/dictionaries/helpers' | ||
|
||
export default withStaticSpeaker((props: ViewPorps<HjdictResult>) => { | ||
switch (props.result.type) { | ||
case 'lex': | ||
return renderLex(props.result, props.recalcBodyHeight) | ||
case 'related': | ||
return renderRelated(props.result) | ||
} | ||
return null | ||
}, 'dictHjdict-Speaker') | ||
|
||
function renderLex (result: HjdictResultLex, recalcBodyHeight: () => void) { | ||
const { header, entries } = result | ||
return ( | ||
<div className='dictHjdict-Entry' onClick={e => handleClick(e, recalcBodyHeight)}> | ||
{header && ( | ||
<header className='word-details-header' dangerouslySetInnerHTML={{ __html: header }} /> | ||
)} | ||
{entries.map((entry, i) => ( | ||
<div dangerouslySetInnerHTML={{ __html: entry }} key={i} /> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
function renderRelated (result: HjdictResultRelated) { | ||
return ( | ||
<div className='dictHjdict-Entry' dangerouslySetInnerHTML={{ __html: result.content }} /> | ||
) | ||
} | ||
|
||
function handleClick (e: React.MouseEvent<HTMLElement>, recalcBodyHeight: () => void): void { | ||
const $tab = getWordDetailsTab(e.target) | ||
if ($tab) { | ||
if ($tab.classList.contains('word-details-tab-active')) { | ||
return | ||
} | ||
const doc = $tab.ownerDocument | ||
if (doc) { | ||
const index = +($tab.dataset.categories || '0') | ||
|
||
const $panes = doc.querySelectorAll('.word-details-pane') | ||
|
||
doc.querySelectorAll('.word-details-tab') | ||
.forEach(($tab, i) => { | ||
if (i === index) { | ||
$tab.classList.add('word-details-tab-active') | ||
$panes[i].classList.add('word-details-pane-active') | ||
} else { | ||
$tab.classList.remove('word-details-tab-active') | ||
$panes[i].classList.remove('word-details-pane-active') | ||
} | ||
}) | ||
|
||
recalcBodyHeight() | ||
} | ||
} | ||
} | ||
|
||
function getWordDetailsTab (target: any): HTMLElement | null { | ||
for (let el = target; el; el = el.parentElement) { | ||
if (el.classList && el.classList.contains('word-details-tab')) { | ||
return el | ||
} | ||
} | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"name": { | ||
"en": "Hu Jiang", | ||
"zh_CN": "沪江小D", | ||
"zh_TW": "沪江小D" | ||
}, | ||
"options": { | ||
"engas": { | ||
"en": "Treat English as", | ||
"zh_CN": "对全英文使用词典", | ||
"zh_TW": "對全英文使用字典" | ||
}, | ||
"chsas": { | ||
"en": "Treat Chinese as", | ||
"zh_CN": "对全中文使用词典", | ||
"zh_TW": "對全中文使用字典" | ||
}, | ||
"uas": { | ||
"en": "Treat 'ü' as", | ||
"zh_CN": "将 'ü' 字符当作", | ||
"zh_TW": "把 'ü' 字元當成" | ||
}, | ||
"aas": { | ||
"en": "Treat 'ä' as", | ||
"zh_CN": "将 'ä' 字符当作", | ||
"zh_TW": "把 'ä' 字元當成" | ||
}, | ||
"eas": { | ||
"en": "Treat 'é' as", | ||
"zh_CN": "将 'é' 字符当作", | ||
"zh_TW": "把 'é' 字元當成" | ||
}, | ||
"related": { | ||
"en": "Show related results", | ||
"zh_CN": "失败时显示备选", | ||
"zh_TW": "失敗時顯示備選" | ||
}, | ||
"chsas-jp/cj": { | ||
"en": "中 → 日", | ||
"zh_CN": "中 → 日", | ||
"zh_TW": "中 → 日" | ||
}, | ||
"chsas-jp/jc": { | ||
"en": "日 → 中", | ||
"zh_CN": "日 → 中", | ||
"zh_TW": "日 → 中" | ||
}, | ||
"chsas-kor": { | ||
"en": "Korean", | ||
"zh_CN": "韩文", | ||
"zh_TW": "韓文" | ||
}, | ||
"chsas-w": { | ||
"en": "English", | ||
"zh_CN": "英文", | ||
"zh_TW": "英文" | ||
}, | ||
"chsas-fr": { | ||
"en": "French", | ||
"zh_CN": "法文", | ||
"zh_TW": "法文" | ||
}, | ||
"chsas-de": { | ||
"en": "Deutsch", | ||
"zh_CN": "德文", | ||
"zh_TW": "德文" | ||
}, | ||
"chsas-es": { | ||
"en": "Spanish", | ||
"zh_CN": "西班牙文", | ||
"zh_TW": "西班牙文" | ||
}, | ||
"engas-w": { | ||
"en": "English", | ||
"zh_CN": "英文", | ||
"zh_TW": "英文" | ||
}, | ||
"engas-fr": { | ||
"en": "French", | ||
"zh_CN": "法文", | ||
"zh_TW": "法文" | ||
}, | ||
"engas-de": { | ||
"en": "Deutsch", | ||
"zh_CN": "德文", | ||
"zh_TW": "德文" | ||
}, | ||
"engas-es": { | ||
"en": "Spanish", | ||
"zh_CN": "西班牙文", | ||
"zh_TW": "西班牙文" | ||
}, | ||
"uas-fr": { | ||
"en": "French", | ||
"zh_CN": "法文", | ||
"zh_TW": "法文" | ||
}, | ||
"uas-de": { | ||
"en": "Deutsch", | ||
"zh_CN": "德文", | ||
"zh_TW": "德文" | ||
}, | ||
"uas-es": { | ||
"en": "Spanish", | ||
"zh_CN": "西班牙文", | ||
"zh_TW": "西班牙文" | ||
}, | ||
"aas-fr": { | ||
"en": "French", | ||
"zh_CN": "法文", | ||
"zh_TW": "法文" | ||
}, | ||
"aas-de": { | ||
"en": "Deutsch", | ||
"zh_CN": "德文", | ||
"zh_TW": "德文" | ||
}, | ||
"eas-fr": { | ||
"en": "French", | ||
"zh_CN": "法文", | ||
"zh_TW": "法文" | ||
}, | ||
"eas-es": { | ||
"en": "Spanish", | ||
"zh_CN": "西班牙文", | ||
"zh_TW": "西班牙文" | ||
} | ||
} | ||
} |
Oops, something went wrong.