Page 1 of 1

[LB6 Action] Wolfram Alpha Live Search

Posted: Sun Apr 13, 2014 8:39 pm
by ptujec
Hi LB6 beta testers!

Can anybody fix this javascript to get live search going for Wolfram Alpha?

Code: Select all

function run(arguments) {
    var search = arguments[0];
    if (search == undefined || search.length == 0) {
        return [];
    }

    var result = HTTP.getJSON('http://www.wolframalpha.com/input/autocomplete.jsp?qr=' + encodeURIComponent(search), 3);

    if (result == undefined) {
        LaunchBar.log('HTTP.getJSON() returned undefined');
        return [];
    }
    if (result.error != undefined) {
        LaunchBar.log('Error in HTTP request: ' + result.error);
        return [];
    }

    try {
        var suggestions = [];
        for (var suggestion in result.data) {
            suggestions.push({
                             'title' : suggestion,
                             'icon' : 'walpha.png'
                             });
        }
        return suggestions;
    } catch (exception) {
        LaunchBar.log('Exception while parsing result: ' + exception);
        return [];
    }
}


This is what I get:
Image
I have no Javascript knowledge. I just tried to modify the duden lbaction. But this is not Applescript ;)

So smart people please help!

Re: Wolfram Alpha Live Search

Posted: Sat Jun 14, 2014 5:08 pm
by spacek33z
The URL for the autocomplete is not correct. What happens when you change rule 7 to this?

Code: Select all

var result = HTTP.getJSON('http://www.wolframalpha.com/input/autocomplete.jsp?qr=0&i=' + encodeURIComponent(search), 3);


Because this URL outputs something: http://www.wolframalpha.com/input/autoc ... qr=0&i=2*2, but the URL in the javascript just outputs null.

I've not tested it myself because honestly I'm too lazy now, but this is definitely part of the problem.

Re: Wolfram Alpha Live Search

Posted: Sat Jun 14, 2014 8:52 pm
by ptujec
That didn't change much unfortunately

Re: Wolfram Alpha Live Search

Posted: Sun Jun 15, 2014 4:13 pm
by xmanu
I will take a look at this on Monday. It should be possible to build a LB Action out of this, but it will be a bit more complicated than the Duden action.
Give me a few days...

Re: Wolfram Alpha Live Search

Posted: Mon Jun 16, 2014 10:09 am
by xmanu
Few days were not needed ;)

Here is a WolframAlpha Action:
http://manuel.weiel.eu/private-projects/launchbar-actions/search-wolfram-alpha/

Re: Wolfram Alpha Live Search

Posted: Mon Jun 16, 2014 10:19 am
by ptujec
Awesome! Thanks!

Re: [LB6 Action] Wolfram Alpha Live Search

Posted: Sun Oct 19, 2014 9:16 pm
by devananda
Gratitude from me!

Re: [LB6 Action] Wolfram Alpha Live Search

Posted: Fri Oct 31, 2014 9:37 pm
by cubby
Does anyone have this action that cans share it? The link above is down.