Skip to content

Commit

Permalink
Replace inline onclick with addEventListener inside .js file to be co…
Browse files Browse the repository at this point in the history
…mpatible with CSP

Signed-off-by: Orazio <22700499+orazioedoardo@users.noreply.github.com>
  • Loading branch information
orazioedoardo committed Aug 11, 2024
1 parent 4df2d1d commit 56c3878
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions scripts/pi-hole/js/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document.addEventListener("DOMContentLoaded", () => {
logout_button = document.getElementById("logout-button");

Check failure on line 2 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

Identifier 'logout_button' is not in camel case.

Check failure on line 2 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

Global variable leak, declare the variable if it is intended to be local.

Check failure on line 2 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

'logout_button' is not defined.
logout_button.addEventListener("click", () => {

Check failure on line 3 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

Identifier 'logout_button' is not in camel case.

Check failure on line 3 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

'logout_button' is not defined.
utils.doLogout();

Check failure on line 4 in scripts/pi-hole/js/logout.js

View workflow job for this annotation

GitHub Actions / Node

'utils' is not defined.
});
});
3 changes: 2 additions & 1 deletion scripts/pi-hole/lua/header_authenticated.lp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
]]--
mg.include('header.lp','r')
?>
<script src="<?=pihole.fileversion('scripts/pi-hole/js/logout.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/vendor/select2.min.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/vendor/datatables.min.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/vendor/datatables.select.min.js')?>"></script>
Expand Down Expand Up @@ -85,7 +86,7 @@ mg.include('header.lp','r')
<a class="btn-link" href="https://github.com/pi-hole" rel="noopener" target="_blank"><i class="fa-fw menu-icon fab fa-github"></i> GitHub</a>
<a class="btn-link" href="https://discourse.pi-hole.net/c/announcements/5" rel="noopener" target="_blank"><i class="fa-fw menu-icon fa-solid fa-rocket"></i> Pi-hole Releases</a>
<? if pihole.needLogin() then ?>
<a class="btn-link" href="#" onclick="utils.doLogout();"><i class="fa-fw menu-icon fa-solid fa-arrow-right-from-bracket"></i> Log out</a>
<a class="btn-link" href="#" id="logout-button"><i class="fa-fw menu-icon fa-solid fa-arrow-right-from-bracket"></i> Log out</a>
<? end ?>
</li>
</ul>
Expand Down

0 comments on commit 56c3878

Please sign in to comment.