Details

    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      A curious JavaScript error comes up when I load the page with the either format. It doesn't stop the format working, but might be worth a look. I'm using Firefox under Windows. IE throws a similar error around the same place (hard to tell with IE).

      uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost/moodle/course/view.php?id=2 :: <TOP_LEVEL> :: line 269" data: no] Line 0

      Line 269 is...

      set_number_of_toggles(3);set_current_week(1);document.getElementsByTagName("body")[0].addEventListener("load",reload_toggles(),false);document.getElementsByTagName("body")[0].addEventListener("unload",save_toggles(),false);

      ...and the surrounding HTML looks like...

      <p class="message">Nothing new since your last login</p></div></div><script type="text/javascript">
      //<![CDATA[
      elementCookieHide("inst14","Show Recent Activity block","Hide Recent Activity block");
      //]]>
      </script><span id="sb-9" class="skip-block-to"></span></div></td></tr></table> <script type="text/javascript" defer="defer"> // Defer running of the script until all HMTL has been passed.
      //<![CDATA[
      set_number_of_toggles(3);set_current_week(1);document.getElementsByTagName("body")[0].addEventListener("load",reload_toggles(),false);document.getElementsByTagName("body")[0].addEventListener("unload",save_toggles(),false);//]]>
      </script>
      </div>

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            gb2048 Gareth J Barnard added a comment -

            Possible solution in format.php at the top & bottom - old code commented out for reference in this case:

            top:
            // For persistence of toggles.
            require_js(array('yui_yahoo', 'yui_cookie', 'yui_event'));

            bottom:
            //<![CDATA[
            <?php
            echo 'set_number_of_toggles('.$course->numsections.');'; // Tell JavaScript how many Toggles to reset.
            echo 'set_current_week('.$theweek.');'; // Ensure that the current week is always open.
            // Restore the state of the toggles from the cookie if not in 'Show week x' mode, otherwise show that week.
            if ($displaysection == 0)

            { //echo 'document.getElementsByTagName("body")[0].addEventListener("load",reload_toggles,false);'; echo 'YAHOO.util.Event.onDOMReady(reload_toggles);'; }

            else

            { echo 'show_week('.$displaysection.');'; }

            // Save the state of the toggles when the page unloads. This is a stopgap as toggle state is saved every time they change. This is because there is no
            // 'refresh' event yet which would be the best implementation.
            //echo 'document.getElementsByTagName("body")[0].addEventListener("unload",save_toggles,false);';

            ?>
            //]]>

            Show
            gb2048 Gareth J Barnard added a comment - Possible solution in format.php at the top & bottom - old code commented out for reference in this case: top: // For persistence of toggles. require_js(array('yui_yahoo', 'yui_cookie', 'yui_event')); bottom: //<![CDATA[ <?php echo 'set_number_of_toggles('.$course->numsections.');'; // Tell JavaScript how many Toggles to reset. echo 'set_current_week('.$theweek.');'; // Ensure that the current week is always open. // Restore the state of the toggles from the cookie if not in 'Show week x' mode, otherwise show that week. if ($displaysection == 0) { //echo 'document.getElementsByTagName("body")[0].addEventListener("load",reload_toggles,false);'; echo 'YAHOO.util.Event.onDOMReady(reload_toggles);'; } else { echo 'show_week('.$displaysection.');'; } // Save the state of the toggles when the page unloads. This is a stopgap as toggle state is saved every time they change. This is because there is no // 'refresh' event yet which would be the best implementation. //echo 'document.getElementsByTagName("body") [0] .addEventListener("unload",save_toggles,false);'; ?> //]]>
            Hide
            gb2048 Gareth J Barnard added a comment -

            Fixed

            Show
            gb2048 Gareth J Barnard added a comment - Fixed

              People

              • Assignee:
                gb2048 Gareth J Barnard
                Reporter:
                gb2048 Gareth J Barnard
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  25/Nov/09