One More Time - Special Jury Award Winner
Published on 04/07/2021
Login to the Marketing Cloud instance
Navigate to Cloud Pages and click Create Collection.
Name the Collection:
Hover over the collection and click Open Collection.
Click Create and select Landing Page in the next window
Enter the Name for the Landing Page and click Next in the Pop-up window:
In the next step, select any layout (Blank should work for us) and click Create:
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:
<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>
Click Save and then Schedule/Publish:
Ensure Publish Immediately checkbox is checked and click Publish
Upon Successful publish, click on the link generated in the middle of the header section:
The One More Time lyrics will be displayed!
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>
Analyze the song lyric to find:
I used this tool to analyze: https://www.online-utility.org/text/analyzer.jsp
Manually identified the rules that are unique and differentiating:
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.
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 Character | Phrase |
---|---|
A | Music's got me |
B | and dance |
C | so free |
D | One more time |
E | We're gonna |
… | … |
Character Sequence | Phrase Combination |
---|---|
D | One more time |
aDaaDa | One more time One more time |
EIaPN | We'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:
DaDaaDaEIaPN
SRaOMQTaDaEIaPNSRaOMQTaDaEIaPN…
See number of times a sequence is repeated:
D aDaaDa EIaPN
SRaOMQTaDa EIaPN SRaOMQTaDa EIaPN …
Here,
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:
Index | Sequence |
---|---|
0 | D |
1 | aDaaDa |
2 | EIaPN |
3 | `SRaOMQTaDa |
4 | aOMQTaDaaX`J]YLaUWaIaO^HaX`Za[OMaJ\\MaEIaDaDaDaUaJKEGR`Wa_YLaALQVaV`NaF`SRaEIaDaIBCaALCaIBCa |
5 | DaALCaEI |
6 | aIBC |
7 | a |
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
Sequence | Repetition count |
---|---|
012 | 1 |
32 | 3 |
1232 | 1 |
4 | 1 |
567 | 5 |
7 | 1 |
57 | 1 |
567 | 4 |
57 | 1 |
567 | 2 |
7 | 1 |
567 | 4 |
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.