Let's start using jQuery and replace:

    document.addEventListener( 'DOMContentLoaded', function () { xxx } );

with:

    $( function () { xxx } );

And `document.getElementById( 'logout-form' )` with `$( '#logout-form' )`