• We just upgraded the platform on which this website runs! Please inform @Jaxel of any issues.

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']);
    }
});
 

Jaxel

Administrator
Does your console say there is a value for spiller_1? Do you have a div ID of spillereHer?
 

ProTableTop

New member
I got this working from my main page to a second one but then I can not seem to get it to work on a 3rd page. Would anything need to change to pick the data up on a 3rd page?
 

Jaxel

Administrator
I got this working from my main page to a second one but then I can not seem to get it to work on a 3rd page. Would anything need to change to pick the data up on a 3rd page?
Change all 2 references to 3.

Also, don't nest the two of them together.
 

ProTableTop

New member
Change all 2 references to 3.

Also, don't nest the two of them together.
This is what I got and it's not pulling still.

packageDb.collection('360005BB94').doc('fields').onSnapshot(function(docRef3)
{
if (docRef3.exists)
{
docData3 = docRef3.data();
console.log("Retrieving data: ", docData3);
$('#Player_CP_1s').text(docData3['Player_CP_1s']);
$('#Player_CP_2s').text(docData3['Player_CP_2s']);
$('#Player_VP_1s').text(docData3['Player_VP_1s']);
$('#Player_VP_2s').text(docData3['Player_VP_2s']);
}
});
 

ProTableTop

New member
Tried a bunch of stuff and console.log("Snapshot received: ", docRef3) to see if its hitting the data at all and it looks like this (3rd) page cant pull the data at all like th (2nd one can).