Skip to content

Commit

Permalink
Add flow annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPJPJPOPOP committed Jan 6, 2018
1 parent 83da88d commit 939d8b6
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions assets/js/spellchecker.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @flow

var spellers = {}, spellerData = {};
var spellers = ({} /*: {[string]: string[]} */), spellerData = {};
var currentSpellCheckerRequest;

/* exported getSpellers, populateSecondarySpellCheckerList */
/* global config, modeEnabled, persistChoices, readCache, ajaxSend, ajaxComplete, filterLangList, allowedLang, analyzers, cache,
localizeInterface, getLangByCode, restoreChoices, callApy */
/* global ENTER_KEY_CODE */

function getSpellers() {
function getSpellers() /*: JQueryPromise<any> */ {
var deferred = $.Deferred();

if(config.SPELLERS) {
Expand All @@ -20,7 +20,7 @@ function getSpellers() {
var spellers = readCache('spellers', 'LIST_REQUEST');
if(spellers) {
spellerData = spellers;
populatePrimarySpellCheckerList(spellerData);
populatePrimarySpellCheckerList(spellerData /*: {} */);
deferred.resolve();
}
else {
Expand Down Expand Up @@ -78,7 +78,7 @@ if(modeEnabled('spellchecking')) {
persistChoices('spellchecker');
});

$('#spellCheckerInput').keydown(function (e) {
$('#spellCheckerInput').keydown(function (e /*: JQueryKeyEventObject */) {
if(e.keyCode === ENTER_KEY_CODE && !e.shiftKey) {
e.preventDefault();
check();
Expand Down Expand Up @@ -163,7 +163,8 @@ function populateSecondarySpellCheckerList() {
$('#secondarySpellCheckerMode').fadeOut('fast');
}
}
function populatePrimarySpellCheckerList(data) {

function populatePrimarySpellCheckerList(data /*: {} */) {
$('.spellCheckerMode').empty();

spellers = {};
Expand All @@ -178,11 +179,11 @@ function populatePrimarySpellCheckerList(data) {
}
}

var spellerArray = [];
$.each(spellers, function (spellerLang, lang) {
var spellerArray /*: [string, string][] */ = [];
$.each(spellers, function (spellerLang /*: string */, lang /*: string */) {
spellerArray.push([spellerLang, lang]);
});
spellerArray = filterLangList(spellerArray, function (speller) {
spellerArray = filterLangList(spellerArray, function (speller /*: [string, string] */) {
return allowedLang(speller[0]);
});
spellerArray.sort(function (a, b) {
Expand Down Expand Up @@ -231,8 +232,13 @@ function check() {
}
$('.spellError').each(function () {
var currentTokenId = this.id;
$(this).popover({animation: false, placement: 'bottom', trigger: 'manual', html: true,
content: content[currentTokenId]});
$(this).popover({
animation: false,
placement: 'bottom',
trigger: 'manual',
html: true,
content: content[currentTokenId]
});
});
originalWordsIndex++;
}
Expand All @@ -254,6 +260,10 @@ function spellCheckerNotAvailable(data) {
$('#spellCheckerInput').append($('<div></div>').text(data.explanation));
}

/*:: import {modeEnabled, ajaxSend, ajaxComplete, filterLangList, callApy} from "./util.js" */
/*:: export {getSpellers, populateSecondarySpellCheckerList} */

/*:: import {modeEnabled, ajaxSend, ajaxComplete, allowedLang, filterLangList, callApy, ENTER_KEY_CODE} from "./util.js" */
/*:: import {persistChoices, restoreChoices} from "./persistence.js" */
/*:: import {localizeInterface, getLangByCode} from "./localization.js" */
/*:: import {readCache, cache} from "./persistence.js" */
/*:: import {analyzers} from "./analyzer.js" */

0 comments on commit 939d8b6

Please sign in to comment.