avoid display spell checker if there is no dictionary

This commit is contained in:
Laurent Mazet 2020-10-16 08:05:51 +02:00
parent 10c12f97a4
commit 356a2ef7d8
3 changed files with 29 additions and 4 deletions

View File

@ -24,13 +24,14 @@ LOWS = $(addsuffix .low,$(LANGS))
DICTS = $(addsuffix .dict,$(LANGS))
DEPEND = Makefile
#DEPEND = Makefile
#MAKEFLAGS = -s
.PHONY: all required count clean low
.PHONY: all required count clean low list
all: required
make $(addprefix check-,$(LANGS))
make list
$(ROOT_DICT):
mkdir $(ROOT_DICT)
@ -45,6 +46,15 @@ low: $(LOWS)
required: ${OBJ_DIR} ${OBJ_DIR}/src.mk ${ROOT_DICT}
list: $(ROOT_DICT)/list.js
$(ROOT_DICT)/list.js: $(wildcard $(ROOT_DICT)/*.dict)
ls -s ${ROOT_DICT}/*.dict| \
awk 'BEGIN { printf "window.DictionaryList = {\n" } \
{ $$0 = gensub(/(.+) .*\/(.+)\.dict/, "\\1 \\2", "g"); \
printf "\"%s\": %d,\n", $$2, $$1 } \
END { printf "\"none\": 0\n};" }' > $@
$(OBJ_DIR)/src.mk:
echo Creation language table
wget $(ASPDICT) -q -O - | \

View File

@ -9,6 +9,7 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<script src="config.js"></script>
<script src="dict/list.js"></script>
<script src="l10n.js"></script>
<script src="alert.js"></script>
<script src="touch2click.js"></script>

View File

@ -31,6 +31,8 @@
const Conf = window.TrivabbleConf || {};
const DictionaryList = window.DictionaryList || {};
function setConf(parameterName, defaultValue) {
if (typeof Conf[parameterName] === "undefined") {
Conf[parameterName] = defaultValue;
@ -247,6 +249,18 @@
}
}
function checkDictionaryExistance() {
const code = document.getElementById("board-lang").value;
if (DictionaryList.hasOwnProperty(code) && getSetting("ENABLE_SPELL_CHECKER") && !document.getElementById("disable-spell-checker").checked) {
document.getElementById("check-spelling").hidden = false;
document.getElementById("info-spell-checking").hidden = false;
} else {
document.getElementById("check-spelling").hidden = true;
document.getElementById("info-spell-checking").hidden = true;
}
}
function getDictionary(code, callback, force) {
if (downloadedDictionaries[code]) {
if (downloadedDictionaries[code].length) {
@ -730,6 +744,7 @@
case "boardLang":
document.getElementById("board-lang").value = value;
setSetting("BoardLang", value);
checkDictionaryExistance(value);
break;
}
}
@ -1981,8 +1996,7 @@
function toggleSpellChecker(e) {
const disabled = !getSetting("ENABLE_SPELL_CHECKER") || document.getElementById("disable-spell-checker").checked;
document.getElementById("check-spelling").hidden = disabled;
document.getElementById("info-spell-checking").hidden = disabled;
checkDictionaryExistance();
if (e) {
setSetting("DisableSpellChecker", disabled);