B4J Question [BANAno]: Two comments about tutorial

B4JExplorer

Active Member
Licensed User
Longtime User
Regarding the Demo at

https://www.b4x.com/android/forum/threads/banano-authentication-to-a-b4j-server-rest-api.100269/


,

1. Minor point - app.js refers to BANano v2.15 ; should be 2.17.


2. The client screen is running almost as expected. GetInfo shows 'You are not connected to the internet!"

But Login returns the same message.


I'm trying to trace through the app.js code, but of course it's not structured for debugging.

Is there anything else I might look at, before continuing with the js code?


(Sorry, Alain :))
 

alwaysbusy

Expert
Licensed User
Longtime User
1. Minor point - app.js refers to BANano v2.15 ; should be 2.17.
Where do you see this?

You are not connected to the internet!
Are you connected to the internet? Meaning, can the file http://gorgeousapps.com/donotdelete.gif be downloaded? (try it in a browser, you should get a dark gray background with a white pixel in the middle)

This is what I get:

upload_2019-1-31_17-24-40.png


(Sorry, Alain :))
Absolutely no problem!
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Regarding the Demo at

https://www.b4x.com/android/forum/threads/banano-authentication-to-a-b4j-server-rest-api.100269/


,

1. Minor point - app.js refers to BANano v2.15 ; should be 2.17.


2. The client screen is running almost as expected. GetInfo shows 'You are not connected to the internet!"

But Login returns the same message.


I'm trying to trace through the app.js code, but of course it's not structured for debugging.

Is there anything else I might look at, before continuing with the js code?


(Sorry, Alain :))


It's happening during the Login_Clicked event, which transpiles as an async function.

So the _token var is an empty string, and it attempts to run BANano.CheckInternetConnectWait (transpiled as await banano_isconnectedWait()), and it fails. As a result, in the Else block, it says that we aren't connected.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Just to be sure: you did follow these 4 steps:

1. Run the Client code to generate the app
2. Start the Chrome Webserver plugin and point to the folder where client.html is
3. Start the B4J server
4. Browse to the Chrome Webserver (e.g. http://127.0.0.1:8887/client.html)

Opening the html by double clicking it will not work (it needs a cookie). Are your cookies enabled?
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Where do you see this?


Are you connected to the internet? Meaning, can the file http://gorgeousapps.com/donotdelete.gif be downloaded? (try it in a browser, you should get a dark gray background with a white pixel in the middle)

This is what I get:

View attachment 76965



Absolutely no problem!


"Where do you see this?"

In the initial comment, at the top of app.js

<!-- This WebApp/WebSite was created using BANano v2.15, a B4X library written by Alain Bailleul (2018 - 2019). -->
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Just to be sure: you did follow these 4 steps:

1. Run the Client code to generate the app
2. Start the Chrome Webserver plugin and point to the folder where client.html is
3. Start the B4J server
4. Browse to the Chrome Webserver (e.g. http://127.0.0.1:8887/client.html)

Opening the html by double clicking it will not work (it needs a cookie). Are your cookies enabled?

Cookies are enabled.

The banano_isconnectedWait() function seems to be running as expected.

What's meant by double-clicking on client.html? The only way I can double-click, is on the desktop.

I'll try this from the hotel, tonight. Maybe my wifi at the office is blocking something.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
What's meant by double-clicking on client.html? The only way I can double-click, is on the desktop.
That is what you can't do. You have to open your browser and 'surf' to your Chrome Webserver by typing http://127.0.0.1:8887/client.html in the browser.

If you open the html file from disk, (you see file:// in the browser), then it will not work as in case of opening a file this way, the browser has cookies restrictions.

Open the console (F12) in the chrome browser and see if it gives you errors. Maybe we can get a clue from there.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
That is what you can't do. You have to open your browser and 'surf' to your Chrome Webserver by typing http://127.0.0.1:8887/client.html in the browser.

If you open the html file from disk, (you see file:// in the browser), then it will not work as in case of opening a file this way, the browser has cookies restrictions.

Open the console (F12) in the chrome browser and see if it gives you errors. Maybe we can get a clue from there.

Yes, that's what I did initially. That window is open. But it's not possible to double-click on it, since we're not working from the desktop. But I typed it in, and also F6 and <Enter>, and <F5> to try a refresh. Done all of those things, initially.

Anyway, let me try this tonight from a different location. This wouldn't be the first time going crazy, when it turned out that some firewall was in place that the office didn't tell us about.


Regards,
 
Upvote 0

Kiffi

Well-Known Member
Licensed User
Longtime User
Many web servers cache the content of the website. This means that a changed JavaScript (app.js) will not be reloaded even if <F5> is pressed. Sometimes it helps to press <Ctrl> + <F5>. The Chrome developer console also has a checkbutton "Disable cache" in the tab Network, which you can activate:

dWEHgHo.png


If all this does not help, you can give the app.js a new name each time you transpose. This should work in any case:

B4X:
BANano.JAVASCRIPT_NAME = "app" & DateTime.Now & ".js"
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Thanks, Kiffi.

Either way, I'll wait till tonight, and use the wifi at the hotel.

Will update this thread, with the success status.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Looks like everything's ok, now.

Thanks, Kiffi and Alain.

I'm actually more interested in the translated Javascript code and the inline js. I explored that at the office in the afternoon, and really enjoy seeing the magic happen. Good stuff.

Looking forward to the version with inline php support. That's mainly what I do at the office.

Regards,
 
Upvote 0
Top