[LB6 Action] Wolfram Alpha Live Search

Sharing and discussing custom actions for LaunchBar
ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

[LB6 Action] Wolfram Alpha Live Search

Postby ptujec » Sun Apr 13, 2014 8:39 pm

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!

spacek33z
Posts: 8
Joined: Fri Jun 13, 2014 4:28 pm

Re: Wolfram Alpha Live Search

Postby spacek33z » Sat Jun 14, 2014 5:08 pm

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.

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Wolfram Alpha Live Search

Postby ptujec » Sat Jun 14, 2014 8:52 pm

That didn't change much unfortunately

xmanu
Posts: 14
Joined: Sun Apr 13, 2014 11:20 pm

Re: Wolfram Alpha Live Search

Postby xmanu » Sun Jun 15, 2014 4:13 pm

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...

xmanu
Posts: 14
Joined: Sun Apr 13, 2014 11:20 pm

Re: Wolfram Alpha Live Search

Postby xmanu » Mon Jun 16, 2014 10:09 am

Few days were not needed ;)

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

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Wolfram Alpha Live Search

Postby ptujec » Mon Jun 16, 2014 10:19 am

Awesome! Thanks!

devananda
Rank 1
Rank 1
Posts: 22
Joined: Sat Jun 25, 2011 9:36 am

Re: [LB6 Action] Wolfram Alpha Live Search

Postby devananda » Sun Oct 19, 2014 9:16 pm

Gratitude from me!

cubby
Posts: 1
Joined: Fri Oct 31, 2014 9:35 pm

Re: [LB6 Action] Wolfram Alpha Live Search

Postby cubby » Fri Oct 31, 2014 9:37 pm

Does anyone have this action that cans share it? The link above is down.


Return to “LaunchBar Actions”

Who is online

Users browsing this forum: No registered users and 1 guest

cron