Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 15    Views: 61

Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
06/22/14 07:22 PM (10 years ago)

Data URL

My Map App, is now 8 Apps, because I need and want to keep the geography - and config.txt files - small. For my Map of the US, I need to try something I haven't yet tried: inserting a data url statement in the second Menu Simple menu. I have over 1500 locations for the US! Too much for one config.txt file to handle! So I broke the US into 8 regions. I added a second level Menu Simple, that users use to select which region. When they tap the region their State is in, the data url will load that portion of the config.txt file, that has the next Menu Simple with the States in the region, and then tapping the State, the next Menu Simple with the cities and the locations... Is there an up-to-date reference, example, of how we use dataURL with Menu Simple? "itemId":"****", "itemType":"BT_screen_menuListSimple", "itemNickname":"Travel Map", "navBarTitleText":"Travel Map", "listRowBackgroundColor":"#000000", "listTitleFontColor":"#FFFF33", "navBarStyle":"solid" "childItems":[ { "itemId":"S0", "itemType":"BT_menuItem", "loadScreenWithItemId":"S1", "titleText":"On To The Maps!" }, ... { "itemId": "S1", "itemType": "BT_screen_menuListSimple", "itemNickname": "Travel Map", "navBarTitleText": "Travel Map", "listRowBackgroundColor":"#000000", "listTitleFontColor":"#FFFF33", "childItems": [ { "itemId": "SRg0iI", "itemType": "BT_menuItem", "loadScreenWithItemId": "SRg0", "titleText": "New England"}, ... { "itemId": "SRg0", "itemType": "BT_screen_menuListSimple", "itemNickname": "New England", "navBarTitleText": "New England", "listRowBackgroundColor":"#000000", "listTitleFontColor":"#FFFF33", "titleText": "New England", "dataURL":"http://www.****/NewEngland.txt" } , My .txt file at the dataURL destination begins with: "childItems": [ { "itemId": "SCo0iI", "itemType": "BT_menuItem", "loadScreenWithItemId": "SCo0", "titleText": "Connecticut"}, ... }] I followed the design of my other working Map Apps for travel areas where the data is small enough to include with the config.txt. This is my first experiment with dataURL. The JSON Validator only likes my .txt file if I put a '{' at the top and a '}' at the end of the file. Then JSON is valid. XCode simulator doesn't like it either way! With '{}' at beginning and end, I get: 2014-06-22 19:12:16.283 travelmap[47774:60b] BT_screen_menuListSimple: ERROR parsing JSON: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 "Object key string expected" UserInfo=0xdc825b0 {NSLocalizedDescription=Object key string expected}" ) And without those, I get: ERROR parsing JSON: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=10 "Garbage after JSON" UserInfo=0xdf55900 {NSLocalizedDescription=Garbage after JSON}" ) I'm looking for a dataURL reference - or some examples. I am Self Hosted v3.0.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/22/14 07:55 PM (10 years ago)
The Menu Simple page has the answer at the bottom: https://www.buzztouch.com/plugins/plugin.php?pid=334A4B840178A021CF61919 I have pasted a copy that is slightly edited. This applies to any plugin's dataURL ... BuzzTouch ensures that consistency across its ecosystem. JSON Data for a dataURL ------------------------------------ The data items could come from a backend script or from a text file at the dataURL. Loading the dataURL in your browser would produce output like this. Structure yours accordingly. { "childItems":[ { "itemId":"menu_1", "itemType":"BT_menuItem", "titleText":"This is row 1", "loadScreenWithItemId":"1234" }, { "itemId":"menu_2", "itemType":"BT_menuItem", "titleText":"This is row 2", "loadScreenWithItemId":"5678" }, { "itemId":"menu_3", "itemType":"BT_menuItem", "titleText":"This is row 3", "loadScreenWithItemId":"2948" } ] } Remember to share your lovely app when it is available! -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/22/14 07:56 PM (10 years ago)
Also, you may want to copy-paste that JSON text block into http://JSONlint.com to see it in human-understandable format (with indentation). -- Niraj
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/22/14 08:02 PM (10 years ago)
OK, the example has "{}" at top and end. It looks like I put the dataURL call at the right point. XCode doesn't like the remote file, so I will keep debugging that! Valid JSON doesn't always mean a valid App!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/22/14 09:42 PM (10 years ago)
Delete the app from the Simulator or hit the Refresh arrow to clear the cache. The old data might be lingering. -- Niraj
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/22/14 09:45 PM (10 years ago)
So, I took out one dataURL and replaced it with the contents of the remote file. That worked. I then took all that out, and used the dataURL call, and again, XCode says there;s a problem reading JSON data. With AND without the extra set of '{}' curlies at the beginning and end. I wonder if it doesn't like .txt extension files?
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/22/14 10:49 PM (10 years ago)
I just did something right! dataURL worked. This time, with '{}' squiggles at beginning and end! (It just didn't work, withOUT the squiggles!) Glad to know the correct procedure.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/23/14 06:42 AM (10 years ago)
Congratulations! :-) -- Niraj
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 08:11 AM (10 years ago)
My Map App works very well, in its purpose of being a directory of places, and ultimately the live map of places in a city. BUT, it does NOT look lovely! At least the Android version. I posted about this 2 weeks ago https://www.buzztouch.com/forum/thread.php?tid=D035CEBC1BDF58B803E35F2&sortColumn=FT.id&sortUpDown=DESC&currentPage=1
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/23/14 08:50 AM (10 years ago)
Eye of the beholder and all that ... You'll learn soon enough about this mobile coding. A PHP guy like you haz madz skillz :-)
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 11:10 AM (10 years ago)
A transparent row in Android, when it should be solid black, is more than Beauty in the Eye of the Beholder... it is a bug in the code somewhere. It's not my code, and it's been two weeks. I've posted here. I've sent PMs to Evangelists here. I've not written to the author (David). As for https://www.buzztouch.com/plugins/plugin.php?pid=334A4B840178A021CF61919... My requirement is more complicated than the example. In the example, the dataURL is one Child Item. In my case, I want to do the Child Item, PLUS carry on with a mile of additional JSON, to finish off that Region's States, Cities, and Maps. When I get to the end of the childitem with the ] and }... and then want proceede with additional code with a {... Because BT requires the dataURL file to begin with a { that would not otherwise be a part of a childitem... the new { causes a JSON Validate error Multiple JSON root elements[
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 12:52 PM (10 years ago)
Is there an example of "include"-ing (as we would say in PHP), JSON code from a dataURL, that proceeds additionaly beyond the childitem? If not, I can build my core shell with more of the additional code (I'm trying to make the core/shell App be as small as possible), which will have 4 more screens with childitems, which would be 4 additional dataURL calls. Each dataURL call results in/requires the user to sit for a few seconds watching a spinning wheel. is that good user experience? Will Apple reject that practice?
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 12:53 PM (10 years ago)
In the end, I want my core/shell to have the Main Menu, then each menu item call a dataURL to finish off the program to conclusion.
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 01:16 PM (10 years ago)
Is the scenario I am up against, inherent to just MenuSimple? Are there other Menu plugins that don't have this dataURL limitation? David wrote in this latest thread/Blog, that he doesn't want to compete with Plug In developers, but MenuSimple is pretty great - because it is simple!!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/23/14 07:29 PM (10 years ago)
A screen can only have Child Items. A screen cannot have Grandchild Items that are controlled via BT Central. However, a custom-made plugin can indeed have Grandchild Items and beyond. But they will only be processed by the native code and not by BT Central code. Read this for insight: https://www.buzztouch.com/forum/thread.php?tid=984AD88720F044EBC4F9FDE -- Niraj
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
06/23/14 07:57 PM (10 years ago)
I think we're talking about two different things... but I'll learn something from your thread. For the US, my Map will have almost 2000 Locations! Of course, there's a 3-deep menu structure: States and Cities and Categories, before getting to an individual State/City/Category Map with maybe 5-10 pins... BUT - I have to have all of that data in my App. I want to split it up into smaller chunks, as it takes a while to download. I'd rather create the equivalent of 8 Apps, but via a new menu of "Regions" - not 8 physical Apps. Selecting Midwest, then goes to my site and downloads the dataurl that will then pick up from that "Regions" menu, and finish the job right out to the closing '}' of the config.txt. it's like I want a whole new config.txt file, but just the slice that begins where the "Regions" menu left off. It's not that I want a dataurl for a childitem, I want to do like we do in PHP with an include()... Is this a experience someone has had, or read about?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.