Changeset 36022 for main


Ignore:
Timestamp:
2022-01-21T13:19:40+13:00 (8 months ago)
Author:
davidb
Message:

Refined show-more for lyrics, where first verse/block is shown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/transform/pages/document.xsl

    r36018 r36022  
    309309           <b>Lyrics:</b>
    310310         </div>
     311         <gsf:div id="lyrics-first-block"/>
    311312         <div id="lyrics-div-show-more">
    312313           <div id="lyrics-div" style="display: none;">
     
    316317         
    317318         <gsf:script>
     319           function pretty_print_lyrics(lyrics) {
     320             pp_lyrics = lyrics.replace(/\\\\n/g,"⏎")
     321             pp_lyrics = pp_lyrics.replace(/⏎⏎/g,"&lt;hr class=\"verse-divider\"/&gt;")
     322             pp_lyrics = pp_lyrics.replace(/⏎/g," ⏎ ")
     323
     324         return pp_lyrics
     325         }
     326         
    318327           $( document ).ready(function() {
    319328             var lyrics = $('#lyrics').html();
    320329             lyrics = lyrics.replace(/\\\\n\\n/g,"⏎⏎")
    321              lyrics = lyrics.replace(/\\\\n/g,"⏎")
    322              lyrics = lyrics.replace(/⏎⏎/g,"&lt;hr class=\"verse-divider\"/&gt;")
    323              lyrics = lyrics.replace(/⏎/g," ⏎ ")
    324          
    325              $("#lyrics").html(lyrics)
     330
     331         var first_block_pos = lyrics.indexOf("⏎⏎")
     332         if (first_block_pos != -1) {
     333           var lyrics_first_block = lyrics.substring(0,first_block_pos)
     334           var lyrics_remaining   = lyrics.substring(first_block_pos)
     335         }
     336         else {
     337           var lyrics_first_block = ""
     338           var lyrics_remaining   = lyrics
     339         }
     340
     341             lyrics_first_block = pretty_print_lyrics(lyrics_first_block)
     342             lyrics_remaining = pretty_print_lyrics(lyrics_remaining)
     343         
     344             $("#lyrics-first-block").html(lyrics_first_block)
     345             $("#lyrics").html(lyrics_remaining)
     346         
    326347             $("#lyrics-div").show()
    327348
Note: See TracChangeset for help on using the changeset viewer.