home *** CD-ROM | disk | FTP | other *** search
HTML Component | 2002-12-11 | 5.0 KB | 189 lines |
- <PUBLIC:COMPONENT lightWeight=true>
- <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="load()" />
- <PUBLIC:METHOD NAME="reload" />
- <PUBLIC:METHOD NAME="updateMedia" />
- <PUBLIC:METHOD NAME="scriptCommand" />
- <PUBLIC:METHOD NAME="edit" />
- <PUBLIC:METHOD NAME="synchronizedLyric" />
- <PUBLIC:ATTACH EVENT="onresize" ONEVENT="doresize()" />
- <PUBLIC:METHOD NAME="noData" />
-
- <SCRIPT LANGUAGE="JScript">
-
- function reload() { load(); }
-
- var oCurrentMedia = null;
- function load()
- {
- oCurrentMedia = null;
- var s = '<table width=368 class=pane border=0 cellpadding=0 cellspacing=0>';
-
- s += '<tr><td class=artist>' + L_LyricsTitle_Text + '</td></tr>';
- s += '<tr><td height=16><table width=368 border=0 cellpadding=0 cellspacing=0><td id=trackNameLyrics width=200 class=text></td><td class=textTitle align=right valign=top id=lyricsEditButton onbuttonclick="trackIt(\'TIN0\'); return oCurrentPage.edit(true);" style="behavior:url(barbutton.htc)" text="' + L_AddLyricsButton_Text + '"></td></tr></table></td></tr>';
- s += '<tr><td height=14 class=text id=lyricsHeader></td></tr>';
- s += '<tr><td height=10></td></tr>';
- s += '<tr><td valign=top id=lyricsArea><table height=100% border=0 cellpadding=0 cellspacing=0>';
-
- s += '<tr><td width=368 height=100% valign=top><span id=lyricsText class=text style="overflow-y: scroll; width: 368; height:100%"></span>';
- s += '<textarea id=lyricsTextEdit class=text style="display:none; width:100%;"></textarea></td></tr>';
-
- s += '</table></td></tr>';
- s += '<tr><td style="display:none" id=lyricsErrorArea></td></tr>';
- s += '</table>';
- element.innerHTML = s;
- }
-
- function doresize()
- {
- var el = element.document.all('lyricsArea'), iHeight;
- if (el)
- {
- iHeight = Math.max(element.document.body.clientHeight - getElementTop('lyricsArea'), 10);
- // element.document.all('lyricsText').style.height = iHeight;
- element.document.all('lyricsTextEdit').style.height = iHeight;
- el.style.height = iHeight;
- }
- }
-
- var fIsEditing = false;
- var fHasSynchronizedLyrics = false;
- function updateMedia(media)
- {
- var c, s = '', a = element.document.all, oButton;
-
- fHasSynchronizedLyrics = false;
-
- doresize();
- if (fIsEditing) doSave(oCurrentMedia);
- a('lyricsText').style.display = 'block';
- a('lyricsTextEdit').style.display = 'none';
- fIsEditing = false;
-
- SetArtistAlbumHeader('lyricsHeader', true, true, false);
- a('trackNameLyrics').innerText = a('trackNameSaved').innerText;
- oButton = a('lyricsEditButton');
-
- a('lyricsArea').style.display = 'inline';
- a('lyricsErrorArea').style.display = 'none';
-
- if (media)
- {
- if (isCD(media))
- {
- var oDL = element.document.all('dataload');
- oDL.setNoData(L_NoLyricsForCDError_Text, 'images\\album-review.gif', false);
- }
-
- s = media.getItemInfo('WM/Lyrics');
- if (!s.length)
- {
- var iCount = media.getAttributeCountByType("WM/Lyrics_Synchronised", "");
- if (iCount > 0)
- {
- fHasSynchronizedLyrics = true;
- }
- else
- {
- s = L_NoLyrics_Text;
- oButton.text = L_AddLyricsButton_Text;
- }
- }
- else
- oButton.text = L_EditLyricsButton_Text;
-
- a('lyricsText').innerText = s;
- a('lyricsTextEdit').innerHTML = '';
- }
-
- if (fHasSynchronizedLyrics)
- {
- oButton.style.display = 'none';
- }
- else if (!media || media.isReadOnlyItem('WM/Lyrics'))
- {
- var oDL = a('dataload');
- if (media)
- oDL.setNoData(L_NoLyricsForReadOnlyError_Text, 'images\\album-review.gif', false);
- else
- oDL.setNoMedia();
- oButton.style.display = 'none';
- }
- else
- {
- oButton.style.display = 'inline';
- }
-
- oCurrentMedia = media;
- }
-
- function noData(sHTML)
- {
- var a = element.document.all;
- a('lyricsArea').style.display = 'none';
- a('lyricsErrorArea').style.display = 'inline';
- a('lyricsErrorArea').innerHTML = sHTML;
- a('lyricsEditButton').style.display = 'none';
- }
-
-
- function doSave(oMedia)
- {
- if (oMedia && !oMedia.isReadOnlyItem('WM/Lyrics'))
- oMedia.setItemInfo('WM/Lyrics', element.document.all('lyricsTextEdit').innerText);
- }
-
- function edit(fSave)
- {
- var lt, lte, ltb;
- lt = element.document.all('lyricsText');
- lte = element.document.all('lyricsTextEdit');
- ltb = element.document.all('lyricsEditButton');
- if (fIsEditing)
- {
- var p = element.document.all('player');
- var m = p.currentMedia;
-
- if (fSave)
- doSave(m);
-
- lt.style.display = 'block';
- lte.style.display = 'none';
- ltb.text = L_AddLyricsButton_Text;
- fIsEditing = false;
- updateUI();
- }
- else
- {
- lt.style.display = 'none';
- lte.style.display = 'block';
-
- if (lt.innerText == L_NoLyrics_Text)
- lte.innerText = '';
- else
- lte.innerText = lt.innerText;
- ltb.text = L_SaveLyricsButton_Text;
- fIsEditing = true;
- }
- return false;
- }
-
- function updateUI()
- {
- try
- {
- var p = element.document.all('player');
- var m = p.currentMedia;
- updateMedia(m);
- } catch(e)
- {
- }
- }
-
- function synchronizedLyric(sLyric)
- {
- if (fHasSynchronizedLyrics)
- element.document.all('lyricsText').innerText = sLyric;
- }
- </SCRIPT>
- </PUBLIC:COMPONENT>
-