Sharing and discussing custom actions for LaunchBar
-
ptujec
- Wizard

- Posts: 321
- Joined: Fri Dec 19, 2008 11:36 am
-
Contact:
Post
by 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:

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
Post
by 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

- Posts: 321
- Joined: Fri Dec 19, 2008 11:36 am
-
Contact:
Post
by 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
Post
by 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
Post
by xmanu » Mon Jun 16, 2014 10:09 am
-
ptujec
- Wizard

- Posts: 321
- Joined: Fri Dec 19, 2008 11:36 am
-
Contact:
Post
by ptujec » Mon Jun 16, 2014 10:19 am
Awesome! Thanks!
-
devananda
- Rank 1

- Posts: 21
- Joined: Sat Jun 25, 2011 9:36 am
Post
by devananda » Sun Oct 19, 2014 9:16 pm
Gratitude from me!
-
cubby
- Posts: 1
- Joined: Fri Oct 31, 2014 9:35 pm
Post
by cubby » Fri Oct 31, 2014 9:37 pm
Does anyone have this action that cans share it? The link above is down.