Should scripts in my widget run each time the presentation plays?

  • 1
  • Question
  • Updated 3 years ago
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Ray Durkin

Ray Durkin

  • 3,480 Points 3k badge 2x thumb
Hi Eli,

Can you provide a little more detail?  What widget are you talking about specifically and are the scripts custom html you added?
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
It is my own widget, and it is custom html that i added.
Photo of HSuarez


  • 11,896 Points 10k badge 2x thumb
If you like, you can also post the code here on Community and get feedback for it, or even find beta testers for the widget.
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
<!DOCTYPE html>
    <meta charset="utf-8" />
        body {
            width: 100%;
            height: 100%;
            margin: 0px;

        #myFrame {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            border: none;
            overflow: hidden;

    <script src="//"></script>
    <script src=""></script>
    <!-- This is the frame we're going to load our content into. That's it for the HTML. One frame. -->
    <iframe id="myFrame" frameborder="0" scrolling="no"></iframe>

    <script type="text/javascript">
		// Helpful to know you have the latest version
		console.log("Version 0.1.0");
		// Start the loading spinner and get our prefs
	    var isLoading = true,
		prefs = new gadgets.Prefs(),
		presentationId = prefs.getString("presentationId"),
		widgetId = prefs.getString("id"),
		displayId = "test",
		startTime = 0;"", "rsparam_get", null, widgetId, "displayId");
		gadgets.rpc.register("rsparam_set_" + widgetId, handler);

		function handler(name, value) {
			displayId = value;

			var url = "url to post to proof of play database";
			var data = "display=" + displayId + "&presentation=" + presentationId + "&startTime=" + startTime;
			$.post(url, data);
		// No Right-Clicky - No Laundry!!
		window.oncontextmenu = function() {return false;};

		$(document).ready(function() {
			// Doc is ready, so let's load our presentation into the iFrame.
			$("#myFrame").attr("src", ''+presentationId+'&showui=false').attr("width", prefs.getInt("rsW")).attr("height", prefs.getInt("rsH"));
			// Turn off the loading spinner
			if (isLoading) {
				isLoading = false;

		function readyEvent() {
			startTime =;
			// Tell the player that we have our content loaded and to unhide the iFrame."", "rsevent_ready", null, prefs.getString("id"), false, false, false, true, false);
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
It's a widget for proof of play that is supposed to post data about the presentation every time it plays so there is a log to show customers when there content played and on which display.
Photo of Stuart Lees

Stuart Lees, Employee

  • 586 Points 500 badge 2x thumb
Hi Eli,

Your Widget will be loaded into an <iframe> which Viewer does when initializing the presentation. All your scripts and code will be executed upon the Widget being loaded. It is the Widgets responsibility to notify Viewer that it is ready. Beyond that, your scripts will not be run again, however Viewer will tell the Widget to play, pause, and stop during its rotation of content in your placeholder and potential multiple presentations. Your Widget can register for these events and provide logic on what it should do in these situations.

See and also for more information.