• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript to update variables works in Chrome and Edge, but not IE 11

Guest
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

So the client wants each slide to show the elapsed time and the total course duration (they don't want to use what's already displayed in the TOC because the TOC is hidden and they want the time info to always be visible).

 

So, I've implemented an advanced action that takes place upon entering each slide. Here is the javascript:

 

var frames = window.cpAPIInterface.getVariableValue("cpInfoFrameCount");
var speed = window.cpAPIInterface.getVariableValue("cpInfoFPS");
var start = window.cpAPIInterface.getVariableValue("cpInfoCurrentFrame");

frames = frames/speed;

var ss = frames.toFixed(0);

var convertSeconds = function(sec) {
   	var hrs = Math.floor(sec / 3600);
	var min = Math.floor((sec - (hrs * 3600)) / 60);
        var seconds = sec - (hrs * 3600) - (min * 60);
        seconds = Math.round(seconds * 100) / 100;

	seconds = String(seconds).padStart(2, '0');
           
        window.cpAPIInterface.setVariableValue("var_sec_duration",seconds);
        window.cpAPIInterface.setVariableValue("var_min_duration",min);
}

convertSeconds(ss);

start = start/speed;

var cur_ss = start.toFixed(0);

var set_cur_time = function(sec) {
   	var hrs = Math.floor(sec / 3600);
	var min = Math.floor((sec - (hrs * 3600)) / 60);
        var seconds = sec - (hrs * 3600) - (min * 60);
        seconds = Math.round(seconds * 100) / 100;

	seconds = String(seconds).padStart(2, '0');

        window.cpAPIInterface.setVariableValue("var_sec_elapsed",seconds);
        window.cpAPIInterface.setVariableValue("var_min_elapsed",min);
}

set_cur_time(cur_ss);

 

And then on the slide I display " $$var_min_elapsed$$:$$var_sec_elapsed$$ / $$var_min_duration$$:$$var_sec_duration$$ "

 

This works really well on both Chrome and Edge, but on IE 11, for some reason it just shows 0:0, no matter what slide you're on.

 

Any ideas re: what could be going wrong here?

TOPICS
Advanced , Advanced actions

Views

116

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 23, 2020 Dec 23, 2020

Copy link to clipboard

Copied

LATEST

It's some DOM jQuery messup in IE.

Have you tried to use $$cpInfoCurrentTime$$. Somthing like: Var timer = $$cpInfoCurrentTime$$ - ($$cpInfoCurrentTime$$ - 1 sec); 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources