Skip to content

Commit ba57b1c

Browse files
committed
🚧 Add variant for hunspell, for comparisons
The code needs some cleanup, but works.
1 parent 3c53f08 commit ba57b1c

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

‎lib/app.js

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/app.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ if(hostname === "localhost") {
394394
var modesUrl/*:string*/ = protocol+"//"+hostname+":"+(port.toString())+subdir+"/listPairs";
395395
var checkUrl/*:string*/ = protocol+"//"+hostname+":"+(port.toString())+subdir+"/translateRaw";
396396
log(checkUrl);
397+
var hunUrl/*:string*/ = protocol+"//"+hostname+":"+(port.toString())+subdir+"/hunspell";
397398

398399
$(document).ready(function() {
399400
if(window.location.host.match("^localhost:") || window.location.protocol === "file:") {
@@ -460,15 +461,24 @@ var servercheck = function(userpass/*:userpass*/,
460461
// TODO: Should this be synchronous? We can't really change the text
461462
// after the user has typed unless the text still matches what we
462463
// sent.
463-
return $.ajax(checkUrl, {
464+
let url = checkUrl;
465+
let data = {
466+
langpair: mode,
467+
q: text
468+
};
469+
if(getVariant(searchToObject()) === "hunspell") {
470+
url = hunUrl;
471+
data = {
472+
lang: getLang(searchToObject()),
473+
q: text
474+
};
475+
}
476+
return $.ajax(url, {
464477
beforeSend: function(xhr) {
465478
xhr.setRequestHeader("Authorization", basicAuthHeader(userpass));
466479
},
467480
type: "POST",
468-
data: {
469-
langpair: mode,
470-
q: text
471-
},
481+
data: data,
472482
success: function(res) {
473483
cb(text, res, off);
474484
},
@@ -547,6 +557,7 @@ var getModes = function()/*: void*/ {
547557
},
548558
dataType: "json"
549559
});
560+
modeToDropdown({ src: "se_NO", trglang: "se_NO", trgsuff: "hunspell" });
550561
};
551562

552563
var modeToDropdown = function(m/*:mode*/)/*:void*/ {

0 commit comments

Comments
 (0)