Skip to content

Notifications

ChainedTears edited this page Nov 29, 2023 · 2 revisions

πŸ“£ Notifications Documentation

🌟 Introduction

The notifications module in DuckOS is responsible for displaying user notifications and maintaining a history of these notifications. Notifications serve to provide users with important information or alerts about system events. This documentation explains the structure of the notifications system and provides an overview of its functions.

πŸ”‘ Core Concepts

  1. notification and notifhistory Elements
    • The notification element represents the main notification display area.
    • The notifhistory element is a container for storing a history of past notifications.
  2. notificationClickFunction
    • notificationClickFunction is a variable that holds the function to be executed when the user clicks on a notification.
  3. hideTimeout
    • hideTimeout is a variable that stores the timeout for hiding a notification after a certain duration.

πŸ› οΈ Functions

  1. showNotification(title, message, clickFunction)
    • Displays a notification with the specified title and message.
    • Optionally takes a clickFunction parameter, which is executed when the user clicks on the notification.
    • Adds the notification to the history.
  2. hideNotification(event)
    • Hides the currently displayed notification with a sliding animation.
    • Optionally takes an event parameter to stop event propagation.
  3. executeNotificationFunction()
    • Executes the stored notification click function.
  4. clearHideTimeout()
    • Clears the timeout set for hiding the notification.
  5. setHideTimeout()
    • Sets a timeout for hiding the notification after a predefined duration (default is 3000 milliseconds).

πŸ“œ Notification History

Notifications are added to the notifhistory element, creating a record of past notifications. Each history item includes the title, message, and a "Remove" button for user interaction.

πŸ’‘ Example Usage

The provided code includes an example of displaying a notification after a certain delay. Developers can use the showNotification function to display custom notifications throughout the application.

// Example usage:
setTimeout(function() {
  showNotification("Welcome to DuckOS v6", "Feel free to explore the latest UI and all the exciting new features!");
}, 4500);

πŸŽ‰ Conclusion

The notifications module enhances user interaction by providing real-time feedback and important information. Developers can customize notifications and use them to inform users about system events, updates, or any other relevant information. The notification history feature allows users to review past notifications for reference.