home *** CD-ROM | disk | FTP | other *** search
/ Minami 79 / MINAMI79.iso / Extra / MPSetup.exe / 1033 / RCDATA / CABINET / wmploc.DLL / HTML / LYRICS.HTC < prev    next >
Text File  |  2002-12-14  |  5KB  |  189 lines

  1. <PUBLIC:COMPONENT lightWeight=true>
  2. <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="load()" />
  3. <PUBLIC:METHOD NAME="reload" />
  4. <PUBLIC:METHOD NAME="updateMedia" />
  5. <PUBLIC:METHOD NAME="scriptCommand" />
  6. <PUBLIC:METHOD NAME="edit" />
  7. <PUBLIC:METHOD NAME="synchronizedLyric" />
  8. <PUBLIC:ATTACH EVENT="onresize" ONEVENT="doresize()" />
  9. <PUBLIC:METHOD NAME="noData" />
  10.  
  11. <SCRIPT LANGUAGE="JScript">
  12.  
  13. function reload() { load(); }
  14.  
  15. var oCurrentMedia = null;
  16. function load()
  17. {
  18.     oCurrentMedia = null;
  19.     var s = '<table width=368 class=pane border=0 cellpadding=0 cellspacing=0>';
  20.     
  21.     s += '<tr><td class=artist>' + L_LyricsTitle_Text + '</td></tr>';
  22.     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>';
  23.     s += '<tr><td height=14 class=text id=lyricsHeader></td></tr>';
  24.     s += '<tr><td height=10></td></tr>';
  25.     s += '<tr><td valign=top id=lyricsArea><table height=100% border=0 cellpadding=0 cellspacing=0>';
  26.  
  27.     s += '<tr><td width=368 height=100% valign=top><span id=lyricsText class=text style="overflow-y: scroll; width: 368; height:100%"></span>';
  28.     s += '<textarea id=lyricsTextEdit class=text style="display:none; width:100%;"></textarea></td></tr>';
  29.     
  30.     s += '</table></td></tr>';
  31.     s += '<tr><td style="display:none" id=lyricsErrorArea></td></tr>';
  32.     s += '</table>';
  33.     element.innerHTML = s;
  34. }
  35.  
  36. function doresize()
  37. {
  38.     var el = element.document.all('lyricsArea'), iHeight;
  39.     if (el)
  40.     {
  41.         iHeight = Math.max(element.document.body.clientHeight - getElementTop('lyricsArea'), 10);
  42. //        element.document.all('lyricsText').style.height = iHeight;
  43.         element.document.all('lyricsTextEdit').style.height = iHeight;
  44.         el.style.height = iHeight;
  45.     }
  46. }
  47.  
  48. var fIsEditing = false;
  49. var fHasSynchronizedLyrics = false;
  50. function updateMedia(media) 
  51. {
  52.     var c, s = '', a = element.document.all, oButton;
  53.  
  54.     fHasSynchronizedLyrics = false;
  55.  
  56.     doresize();
  57.     if (fIsEditing)    doSave(oCurrentMedia);
  58.     a('lyricsText').style.display = 'block';
  59.     a('lyricsTextEdit').style.display = 'none';
  60.     fIsEditing = false;
  61.     
  62.     SetArtistAlbumHeader('lyricsHeader', true, true, false);
  63.     a('trackNameLyrics').innerText = a('trackNameSaved').innerText;
  64.     oButton = a('lyricsEditButton');
  65.  
  66.     a('lyricsArea').style.display = 'inline';
  67.     a('lyricsErrorArea').style.display = 'none';
  68.  
  69.     if (media)
  70.     {
  71.         if (isCD(media))
  72.         {
  73.             var oDL = element.document.all('dataload');
  74.             oDL.setNoData(L_NoLyricsForCDError_Text, 'images\\album-review.gif', false);
  75.         }
  76.         
  77.         s = media.getItemInfo('WM/Lyrics');
  78.         if (!s.length)
  79.         {
  80.             var iCount = media.getAttributeCountByType("WM/Lyrics_Synchronised", "");
  81.             if (iCount > 0)
  82.             {
  83.                 fHasSynchronizedLyrics = true;
  84.             }
  85.             else
  86.             {
  87.                 s = L_NoLyrics_Text;
  88.                 oButton.text = L_AddLyricsButton_Text;
  89.             }
  90.         }
  91.         else
  92.             oButton.text = L_EditLyricsButton_Text;
  93.  
  94.         a('lyricsText').innerText = s;
  95.         a('lyricsTextEdit').innerHTML = '';
  96.     }
  97.  
  98.     if (fHasSynchronizedLyrics)
  99.     {
  100.         oButton.style.display = 'none';
  101.     }
  102.     else if (!media || media.isReadOnlyItem('WM/Lyrics'))
  103.     {
  104.         var oDL = a('dataload');
  105.         if (media)
  106.             oDL.setNoData(L_NoLyricsForReadOnlyError_Text, 'images\\album-review.gif', false);
  107.         else
  108.             oDL.setNoMedia();
  109.         oButton.style.display = 'none';
  110.     }
  111.     else
  112.     {
  113.         oButton.style.display = 'inline';
  114.     }
  115.     
  116.     oCurrentMedia = media;
  117. }
  118.  
  119. function noData(sHTML)
  120. {
  121.     var a = element.document.all;
  122.     a('lyricsArea').style.display = 'none';
  123.     a('lyricsErrorArea').style.display = 'inline';
  124.     a('lyricsErrorArea').innerHTML = sHTML;
  125.     a('lyricsEditButton').style.display = 'none';
  126. }
  127.  
  128.  
  129. function doSave(oMedia)
  130. {
  131.     if (oMedia && !oMedia.isReadOnlyItem('WM/Lyrics'))
  132.         oMedia.setItemInfo('WM/Lyrics', element.document.all('lyricsTextEdit').innerText);
  133. }
  134.  
  135. function edit(fSave)
  136. {
  137.     var lt, lte, ltb;
  138.     lt = element.document.all('lyricsText');
  139.     lte = element.document.all('lyricsTextEdit');
  140.     ltb = element.document.all('lyricsEditButton');
  141.     if (fIsEditing)
  142.     {
  143.         var p = element.document.all('player');
  144.         var m = p.currentMedia;
  145.         
  146.         if (fSave)
  147.             doSave(m);
  148.             
  149.         lt.style.display = 'block';
  150.         lte.style.display = 'none';
  151.         ltb.text = L_AddLyricsButton_Text;
  152.         fIsEditing = false;
  153.         updateUI();
  154.     }
  155.     else
  156.     {
  157.         lt.style.display = 'none';
  158.         lte.style.display = 'block';
  159.         
  160.         if (lt.innerText == L_NoLyrics_Text)
  161.             lte.innerText = '';
  162.         else
  163.             lte.innerText = lt.innerText;
  164.         ltb.text = L_SaveLyricsButton_Text;
  165.         fIsEditing = true;
  166.     }
  167.     return false;
  168. }
  169.  
  170. function updateUI()
  171. {
  172.     try
  173.     {
  174.         var p = element.document.all('player');
  175.         var m = p.currentMedia;
  176.         updateMedia(m);
  177.     } catch(e)
  178.     {
  179.     }
  180. }
  181.  
  182. function synchronizedLyric(sLyric)
  183. {
  184.     if (fHasSynchronizedLyrics)
  185.         element.document.all('lyricsText').innerText = sLyric;
  186. }
  187. </SCRIPT>
  188. </PUBLIC:COMPONENT>
  189.