Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/craigmccauley/craigs-spell-check-dialog

jQuery/bootstrap plugin to provide a spellcheck dialog.
https://github.com/craigmccauley/craigs-spell-check-dialog

Last synced: 19 days ago
JSON representation

jQuery/bootstrap plugin to provide a spellcheck dialog.

Awesome Lists containing this project

README

        

# Craig's Spell Check Dialog
jQuery plugin to provide a spell check dialog

##Usage

Some conteent

Check for errors

$(function(){
var spellchecker = $(document).cscd({
//either specify your server URL
spellcheckURL : "http://localhost/SpellCheck/api/CheckWords",
//or you can use client side spellchecking with Typo.js
//CSCD will automatically look for .aff and .dic files in specified directory
//ex. en_CA.aff/en_CA.dic
//make sure you can serve .aff and .dic files as text/plain from your web server
dictionaryPath : "./Dictionary/",
//sample alert (not required, will use js alert by default)
alertFunction : function(header, body, callback){
$('#spellCheckModal #confirmModalTitle').text(header);
$('#spellCheckModal #confirmModalMsg').text(body);
$('#spellCheckModal').modal('show');
$('#spellCheckOkButton').unbind('click').on('click', function () {
if (callback) {
callback();
}
}).focus();
}
});
$('#spellcheckbutton').click(function(){
spellchecker.cscd(
//execute spellcheck function
'SpellCheck',
//html content to check
$('#mycontent').html(),
//callback function
function(data){
$('#mycontent').html(data);
}
);
});
});



##On the Server Side - if needed
You will need a function that accepts an array of strings and returns a Dictionary<string, string[]>.
The array of strings passed in is a unique list of words.
In the dictionay passed back the key string is the misspelled word, value array of strings are the suggestions.
In .Net it would look like this.

public Dictionary Post([FromBody]string[] words)

If you are not using .Net the request body will look similar to this

=wordtocheck1&=wordtocheck2&=wordtocheck3&=wordtocheck4

and your response body should look similar to this

{"typo1":["sug1", "sug2"],"typo2":["sug1","sug2"]}