-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
042e2b1
commit c2fa676
Showing
6 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import $ from 'jquery'; | ||
|
||
import {Settings} from './settings.js'; | ||
import {Hub} from './hub.js'; | ||
|
||
import * as local from './local.js'; | ||
|
||
const localKey = 'aprilfools2024'; | ||
|
||
function toggleButton() { | ||
const theme = Settings.getStoredSettings().theme; | ||
const date = new Date(); | ||
// month is 0-index and date is 1-indexed, because obviously that makes sense | ||
const is_april_1 = date.getMonth() === 3 && date.getDate() === 1; | ||
$('#true-dark .content').toggle( | ||
is_april_1 && theme !== 'real-dark' && local.localStorage.get(localKey, '') !== 'hidden', | ||
); | ||
} | ||
|
||
export function setup_real_dark(hub: Hub) { | ||
const overlay = $('#real-dark'); | ||
let overlay_on = false; | ||
const toggleOverlay = () => { | ||
const theme = Settings.getStoredSettings().theme; | ||
overlay_on = theme === 'real-dark'; | ||
overlay.toggle(overlay_on); | ||
}; | ||
|
||
const eventHub = hub.createEventHub(); | ||
eventHub.on('settingsChange', () => { | ||
toggleButton(); | ||
toggleOverlay(); | ||
}); | ||
toggleButton(); | ||
toggleOverlay(); | ||
$('#true-dark .content').on('click', e => { | ||
if (e.target.classList.contains('content')) { | ||
// A little bit of a hack: | ||
$('#settings .theme').val('real-dark').trigger('change'); | ||
} | ||
}); | ||
$('#true-dark .content .close').on('click', e => { | ||
local.localStorage.set(localKey, 'hidden'); | ||
toggleButton(); | ||
toggleOverlay(); | ||
}); | ||
|
||
window.addEventListener( | ||
'mousemove', | ||
e => { | ||
if (overlay_on) { | ||
overlay.css({top: e.pageY - window.innerHeight, left: e.pageX - window.innerWidth}); | ||
} | ||
}, | ||
false, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters