Including external resources - JSClient Mobile App (Offline) - OS 8.0.2

Aidan Dunn aidan at freedomsoftware.co.nz
Tue Jan 24 16:19:39 EST 2017


I've been having an issue with OS 8 since I started using it, and was hoping someone could give some insight.

The problem is pretty simple; how does one include an external resource such as a collection of javascript functions (a script file) to a Offline Mobile application?

I am using a fully functional developer version of OS 8.0.2 with a active "Web Services Server" key installed. The application works as expected on both a browser and online mobile application.

The short of it is that I don't know how to tell the application to use script or CSS files when in offline mode. This is with a SCAF pre-bundled with the wrapper and without (updating the application).

Background on things I have tried...

I've simplified the application to a state that it does nothing but call a function in the script file on $init, calling it causes a javascript error (because the function isn't defined) and is displayed as a popup on the device.

In order to try to get the file to execute in the application, I added the file to the application's SCAF sqlite database, jsfiles table, by opening it in Omnis "SQL Browser" and doing an insert command. Doing some length checks on file_binary column, I could verify the file was in fact added. Using a variation of path strings, finally settling on what the omnis SCAF uses.
As I was writing this I have actually noticed that the custom files that I had added to the scripts, css & images folders of the html folder have been added to the omnis.db SCAF, jsfiles table, so I think it's reasonable to assume messing around with the SCAF is not necessary.

I did a check on what files were being requested by the application by coding javascript to output a string of all the script sources used on the page. Online was making nearly 9 non-local requests (to my machine) where as Offline only had 4 (omnis) script references to local files (file:/data/user/0/appName/files/html/scripts/scriptname.js).

In order to verify the files were actually being loaded into the application; I installed the APK on the an Android emulation (couldn't be a device as I don't have a "rooted" one) and logged into it as a superuser using the Android Debug Bridge (ADB) shell. I navigated the folder structure using the path supplied by the Offline app's script href/src strings, and verified that the html folder structure did in fact contain my files.

As a last ditch attempt I created some javascript to manually add the reference to where the custom javascript file should be kept, using the existing references as a reference (hah). That included creating a script element, adding the "src" attributes to the element and appending that to the page's head element. Then calling a function from the file (like initially doing), but it only gave the same error.


P.S: Insight into using images would be appreciated aswell; the current online solution i'm using is to write CSS to add it to the background of a image object.


Any help with this problem would be greatly appreciated. Perhaps examples on how you were able to do this?


Aidan Dunn




More information about the omnisdev-en mailing list