achudars / adaptable-cookery-book

Other
2 stars 0 forks source link

Terms that might cause difficulties should have the Thesaurus API on hover linked to them #13

Closed achudars closed 10 years ago

achudars commented 10 years ago

tooltip

achudars commented 10 years ago

Currently using Big Huge Thesaurus for the implementation. It can return various types (PHP, XML, JSON), but I stumbled upon many cross-domain issues when trying to implement it.

the only one that worked was:

var API_KEY = "3691e6b302f58d4e90d209e0762b1e04";

$.ajax({
        type: "GET",
        url: "http://words.bighugelabs.com/api/2/" + API_KEY + "/" + word + "/json?callback=?",
        processData : true,
        data: {},
        dataType: "json",
        success:
        function(data) {
           synonyms = JSON.parse(JSON.stringify(data.noun.syn));
            $(".the").one().mouseenter(function() {
                $(this).one().attr('data-original-title', synonyms[0]+", "+synonyms[1]+", "+synonyms[2]);
            });
        }
    });
achudars commented 10 years ago

I really wanted to implement merriam-webster. The issue with this one is that it only returns XML, so an example string is:

http://www.dictionaryapi.com/api/v1/references/collegiate/xml/dog?key=df5d8f5f-34bf-4298-b6a5-f7b9ae1242e1

I also get cross-domain issues and I don't possess enough mental capacity to resolve it. I'm assuming the code shouldn't change much from the above comment.