Merge branch 'remove_spellckecker_button_if_no_dictionary_avaliable-2' into 'develop'
Avoid display spell checker if there is no dictionary See merge request raphj/trivabble!20
This commit is contained in:
commit
de5d32d43a
7
Makefile
7
Makefile
|
@ -10,7 +10,7 @@ endif
|
|||
|
||||
.PHONY: all help lang start-dev-server
|
||||
|
||||
all: lang
|
||||
all: lang emptydictlist
|
||||
|
||||
help:
|
||||
@echo make extract-lang-dists: extract the distributions per language from Wikipedia
|
||||
|
@ -26,6 +26,11 @@ extract-lang-dists:
|
|||
|
||||
lang: public/l10n/js/fr.js
|
||||
|
||||
emptydictlist: public/dict/list.js
|
||||
|
||||
public/dict/list.js:
|
||||
mkdir -p public/dict/ && touch public/dict/list.js
|
||||
|
||||
eslint:
|
||||
-${ESLINT} **/*.js
|
||||
|
||||
|
|
|
@ -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 - | \
|
||||
|
|
|
@ -17,9 +17,6 @@ window.TrivabbleConf = {
|
|||
// To tweak only if your webserver is shared with other conflicting resources at / (e.g. Yunohost integration)
|
||||
APP_PATH: "",
|
||||
|
||||
// Whether the spell checker is enabled (dictionaries must be downloaded on the server before enabling this option)
|
||||
ENABLE_SPELL_CHECKER: false,
|
||||
|
||||
// The color of the flash light when double clicking on a cell
|
||||
FLASH_LIGHT_COLOR: "#EE6633",
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
const Conf = window.TrivabbleConf || {};
|
||||
|
||||
const DictionaryList = window.DictionaryList || {};
|
||||
|
||||
function setConf(parameterName, defaultValue) {
|
||||
if (typeof Conf[parameterName] === "undefined") {
|
||||
Conf[parameterName] = defaultValue;
|
||||
|
@ -52,7 +54,6 @@
|
|||
setConf("APP_PATH", "");
|
||||
setConf("ENABLE_MSG_SOUND", true);
|
||||
setConf("ENABLE_TILE_SOUND", true);
|
||||
setConf("ENABLE_SPELL_CHECKER", false);
|
||||
setConf("DOUBLE_TAP_DURATIONS", [650, 1100, 1800, 3000, 5000]);
|
||||
setConf("DOUBLE_TAP_DURATION", middle("DOUBLE_TAP_DURATIONS"));
|
||||
setConf("FLASH_LIGHT_DURATIONS", [800, 1600, 3200]);
|
||||
|
@ -247,6 +248,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
function checkDictionaryExistance() {
|
||||
const code = document.getElementById("board-lang").value;
|
||||
const availableLang = Object.prototype.hasOwnProperty.call(DictionaryList, code);
|
||||
document.getElementById("disable-spell-checker-p").hidden = !availableLang;
|
||||
|
||||
if (availableLang && !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 +745,7 @@
|
|||
case "boardLang":
|
||||
document.getElementById("board-lang").value = value;
|
||||
setSetting("BoardLang", value);
|
||||
checkDictionaryExistance(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1980,9 +1996,8 @@
|
|||
}
|
||||
|
||||
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;
|
||||
const disabled = document.getElementById("disable-spell-checker").checked;
|
||||
checkDictionaryExistance();
|
||||
|
||||
if (e) {
|
||||
setSetting("DisableSpellChecker", disabled);
|
||||
|
@ -1994,7 +2009,6 @@
|
|||
}
|
||||
|
||||
function initSpellChecker() {
|
||||
document.getElementById("disable-spell-checker-p").hidden = !getSetting("ENABLE_SPELL_CHECKER");
|
||||
document.getElementById("disable-spell-checker").checked = getSetting("DisableSpellChecker");
|
||||
toggleSpellChecker();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue