LOLz - Nublet 101 - msg.template - i dont need no template node

When you know just enough html but not enough web based javascript to write it up nice in the template node.

function node to the rescue!

const video_URL = msg.video_URL;
const video_times = msg.video_times;
const video_uid = msg.video_uid;
var template = msg.template;
video_URL.forEach(function(url, index){
  template += '<div><center><b>' + video_times[index] + '</b></center><video id="' + video_uid[index] + '" width="300" controls preload="none" poster="' + url + '.thumb"><source src="' + url + '"type="video/mp4">Your browser does not support HTML5 video.</video><center><button class="button button1" onclick="setPlaySpeed(0.25,' + video_uid[index] + ')" type="button"><b>1/4</b></button><button class="button button1" onclick="setPlaySpeed(0.5,' + video_uid[index] + ')" type="button"><b>1/2</b></button><button class="button button2" onclick="setPlaySpeed(1,' + video_uid[index] + ')" type="button"><b>Normal</b></button><button class="button button1" onclick="setPlaySpeed(2,' + video_uid[index] + ')" type="button"><b>2x</b></button><button class="button button1" onclick="setPlaySpeed(4,' + video_uid[index] + ')" type="button"><b>4x</b></button><button class="button button1" onclick="setPlaySpeed(8,' + video_uid[index] + ')" type="button"><b>8x</b></button><button class="button button1" onclick="setPlaySpeed(16,' + video_uid[index] + ')" type="button"><b>16x</b></button><button class="button button1" onclick="setPlaySpeed(32,' + video_uid[index] + ')" type="button"><b>32x</b></button></center></div><p></p><p></p><p></p>';
});
template += '<script>'
video_uid.forEach(function(uid){
  template += 'var ' + uid + ' = document.getElementById("' + uid + '");';
});
template += 'function setPlaySpeed(speed,id) { id.playbackRate = speed; } </script> </body> </html>';

msg.template = template;

return msg;

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.