Advertisement
Guest User

Untitled

a guest
May 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. $(function() {
  2. // console.log('load');
  3. //debug at browser
  4. play();
  5. });
  6.  
  7. /* These are JavaScript commands that can be called throught the AMCP interface
  8. Command examples are based on the assumption that demo.html is running on channel 1-1
  9. I.e. PLAY 1-1 DEMO
  10. */
  11.  
  12. // CALL 1-1 PLAY
  13. function play() {
  14. console.log('play');
  15. document.getElementById("demo").innerHTML="play";
  16.  
  17. //check if we have included template-specific function from another file
  18. if (typeof templatePlay == 'function') {
  19. templatePlay();
  20. }
  21. }
  22. // CALL 1-1 STOP
  23. function stop() {
  24.  
  25. document.getElementById("demo").innerHTML="stop";
  26. //check if we have included template-specific function from another file
  27. if (typeof templateStop == 'function') {
  28. templateStop();
  29. }
  30. }
  31.  
  32.  
  33. function update(xml) {
  34. console.log('update1');
  35.  
  36. if ( settings.showFieldNames != true) {
  37. // check in what page we are, so we can use correct settings
  38. var pageName = location.href.split("/").slice(-1)[0].split(".")[0].toLowerCase();
  39. console.log(pageName);
  40.  
  41. var settingsFields = settings[pageName]; //get object contains this pages fields
  42.  
  43. var parser = new DOMParser();
  44. var valueList = parser.parseFromString(xml, "text/xml");
  45.  
  46. //f0 = valueList.evaluate("/templateData/componentData[@id='f0']/data/@value", valueList, null, XPathResult.STRING_TYPE, null).stringValue;
  47.  
  48. for (i = 0; i < Object.keys(settingsFields).length; i++) {
  49. // ### check if div exists
  50. var fieldName = "f" + i;
  51. if (document.getElementById(fieldName) !=null) {
  52. // check if we have value from client, if not, use from settings
  53. var searchString = "/templateData/componentData[@id='f" + i + "']/data/@value";
  54. fieldFromClient = valueList.evaluate(searchString, valueList, null, XPathResult.STRING_TYPE, null).stringValue;
  55.  
  56. if (fieldFromClient != ""){
  57. document.getElementById(fieldName).innerHTML=fieldFromClient;
  58. }
  59. else {
  60. document.getElementById(fieldName).innerHTML=settingsFields[fieldName];
  61. }
  62. }
  63. }
  64. }
  65. // else leave fields as is
  66.  
  67. if (typeof templateUpdate == 'function') {
  68. templateUpdate();
  69. }
  70. }
  71.  
  72.  
  73. // CALL 1-1 NEXT
  74. function next() {
  75.  
  76. document.getElementById("demo").innerHTML="next";
  77.  
  78. if (typeof templateNext == 'function') {
  79. templateNext();
  80. }
  81. }
  82. // CALL 1-1 REMOVE
  83. function remove() {
  84. document.getElementById("demo").innerHTML="remove";
  85. }
  86.  
  87. // CALL 1-1 INVOKE STRING
  88. function invoke(str) {
  89. eval(str);
  90. }
  91. // CALL 1-1 INVOKE "otherFunction('testing');"
  92. function otherFunction(str) {
  93. document.getElementById("demo").innerHTML="Other function called with: " + str;
  94. }
  95.  
  96. // Send a log message to CasparCG
  97. //console.log('This message will end up in CCG logs');
  98. //alert('Alerts do also'); /* Alerts also end up in CCG logs */
  99.  
  100. // Call a function in CCG through JS
  101. if(!window.AMCP) {AMCP = function(str){ console.log(str); };} /* This creates a dummy window.AMCP function so testing in regular browsers doesn't throw an error */
  102. //window.AMCP('This is a AMCP log message from a HTML template');
  103.  
  104. // Define onEnterFrame() to minimize errors in CCG logs
  105. function onEnterFrame() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement