1016
1016
d . getElementById ( 'loader' ) . style . display = 'none' ; // Hide the loader
1017
1017
d . getElementById ( 'content' ) . style . visibility = 'visible' ; // Show the content
1018
1018
d . getElementById ( 'today' ) . innerHTML = showDate ( ) ;
1019
+
1020
+ if ( 'serviceWorker' in navigator ) {
1021
+ try {
1022
+ navigator . serviceWorker
1023
+ . register ( '/project-kitten/sw.js?v=7' )
1024
+ . then ( registration => {
1025
+ console . log ( 'Service Worker registered with scope:' , registration . scope ) ;
1026
+ } )
1027
+ . catch ( error => {
1028
+ if ( error . message . includes ( "ServiceWorkerContainer.register: Script URL's scheme is not 'http' or 'https'" ) ) {
1029
+ return console . warn ( 'Service Worker registration error: Insecure context. Please use HTTPS or localhost.' , error ) ;
1030
+ }
1031
+ console . error ( 'Service Worker registration failed:' , error ) ;
1032
+ } ) ;
1033
+ } catch ( error ) {
1034
+ console . error ( 'Unexpected error during Service Worker registration:' , error ) ;
1035
+ }
1036
+ } else {
1037
+ console . log ( 'Service Workers are not supported in this browser.' ) ;
1038
+ }
1039
+
1040
+ scheduleMidnightRefresh ( ) ;
1019
1041
1020
1042
// events listeners
1021
1043
bg . addEventListener ( 'change' , bgChange ) ;
1025
1047
root . addEventListener ( 'mousemove' , throttle ( mouseMoveEvents , 16 ) ) ;
1026
1048
root . addEventListener ( 'mousedown' , mouseDownEvents ) ;
1027
1049
root . addEventListener ( 'mouseup' , mouseUpEvents ) ;
1050
+ w . addEventListener ( 'resize' , onResize ) ;
1051
+ w . dispatchEvent ( new Event ( 'resize' ) ) ;
1052
+ w . addEventListener ( 'keyup' , classToggle ) ;
1053
+ w . addEventListener ( 'focus' , ( ) => monitorOnlineStatus ( updateOnlineStatusUI ) ) ;
1054
+ textarea . addEventListener ( 'wheel' , onScroll ) ;
1055
+ // console.log('%c🐾Welcome to the Cuddle Zone of Coding!🐾\n%cKeep your coding paws steady and have fun!', 'font-size: 20px; background-color: #f7f7f7; color: #000000; padding: 0 4px; border-radius: 5px;', 'font-size: 16px; background-color: #e0e6ed; color: #000000; padding: 0 4px; border-radius: 5px;');
1028
1056
}
1029
1057
1030
1058
// const concat = (...arrays) => [].concat(...arrays.filter(Array.isArray));
@@ -1682,10 +1710,6 @@ function btn(e) {
1682
1710
w . setTimeout ( scheduleMidnightRefresh , 60000 ) ;
1683
1711
}
1684
1712
1685
- w . addEventListener ( 'load' , function ( ) {
1686
- scheduleMidnightRefresh ( ) ;
1687
- } , { once : true } ) ;
1688
-
1689
1713
function doAfter19h ( action ) {
1690
1714
const now = new Date ( ) ;
1691
1715
const currentHour = now . getHours ( ) ;
@@ -1699,7 +1723,7 @@ function btn(e) {
1699
1723
}
1700
1724
1701
1725
function resizeElementToFullSize ( ) {
1702
- const padding = 48 ;
1726
+ const padding = 36 ;
1703
1727
if ( w . matchMedia ( '(max-width: 960px)' ) . matches ) return ;
1704
1728
1705
1729
// Reset height to natural before measuring
@@ -1716,27 +1740,6 @@ function btn(e) {
1716
1740
overlay . style . height = `${ adjusted } px` ;
1717
1741
}
1718
1742
1719
-
1720
- if ( 'serviceWorker' in navigator ) {
1721
- try {
1722
- navigator . serviceWorker
1723
- . register ( '/project-kitten/sw.js?v=7' )
1724
- . then ( registration => {
1725
- console . log ( 'Service Worker registered with scope:' , registration . scope ) ;
1726
- } )
1727
- . catch ( error => {
1728
- if ( error . message . includes ( "ServiceWorkerContainer.register: Script URL's scheme is not 'http' or 'https'" ) ) {
1729
- return console . warn ( 'Service Worker registration error: Insecure context. Please use HTTPS or localhost.' , error ) ;
1730
- }
1731
- console . error ( 'Service Worker registration failed:' , error ) ;
1732
- } ) ;
1733
- } catch ( error ) {
1734
- console . error ( 'Unexpected error during Service Worker registration:' , error ) ;
1735
- }
1736
- } else {
1737
- console . log ( 'Service Workers are not supported in this browser.' ) ;
1738
- }
1739
-
1740
1743
let resizeTimeout ;
1741
1744
1742
1745
function onResize ( ) {
@@ -1778,11 +1781,6 @@ function btn(e) {
1778
1781
e . currentTarget . scrollTop += Math . sign ( e . deltaY ) * 24 ;
1779
1782
}
1780
1783
1781
- textarea . addEventListener ( 'wheel' , onScroll ) ;
1782
1784
d . addEventListener ( 'DOMContentLoaded' , init , { once : true } ) ;
1783
- w . addEventListener ( 'keyup' , classToggle ) ;
1784
- w . addEventListener ( 'focus' , ( ) => monitorOnlineStatus ( updateOnlineStatusUI ) ) ;
1785
- w . addEventListener ( 'resize' , onResize ) ;
1786
1785
1787
- // console.log('%c🐾Welcome to the Cuddle Zone of Coding!🐾\n%cKeep your coding paws steady and have fun!', 'font-size: 20px; background-color: #f7f7f7; color: #000000; padding: 0 4px; border-radius: 5px;', 'font-size: 16px; background-color: #e0e6ed; color: #000000; padding: 0 4px; border-radius: 5px;');
1788
1786
} ) ( window , document ) ;
0 commit comments