One More Time - Special Jury Award Winner


Adding the code and displaying it from the CloudPages:

  1. Login to the Marketing Cloud instance

  2. Navigate to Cloud Pages and click Create Collection. alt

  3. Name the Collection: alt

  4. Hover over the collection and click Open Collection. alt

  5. Click Create and select Landing Page in the next window alt

  6. Enter the Name for the Landing Page and click Next in the Pop-up window: alt

  7. In the next step, select any layout (Blank should work for us) and click Create: alt

  8. In the Editor page, ensure the Code View is selected and on the left – Code Editor, replace all the lines with the following Code Snippet: alt

    Snippet

    <script runat="server">for(Platform.Load("core","1"),a="Music's got me|and dance|so free|One more time|We're gonna|Come on|do it|too late|Celebrate|You|know|feeling|stop|yeah|Don't|Oh|the|right|all|dancing|Celebration|Need|tonight|Mmm|Just|no|We|can't|know I'm|wait|Hey!|,|<br>".split("|"),b="D~aDaaDa~EIaPN~SRaOMQTaDa~aOMQTaDaaXJ]YLaUWaIaO^HaXZa[OMaJ\\MaEIaDaDaDaUaJKEGRWa_YLaALQVaVNaFSRaEIaDaIBCaALCaIBCa~DaALCaEI~aIBC~a".split("~"),c="0121~323~12321~41~5675~71~5674~571~5672~71~5674".split("~"),d="a_J",f=e="",i=65;i<99;)e+=String.fromCharCode(i++);for(k in c)for(g=c[k],h=g.slice(-1),g=g.slice(0,-1),i=0;i<h;i++)f+=g.replace(/\d/g,function(a){return b[a]});for(k=0;k<384;)q=a[e.indexOf(f[k])],Write(!k&&q||k&&d.indexOf(f[k-1])>-1?q:q.toLowerCase()),++k<384&&"`"!=f[k]&&Write(" ")</script>
    
  9. Click Save and then Schedule/Publish: alt

  10. Ensure Publish Immediately checkbox is checked and click Publish alt

  11. Upon Successful publish, click on the link generated in the middle of the header section: alt

The One More Time lyrics will be displayed!

Formatted Code:

The above code snippet is the minified version of the following code:

    Platform.Load("core", "1");
    SongString = "Music's got me|and dance|so free|One more time|We're gonna|Come on|do it|too late|Celebrate|You|know|feeling|stop|yeah|Don't|Oh|the|right|all|dancing|Celebration|Need|tonight|Mmm|Just|no|We|can't|know I'm|wait|Hey!|,|<br>".split("|");
    SongStringAsciified = "D~aDaaDa~EIaPN~`SRaOMQTaDa~aOMQTaDaaX`J]YLaUWaIaO^HaX`Za[OMaJ\\MaEIaDaDaDaUaJKEGR`Wa_YLaALQVaV`NaF`SRaEIaDaIBCaALCaIBCa~DaALCaEI~aIBC~a".split("~");
    SongStringCode = "0121~323~12321~41~5675~71~5674~571~5672~71~5674".split("~");
    ruleExclusion = "a_J";
    f = ASCIIChars = "";
    for (i = 65; i < 99;) 
        ASCIIChars += String.fromCharCode(i++);
    for (k in SongStringCode) {
        g = SongStringCode[k];
        h = g.slice(-1)
        g = g.slice(0, -1);
        for (i = 0; i < h; i++) {
            f += g.replace(/\d/g, function(a) {
                return SongStringAsciified[a]
            });
        }
    }
 
    for (k = 0; k < 384;) {
        q = SongString[ASCIIChars.indexOf(f[k])]
        Write(!k && q || k && ruleExclusion.indexOf(f[k - 1]) > -1 ? q : q.toLowerCase())
        ++k < 384 && "`" != f[k] && Write(" ")
    }
</script>

Pre-works:

Stage 1:

Analyze the song lyric to find:

  1. Unique strings.
  2. Strings that occur together.
  3. Count of phrases that repeat.

I used this tool to analyze: https://www.online-utility.org/text/analyzer.jsp

Stage 2:

Manually identified the rules that are unique and differentiating:

  1. All first rows start with Capital Letters.
  2. Capital letters after certain punctuation marks, but not all (like exclamation mark ‘!’).
  3. Capital letters in the middle – for the character ‘I’.

Stage 3:

Assign the single unique character for the repeating phrases to reduce the total character length for the SSJS Script. I used ASCII Characters that between 65-99.

Code Explanation:

Above three stages are the reflection of line 3 through 6. Notice all the values are arrays – string with split function.

_Line 3: _Unique phrases.

_Line 4: _ASCII Characters for each phrase in line 3.

Example:
ASCII CharacterPhrase
AMusic's got me
Band dance
Cso free
DOne more time
EWe're gonna
Character SequencePhrase Combination
DOne more time
aDaaDaOne more time

One more time
EIaPNWe're gonna celebrate
Oh yeah, all right

_Line 5: _Algorithm to generate number of times the ASCII Code repeats.

For example: ASCII Converted String would be like this:

DaDaaDaEIaPNSRaOMQTaDaEIaPNSRaOMQTaDaEIaPN…

See number of times a sequence is repeated:

D aDaaDa EIaPNSRaOMQTaDa EIaPN SRaOMQTaDa EIaPN …

Here,

  • D occurs once.
  • aDaaDa occurs once.
  • EIaPN occurs thrice.
  • `SRaOMQTaDa occurs twice.

Similarly, a specific sequence keeps occurring multiple times. In order to, reduce the repetitive sequence, a number is allocated for each recurring sequence, resultant would be:

IndexSequence
0D
1aDaaDa
2EIaPN
3`SRaOMQTaDa
4aOMQTaDaaX`J]YLaUWaIaO^HaX`Za[OMaJ\\MaEIaDaDaDaUaJKEGR`Wa_YLaALQVaV`NaF`SRaEIaDaIBCaALCaIBCa
5DaALCaEI
6aIBC
7a

Now, the recurring sequence algorithm is be built and the last character is considered as count:

Explanation for this: 0121~323~12321~41~5675~71~5674~571~5672~71~5674

SequenceRepetition count
0121
323
12321
41
5675
71
571
5674
571
5672
71
5674

Line 8 and 9 is to build the ASCII Characters.

Line 10 thru 19 is to unscramble the logic that we discussed above. Practically, it is all about replacing the numbers with the characters and then characters with the phrases of the song lyrics.

Line 21 thru 25 is to print the song lyrics. Additional logic handled here is where to capitalize the characters and where to proceed with the lowercase. Since the capitalization of the letter is handled based on the upcoming and previous word/string/character, the incremental operation is handled inside the looping structure.

All Rights Reserved
Made with by your fellow SFMC users.
All Rights Reserved
Made with by your fellow SFMC users.