lundi 2 mars 2015

Get custom post type slugs in javascript in header


I am using the following javascript to show and hide various divs on hover:



<script type="text/javascript" language="JavaScript">
function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

function HideAllShowOne(d) {
// Between the quotation marks, list the id values of each div.

var IDvaluesOfEachDiv = "agencyworks representation vision contact baby-g-jp nasty-gal zara target burger-king vans club-monaco hermes la-mer assouline levis chevrolet converse strange-love";

//-------------------------------------------------------------
IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/[,\s"']/g," ");
IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/^\s*/,"");
IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/\s*$/,"");
IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/ +/g," ");
var IDlist = IDvaluesOfEachDiv.split(" ");
for(var i=0; i<IDlist.length; i++) { HideContent(IDlist[i]); }
ShowContent(d);
}
</script>


I would like to be able to have the code dynamiclly get all the slugs of the custom post type ("works") instead of manually having to enter them in like I have done above (baby-g-jp nasty-gal zara target burger-king vans club-monaco hermes la-mer assouline levis chevrolet converse strange-love)


If anyone can offer some insight it would be greatly appreciated.





Aucun commentaire:

Enregistrer un commentaire