0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-21 21:48:21 -05:00

Add comments and docstrings to the code

This commit is contained in:
alamin655 2023-07-07 20:05:55 +05:30 committed by GitHub
parent 09d9573c55
commit 6bc06a34f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,26 @@
// This function is executed when any page on the website finishes loading and /**
// this function retrieves the cookies if it is present on the user's machine. * This function is executed when any page on the website finishes loading and
// If it is available then the saved cookies is display in the cookies tab * this function retrieves the cookies if it is present on the user's machine.
// otherwise an appropriate message is displayed if it is not available. * If it is available then the saved cookies is display in the cookies tab
* otherwise an appropriate message is displayed if it is not available.
*
* @function
* @listens DOMContentLoaded
* @returns {void}
*/
document.addEventListener( document.addEventListener(
'DOMContentLoaded', 'DOMContentLoaded',
() => { () => {
try { try {
// Decode the cookie value
let cookie = decodeURIComponent(document.cookie) let cookie = decodeURIComponent(document.cookie)
// Set the value of the input field to the decoded cookie value if it is not empty
// Otherwise, display a message indicating that no cookies have been saved on the user's system
document.querySelector('.cookies input').value = document.querySelector('.cookies input').value =
cookie !== '' ? cookie : 'No cookies have been saved on your system' cookie !== '' ? cookie : 'No cookies have been saved on your system'
} catch (error) { } catch (error) {
// If there is an error decoding the cookie, log the error to the console
// and display an error message in the input field
console.error('Error decoding cookie:', error) console.error('Error decoding cookie:', error)
document.querySelector('.cookies input').value = 'Error decoding cookie' document.querySelector('.cookies input').value = 'Error decoding cookie'
} }