I am in the process of designing an interface for individuals who have no background in programming. My goal is to allow them to input certain details, and then be able to simply copy and paste the code to make everything function seamlessly.
Here is a sample of the configuration object I am using:
var initSocialShare = {
config: {
facebook: false,
linkedin: false,
twitter: false,
pocket: false,
copy: false
}
}
My objective is to display this content inside a text area like so:
document.querySelector('#shareButton-code').innerHTML +=
`<script>
var initSocialShare = {
config: {
facebook: ${obj},
linkedin: ${obj},
twitter: ${obj},
pocket: ${obj},
copy: ${obj}
}
}
${initButtons}
${showOverlay}
${copyText}
initButtons()
</script>`;
How can I showcase the results of the loop within the script:
for (var key in initSocialShare.config) {
// if (!initSocialShare.config.hasOwnProperty(key)) continue;
var obj = initSocialShare.config[key];
console.log(obj);
}
This section is part of my initialization method where I push the link to an array:
if(initSocialShare.config.facebook){
s.push( '"#" id="fs_facebook-btn" data-count="fb" onclick="window.open(\'https://www.facebook.com/sharer/sharer.php?u=' + u + "', '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0');return false\" title=\"Share on Facebook\"")
}
Therefore, when users copy the code, this particular segment must function correctly.