Hi Laci

> I would like to extend the functionality of a plugin called Library Tracker 
> <http://inmysocks.tiddlyspot.com/#My%20Plugins>. so to have an autocomplete 
> dropdown list on titles with the help of the google books api, similar to 
> this:https://www.librarieshacked.org/tutorials/autocompletewithapi 
> <https://www.librarieshacked.org/tutorials/autocompletewithapi> . 
> This would be the final goal, now I just would like to transform the api_url 
> when the input box is edited so that in the next step I could do an ajax 
> request... but thats not for today, I have no idea how to do that in 
> TiddlyWikki but with some research and the help of the community, with small 
> steps I hope to get there soon. :)

OK, you’ve chosen a goal that will be quite demanding :)

The user interface of TiddlyWiki is built out of wikitext; for example, the 
autocompletion of tags in the editor looks like this:

https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/EditTemplate/tags.tid
 
<https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/EditTemplate/tags.tid>

Off the top of my head, this is what would be needed to build an API-based 
autocomplete along the same principles:

* Introduce a new message handler that can retrieve entries from the 
autocomplete API and store them as temporary tiddlers
* Figure out a way to trigger that message whenever the text of an edit control 
changes
* Add a dropdown to the book title field in the library tracker that selects 
the autocomplete tiddlers and searches for the typed text

Best wishes

Jeremy.



> 
> 
> Thanks,
> Laci
> 
> On Thu, Jul 14, 2016 at 2:58 PM, Jeremy Ruston <jeremy.rus...@gmail.com 
> <mailto:jeremy.rus...@gmail.com>> wrote:
> JavaScript macros are intended to generate an output string from their input 
> parameters; they are not supposed to have side effects.
> 
> What are you trying to do here? It looks like you’re trying to compose a 
> search URL for Google books; is the intention to provide a UI onto the 
> search, or to search with information drawn from the current tiddler?
> 
> Best wishes
> 
> Jeremy
> 
>> On 14 Jul 2016, at 12:01, László Zsigmond <zsigmond.88.las...@gmail.com 
>> <mailto:zsigmond.88.las...@gmail.com>> wrote:
>> 
>> Hello!
>> 
>> I'm trying to start with my first homebrew javascript snippet/macro that 
>> gets the value of a tiddler's field and replaces two strings inside it...
>> I came up with the following not working code that should just return that 
>> modified string. This script shouldn't run jut once but
>> each time one input element (inputterm) is edited. Have no idea how to call 
>> such a function in Tiddlywiki context, for getElements it
>> would be safer to use ids but I just want to see if my plan is doable in the 
>> first place.
>> 
>> Help please.
>> 
>> 
>> Laci
>> 
>> /*\
>> title: $:/macros/obeliksz/library_api_macro.js
>> type: application/javascript
>> module-type: macro
>> 
>> <<libraryapimacro>>
>> 
>> Example:
>> <<libraryapimacro>>
>> 
>> \*/
>> (function(){
>> 
>> /*jslint node: true, browser: true */
>> /*global $tw: false */
>> "use strict";
>> 
>> /*
>> Information about this macro
>> Replaces inside the api_url string the inputterm with the more than 3 
>> characters
>> typed input from the title's edit-text and inputauthor with author edit-text
>> default api_url: 
>> https://www.googleapis.com/books/v1/volumes?printType=books&q=+intitle:inputterm+inauthor:inputauthor
>>  
>> <https://www.googleapis.com/books/v1/volumes?printType=books&q=+intitle:inputterm+inauthor:inputauthor>
>> 
>> */
>> 
>> exports.name <http://exports.name/> = "libraryapimacro";
>> 
>> /*
>> Run the macro
>> */
>> exports.run = function() {
>>     var api_url = {{$:/plugins/inmysocks/LibraryTracker/Library Tracker 
>> Settings!!api_url}}
>>     var inputterm = 
>> document.getElementsByClassName('tc-edit-texteditor')[0].value
>>     var inputauthor = document.getElementsByTagName('select')[1].value    
>>      var output ="New url: " + 
>> api_url.replace("inputterm",inputterm).replace("inputauthor",inputauthor);
>>      return output;
>> };
>> 
>> })();
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TiddlyWiki" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to tiddlywiki+unsubscr...@googlegroups.com 
>> <mailto:tiddlywiki+unsubscr...@googlegroups.com>.
>> To post to this group, send email to tiddlywiki@googlegroups.com 
>> <mailto:tiddlywiki@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/tiddlywiki 
>> <https://groups.google.com/group/tiddlywiki>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/35b77f29-53b6-404d-8b1d-f4b137091131%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/tiddlywiki/35b77f29-53b6-404d-8b1d-f4b137091131%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/tiddlywiki/gNlWaoeE6yg/unsubscribe 
> <https://groups.google.com/d/topic/tiddlywiki/gNlWaoeE6yg/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> tiddlywiki+unsubscr...@googlegroups.com 
> <mailto:tiddlywiki+unsubscr...@googlegroups.com>.
> To post to this group, send email to tiddlywiki@googlegroups.com 
> <mailto:tiddlywiki@googlegroups.com>.
> Visit this group at https://groups.google.com/group/tiddlywiki 
> <https://groups.google.com/group/tiddlywiki>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/924DF5FD-52CF-4829-BD41-ED3E754D72FE%40gmail.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/924DF5FD-52CF-4829-BD41-ED3E754D72FE%40gmail.com?utm_medium=email&utm_source=footer>.
> 
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to tiddlywiki+unsubscr...@googlegroups.com 
> <mailto:tiddlywiki+unsubscr...@googlegroups.com>.
> To post to this group, send email to tiddlywiki@googlegroups.com 
> <mailto:tiddlywiki@googlegroups.com>.
> Visit this group at https://groups.google.com/group/tiddlywiki 
> <https://groups.google.com/group/tiddlywiki>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/CAJ9a8aUa7SdsdL6toB3k4XwPHAMaY1-UnfKicV9%2B2x3%2BNEvgvQ%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/CAJ9a8aUa7SdsdL6toB3k4XwPHAMaY1-UnfKicV9%2B2x3%2BNEvgvQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7B86F7D0-9C2B-48B3-AD77-CB8E4F002DE3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to