Originally Posted by
Wadson
Could you give an example script plse
Here's what I did. First put this near the beginning of your track code somewhere - I stuck it right before the </head> tag:
Code:
<script language="javascript">
<!--
var composers = new Array;
var lyricists = new Array;
var songwriters = new Array;
function collectCredit(name,role)
{
switch (role.toLowerCase())
{
case "composer":
var o = new Object();
o.name = name;
o.role = role;
composers.push(o);
break;
case "songwriter":
var o = new Object();
o.name = name;
o.role = role;
songwriters.push(o);
break;
case "lyricist":
var o = new Object();
o.name = name;
o.role = role;
lyricists.push(o);
break;
}
}
function displayCredits(type)
{
// Display the credits, then dump the arrays for the next track. Display composers.
// If there are none, display songwriters and lyricists
if (composers.length > 0)
{
var o;
for (o in composers)
document.write("<i>" + composers[o].name + " (Composer)&lt;/i><br>");
composers.length = 0;
}
else
{
if (songwriters.length > 0)
{
var o1;
for (o1 in songwriters)
document.write("<i>" + songwriters[o1].name + " (Songwriter)&lt;/i><br>");
songwriters.length = 0;
}
if (lyricists.length > 0)
{
var o2;
for (o2 in lyricists)
document.write("<i>" + lyricists[o2].name + " (Lyrics)&lt;/i><br>");
lyricists.length = 0;
}
}
}
-->
</script>
collectCredit builds arrays of credits. I was interested in three particular sorts of credits; it should be pretty obvious how to modify it for different credits.
displayCredits displays them. The reason I broke the two operations apart was part aesthetic: I wanted all the composers together, or all the songwriters, etc. The other part was that I wanted to display songwriters and lyricists only if there were no composers. This is a purely arbitary choice based on my approach, and you could easily change the logic here, too.
Then use this or something like it to call the code:
Code:
<dax:if(trackartist)>
<i>(<dax:trackartist/>)</i>
<dax:else>
<dax:author>
<script language="javascript">
<!--
collectCredit("<dax:authorname/>","<dax:authorrole/>");
-->
</script>
</dax:author>
<script language="javascript">
<!--
displayCredits();
-->
</script>
</dax:if>
Nothing too complex going on here. If there's an artist I display that entry and don't bother with the rest of it. If not, then I extract and display the other information. The <dax:author> tag is an iterator, as Andrei explained earlier. It's what lets me collect the information.
Doubtless this could be improved, but it runs in reasonable time for me and doesn't crash OCD, which is what I look for in a theme.
One improvement: if you don't like italics replace the <i> and </i> tags with <span class=xxxx> and </span> tags in the emitted code - the part inside the document.write call. Then define a style for xxxx using either the <style> tag or the CSS page in your theme. If you do it that way, someone could come along later and write a compatible external stylesheet to change it - see the 'Stylesheet' entry in the 'Theme' sheet of the 'Customize View' page. Get that page from the context menu most everywhere.
Hope that's useful to you.