Update CodeMirror Spell Checker to v1.0.5

patch-ionaru
Wes Cossick 9 years ago
parent 8754f008fd
commit 438b3ef531

@ -1,43 +1,52 @@
// Initialize data globally to reduce memory consumption
var num_loaded = 0;
var aff_loading = false;
var dic_loading = false;
var aff_data = "";
var dic_data = "";
var typo;
CodeMirror.defineMode("spell-checker", function(config, parserConfig) { CodeMirror.defineMode("spell-checker", function(config, parserConfig) {
// Initialize data
var num_loaded = 0;
var aff_data = "";
var dic_data = "";
var typo;
// Load AFF/DIC data // Load AFF/DIC data
var xhr_aff = new XMLHttpRequest(); if(!aff_loading){
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true); aff_loading = true;
xhr_aff.onload = function (e) { var xhr_aff = new XMLHttpRequest();
if (xhr_aff.readyState === 4 && xhr_aff.status === 200) { xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
aff_data = xhr_aff.responseText; xhr_aff.onload = function (e) {
num_loaded++; if (xhr_aff.readyState === 4 && xhr_aff.status === 200) {
aff_data = xhr_aff.responseText;
if(num_loaded == 2){ num_loaded++;
typo = new Typo("en_US", aff_data, dic_data, {
platform: 'any' if(num_loaded == 2){
}); typo = new Typo("en_US", aff_data, dic_data, {
platform: 'any'
});
}
} }
} };
}; xhr_aff.send(null);
xhr_aff.send(null); }
var xhr_dic = new XMLHttpRequest(); if(!dic_loading){
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true); dic_loading = true;
xhr_dic.onload = function (e) { var xhr_dic = new XMLHttpRequest();
if (xhr_dic.readyState === 4 && xhr_dic.status === 200) { xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
dic_data = xhr_dic.responseText; xhr_dic.onload = function (e) {
num_loaded++; if (xhr_dic.readyState === 4 && xhr_dic.status === 200) {
dic_data = xhr_dic.responseText;
if(num_loaded == 2){ num_loaded++;
typo = new Typo("en_US", aff_data, dic_data, {
platform: 'any' if(num_loaded == 2){
}); typo = new Typo("en_US", aff_data, dic_data, {
platform: 'any'
});
}
} }
} };
}; xhr_dic.send(null);
xhr_dic.send(null); }
// Define what separates a word // Define what separates a word

Loading…
Cancel
Save