Simplistic JavaScript for HTML5 Templates

#1
Hi

Wanted to share a simple Javascript that can be inserted into and used with HTML Templates.
It's made specifically for use with CasparCG Client.

Share and enjoy
7omas


Using the original XML method:
CasparCG.js

Code: Select all

/*
*	Data sent from CasparCG Client as templateData
*	is pushed into corresponding HTML id element
*
*	Usage:
*	insert a script reference in the HTML template header.
*	ex: <script type="text/javascript" src="CasparCG.js"></script>
*	Make sure that the id that you refer to is the innermost tag.
*	Everything within that tag id will be replaced by the value sent from CasparCG
*	
*	put together by Tomas Linden
*
*
	Structure of data sent from CasparCG:
	<templateData>
		<componentData id="#idCaspar#">
			<data id="text" value="#valCaspar#" />
		</componentData>
		:
		:
		<componentData id="#idCaspar#">
			<data id="text" value="#valCaspar#" />
		</componentData>
	</templateData>
*/
// Global variable for data from CasparCG
var dataCaspar = {};


// Replace characters that could become a problem if left as is
function escapeHtml(unsafe) {
	return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}


// Parse templateData into an XML object
function parseCaspar(str)	{
	var xmlDoc;
	if (window.DOMParser)	{
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(str,"text/xml");
	}
	dataCaspar = XML2JSON(xmlDoc.documentElement.childNodes);
}


// Make the XML templateData message into a more simple key:value object
function XML2JSON(node)	{
	var data = {};	// resulting object
	for (k=0;k<node.length;k++)	{
		var idCaspar = node[k].getAttribute("id");
		var valCaspar = node[k].childNodes[0].getAttribute("value");
		if ( idCaspar != undefined && valCaspar != undefined)	{ data[idCaspar] = valCaspar; };
	}
	return data;
}


// Main function to insert data
function dataInsert(dataCaspar)	{
	for (var idCaspar in dataCaspar) {
		var idTemplate = document.getElementById(idCaspar);
		if (idTemplate != undefined)	{ idTemplate.innerHTML = escapeHtml(dataCaspar[idCaspar]); }
	}
}


// insert data from CasparCg client when activated
function play(str) {
	parseCaspar(str);	// Parse templateData into an XML object
	dataInsert(dataCaspar);	// Insert data
}


// Call for a stop from CasparCG client
function stop () {
  // insert here
}


// Call for a update of data from CasparCG client
function update(str) {
	parseCaspar(str);	// Parse templateData into an XML object
	dataInsert(dataCaspar);	// Insert data
}
CasparCG.html

Code: Select all

<!DOCTYPE html>
<html>
	<head>
		<title>HTML Template</title>
		<script type="text/javascript" src="CasparCG.js"></script>
		<style type="text/css">
			div {
				color: rgb(100, 100, 255);
				background: rgba(0, 0, 0, 0.5);
			}
		</style>
	</head>
	<body>
		<!-- The id determines what the key in CasparCG Client has to be -->
		<div id="f0">This text will be replaced</div>
	</body>
</html>
The following code use the added JSON-functionality in the 2.0.8 Client

Using JSON data method:
CasparCG.js

Code: Select all

/*
*   Data sent from CasparCG Client as JSON data
*   is pushed into corresponding HTML id element
*
*   Usage:
*   insert a script reference in the HTML template header.
*   ex: <script type="text/javascript" src="CasparCG.js"></script>
*   Make sure that the id that you refer to is the innermost tag
*   and that "send as JSON" has been checked in the client. (2.0.8)
*   Everything within that tag id will be replaced by the value sent from CasparCG
*   
*   put together by Tomas Linden
*
*
   Structure of data sent from CasparCG:
    {"#idCaspar":"#valCaspar#"}
*/
// Global variable for data from CasparCG
var dataCaspar = {};

// Replace characters that could become a problem if left as is
function escapeHtml(unsafe) {
   return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}

// Main function to insert data
function dataInsert(dataCaspar)   {
   for (var idCaspar in dataCaspar) {
      var idTemplate = document.getElementById(idCaspar);
      if (idTemplate != undefined)   { idTemplate.innerHTML = escapeHtml(dataCaspar[idCaspar]); }
   }
}

