manonamora

Notification Settings

Sep 2nd, 2022 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Settings to Toggle Notifications
  2. //Requires Chapel's Notify Macro
  3.  
  4. //Method 1: JavaScript + CSS
  5. //JavaScript
  6. var settingNoNotificationHandler = function () {
  7.     if (settings.notif) { // is true
  8.         $("html").addClass("nonotif");
  9.     }
  10.     else { // is false
  11.         $("html").removeClass("nonotif");
  12.     }
  13. };
  14. Setting.addToggle("notif", {
  15.     label : "<b>Disable Notification</b>",
  16.     default : false,
  17.     onInit   : settingNoNotificationHandler,
  18.     onChange : settingNoNotificationHandler
  19. });
  20.  
  21. //CSS
  22. html.nonotif #notify.open { display: none; }
  23.  
  24. //Method 2: JavaScript + <<if>> macro
  25. //JavaScript
  26. Setting.addToggle("notifications", {
  27.     label : "Enable Notification.",
  28.     default : true,
  29. });
  30. //Sugarcube
  31. <<if settings.notifications>><<notify 3s>>Notification active!<</notify>><</if>>
Tags: sugarcube
Advertisement
Add Comment
Please, Sign In to add comment