Trouble with interface.html #6946
Replies: 1 comment
-
Posted at 2024-06-08 by user140377 Did you try with a \n in both Puck.eval()? Do you have your code somewhere so we can test this? Posted at 2024-06-10 by @gfwilliams I think what you're after for docs is: https://www.espruino.com/Bangle.js+Storage The
is probably causing you issues - So I'd definitely put a 500ms delay after But then what you're doing should work, but I'm concerned based on the name If so, You could potentially use Personally, I probably wouldn't advise trying to push HTML from the Bangle up to the Ideally, you could even just do Although it depends on how you wrote the data - if you're using a StorageFile you'll need Posted at 2024-06-11 by tev Thanks for the support. That's pretty much what I figured was going on. I was just hoping there was a more reliable way than using a fixed delay before running the second command, as that seems a bit like a fragile approach since it relies on trying to guess how long app loading time will take. But technically, I don't really need to load my whole app and its UI. What I'd ideally like is to be able to import a few functions from the app and execute those, perhaps using As far as returning vs. printing, I in fact tried both approaches in My code involved in this is currently very simple. I could put most of it in interface.html, but it's just that testing that currently involves pushing it up to Github Pages and waiting up to ten minutes just to test the code, whereas I can test code on the Bangle device immediately. I'd have to look into getting a local web server going to work around that, which is another time and effort investment I will have to consider. Update:
as a test (
“skipping save to storage” is a normal debug message that my app logs to the console, so it's as if it's trying to parse the wrong part of the console (the output of Posted at 2024-06-11 by tev Never mind, I think I totally botched the syntax. It should be:
My mind gets along much better with Python than this mess. :D Posted at 2024-06-12 by @gfwilliams
This is why I'd really suggest you do what I said and just use Glad you got it working though! If you want to make changes quicker, you can always try hosting the app loader locally if you can get an HTTP server on your PC - changes are then super quick to make. Posted at 2024-06-17 by tev First of all, I totally misunderstood your link to the Storage documentation. I took it as the generic documentation for the Still, it doesn't seem all that straightforward what functions are available for I got the local web server working on Linux, though. That was really easy. Just go into the root of my BangleApps project directory and run I think I finally got my desired functionality working using Posted at 2024-06-17 by user140377 Just in case someone finds the the command to long: Try just 'npm start' Posted at 2024-06-17 by @gfwilliams
That's why we have It's easier to look in the interface.js file itself where there are a bunch of comments at the top explaining what's available and what it does: https://github.com/espruino/EspruinoAppLoaderCore/blob/1cdcb3405f78ef35f231b9c3df501721bda75525/lib/interface.js Posted at 2024-06-17 by tev Ah, okay. But I swear that when I try to use Posted at 2024-06-19 by @gfwilliams Could it be because you forked your app loader from the main one some time ago, and you haven't updated it with all the latest changes? Posted at 2024-06-20 by tev Ah, I see what happened. I thought I had updated my fork, but I was working on a different branch that got old. Now I see that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2024-06-07 by tev
Hi all, I'm working on my first app and am having a really frustrating time getting interface.html working the way I want. The only docs I'm able to find for this are in the BangleApps README, and it just doesn't seem adequate at all.
The problem: I want a “download” button in the app loader that when pressed displays a page with a very simple HTML representation of the data logged in my app. I already have a small function in my app's app.js that returns the desired HTML code as a string, and I just want to call that function and inject it directly into the page as shown in the README example. But for some reason, I can't get it to work at all.
Here is what my interface.html currently looks like:
The idea is to load my app first (so that I have access to its routines—there's probably a cleaner way to do this, but my focus is on making it work first, then worry about refactoring) and then call the function that runs on the Bangle itself and outputs the HTML I want injected into the page. The app gets loaded, but that's as far as it gets. The second call to Puck.eval just returns nothing, every time. And I can see from the Espruino console that my
printHTMLStampLog
function does get called and outputs the desired data, but it just doesn't get returned.What's going on here? After a full day and a half of investigation, I suspect a race condition, because if I fumble around in the browser console and run the second .eval() call by itself after my app is already loaded, it kind of works (except it's somehow not rendering the HTML tags, but we'll deal with that later). I was under the impression that this code would load the app and only call the second part once the first part finishes. Instead, it seems to run the second part too early, and it usually returns nothing, or occasionally, some other nonsense from the Espruino console that has nothing to do with what my app's code is actually writing.
I've looked at a lot of source code for other apps, but it's not getting me anywhere. No one seems to try to use their app's assets directly, and instead they just dump all the code for reading/writing and encoding/decoding data in
interface.html
. That's not what I want to do because that means needlessly copying and pasting perfectly good code I already wrote into multiple files, and that's a code-maintenance nightmare. I do not wish to take that route. I'd like to leverage the existing on-device app code for this functionality as much as possible.Can anyone help me get this working properly?
Beta Was this translation helpful? Give feedback.
All reactions