// Call for a update of data from CasparCG client
function update(str) {
   dataCaspar = JSON.parse(str || "null");
   dataInsert(dataCaspar);   // Insert data
}

function play() { console.log("Start sent");	}
function stop() { console.log("Stop sent");	}
2015-03-02 Added css to make the text more visible
2015-07-15 Added JSON-version
Last edited by 7omas on 15 Jul 2015, 21:06, edited 2 times in total.

Re: Simplistic JavaScript for HTML5 Templates

#5
The current implementation is using the Template-field in Inspector
of the CasparCG Client and that is always sent as XML (unless I missed something).
As balte said. It's made as a simple way for newcomers to get started.

I have requested to add a selection for "send as JSON" together with "Use stored data", "Use uppercase data" and "Trigger on next" on GitHub (Issue #138 for CasparCG Client)

Re: Simplistic JavaScript for HTML5 Templates

#9
This seems to be what I'm looking for, but I can't make it work. I am using the test files with no changes. Is there anything else I have to do apart from adding the html template in the client, giving f0 a new value and pressing F2/Play?

Here's what the server receives:

[2015-07-01 12:51:14.938] [09953B58] [info] Received message from 127.0.0.1: CG 1-20 ADD 0 "nyheter/CASPARCG" 1 "<templateData><componentData id=\"f0\"><data id=\"text\" value=\"hello world\"/></componentData></templateData>"\r\n

But the output still shows "This text will be replaced".

Re: Simplistic JavaScript for HTML5 Templates

#10
Da_Elf:

I don't know about the resources. I use Html because I understand how that works.

1up:

Strange. I've just tested it and it works as expected on my machine.
I just added another way to do it using JSON (see bottom of original post)
but that requires using the 2.0.8 Client that can be found at builds.casparcg.com

You have probably already checked this but I¨ll write it out just to make sure:
Both files must be in the same Template-directory and make sure the js-file is named correctly.

In the new JSON version there will be console logs sent when play and stop are sent,
this will tell you that the js-file (hopefully) has been correctly loaded.

Re: Simplistic JavaScript for HTML5 Templates

#12
Hi 7omas

I have been using your js files (the xml version) and I 'll trying to write data inside the span tag of f0, f1, f2 so forth. The reason is for having the great https://github.com/jquery-textfill/jquery-textfill enabled for resizing text, very useful for us brodacasters.
I am not so good with js, so could you help me ? My html should look like that:

Code: Select all

      <div id="f0"><span></span></div>
      <div id="f1"><span></span></div>
I 'm trying to modify the code for this in the "dataInsert" function. Is that the right place ?
With some other template, I 'm having success with jquery like this

Code: Select all

$('#mytextId span').html(mytext);
And I had success with your code with this, on this way:

Code: Select all

$("#" + idCaspar).html (escapeHtml(dataCaspar[idCaspar]));
Now it 's difficult to add the span tag to it. how do you think to be the best way to achieve ?

many tahanks in advance

Re: Simplistic JavaScript for HTML5 Templates

#14
Hi gray1st
Yes, the only way to use the resize features of the textfill library is using a child element, by default span, that's the use case. so I need to have my f0, f1.. data inside the span tag, like that

Code: Select all

<div id="f0"><span>Data needs to go here</span></div>
Have you tried using it without sending anything to the span element?
Yes, I have tried that but it puts outside the span tag and do not resize as expected.

Thanks

Re: Simplistic JavaScript for HTML5 Templates

#17
gray1st and hreinnbeck ,

many thanks, both options worked!

What really did the trick was the delay a lit bit before applying the textfill functions (it did not have time to analyse the size of the content and stretch text through font-size..). code as follow if someone is interested:

Code: Select all

function init() {
        $('#f0').textfill({
        debug: true,
        maxFontPixels: 80,
        minFontPixels: 10,
    });
  }

function init1() {
        $('#f1').textfill({
        debug: true,
        maxFontPixels: 85,
        minFontPixels: 10,
    });
}

setTimeout(func, 40);
function func() {
    $(init);
    $(init1);
}

Re: Simplistic JavaScript for HTML5 Templates

#18
Dear all,

as you know I'm new in using CCG. Now I want to start making my own test-templates. I was searching the forum and found this thread very interesting. I now created the two files (html and js) and placed them into the templates folder. I can add them using the client, but it seems that it doesn't work. Only the standard text is shown and not the text set using the variable. See attached image and logfile. Can you find the error or do you have any idea?

Code: Select all

[2016-01-12 18:32:00.050] [3240] [info]    ############################################################################
[2016-01-12 18:32:00.051] [3240] [info]    CasparCG Server is distributed by the Swedish Broadcasting Corporation (SVT)
[2016-01-12 18:32:00.051] [3240] [info]    under the GNU General Public License GPLv3 or higher.
[2016-01-12 18:32:00.051] [3240] [info]    Please see LICENSE.TXT for details.
[2016-01-12 18:32:00.051] [3240] [info]    http://www.casparcg.com/
[2016-01-12 18:32:00.051] [3240] [info]    ############################################################################
[2016-01-12 18:32:00.051] [3240] [info]    Starting CasparCG Video and Graphics Playout Server 2.0.7.e9fc25a Stable
[2016-01-12 18:32:00.051] [3240] [info]    on Windows 7 Professional 
[2016-01-12 18:32:00.051] [3240] [info]    Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz Physical Threads: 4
[2016-01-12 18:32:00.051] [3240] [info]    ESPRIMO P900
[2016-01-12 18:32:00.055] [3240] [info]    Decklink 10.5.4
[2016-01-12 18:32:00.056] [3240] [info]     - DeckLink 4K Extreme [1]
[2016-01-12 18:32:00.057] [3240] [info]    Bluefish Not found
[2016-01-12 18:32:00.057] [3240] [info]    FreeImage 3.15.4
[2016-01-12 18:32:00.057] [3240] [info]    FFMPEG-avcodec 55.52.102
[2016-01-12 18:32:00.057] [3240] [info]    FFMPEG-avformat 55.33.100
[2016-01-12 18:32:00.057] [3240] [info]    FFMPEG-avfilter 4.2.100
[2016-01-12 18:32:00.057] [3240] [info]    FFMPEG-avutil 52.66.100
[2016-01-12 18:32:00.057] [3240] [info]    FFMPEG-swscale 2.5.102
[2016-01-12 18:32:00.057] [3240] [info]    Flash 20.0.0.270
[2016-01-12 18:32:00.059] [3240] [info]    flash[cg20.fth.pal|0] Initialized.
[2016-01-12 18:32:00.059] [3240] [info]    flash[cg20.fth.pal|0] Invoking info-command: <invoke name="GetInfo" returntype="xml"><arguments></arguments></invoke>
[2016-01-12 18:32:00.118] [3228] [debug]   flash-player[cg20.fth.pal|1024x576] [command]      <invoke name="OnCommand" returntype="xml"><arguments><string>Command recieved @GetInfo@?@</string></arguments></invoke>
[2016-01-12 18:32:00.183] [3228] [info]    flash-player[cg20.fth.pal|1024x576] Initialized.
[2016-01-12 18:32:00.184] [3228] [debug]   flash-player[cg20.fth.pal|1024x576] [command]      <invoke name="OnCommand" returntype="xml"><arguments><string>Command recieved @GetInfo@?@</string></arguments></invoke>
[2016-01-12 18:32:00.260] [3240] [trace]   Template-Host 2.0.4.3803 RC
[2016-01-12 18:32:00.260] [3240] [info]    NewTek iVGA unavailable (Processing.AirSend.x86.dll)
[2016-01-12 18:32:00.260] [3240] [info]    casparcg.config:
-----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <paths>
      <media-path>media\</media-path>
      <log-path>log\</log-path>
      <data-path>data\</data-path>
      <template-path>templates\</template-path>
      <thumbnails-path>thumbnails\</thumbnails-path>
   </paths>
   <channels>
      <channel>
         <video-mode>1080i5000</video-mode>
         <consumers>
            <decklink>
               <device>1</device>
               <key-device>device + 1</key-device>
               <embedded-audio>true</embedded-audio>
               <channel-layout>stereo</channel-layout>
               <latency>normal</latency>
               <keyer>external</keyer>
               <key-only>false</key-only>
               <buffer-depth>4</buffer-depth>
               <custom-allocator>true</custom-allocator>
            </decklink>
         </consumers>
      </channel>
      <channel>
         <video-mode>PAL</video-mode>
         <consumers>
            <screen>
               <device>1</device>
            </screen>
         </consumers>
      </channel>
   </channels>
   <controllers>
      <tcp>
         <port>5250</port>
         <protocol>AMCP</protocol>
      </tcp>
   </controllers>
</configuration>
-----------------------------------------
[2016-01-12 18:32:00.260] [3240] [info]    Initialized html module.
[2016-01-12 18:32:00.261] [3240] [info]    Initializing OpenGL Device.
[2016-01-12 18:32:00.275] [4124] [info]    OpenGL 4.4.0 NVIDIA Corporation
[2016-01-12 18:32:00.275] [4124] [info]    Successfully initialized OpenGL Device.
[2016-01-12 18:32:00.279] [3240] [info]    Initialized ffmpeg module.
[2016-01-12 18:32:00.279] [3240] [info]    Initialized bluefish module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized decklink module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized oal module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized newtek module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized ogl module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized flash module.
[2016-01-12 18:32:00.280] [3240] [info]    Initialized image module.
[2016-01-12 18:32:00.282] [4124] [info]    [shader] Blend-modes are disabled.
[2016-01-12 18:32:00.283] [3240] [info]    video_channel[1|1080i5000] Successfully Initialized.
[2016-01-12 18:32:00.289] [3304] [info]    DeckLink 4K Extreme [1-1|1080i5000] Using custom allocator.
[2016-01-12 18:32:00.289] [3304] [info]    DeckLink 4K Extreme [1-1|1080i5000] Enabled embedded-audio.
[2016-01-12 18:32:00.289] [3304] [info]    DeckLink 4K Extreme [1-1|1080i5000] Disabled low-latency mode.
[2016-01-12 18:32:00.289] [3304] [info]    DeckLink 4K Extreme [1-1|1080i5000] Enabled external keyer.
[2016-01-12 18:32:00.303] [3304] [info]    DeckLink 4K Extreme [1-1|1080i5000] Reference signal: not detected.
[2016-01-12 18:32:00.362] [3240] [info]    DeckLink 4K Extreme [1-1|1080i5000] Successfully Initialized.
[2016-01-12 18:32:00.362] [3228] [info]    flash-player[cg20.fth.pal|1024x576] Uninitialized.
[2016-01-12 18:32:00.363] [4760] [info]    flash[cg20.fth.pal|5000] Uninitialized.
[2016-01-12 18:32:00.369] [4612] [info]    output[1] DeckLink 4K Extreme [1-1|1080i5000] Added.
[2016-01-12 18:32:00.371] [3240] [info]    video_channel[2|PAL] Successfully Initialized.
[2016-01-12 18:32:00.373] [3240] [info]    
+---------------+
| filter_buffer |default--[720x576 64:45 bgra]--auto-inserted scaler 1:default
|   (buffer)    |
+---------------+

                                                             +-------------------+
auto-inserted scaler 0:default--[720x576 64:45 bgra]--default| filter_buffersink |
                                                             |   (buffersink)    |
                                                             +-------------------+

                                                             +-----------------+
auto-inserted scaler 1:default--[720x576 64:45 gbrp]--default| Parsed_format_0 |default--[720x576 64:45 gbrp]--Parsed_yadif_1:default
                                                             |    (format)     |
                                                             +-----------------+

                                                      +----------------+
Parsed_format_0:default--[720x576 64:45 gbrp]--default| Parsed_yadif_1 |default--[720x576 64:45 gbrp]--auto-inserted scaler 0:default
                                                      |    (yadif)     |
                                                      +----------------+

                                                     +------------------------+
Parsed_yadif_1:default--[720x576 64:45 gbrp]--default| auto-inserted scaler 0 |default--[720x576 64:45 bgra]--filter_buffersink:default
                                                     |        (scale)         |
                                                     +------------------------+

                                                    +------------------------+
filter_buffer:default--[720x576 64:45 bgra]--default| auto-inserted scaler 1 |default--[720x576 64:45 gbrp]--Parsed_format_0:default
                                                    |        (scale)         |
                                                    +------------------------+


[2016-01-12 18:32:00.374] [3240] [info]    Screen consumer [2|PAL] Successfully Initialized.
[2016-01-12 18:32:00.403] [3808] [info]    Screen consumer [2|PAL] Successfully Initialized.
[2016-01-12 18:32:00.412] [2536] [info]    output[2] Screen consumer [2|PAL] Added.
[2016-01-12 18:32:00.412] [3240] [info]    Initialized channels.
[2016-01-12 18:32:00.413] [3240] [info]    Initialized thumbnail generator.
[2016-01-12 18:32:00.413] [3240] [info]    WinSock2 Initialized.
[2016-01-12 18:32:00.413] [3240] [info]    Listener successfully initialized
[2016-01-12 18:32:00.413] [3240] [info]    Initialized controllers.
[2016-01-12 18:32:00.413] [3240] [info]    Initialized osc.
[2016-01-12 18:32:00.413] [3240] [info]    Started initial media information retrieval.
[2016-01-12 18:32:00.825] [1976] [info]    Initial media information retrieval finished.
[2016-01-12 18:32:33.986] [840]  [info]    Accepted connection from 127.0.0.1 2
[2016-01-12 18:32:34.018] [840]  [info]    Received message from 127.0.0.1: VERSION SERVER\r\n
[2016-01-12 18:32:34.018] [2640] [debug]   Executed command: VersionCommand
[2016-01-12 18:32:34.018] [2640] [info]    Sent message to 127.0.0.1: 201 VERSION OK\r\n2.0.7.e9fc25a Stable\r\n
[2016-01-12 18:32:34.023] [840]  [info]    Received message from 127.0.0.1: INFO\r\n
[2016-01-12 18:32:34.023] [2640] [debug]   Executed command: InfoCommand
[2016-01-12 18:32:34.023] [2640] [info]    Sent message to 127.0.0.1: 200 INFO OK\r\n1 1080i5000 PLAYING\r\n2 PAL PLAYING\r\n\r\n
[2016-01-12 18:32:34.026] [840]  [info]    Received message from 127.0.0.1: CLS\r\n
[2016-01-12 18:32:34.029] [840]  [info]    Received message from 127.0.0.1: TLS\r\n
[2016-01-12 18:32:34.033] [840]  [info]    Received message from 127.0.0.1: DATA LIST\r\n
[2016-01-12 18:32:34.035] [2640] [debug]   Executed command: ClsCommand
[2016-01-12 18:32:34.035] [2640] [info]    Sent more than 512 bytes to 127.0.0.1
[2016-01-12 18:32:34.037] [840]  [info]    Received message from 127.0.0.1: THUMBNAIL LIST\r\n
[2016-01-12 18:32:34.045] [2640] [debug]   Executed command: TlsCommand
[2016-01-12 18:32:34.045] [2640] [info]    Sent more than 512 bytes to 127.0.0.1
[2016-01-12 18:32:34.045] [2640] [debug]   Executed command: DataCommand
[2016-01-12 18:32:34.045] [2640] [info]    Sent message to 127.0.0.1: 200 DATA LIST OK\r\n\r\n
[2016-01-12 18:32:34.053] [2640] [debug]   Executed command: ThumbnailCommand
[2016-01-12 18:32:34.053] [2640] [info]    Sent more than 512 bytes to 127.0.0.1
[2016-01-12 18:33:03.333] [840]  [info]    Received message from 127.0.0.1: CG 2-20 ADD 1 "CASPARCG" 1 "{\"f0\":\"This should be shown!\"}"\r\n
[2016-01-12 18:33:03.334] [4868] [info]    html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] Initialized.
[2016-01-12 18:33:03.335] [4868] [debug]   Executed command: CGCommand
[2016-01-12 18:33:03.336] [4868] [info]    Sent message to 127.0.0.1: 202 CG OK\r\n
[2016-01-12 18:35:15.293] [840]  [info]    Received message from 127.0.0.1: CG 2-20 ADD 1 "CASPARCG" 1 "{\"f0\":\"This should be shown!\"}"\r\n
[2016-01-12 18:35:15.294] [4868] [info]    html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] Initialized.
[2016-01-12 18:35:15.294] [4868] [debug]   Executed command: CGCommand
[2016-01-12 18:35:15.294] [4760] [warning] html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] window.requestAnimationFrame() never called. Animations might have been laggy
[2016-01-12 18:35:15.295] [4868] [info]    Sent message to 127.0.0.1: 202 CG OK\r\n
[2016-01-12 18:35:15.312] [4760] [info]    html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] Uninitialized.
[2016-01-12 18:36:05.310] [840]  [info]    Received message from 127.0.0.1: CG 2-20 STOP 1\r\n
[2016-01-12 18:36:05.311] [4868] [debug]   Executed command: CGCommand
[2016-01-12 18:36:05.311] [4868] [info]    Sent message to 127.0.0.1: 202 CG OK\r\n
[2016-01-12 18:42:09.847] [840]  [info]    Client 127.0.0.1 was disconnected
[2016-01-12 18:42:14.533] [2536] [info]    output[2] Screen consumer [2|PAL] Removed.
[2016-01-12 18:42:14.570] [2536] [info]    Screen consumer [2|PAL] Successfully Uninitialized.
[2016-01-12 18:42:18.211] [2328] [info]    DeckLink 4K Extreme [1-1|1080i5000] Scheduled playback has stopped.
[2016-01-12 18:42:18.232] [3304] [debug]   DeckLink 4K Extreme [1-1|1080i5000] allocated a total of 0 bytes and was called 0 times during playout
[2016-01-12 18:42:18.232] [3240] [info]    DeckLink 4K Extreme [1-1|1080i5000] Successfully Uninitialized.
[2016-01-12 18:42:18.233] [3240] [warning] html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] window.requestAnimationFrame() never called. Animations might have been laggy
[2016-01-12 18:42:18.234] [3240] [info]    html[C:\Program Files (x86)\CasparCG\CasparCG Server 2.0.7\templates\\CASPARCG.html] Uninitialized.
[2016-01-12 18:42:18.320] [3240] [info]    Uninitialized html module.
[2016-01-12 18:42:18.820] [3240] [info]    Successfully shutdown CasparCG Server.
Attachments
html_test_error.png
html_test_error.png (66.89 KiB) Viewed 9204 times

