wet-boew / wet-boew

Web Experience Toolkit (WET): Open source code library for building innovative websites that are accessible, usable, interoperable, mobile-friendly and multilingual. This collaborative open source project is led by the Government of Canada.

Home Page:https://wet-boew.github.io/wet-boew/index-en.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError

IceBane opened this issue · comments

We are getting the below error in our implementation:

Uncaught TypeError: g.indexOf is not a function
at HTMLDocument. (wet-boew.js:9816:7)
at HTMLDocument.dispatch (jquery.min.js:2:42571)
at v.handle (jquery.min.js:2:40572)
(anonymous) @ wet-boew.js:9816
dispatch @jquery.min.js:2
v.handle @jquery.min.js:2

here is the code at lines 9815-9818

confirm = function( event ) {
var elm = event.target,
$elm = $( elm ),
settings = $elm.data();

Any idea what might be causing this?

What version of WET and jquery?

I am going to assume this has to do with the session timeout, as that is what the js code shows for settings= $elem.data();

Post your settings array with the refreshCallBack: value

I think I know the problem, the javascript error is because it is expecting a function where it receives a value.

Change your refreshCallback setting to be an actual function, then in the function call your checkSessionValidity.

Try this:

        var settings = {
            inactivity: 1620000, // 27 mins
            reactionTime: 180000, // 3 mins
            sessionalive: 1620000, // 27 mins
            refreshCallbackUrl: "./keepAlive",
            logouturl: "./login",
            method: "GET",
            refreshCallback: function( response ) {
                checkSessionValidity( response );
            }
        };

Hi mercury64,

That's not it. Still getting same wet-boew.js error on line 9816:7

var elm = event.target

Would you have any other idea why the wet-boew.js file is puking?

Unfortunately I cannot reproduce your issue with wet 4.0.27 and jquery 3.4.1.
I'm using the demo session-en.html page for testing.

One thing, I'm not sure why it happens is my ./keepAlive page is returning "success", but includes a \n.
This is probably just my test environment.

This is the javascript at the end of the page that I am testing with:

<script>

    (function($, window, wb) {
        "use strict";
        $(document).on("wb-ready.wb", function(event) {
            var settings = {
                inactivity: 30000, // 27 mins
                reactionTime: 15000, // 3 mins
                sessionalive: 30000, // 27 mins
                refreshCallbackUrl: "./keepAlive",
                logouturl: "./login",
                method: "GET",
              refreshCallback: function( response ) {   /* callback function used to check the server response */
                    return checkSessionValidity( response );
                }
            }
            $(".wb-sessto").trigger("reset.wb-sessto", settings);
        });

        function checkSessionValidity(responseBody) {

            var str = responseBody.replace(/['"]+/g, "");
            str = str.toUpperCase();

            if (str == "SUCCESS\n") {
                return "true";
            } else {
                return "false";
            }
        }

    })(jQuery, window, wb);
</script>

Sorry, cannot reproduce your error.

Hi mercury64,

That's not it. Still getting same wet-boew.js error on line 9816:7

var elm = event.target

Would you have any other idea why the wet-boew.js file is puking?

You will have to debug in console setting break point at line 9815, 9816 and see what event.target is. This should be the modal pop up button click, maybe the default has been overridden by something else?

Screenshot 2024-05-14 at 09 01 13

What do I look for it I wanted to find this being overridden by something else like you mention?

What do I look for it I wanted to find this being overridden by something else like you mention?

Tough question. I would approach this using one or all of the following methods:

  1. simplify your problem page, remove elements(html, sections, divs, buttons, etc...) one by one and see if the issue resolves itself
  2. get the original demo of session-timeout.html working first, then add your custom javascript
  3. start with a working page(see # 2), then add your elements, see if/when the problem comes back
  • verify you don't have multiple versions of javascript
  • default WET 4.0.27 uses javascript 2.1.4, you are using 3.4.1
  • remove any other custom javascript that is not part of default WET

If you can, post a link to your page, or post the HTML here.

If you cut&paste html, use code formatting three backticks ``` and the key word html, and close with backticks ```

```html
<html>
  <head><title>Your Page</title></head>
  <body>
     ...
  </body>
</html>
```

Okay thanks. I will have to look at this again before our next release.