Forum Discussion

JaceyLett-f2398's avatar
JaceyLett-f2398
Community Member
3 years ago

Javascript suddenly stopped working on Publish and Review 360

My JS worked fine while reviewing in 360, then suddenly stopped. Happened with my original publish file and further ones. I know the JS is being executed. I tested on my Desktop story file, and it does not work there either. Is this a SL glitch?  Thanks for anyone who can help. Code below: 

var player = GetPlayer();
var currentTime = new Date();
var hours = currentTime.getHours();
 
if (hours < 12)
 {
 player.SetVar("greeting","Good morning. Here are your learning objectives:")
 };
 if (hours >= 12 && hours <= 16)
 {
 player.SetVar("greeting","Good afternoon. Here are your learning objectives:")
 };
 if (hours > 17)
 {
 player.SetVar("greeting","Good evening. Here are your learning objectives:")
 };

  • Just as soon as I wrote that, it started working again. Forgot to mention that I checked the code, and no red flags in the console for this JS. I know support is not provided for JS issues, but do any of you coders on here know what could have happened that had nothing to do with SL, Me, the code, Review 360, nor my browsers (checked on Chrome and Edge)? My Articulate is completely updated, btw. Could it be updates (not Articulate updates) that played a hand in this? I'm at a loss. 

  • Hi Jacey,

    I have the same issue. Did you get a solution?

    I have a module that is running online for month. 
    Then I changed anything except of the Javascript:

    -----------

    function kopiereTextInZwischenablage() {
     
        var manuellEingefuegterText = "Ich habe folgendes Avaya-Problem:";

      
        var textBereich = document.createElement("textarea");
        textBereich.value = manuellEingefuegterText;
        document.body.appendChild(textBereich);

     
        textBereich.select();
        document.execCommand("copy");

     
        document.body.removeChild(textBereich);

       
        alert("Folgender Text wurde in den Speicher kopiert: \n\n" + manuellEingefuegterText + "\n\nFüge ihn in das linke Ticketfenster in das Feld BESCHREIBUNG ein mittels Strg + V." );
    }

    kopiereTextInZwischenablage();

    ---------

    Now the same code does not work in the entire file. I mean, I have 30 JS-codes, that all worked. I did not change them. Now all 30 are not working.

    Is it really frustrating as I put into it a lot of work. 

    • JaceyLett-f2398's avatar
      JaceyLett-f2398
      Community Member

      If the code is only failing in Review 360, then try Sebastien's idea of running it at .25 seconds instead of immediately at the start of the slide. Or, place the code further down to go after other code/triggers. That worked for me. :)

  • You have an extra } in your code remove it and the code will work, check the console 

  • Thank you very much for all your feedback. I just gave up and incidentally overwrote the SL-file. So I am building it up again and am checking after each modification if its working.

    • Nedim's avatar
      Nedim
      Community Member

      Your code is working just fine when published. 

  • So, I have found out the problem. In one of 30 javascripts there was a line break in a text. So beware of line breaks in text that is between " text  ".

    So this is correct:

    var manuellEingefuegterText = "Ich habe folgendes Avaya-Problem:";


    AND this would make stop the entire file working:

    var manuellEingefuegterText = "Ich habe folgendes
    Avaya-Problem:";