You can feed it the numbers of the contents you want open:
Code:
switchcontent.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return "0,1"
}
Since things are usually numbered in javascript from 0 to whatever, the above (red) would represent the first two content blocks.
If you have only one instance of the script on a page, that is all you would need.
If you have more than one, you have to test for its class name:
Code:
switchcontent.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
if(Name=='switchgroup2')
return "0,1"
return ""
}
This would select switchgroup2 to open its first two blocks but, only if there were no cookie data for switchgroup2. You can use as many of these as you need, each with its own default block state settings:
Code:
switchcontent.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
if(Name=='switchgroup1')
return "1,2"
if(Name=='switchgroup2')
return "0,1"
return ""
}
This will only work with persistence true and these groups probably also would need collapse previous false if they were set to have more than one block open using the above method. If persist is false, you can use the default expanded property (as documented on the demo page):
Code:
<script type="text/javascript">
var joeexample=new switchcontent("switchgroup2", "p") //Limit scanning of switch contents to just "p" elements
joeexample.setStatus('[open] ', '[closed] ')
joeexample.setColor('green', 'red')
joeexample.collapsePrevious(false) //Allow more than 1 content to be open simultanously
joeexample.setPersist(false)
joeexample.defaultExpanded(0,1)
joeexample.init()
</script>
Bookmarks