@@ -10,7 +10,7 @@ var currentSpellCheckerRequest;
1010
1111function getSpellers ( ) /*: JQueryPromise<any> */ {
1212 var deferred = $ . Deferred ( ) ;
13-
13+ console . log ( config ) ;
1414 if ( config . SPELLERS ) {
1515 spellerData = config . SPELLERS ;
1616 populatePrimarySpellCheckerList ( spellerData ) ;
@@ -25,7 +25,7 @@ function getSpellers() /*: JQueryPromise<any> */ {
2525 }
2626 else {
2727 console . warn ( 'Spellers cache ' + ( spellers === null ? 'stale' : 'miss' ) + ', retrieving from server' ) ;
28- $ . jsonp ( {
28+ /* $.jsonp({
2929 url: config.APY_URL + '/list?q=spellers',
3030 beforeSend: ajaxSend,
3131 success: function (data) {
@@ -41,7 +41,10 @@ function getSpellers() /*: JQueryPromise<any> */ {
4141 ajaxComplete();
4242 deferred.resolve();
4343 }
44- } ) ;
44+ });*/
45+ var data = { "eng" : "test" , "spa" : "test2" } ;
46+ spellerData = data ;
47+ populatePrimarySpellCheckerList ( spellerData ) ;
4548 }
4649 }
4750
@@ -209,7 +212,7 @@ function check() {
209212 var splitWords = words . split ( ' ' ) ;
210213 var content = { } ;
211214 $ ( '#spellCheckerInput' ) . html ( '' ) ;
212- currentSpellCheckerRequest = callApy ( {
215+ /* currentSpellCheckerRequest = callApy({
213216 data: {
214217 'q': words,
215218 'lang': $('#primarySpellCheckerMode').val()
@@ -248,7 +251,39 @@ function check() {
248251 ajaxComplete();
249252 currentSpellCheckerRequest = undefined;
250253 }
251- } , '/speller' , true ) ;
254+ }, '/speller', true);*/
255+ console . log ( splitWords ) ;
256+ 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 } ] ;
257+ var originalWordsIndex = 0 ;
258+ for ( var tokenIndex = 0 ; tokenIndex < data . length ; tokenIndex ++ ) {
259+ console . log ( originalWordsIndex ) ;
260+ if ( data [ tokenIndex ] . known === true ) {
261+ $ ( '#spellCheckerInput' ) . html ( $ ( '#spellCheckerInput' ) . html ( ) + ' ' + splitWords [ originalWordsIndex ] ) ;
262+ originalWordsIndex ++ ;
263+ continue ;
264+ }
265+ $ ( '#spellCheckerInput' ) . html ( $ ( '#spellCheckerInput' ) . html ( ) + ' <span class="spellError" id=' +
266+ splitWords [ originalWordsIndex ] + '>' + splitWords [ originalWordsIndex ] + '</span>' ) ;
267+ content [ splitWords [ originalWordsIndex ] ] = '<div class="spellCheckerList">' ;
268+ for ( var sugg = 0 ; sugg < data [ tokenIndex ] . sugg . length ; sugg ++ ) {
269+ content [ splitWords [ originalWordsIndex ] ] += '<a href="#" class="spellCheckerListItem">' +
270+ data [ tokenIndex ] . sugg [ sugg ] [ 0 ] + '</a>' ;
271+ }
272+ content [ splitWords [ originalWordsIndex ] ] += '</div>' ;
273+ $ ( '.spellError' ) . each ( function ( ) {
274+ console . log ( this . id ) ;
275+ var currentTokenId = this . id ;
276+ $ ( this ) . popover ( {
277+ animation : false ,
278+ placement : 'bottom' ,
279+ trigger : 'manual' ,
280+ html : true ,
281+ content : content [ currentTokenId ]
282+ } ) ;
283+ } ) ;
284+ originalWordsIndex ++ ;
285+ }
286+ console . log ( originalWordsIndex ) ;
252287}
253288
254289function handleSpellCheckerErrorResponse ( jqXHR ) {
0 commit comments