vandench
Newbie
Posts: 1
Registered: 12/9/2005
Member Is Offline
|
| posted on 12/9/2005 at 05:49 PM |
|
|
Dynamically Loading Files
Rather than forcing users to edit the following to add content files
ITEMS = [
{
'file': '../Current_News/cont2.html',
'content': '',
'pause_b': 2,
'pause_a': 1
},
{
'file': '../Current_News/cont1.html',
'content': '',
'pause_b': 2,
'pause_a': 1
}
]
It would be nice to have a loop which would load the ITEMS array dynamically. They would then only have to change some sort of lop counter. Is this
possible to do?
|
|
|
rock
Moderator
Posts: 687
Registered: 4/15/2003
Member Is Offline
|
| posted on 12/10/2005 at 01:17 PM |
|
|
Solution for Tigra Scroller download package demo:
| Code: |
MY_ITEM_NUMBER = 2;
var ITEMS = [];
var l;
for(var j=MY_ITEM_NUMBER; j > 0; j--){
l = ITEMS.length;
ITEMS[l] = {
'file': '../s0_data/cont'+j+'.html',
'content': '',
'pause_b': 2,
'pause_a': 1
}
}
|
BTW: Nice idea :)
|
|
|
jeff
Junior Member
Posts: 3
Registered: 6/27/2006
Member Is Offline
|
| posted on 6/28/2006 at 09:36 AM |
|
|
How do you implement this dynamic capability? I have never done script coding before so forgive me.
|
|
|
tigra
Administrator
Posts: 1982
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 6/28/2006 at 11:43 AM |
|
|
if you place above code in your scroll.tpl?.js file instead of ITEMS variable definition the scroller will be configured to scroll MY_ITEM_NUMBER of
external files named ../s0_data/cont0.html to ../s0_data/cont[MY_ITEM_NUMBER-1].html where [MY_ITEM_NUMBER-1] is actual number. All you need is:
1. place the code in the scroller's config
2. set the number of files you want to scroll
3. fill in directory ../s0_data/ directory with the HTML files sticking to the naming convention
|
|
|