Created
August 26, 2015 09:44
-
-
Save markphi2013/7df861a591e49aa5fb38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processParticipant(participant) { | |
$('#simulator-profile').empty() | |
$("#simulator-profile").append(generateHtmlParticipant(participant)); | |
} | |
function generateHtmlParticipant(participant) { | |
var myTemplate = "<dl> <dt>"+ | |
"Phone: "+ | |
"PARTICIPANT_PHONE"+ | |
"</dt></dl>"+ | |
"<dl> <dt>"+ | |
"Last Optin Date: </br>       "+ | |
"PARTICIPANT_OPTIN_DATE"+ | |
"</dt></dl>"+ | |
"<dl> <dt>"+ | |
"Last Optout Date: </br>"+ | |
((participant['last-optout-date']) ? "<dl><dt>       "+ | |
moment(participant['last-optout-date']).format("DD/MM/YYYY HH:mm:ss")+ | |
"</dt></dl>" : " </dt></dl>" ) | |
/*(((participant['profile'].length) > 0) ? "<dl><dt>"+ | |
"Labels: "+ | |
"<?php ?> ": " </dt></dl>")+ | |
(((participant['tags'].length) > 0) ? "<dl><dt>"+ | |
"Tags: ": " </dt></dl>") | |
var profile = | |
*/ | |
myTemplate = myTemplate.replace('PARTICIPANT_PHONE', participant['phone']); | |
myTemplate = myTemplate.replace('PARTICIPANT_OPTIN_DATE', moment(participant['last-optin-date']).format("DD/MM/YYYY HH:mm:ss")); | |
return myTemplate; | |
} |
Author
markphi2013
commented
Aug 26, 2015
i want to add for loop inside my HTML myTemplate var
function generateHtmlParticipant(participant) {
var myTemplate = "<dl> <dt>"+
"Phone: "+
"PARTICIPANT_PHONE"+
"</dt></dl>"+
"<dl> <dt>"+
"Last Optin Date: </br>       "+
"PARTICIPANT_OPTIN_DATE"+
"</dt></dl>"+
"<dl> <dt>"+
"Last Optout Date: </br>"+
((participant['last-optout-date']) ? "<dl><dt>       "+
moment(participant['last-optout-date']).format("DD/MM/YYYY HH:mm:ss")+
"</dt></dl>" : " </dt></dl>" )+
(((participant['profile'].length) > 0) ? "<dl><dt>"+
"Labels: "+
((for(var i = 0; i < participant['profile'].length; i++)); do "<dl><dt>"+
"<div>       "+
participant['profile'][i]['label']+
": "+
participant['profile'][i]['value']+
"</div></dt></dl>") : " </dt></dl>")+
(((participant['tags'].length) > 0) ? "<dl><dt>"+
"Tags: ": " </dt></dl>")
myTemplate = myTemplate.replace('PARTICIPANT_PHONE', participant['phone']);
myTemplate = myTemplate.replace('PARTICIPANT_OPTIN_DATE', moment(participant['last-optin-date']).format("DD/MM/YYYY HH:mm:ss"));
return myTemplate;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment