Implemented Access data from other pages

Noc

New member
Thanks for creating this web version of Scoreboard Assistant! It looks like it could be very useful and I am starting to set it up similar to my local version of Scoreboard Assistant.

A couple questions I have so far:
  • Although docData can access data from the current page, is there a way it could access data from another page? For instance, I would like to show commentator names on both Versus and Commentators scenes while only having to add fields for and update commentator names on a Commentators page.
  • It seems I cannot upload more than 20 images at once to a subdirectory of my Image library. Could that number be increased?
 

Jaxel

Administrator
Although docData can access data from the current page, is there a way it could access data from another page? For instance, I would like to show commentator names on both Versus and Commentators scenes while only having to add fields for and update commentator names on a Commentators page.
On your versus page, you want to access the contents of your commentators page, correct? Well you CAN do this! On every page, the reference to your package's DB is actually passed in a variable called packageDb.

On your versus page custom JS, you can access the docData of your commentators page with:
Code:
packageDb.collection('UNIQUE_ID_OF_COMMENTATORS_PAGE').doc('fields').onSnapshot(function(docRef2)
{
    if (docRef2.exists)
    {
        docData2 = docRef2.data();
        console.log("Retrieving data: ", docData2);
        // you can now access the data of the commentators page through the variable docData2
    }
});
Just remember to change UNIQUE_ID_OF_COMMENTATORS_PAGE to the 10 character unique ID of that page.

It seems I cannot upload more than 20 images at once to a subdirectory of my Image library. Could that number be increased?
I have increased the upload limit.
 

TrashTalk

New member
Hi Jaxel,

Can you make a tutorial for this feature please.
Or just a more complete example because i don't manage to make it works.

Just an error message in the debug console : docData2 is not defined

:(
 

Brimstone

New member
Hi Jaxel,

Can you make a tutorial for this feature please.
Or just a more complete example because i don't manage to make it works.

Just an error message in the debug console : docData2 is not defined

:(
I'm getting this same error. Were you able to figure it out? Any help would be much appreciated!
 

Jaxel

Administrator
JavaScript is a JIT language, and thus has very specific scoping for variables.
Variables only exist within the { } brackets in which they were created.
 

Brimstone

New member
JavaScript is a JIT language, and thus has very specific scoping for variables.
Variables only exist within the { } brackets in which they were created.
Hehe! Yes, as mentioned in the other thread I posted in, my programming buddy was able to help me with understanding this! Got it working perfectly now! Once I have stuff polished I'll throw it in the Showcase forum!
 

skandis

New member
So, i tried this, but nothing is instered in to my div with the id "spillereHer" - Just a blank page :(
Code:
packageDb.collection('5D3ADA6620').doc('fields').onSnapshot(function(docRef2)
{
    if (docRef2.exists)
    {
        docData2 = docRef2.data();
        console.log("Retrieving data: ", docData2);
        // you can now access the data of the commentators page through the variable docData2
            $('#spillereHer').text(docData2['spiller_1']);
    }
});