Re: Simplistic JavaScript for HTML5 Templates

#20
I've got a hard time figuring this out and I need help.

I want to be able to interact with my template, basically updating the text and trigger the animation out.

I've been testing with the code provided in the first post.

Here's what I've tried:

starting the template:

Code: Select all

CG 1-10 ADD 1 test/casparcg 1 "<templateData><componentData id=\"f0\"><data id=\"text\" value=\"Starting text\" /></componentData></templateData>
This works as expected.

Then update:

Code: Select all

CALL 1-10 update <templateData><componentData id=\"f0\"><data id=\"text\" value=\"Updated text\" /></componentData></templateData>
This also works as expected.

Then I tried to copy the update function an renamed it to "test"

Code: Select all

CALL 1-10 test <templateData><componentData id=\"f0\"><data id=\"text\" value=\"Test function\" /></componentData></templateData>
When I run this, nothing happens.

On all three events I get an OK from Caspar.
What am I doing wrong? Am I using the right commands?

Re: Simplistic JavaScript for HTML5 Templates

#22
didikunz wrote:Why would you want it to be renamed as test, if it runs with update? Why not leave it the way it works?
That was just for testing =) The point wasn't to rename a function, it was to be able to create other functions. Maybe I want to animate out CG using for example CALL 1-10 OUT

but since my CALL 1-10 test ... didn't work, how could I expect another function to work.

Since the UPDATE command worked, I wanted to use the same code for testing

But shouldn't the test function execute the same way the update function do?

Re: Simplistic JavaScript for HTML5 Templates

#23
update is some kind of build it (same as play, stop, next).

If you want to run a generic function, you need the invoke command.

Code: Select all

call 1-10 invoke "test('<templateData><componentData id=\"f0\"><data id=\"text\" value=\"Test function\" /></componentData></templateData>'"
You may need to fiddle a bit with the escaping, but then this should do the trick.

cheers
mcdikki
sublan.tv - Wir teilen Begeisterung

Re: Simplistic JavaScript for HTML5 Templates

#24
mcdikki wrote:update is some kind of build it (same as play, stop, next).

If you want to run a generic function, you need the invoke command.

Code: Select all

call 1-10 invoke "test('<templateData><componentData id=\"f0\"><data id=\"text\" value=\"Test function\" /></componentData></templateData>'"
You may need to fiddle a bit with the escaping, but then this should do the trick.

cheers
mcdikki
Awesome, thank you so much! This worked!