@@ -49,32 +49,48 @@ interface Country {
4949}
5050
5151const colorSchemeIsDark = ( ) => {
52- const colorSchemaMeta = ( document . querySelector ( 'meta[name="color-scheme"]' ) as HTMLMetaElement || null ) . content || "default" ;
53- return colorSchemaMeta === "only dark" || (
54- colorSchemaMeta !== "only light" &&
55- window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
52+ const colorSchemaMeta =
53+ (
54+ ( document . querySelector (
55+ 'meta[name="color-scheme"]' ,
56+ ) as HTMLMetaElement ) || null
57+ ) . content || 'default' ;
58+ return (
59+ colorSchemaMeta === 'only dark' ||
60+ ( colorSchemaMeta !== 'only light' &&
61+ window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches )
5662 ) ;
57- }
63+ } ;
5864
5965const onColorSchemeChange = ( handler : ( dark ?: boolean ) => void ) => {
60- window . matchMedia ( '(prefers-color-scheme: dark)' ) . addEventListener ( 'change' , ( e ) => {
61- handler ( colorSchemeIsDark ( ) ) ;
62- } ) ;
66+ window
67+ . matchMedia ( '(prefers-color-scheme: dark)' )
68+ . addEventListener ( 'change' , ( e ) => {
69+ handler ( colorSchemeIsDark ( ) ) ;
70+ } ) ;
6371 // also detect changes to the meta tag content
64- const colorSchemaMeta = document . querySelector ( 'meta[name="color-scheme"]' ) as HTMLMetaElement ;
72+ const colorSchemaMeta = document . querySelector (
73+ 'meta[name="color-scheme"]' ,
74+ ) as HTMLMetaElement ;
6575 if ( colorSchemaMeta ) {
6676 const observer = new MutationObserver ( ( mutationsList ) => {
6777 for ( const mutation of mutationsList ) {
68- if ( mutation . type === 'attributes' && mutation . attributeName === 'content' ) {
78+ if (
79+ mutation . type === 'attributes' &&
80+ mutation . attributeName === 'content'
81+ ) {
6982 handler ( colorSchemeIsDark ( ) ) ;
7083 }
7184 }
7285 } ) ;
7386 observer . observe ( colorSchemaMeta , { attributes : true } ) ;
7487 }
75- }
88+ } ;
7689
77- document . body . setAttribute ( 'data-color-scheme' , colorSchemeIsDark ( ) ? 'dark' : 'light' ) ;
90+ document . body . setAttribute (
91+ 'data-color-scheme' ,
92+ colorSchemeIsDark ( ) ? 'dark' : 'light' ,
93+ ) ;
7894onColorSchemeChange ( ( dark ) => {
7995 document . body . setAttribute ( 'data-color-scheme' , dark ? 'dark' : 'light' ) ;
8096} ) ;
@@ -301,7 +317,10 @@ const dom = {
301317 callback : ( error : Error | string | null , data ?: unknown ) => void ,
302318 ) {
303319 if ( ! url . startsWith ( 'https://api.github.com/gists' ) ) {
304- return callback ( null , 'invalid url, for security reasons only gists are allowed' ) ;
320+ return callback (
321+ null ,
322+ 'invalid url, for security reasons only gists are allowed' ,
323+ ) ;
305324 }
306325 let request : XMLHttpRequest | null = new XMLHttpRequest ( ) ;
307326 request . open ( 'GET' , url , true ) ;
@@ -415,7 +434,7 @@ class JsonArea {
415434 }
416435
417436 // Function to get current theme based on browser's interpreted scheme
418- const getTheme = ( ) => colorSchemeIsDark ( ) ? 'monokai' : 'default' ;
437+ const getTheme = ( ) => ( colorSchemeIsDark ( ) ? 'monokai' : 'default' ) ;
419438
420439 const editor = CodeMirror . fromTextArea ( this . element , {
421440 mode : 'javascript' ,
@@ -560,7 +579,7 @@ const showSelectedDeltaType = function () {
560579 document . getElementById ( 'delta-panel-json' ) ! . style . display =
561580 type === 'json' ? '' : 'none' ;
562581 compare ( ) ;
563- if ( type === " json" ) {
582+ if ( type === ' json' ) {
564583 areas . delta . editor ! . refresh ( ) ;
565584 }
566585} ;
0 commit comments