Skip to content

Commit

Permalink
Fake data for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPJPJPOPOP committed Jan 7, 2018
1 parent abd87e2 commit abbbab9
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions assets/js/spellchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var currentSpellCheckerRequest;

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

console.log(config);
if(config.SPELLERS) {
spellerData = config.SPELLERS;
populatePrimarySpellCheckerList(spellerData);
Expand All @@ -25,7 +25,7 @@ function getSpellers() /*: JQueryPromise<any> */ {
}
else {
console.warn('Spellers cache ' + (spellers === null ? 'stale' : 'miss') + ', retrieving from server');
$.jsonp({
/*$.jsonp({
url: config.APY_URL + '/list?q=spellers',
beforeSend: ajaxSend,
success: function (data) {
Expand All @@ -41,7 +41,10 @@ function getSpellers() /*: JQueryPromise<any> */ {
ajaxComplete();
deferred.resolve();
}
});
});*/
var data = {"eng": "test", "spa": "test2"};
spellerData = data;
populatePrimarySpellCheckerList(spellerData);
}
}

Expand Down Expand Up @@ -209,7 +212,7 @@ function check() {
var splitWords = words.split(' ');
var content = {};
$('#spellCheckerInput').html('');
currentSpellCheckerRequest = callApy({
/*currentSpellCheckerRequest = callApy({
data: {
'q': words,
'lang': $('#primarySpellCheckerMode').val()
Expand Down Expand Up @@ -248,7 +251,39 @@ function check() {
ajaxComplete();
currentSpellCheckerRequest = undefined;
}
}, '/speller', true);
}, '/speller', true);*/
console.log(splitWords);
var data = [{"token": "I", "sugg": [["keshiriledi", "2.000000"], ["test1", "2.000000"], ["test2", "2.000000"], ["test8", "2.000000"], ["test7", "2.000000"], ["test6", "2.000000"], ["test5", "2.000000"], ["tst4", "2.000000"], ["test3", "2.000000"], ["test9", "2.000000"], ["test0", "2.000000"], ["test123", "2.000000"]], "known": false}, {"token": "am", "sugg": [["hello", "2.000000"]], "known": false}, {"token": "testing", "sugg": [["huh","2.000000"]], "known": false}];
var originalWordsIndex = 0;
for(var tokenIndex = 0; tokenIndex < data.length; tokenIndex++) {
console.log(originalWordsIndex);
if(data[tokenIndex].known === true) {
$('#spellCheckerInput').html($('#spellCheckerInput').html() + ' ' + splitWords[originalWordsIndex]);
originalWordsIndex++;
continue;
}
$('#spellCheckerInput').html($('#spellCheckerInput').html() + ' <span class="spellError" id=' +
splitWords[originalWordsIndex] + '>' + splitWords[originalWordsIndex] + '</span>');
content[splitWords[originalWordsIndex]] = '<div class="spellCheckerList">';
for(var sugg = 0; sugg < data[tokenIndex].sugg.length; sugg++) {
content[splitWords[originalWordsIndex]] += '<a href="#" class="spellCheckerListItem">' +
data[tokenIndex].sugg[sugg][0] + '</a>';
}
content[splitWords[originalWordsIndex]] += '</div>';
$('.spellError').each(function () {
console.log(this.id);
var currentTokenId = this.id;
$(this).popover({
animation: false,
placement: 'bottom',
trigger: 'manual',
html: true,
content: content[currentTokenId]
});
});
originalWordsIndex++;
}
console.log(originalWordsIndex);
}

function handleSpellCheckerErrorResponse(jqXHR) {
Expand Down

0 comments on commit abbbab9

Please sign in to comment.