mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
- latest biome, and fix its configuration - fixes "static" content to be globally configured too (instead of per-line) - fixes issues: - imports fixed up - `Date.now()` vs `+new Date()` - some unused things `_` prefixed After discussion with the team, turned off the unused parameter warning.
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import $ from 'jquery';
|
|
|
|
import {Hub} from './hub.js';
|
|
import * as local from './local.js';
|
|
import {Settings} from './settings.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 takeUsersOutOfRealDark() {
|
|
// take user out of real-dark in case they got stuck previously
|
|
if (Settings.getStoredSettings().theme === 'real-dark') {
|
|
const settings = Settings.getStoredSettings();
|
|
settings.theme = 'dark';
|
|
Settings.setStoredSettings(settings);
|
|
}
|
|
}
|
|
|
|
export function setupRealDark(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 .dark-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,
|
|
);
|
|
}
|