Jump to content
Sign in to follow this  
pconkie

FrogCode Shared js

Recommended Posts

I have the following validdays.js file in a frogcode project

var validDays = [
    {from:'03/09/2018', until:'26/10/2018'},
    {from:'05/11/2018', until:'21/12/2018'},
    {from:'07/01/2019', until:'15/02/2019'},
    {from:'25/02/2019', until:'05/04/2019'},
    {from:'23/04/2019', until:'24/05/2019'},
    {from:'03/06/2019', until:'23/07/2019'}
]

It looks like terms dates, but only because it is test data.  It will list valid days that detentions can take place on.

It will be used in a couple of different widgets and a couple of apps too.

While developing the js file was referenced in the project as other assets are e.g. 

Com.Frog.Utils.require(
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/styles/main.css',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/validdays.js',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/thumb.ejs',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/popover.ejs',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/main.ejs'
).then(function() {

This worked fine until I deployed! I have realised that the require doesn't allow js to be loaded for a published app/widget.

I really don't want to put the code into the app/widgets as this will duplicate it and require me to update it in multiple places.

Any suggestion please for getting around this?

 

Share this post


Link to post
Share on other sites
On 7/3/2019 at 9:58 AM, pconkie said:

I have the following validdays.js file in a frogcode project


var validDays = [
    {from:'03/09/2018', until:'26/10/2018'},
    {from:'05/11/2018', until:'21/12/2018'},
    {from:'07/01/2019', until:'15/02/2019'},
    {from:'25/02/2019', until:'05/04/2019'},
    {from:'23/04/2019', until:'24/05/2019'},
    {from:'03/06/2019', until:'23/07/2019'}
]

It looks like terms dates, but only because it is test data.  It will list valid days that detentions can take place on.

It will be used in a couple of different widgets and a couple of apps too.

While developing the js file was referenced in the project as other assets are e.g. 


Com.Frog.Utils.require(
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/styles/main.css',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/validdays.js',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/thumb.ejs',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/popover.ejs',
    '//package/applications/189607D420048EA5819BDFE3CD8C91047FD735DC518F1808/assets/views/main.ejs'
).then(function() {

This worked fine until I deployed! I have realised that the require doesn't allow js to be loaded for a published app/widget.

I really don't want to put the code into the app/widgets as this will duplicate it and require me to update it in multiple places.

Any suggestion please for getting around this?

 

hi Paul, Mr Quince ask me to have look, what does it do when you try to use it? does it break Frog, show a horrible console log?

I am also looking through the code base to see what else you could use

Share this post


Link to post
Share on other sites

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Action to be performed when the document is read;
    }
};
xhttp.open("GET", "/app/file/......validdays.js", true);
xhttp.send();

that's just a quick google

Have you tried saving it a XML? that will be seen as data file to the browser, not code. If that works the browser can take XML and parse it into data you can use

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...