[tw] Re: Create my own internal-use function
Do that and good luck. I'm sure you get along, at least you have some stuff to get going. For me, learning TW/JavaScript was and is a lot of fun. At some point I had the pleasure to get insights from Eric. Unfortunately, our contact broke off ...somewhat due to the nature of the medium we had prodominantly used to communicate back then. There are a few people around here who might not be so much into theology, but who sure enjoy supporting the occasional js / makro / plugin challenge... after all this is how most all of our beloved plugins came into existence... people taking up on challenges and ruminating on all of the codebits to get them to work ...right. So, we see you around. :-) On 13 Jan., 02:46, Smandoli wrote: > Most of what you wrote seems right on. I was glad to have your help > getting clarity about levels within the data. Aside from that, the first > half was already my thinking. (Oh -- except CreateTiddlyButton, which > looks exciting, but not what I want to attack next.) > > Then you wrote ... > > it looks like it were most helpful if you had a helper object, > > > > Heh ... we have made it back to "create my own internal function." And it > appears I'm in for some javascript education. After studying some TW > source code, I made a primitive first function (which I am calling using > the *this *object instead of *window*). > > The array you described solves problems of > > 1. ordering (inherent in the array index) > 2. definition of boundaries (that is, how many verses are in a book -- > very useful-seeming) > > Your usage of split makes sense. > > The challenge is my inexperience with javascript. Thankfully, it resembles > PHP enough that I feel less intimidated than I would otherwise. > > I will hammer on the code, and yell if I need more help! -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
Most of what you wrote seems right on. I was glad to have your help getting clarity about levels within the data. Aside from that, the first half was already my thinking. (Oh -- except CreateTiddlyButton, which looks exciting, but not what I want to attack next.) Then you wrote ... it looks like it were most helpful if you had a helper object, > Heh ... we have made it back to "create my own internal function." And it appears I'm in for some javascript education. After studying some TW source code, I made a primitive first function (which I am calling using the *this *object instead of *window*). The array you described solves problems of 1. ordering (inherent in the array index) 2. definition of boundaries (that is, how many verses are in a book -- very useful-seeming) Your usage of split makes sense. The challenge is my inexperience with javascript. Thankfully, it resembles PHP enough that I feel less intimidated than I would otherwise. I will hammer on the code, and yell if I need more help! -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To view this discussion on the web visit https://groups.google.com/d/msg/tiddlywiki/-/PFSsFcOweE0J. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
Hi Smandoli, Ok, so instead of Level 3 Verse, you have Level 3 Passage while a Level 4 Verse would be somewhere inside a Level 3 Passage tiddler's body. You also have a lookup makro that allows you to find a corresponding Level 3 Passage tiddler to a corresponding verse. As for your bookdex makro, I still have no clue what purpose those numbers serve. Am I right that you want to use your book array for navigation? As for your Previous and Next links, you could extend your MakroLinkText such that it additionally renders both when you provide a "nav" parameter. You can use your existing loops to figure out the previous tiddler... only your terminal conditions would change. For the Next link you would need to implement equivalent loops in a forward direction. If you want your tiddlers opened at a certain place, you would not render simple TiddlyLinks, but rather use CreateTiddlyButton() with an onClick handler with a dedicated call to story.displayTiddler() in order to open the tiddler where you want to. I hope, the core code explains to you what is required. It might also be nice to not only navigate passages back and forth but also chapters and books... which you can achieve likewise. For these purposes, it looks like it were most helpful if you had a helper object, where you would have one sorted array of all books, and then for each book an array of the number of verses for each chapter. You could simply put something like this somewhere into your MakroLinkText: window.bible = { books:[ [ John, Mark, Mathew ], [ 123, 321, ... ], [ 64, 128, ... ], [ 66, 99, ... ] ] } So, bible.books[0] would give you a sorted array of all book titles while bible.books[1][3] would give you the number of verses in chapter 3 of book 1 or bible.books[2].length would give you the number of chapters in book 2, etc... If you needed to store more information about a chapter, you could either turn that into an object, instead of merely an array or invent some separator by which you split the string. For example, with this pattern "chapterTitle>numVerses" and... chap=bible.books[1][3].split('>'); ...chap[0] would refer to the title of book 1 chapter and chap[1].parseInt() would give you the number of verses for said chapter as an integer. Also, you don't seem to need any "order" field as the tiddler names already come ordered, do they not? Finally, you also have note tiddlers. Currently they only seem to relate to a Level 3 tiddler. I can imagine that you might also want notes for entire books or chapters, so a "n" parameter might be good that works regardless of whether it is the fourth parameter or the second, in other words, to check if it is the not tiddler that is wanted you would check for params.contains['n']. Let me know if that helped any. tb. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
Hi Smandoli, Ok, so instead of Level 3 Verse, you have Level 3 Passage while a Level 4 Verse would be somewhere inside a Level 3 Passage tiddler's body. You also have a lookup makro that allows you to find a corresponding Level 3 Passage tiddler to a corresponding verse. As for your bookdex makro, I still have no clue what purpose those numbers serve. Am I right that you want to use your book array for navigation? As for your Previous and Next links, you could extend your MakroLinkText such that it additionally renders both when you provide a "nav" parameter. You can use your existing loops to figure out the previous tiddler... only your terminal conditions would change. For the Next link you would need to implement equivalent loops in a forward direction. If you want your tiddlers opened at a certain place, you would not render simple TiddlyLinks, but rather use CreateTiddlyButton() with an onClick handler with a dedicated call to story.displayTiddler() in order to open the tiddler where you want to. I hope, the core code explains to you what is required. It might also be nice to not only navigate passages back and forth but also chapters and books... which you can achieve likewise. For these purposes, it looks like it were most helpful if you had a helper object, where you would have one sorted array of all books, and then for each book an array of the number of verses for each chapter. You could simply put something like this somewhere into your MakroLinkText: window.bible = { books:[ [ John, Mark, Mathew ], [ 123, 321, ... ], [ 64, 128, ... ], [ 66, 99, ... ] ] } So, bible.books[0] would give you a sorted array of all book titles while bible.books[1][3] would give you the number of verses in chapter 3 of book 1 or bible.books[2].length would give you the number of chapters in book 2, etc... If you needed to store more information about a chapter, you could either turn that into an object, instead of merely an array or invent some separator by which you split the string. For example, with this pattern "chapterTitle>numVerses" and... chap=bible.books[1][3].split('>'); ...chap[1] would refer to the title of book 1 chapter and chap[2].parseInt() would give you the number of verses for said chapter as an integer. Also, you don't seem to need any "order" field as the tiddler names already come ordered, do they not? Finally, you also have note tiddlers. Currently they only seem to relate to a Level 3 tiddler. I can imagine that you might also want notes for entire books or chapters, so a "n" parameter might be good that works regardless of whether it is the fourth parameter or the second, in other words, to check if it is the not tiddler that is wanted you would check for params.contains['n']. Let me know if that helped any. tb. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
I see! Okay, I posted a pilot version: http://themanthursday.com/wiki/bible_wiki_TEST.htm I provided a half-dozen user stories that should demonstrate what I want much more effectively than my descriptions here. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To view this discussion on the web visit https://groups.google.com/d/msg/tiddlywiki/-/rMHNrY1ufOwJ. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
I'm not quite literate with the bible and I don't really intend to change that, but anyways... I take it there are 3 levels... Level 1: book Level 2: chapter Level 3: verse ...whereas you would keep your actual content in a level 3 tiddler, right? Well, all of this still does not tell me much about the purpose for which you intend to use a Level 1 array. So, the bible has a structure... but what about it is important to you and in which way do you want to make it accessible to you or anyone else in your TiddlyWiki? >From your description, I would think that all structural information can either be extracted from a tiddlers title... or in case of "a book" from something that isn't quite defined yet... although, perhapt it is by the name which in your example is "Mark". On the other hand, if you knew the sequence of books, their title and respective number of chapters and verses, it would be most simple to generate a toc tiddler that contains links to all existing or not existing verses. tb. On 11 Jan., 00:48, Smandoli wrote: > ON SECOND THOUGHT ... I can go further here. > > The array is 2 members wide, 66 deep, and NOT TO BE EDITED. > > I think it would be good to have it in a tiddler's body (that had already > occurred to me). > > This will contribute to the task of ordering 1,000 tiddlers of the type > "scripture passage." The index I have described will provide the top-level > ordering. The ordering from there will be extracted from the tiddler > titles. So Mark 10:23 (chap 10 verse 23) would use the array to get 120, > and then concatenate 10 and 23 (from the title) to produce 1201023. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
ON SECOND THOUGHT ... I can go further here. The array is 2 members wide, 66 deep, and NOT TO BE EDITED. I think it would be good to have it in a tiddler's body (that had already occurred to me). This will contribute to the task of ordering 1,000 tiddlers of the type "scripture passage." The index I have described will provide the top-level ordering. The ordering from there will be extracted from the tiddler titles. So Mark 10:23 (chap 10 verse 23) would use the array to get 120, and then concatenate 10 and 23 (from the title) to produce 1201023. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To view this discussion on the web visit https://groups.google.com/d/msg/tiddlywiki/-/Jz_SVIPJJdAJ. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
Thanks Tobias. I'll take this post down and create descriptions of the functions. I have just been given some work to do, so it may be the weekend. BTW, I'm excited about hYpe. -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To view this discussion on the web visit https://groups.google.com/d/msg/tiddlywiki/-/dXv82I8nk24J. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
[tw] Re: Create my own internal-use function
Hi Smandoli, Please describe what you intend to use the array (or arrays?) for, because that has implications as to how you would add, edit or delete any items in it. We could easily provide you with functions that parse a tiddlers body or that analyse a tagging structure, but all of that depends on what you need your array for in the first place. So please be as detailed as you can in describing all of what you intend to do with you array... after all, perhaps you don't even need a dedicated js version of it. tb. On 9 Jan., 16:04, Smandoli wrote: > Below is a custom macro that is called like this: > <> > It works fine, but there's this honkin' big array in the middle that > REALLY wants to live somewhere else -- not only to make this piece of > code more manageably small, but more importantly, to let me reuse it > elsewhere. > > The result won't be presented to the user, so "wikify" isn't used I > guess; so will it use the "return" command to pass back the array? > And how to I reference the function from here -- is there some kind of > "store." object involved? > > (Honest, I do try to search for existing answers before posting.) > > config.macros.bookdex={ > handler: > function(place,macroName,params,wikifier,paramString,tiddler) { > var book = params[0]; > var bookdex; > > var arrBookdex = new Array(); > > // > // Wants to be replaced by a call to separate macro > arrBookdex ["John" ] = "100"; > arrBookdex ["Mark"] = "120"; > arrBookdex ["Matthew" ] = "140"; > // ... etc. ! > // > > bookdex = arrBookdex[book]; > wikify(bookdex, place); > } > }; -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.