2022-09-28 18:12:32 +00:00
/*EFY UI 2022.09.28*/ let $ = document . querySelector . bind ( document ) , $all = document . querySelectorAll . bind ( document ) , $create = document . createElement . bind ( document ) , $body , $root , $efy _module ,
/*Append: Where, Element*/ $append = ( where , el ) => { where . appendChild ( el ) } ,
/*Insert: Where, Position, Element*/ $insert = ( where , pos , el ) => { where . insertAdjacentElement ( pos , el ) } ,
/*Get CSS Property*/ $css _prop = ( a ) => { return getComputedStyle ( $root ) . getPropertyValue ( a ) . replaceAll ( ' ' , '' ) } ,
/*Add: Element, {Attributes}, [Children, Text] (optional)*/ $add = ( el , atb = { } , cld = [ ] ) => { const x = $create ( el ) ;
for ( let a = Object . keys ( atb ) , b = Object . values ( atb ) , i = 0 ; i < a . length ; i ++ ) { x . setAttribute ( a [ i ] , b [ i ] ) }
cld . forEach ( c => { if ( ! c ) return ; const cd = ( typeof c === 'string' ) ? document . createTextNode ( c ) : c ; x . appendChild ( cd ) } )
return x } ,
/*Cursor FN*/ cursor _fn = ( e ) => { let x = $ ( '[efy_cursor]' ) ; x . style . left = e . pageX + 'px' ; x . style . top = e . pageY + 'px' } ;
window . onload = async ( ) => { $root = $ ( ":root" ) , $body = $ ( "body" ) ; $efy _module = ( a ) => { let b = $css _prop ( '--efy_modules' ) . split ( ',' ) . includes ( a ) ? true : false ; return b } ; let a ;
/*Check LocalStorage*/ try { let x = 'LS' ; localStorage . setItem ( x , x ) ; let y = localStorage . getItem ( x ) ; localStorage . removeItem ( x ) ; if ( x !== y ) { throw new Error ( ) } } catch ( exception ) { $append ( $body , $add ( 'div' , { class : 'efy_no_ls' , efy _alert : '' , style : 'background: #eee; grid-template-columns: 1fr; gap: 0' } , [ $add ( 'h6' , { } , [ 'EFY - Your browser blocks LocalStorage' ] ) , $add ( 'p' , { } , [ "Privacy matters! So block 3rd party cookies if you want, no worries, but please allow 1st party cookies in your browser's settings, to be able to save your EFY preferences locally. Have fun!" ] ) ] ) ) }
/*Sidebar Modules*/ $append ( $body , $add ( 'div' , { id : 'efy_sidebar' , class : 'efy_sidebar' , efy _search : 'details:not(.efy_quick_shortcuts, [efy_logo]), .efy_sidebar [efy_tabs] > *' } , [ $add ( 'div' , { efy _about : '' } , [
$add ( 'details' , { class : 'efy_about' , efy _logo : '' } , [
$add ( 'summary' , { } , [ $add ( 'code' , { } , [ 'EFY' ] ) , $add ( 'code' , { } , [ ' UI' ] ) ] ) ,
$add ( 'div' , { } , [ 'This page uses ' , $add ( 'code' , { } , [ 'EFY' ] ) , ', a customisable, convergent, transparent, modular, futuristic css / js framework that can be added to your own web / local apps & websites.' , $add ( 'br' , { } ) , $add ( 'a' , { href : 'https://efy.ooo/ui' } , [ $add ( 'button' , { tabindex : '-1' } , [ 'Learn more' ] ) ] ) , $add ( 'a' , { href : 'https://matrix.to/#/#efy_ui:matrix.org' } , [ $add ( 'button' , { tabindex : '-1' } , [ 'Matrix Chat' ] ) ] ) ] )
] ) , $add ( 'button' , { efy _sidebar _btn _close : '' } , [ $add ( 'i' , { efy _icon : 'remove' } ) ] )
] )
] ) ) ; $append ( $body , $add ( 'div' , { efy _sidebar _btn _open : '' } ) ) ;
/*Quick Shortcuts*/ if ( $efy _module ( 'efy_quick' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { id : 'efy_quick' , class : 'efy_quick_shortcuts' } , [ $add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'star' } ) , 'Quick Shortcuts' ] ) ,
$add ( 'div' , { class : 'efy_quick_buttons' } ) ,
$add ( 'div' , { efy _clock : '' } ) , $add ( 'div' , { efy _timer : 'efy_ui0' } )
] ) ) ;
for ( let a = [ 'search' , 'reload' , 'fullscreen' , 'back' , 'forward' ] , b = [ 'search' , 'reload' , 'fullscreen' , 'chevron' , 'chevron' ] , i = 0 ; i < a . length ; i ++ ) {
$append ( $ ( '.efy_quick_buttons' ) , $add ( 'button' , { 'class' : ` efy_quick_ ${ a [ i ] } ` } , [ $add ( 'i' , { efy _icon : b [ i ] } ) ] ) )
}
$append ( $ ( '.efy_quick_buttons' ) , $add ( 'input' , { type : 'text' , efy _search _input : '' , efy _display _none : '' , placeholder : 'Search through menu...' } ) ) ;
$ ( ".efy_quick_search" ) . onclick = ( ) => $ ( '.efy_quick_shortcuts [efy_search_input]' ) . toggleAttribute ( 'efy_display_none' ) ;
$ ( ".efy_quick_reload" ) . onclick = ( ) => location . reload ( ) ;
$ ( ".efy_quick_fullscreen" ) . onclick = ( ) => { document . exitFullscreen ( ) ; document . documentElement . requestFullscreen ( ) ; } ;
$ ( ".efy_quick_back" ) . onclick = ( ) => window . history . go ( - 1 ) ;
$ ( ".efy_quick_forward" ) . addEventListener ( 'pointerup' , async ( ) => window . history . go ( 1 ) ) ;
}
/*Theme*/ if ( $efy _module ( 'efy_mode' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { id : 'efy_sbtheme' , efy _select : '' } , [ $add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'star' } ) , 'Theme' ] ) , $add ( 'div' , { efy _tabs : 'efyui_0' } ) ] ) ) ;
/*Tabs*/ for ( let a = [ 'mode' , 'colors' , 'images' , 'border' ] , b = [ 'Mode' , 'Colors' , 'Images' , 'Border' ] , c = $ ( '[efy_tabs=efyui_0]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'button' , { efy _tab : a [ i ] } , [ b [ i ] ] ) ) }
for ( let a = [ 'mode' , 'colors' , 'images' , 'border' ] , c = $ ( '[efy_tabs=efyui_0]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'div' , { efy _content : a [ i ] , efy _select : '' , id : ` efy_ ${ a [ i ] } ` } ) ) }
/*Active*/ for ( let a = [ '[efy_tab=mode]' , '[efy_content=mode]' ] , b = '[efy_tabs=efyui_0] > ' , i = 0 ; i < a . length ; i ++ ) { $ ( b + a [ i ] ) . setAttribute ( 'efy_active' , '' ) }
/*Mode*/ for ( let a = [ 'default_mode' , 'light_light' , 'light_sepia' , 'dark_dark' , 'dark_nord' , 'dark_black' , 'light_trans' , 'dark_trans' ] , b = [ 'Default' , 'Light' , 'Sepia' , 'Dark' , 'Nord' , 'Black' , 'Light' , 'Dark' ] , c = $ ( '#efy_sbtheme [efy_content=mode]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'input' , { type : 'radio' , name : 'efy_mode' , id : a [ i ] } ) ) ; $append ( c , $add ( 'label' , { for : a [ i ] } , [ b [ i ] ] ) ) }
$insert ( $ ( '#efy_sbtheme [efy_content=mode] #light_trans' ) , 'beforebegin' , $add ( 'details' , { efy _help : '' } , [ $add ( 'summary' , { } , [ 'Transparency' ] ) , $add ( 'div' , { } , [ 'If your operating system or window manager supports transparency, the background becomes transparent. Otherwise just import your own images and turn this on.' ] ) ] ) ) ;
/*Colors*/ for ( let a = [ 'efy_color1' , 'efy_color2' , 'efy_color_text' , 'efy_color_bgcol' ] , b = [ 'Color 1' , 'Color 2' , 'Text' , 'Background' ] , c = $ ( '#efy_sbtheme [efy_content=colors]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'label' , { for : a [ i ] } , [ b [ i ] , $add ( 'input' , { id : a [ i ] , type : 'color' , value : '#555555' } ) ] ) ) }
for ( let a = [ 'text' , 'bgcol' ] , c = 'afterend' , i = 0 ; i < a . length ; i ++ ) { let b = $ ( ` #efy_sbtheme [efy_content=colors] [for=efy_color_ ${ a [ i ] } ] ` ) ; $insert ( b , c , $add ( 'label' , { for : ` efy_ ${ a [ i ] } _status ` } , [ 'On / Off' ] ) ) ; $insert ( b , c , $add ( 'input' , { type : 'checkbox' , name : ` efy_ ${ a [ i ] } _color_status ` , id : ` efy_ ${ a [ i ] } _status ` } ) ) }
$insert ( $ ( '#efy_sbtheme [efy_content=colors] [for=efy_text_status]' ) , 'afterend' , $add ( 'br' , { } ) ) ;
$insert ( $ ( '#efy_sbtheme [efy_content=colors] [for=efy_color_text]' ) , 'beforebegin' , $add ( 'details' , { efy _help : '' } , [ $add ( 'summary' , { } , [ 'Custom Colors' ] ) , $add ( 'div' , { } , [ 'These colors override the default ones' ] ) ] ) ) ;
/*Images*/ a = $ ( '#efy_sbtheme [efy_content=images]' ) ; $append ( a , $add ( 'input' , { type : 'file' , accept : 'image/*' , id : 'pictureTest' } ) ) ; $append ( a , $add ( 'div' , { class : 'efy_img_previews' } ) ) ; $append ( a , $add ( 'button' , { class : 'efy_idb_reset' } , [ $add ( 'i' , { efy _icon : 'reload' } ) , 'Reset' ] ) ) ;
/*Help*/ $insert ( $ ( '#efy_sbtheme [efy_content=images] .efy_img_previews' ) , 'afterend' , $add ( 'details' , { efy _help : '' } , [ $add ( 'summary' , { } , [ 'Warning! Bigger = Slower' ] ) , $add ( 'div' , { } , [ 'Keep them bellow 1MB per image, unless your device has a powerful CPU / GPU. You can also convert png, jpg etc to webp to reduce the size' ] ) ] ) ) ;
/*Radius*/ a = $ ( '#efy_sbtheme [efy_content=border]' ) ; $append ( a , $add ( 'p' , { } , [ 'Radius' ] ) ) ; $append ( a , $add ( 'div' , { class : 'efy_sidebar_range' } ) ) ; $append ( a , $add ( 'input' , { class : 'efy_sidebar_selectRadius' , type : 'range' , min : '0' , max : '25' , value : '12' , step : '1' } ) )
}
/*Visual Filters*/ if ( $efy _module ( 'efy_filters' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { id : 'efy_vfilters' , efy _select : '' } , [ $add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'dots' } ) , 'Visual Filters (Beta)' ] ) , $add ( 'div' , { efy _tabs : 'efyui_filters' } ) ] ) ) ;
/*Tabs*/ for ( let a = [ 'bg' , 'content' , 'trans' ] , b = [ 'Background' , 'Content' , 'Trans Elements' ] , c = $ ( '[efy_tabs=efyui_filters]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'button' , { efy _tab : a [ i ] } , [ b [ i ] ] ) ) }
for ( let a = [ 'bg' , 'content' , 'trans' ] , c = $ ( '[efy_tabs=efyui_filters]' ) , i = 0 ; i < a . length ; i ++ ) { $append ( c , $add ( 'form' , { efy _content : a [ i ] , efy _select : '' , class : ` efy_ ${ a [ i ] } _filter ` } ) ) }
/*Active*/ for ( let a = [ '[efy_tab=bg]' , '[efy_content=bg]' ] , b = '[efy_tabs=efyui_filters] >' , i = 0 ; i < a . length ; i ++ ) { $ ( b + ' ' + a [ i ] ) . setAttribute ( 'efy_active' , '' ) }
$all ( '[efy_tabs=efyui_filters] form' ) . forEach ( y => { let z = y . getAttribute ( 'efy_content' ) ;
$append ( y , $add ( 'button' , { type : 'reset' } , [ $add ( 'i' , { efy _icon : 'reload' } ) , 'Reset' ] ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _brightness ` , type : 'range' , min : '0' , max : '3' , value : '1' , step : '0.1' } ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _blur ` , type : 'range' , min : '0' , max : '100' , value : '0' , step : '1' } ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _saturate ` , type : 'range' , min : '0' , max : '3' , value : '1' , step : '0.1' } ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _contrast ` , type : 'range' , min : '0.1' , max : '3' , value : '1' , step : '0.1' } ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _hue-rotate ` , type : 'range' , min : '0' , max : '360' , value : '0' , step : '1' } ) ) ;
$append ( y , $add ( 'input' , { class : ` efy_ ${ z } _sepia ` , type : 'range' , min : '0' , max : '1' , value : '0' , step : '0.1' } ) ) ;
for ( let a = [ 'Brightness' , 'Blur' , 'Saturation' , 'Contrast' , 'Hue' , 'Sepia' ] , i = 0 ; i < a . length ; i ++ ) {
$insert ( $ ( ` [efy_tabs=efyui_filters] [efy_content= ${ z } ] input:nth-of-type( ${ i + 1 } ) ` ) , 'beforebegin' , $add ( 'p' , { } , [ a [ i ] ] ) ) }
} ) }
/*Backup*/ if ( $efy _module ( 'efy_backup' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { id : 'efy_backup' } , [ $add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'arrow_down' } ) , 'Save & Restore' ] ) ] ) ) ;
for ( let a = [ 'localstorage' , 'idb' ] , b = [ 'Settings' , 'Images' ] , c = '#efy_backup' , i = 0 ; i < a . length ; i ++ ) {
$append ( $ ( c ) , $add ( 'p' , { } , [ ` EFY ${ b [ i ] } ` ] ) ) ;
$append ( $ ( c ) , $add ( 'a' , { href : '#' , class : ` efy_ ${ a [ i ] } _export ` , download : ` efy_ ${ b [ i ] } .json ` } , [
$add ( 'button' , { tabindex : '-1' } , [ $add ( 'i' , { efy _icon : 'arrow_down' } ) , 'Save' ] ) ] ) ) ;
$append ( $ ( c ) , $add ( 'button' , { type : 'reset' , class : ` efy_ ${ a [ i ] } _reset ` } , [ $add ( 'i' , { efy _icon : 'reload' } ) , 'Reset' ] ) ) ;
$append ( $ ( c ) , $add ( 'input' , { type : 'file' , class : ` efy_ ${ a [ i ] } _import ` , accept : '.json' } ) )
} }
/*Accessibility*/ if ( $efy _module ( 'efy_accessibility' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { id : 'efy_accessibility' , efy _select : '' } , [ $add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'accessibility' } ) , 'Accessibility (Beta)' ] ) ,
$add ( 'details' , { id : 'efy_btn_align' , efy _select : '' } , [ $add ( 'summary' , { } , [ 'Menu Button Position' ] ) , $add ( 'div' , { } ) ] ) ,
$add ( 'details' , { id : 'efy_accessibility_outline' , efy _select : '' } , [ $add ( 'summary' , { } , [ 'Outline' ] ) , $add ( 'p' , { } , [ "Safari & Webkit don't support custom outline radius yet, so it's not up to efy, but the outline itself works and the radius as well on other browsers." ] ) , $add ( 'input' , { id : 'efy_outline' , type : 'checkbox' , name : 'efy_accessibility' } ) , $add ( 'label' , { for : 'efy_outline' } , [ 'Focus Outline' ] ) ] ) ,
$add ( 'details' , { id : 'efy_accessibility_text' , efy _select : '' } , [ $add ( 'summary' , { } , [ 'Text Size' ] ) , $add ( 'form' , { class : 'efy_text_accessibility' } , [
$add ( 'button' , { type : 'reset' } , [ $add ( 'i' , { efy _icon : 'reload' } ) , 'Reset' ] ) ,
$add ( 'p' , { } , [ 'Zoom' ] ) , $add ( 'input' , { class : 'efy_ui_zoom' , type : 'range' , min : '1' , max : '2' , value : '1' , step : '0.01' } ) ,
$add ( 'p' , { } , [ 'Text Spacing' ] ) , $add ( 'input' , { class : 'efy_text_spacing' , type : 'range' , min : '0' , max : '15' , value : '0' , step : '1' } )
] ) ] ) ,
$add ( 'details' , { id : 'efy_accessibility_cursor' , efy _select : '' } , [ $add ( 'summary' , { } , [ 'Cursor' ] ) , $add ( 'p' , { } , [ 'WARNING! Only hide it on touchscreen devices!' ] ) ] )
] ) ) ;
for ( let i = 0 , a = [ 'left_top' , 'middle_top' , 'right_top' , 'left_middle' , 'middle_middle' , 'right_middle' , 'left_bottom' , 'middle_bottom' , 'right_bottom' ] ; i < a . length ; i ++ ) { $append ( $ ( '#efy_btn_align > div' ) , $add ( [ 'input' ] , { type : 'radio' , name : 'efy_btn_align' , id : a [ i ] } ) ) } $ ( '#middle_middle[name=efy_btn_align]' ) . setAttribute ( 'disabled' , '' ) ;
for ( let a = [ 'efy_cursor_default' , 'efy_cursor_custom' , 'efy_cursor_none' ] , b = [ 'Default' , 'Custom' , 'Hide (Touchscreen)' ] , c = $ ( '#efy_accessibility_cursor' ) , i = 0 ; i < a . length ; i ++ ) {
$append ( c , $add ( 'input' , { type : 'radio' , name : 'efy_accessibility_cursor' , id : a [ i ] } ) ) ;
$append ( c , $add ( 'label' , { for : a [ i ] } , [ b [ i ] ] ) ) ;
} $ ( '#efy_cursor_default' ) . setAttribute ( 'checked' , '' ) ;
/*Cursor*/ $append ( $body , $add ( 'div' , { efy _cursor : '' } ) ) ; /*Storage*/ if ( localStorage . efy _cursor == 'custom' ) { $root . setAttribute ( 'efy_cursor_custom' , '' ) ; document . addEventListener ( 'pointermove' , cursor _fn ) ; $ ( '#efy_cursor_custom' ) . setAttribute ( 'checked' , '' ) } else if ( localStorage . efy _cursor == 'none' ) { $root . setAttribute ( 'efy_cursor_none' , '' ) ; $ ( '#efy_cursor_none' ) . setAttribute ( 'checked' , '' ) }
/*Custom*/ $ ( '#efy_cursor_custom' ) . addEventListener ( 'change' , ( ) => { if ( $ ( '#efy_cursor_custom' ) . checked ) { $root . removeAttribute ( 'efy_cursor_none' ) ; $root . setAttribute ( 'efy_cursor_custom' , '' ) ; document . addEventListener ( 'pointermove' , cursor _fn ) ; localStorage . efy _cursor = 'custom' } } ) ;
/*None*/ $ ( '#efy_cursor_none' ) . addEventListener ( 'change' , ( ) => { if ( $ ( '#efy_cursor_none' ) . checked ) { $root . removeAttribute ( 'efy_cursor_custom' ) ; $root . setAttribute ( 'efy_cursor_none' , '' ) ; document . removeEventListener ( 'pointermove' , cursor _fn ) ; localStorage . efy _cursor = 'none' } } ) ;
/*Default*/ $ ( '#efy_cursor_default' ) . addEventListener ( 'change' , ( ) => { if ( $ ( '#efy_cursor_default' ) . checked ) { $root . removeAttribute ( 'efy_cursor_custom' ) ; $root . removeAttribute ( 'efy_cursor_none' ) ; document . removeEventListener ( 'pointermove' , cursor _fn ) ; localStorage . removeItem ( 'efy_cursor' ) } } ) ;
}
/*Audio*/ if ( $efy _module ( 'efy_audio' ) ) { $append ( $ ( '.efy_sidebar' ) , $add ( 'details' , { efy _select : '' , id : 'efy_audio' } , [
$add ( 'summary' , { } , [ $add ( 'i' , { efy _icon : 'audio' } ) , 'Audio Effects (Beta)' ] ) ,
$add ( 'p' , { } , [ 'You might have to click / tap on the ssl / lock icon on your browser & allow sounds, to hear them automatically.' ] ) ] ) ) ;
for ( let a = [ 'status' , 'click' , 'hover' ] , b = [ 'On / Off' , 'Click & Tap' , 'Mouse Hover' ] , c = '#efy_audio > p' , d = 'beforebegin' , i = 0 ; i < a . length ; i ++ ) {
$insert ( $ ( c ) , d , $add ( 'input' , { type : 'checkbox' , name : 'efy_audio' , id : ` efy_audio_ ${ a [ i ] } ` } ) ) ;
$insert ( $ ( c ) , d , $add ( 'label' , { for : ` efy_audio_ ${ a [ i ] } ` } , [ b [ i ] ] ) )
} }
/*Sidebar Modules - End*/
/*Theme*/ if ( localStorage . efy _mode ) { $root . setAttribute ( "efy_mode" , localStorage . efy _mode ) ; $ ( "#" + localStorage . efy _mode ) . setAttribute ( "checked" , "1" ) }
else { $root . setAttribute ( 'efy_mode' , 'default_mode' ) ; $ ( "#default_mode" ) . setAttribute ( "checked" , "1" ) }
$all ( "[name=efy_mode]" ) . forEach ( x => { x . onclick = ( ) => { $root . setAttribute ( "efy_mode" , x . id ) ; localStorage . efy _mode = x . id ; } ; } ) ;
2022-09-05 18:05:42 +00:00
/*Colors*/ let efy _color = { 'color1' : 'efy_color' , 'color2' : 'efy_color2' , 'color_text' : 'efy_text' , 'color_bgcol' : 'efy_bgcol' } , rgb2hex = c => "#" + c . match ( /\d+/g ) . map ( x => ( + x ) . toString ( 16 ) . padStart ( 2 , 0 ) ) . join ` ` ;
2022-09-28 18:12:32 +00:00
Object . keys ( efy _color ) . forEach ( z => { $ ( ` #efy_ ${ z } ` ) . oninput = ev => {
let x = ev . target . value , r = parseInt ( x . substr ( 1 , 2 ) , 16 ) , g = parseInt ( x . substr ( 3 , 2 ) , 16 ) , b = parseInt ( x . substr ( 5 , 2 ) , 16 ) ; x = ` ${ r } , ${ g } , ${ b } ` ; localStorage . setItem ( efy _color [ z ] , x ) ; $root . style . setProperty ( ` --efy_ ${ z } _var ` , x ) ; }
let y = $css _prop ( ` --efy_ ${ z } _var ` ) ;
if ( localStorage . getItem ( efy _color [ z ] ) ) { y = localStorage . getItem ( efy _color [ z ] ) ; $root . style . setProperty ( ` --efy_ ${ z } _var ` , y ) }
$ ( ` #efy_ ${ z } ` ) . value = rgb2hex ( "rgb(" + y + ")" ) ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Radius*/ let efy _radius _input = $ ( ".efy_sidebar_selectRadius" ) , efy _sidebar _range = $ ( ".efy_sidebar_range" ) ;
2022-09-05 18:05:42 +00:00
// efy_radius_steps = (efy_radius_input.max - efy_radius_input.min) , - use this instead of width // efy_radius = localStorage.efy_radius;
2022-09-28 18:12:32 +00:00
async function efy _radius _fn ( ) { let x , radius = localStorage . efy _radius ; if ( radius ) { x = radius . replace ( 'rem' , '' ) ; efy _radius _input . value = x ; $root . style . setProperty ( "--efy_radius" , radius ) ; } else { x = 12 ; }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Radius: Input*/ $ ( '[efy_tabs=efyui_0] [efy_tab="border"]' ) . addEventListener ( 'pointerup' , ( ) => { setTimeout ( ( ) => { let za = $ ( '.efy_sidebar_selectRadius' ) , z = getComputedStyle ( za ) . getPropertyValue ( 'width' ) . replace ( 'px' , '' ) ; efy _sidebar _range . innerText = x ; efy _sidebar _range . style . left = ( x * ( z - 32 ) / efy _radius _input . max ) + 'rem' ; } , 100 ) ; } , { once : true } ) ; } efy _radius _fn ( ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
efy _radius _input . oninput = ( ) => { let za = $ ( '.efy_sidebar_selectRadius' ) , z = getComputedStyle ( za ) . getPropertyValue ( 'width' ) . replace ( 'px' , '' ) , x = efy _radius _input . value ; $root . style . setProperty ( "--efy_radius" , x + "rem" ) ; localStorage . efy _radius = x + "rem" ; efy _sidebar _range . style . left = ( x * ( z - 32 ) / efy _radius _input . max ) + 'rem' ; efy _sidebar _range . innerText = x ; } ;
/*Radius: Window Resize*/ window . addEventListener ( 'resize' , ( ) => { let za = $ ( '.efy_sidebar_selectRadius' ) , z = getComputedStyle ( za ) . getPropertyValue ( 'width' ) . replace ( 'px' , '' ) , x = efy _radius _input . value ; efy _sidebar _range . style . left = ( x * ( z - 32 ) / efy _radius _input . max ) + 'rem' ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*EFY Button Position*/ if ( localStorage . efy _btn _align ) { $ ( "#" + localStorage . efy _btn _align ) . setAttribute ( "checked" , "1" ) ; $ ( "[efy_sidebar_btn_open]" ) . setAttribute ( "efy_btn_align" , localStorage . efy _btn _align ) ; } else { let y = $css _prop ( '--efy_sidebar_button' ) ;
$ ( '#' + y ) . setAttribute ( "checked" , "1" ) ; $ ( '[efy_sidebar_btn_open]' ) . setAttribute ( 'efy_btn_align' , y ) ; }
$all ( "[name=efy_btn_align]" ) . forEach ( x => { x . onclick = ( ) => { $ ( "[efy_sidebar_btn_open]" ) . setAttribute ( "efy_btn_align" , x . id ) ; localStorage . efy _btn _align = x . id ; } ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*BgImg Filter*/ let efy _bg _filter = { } , efy _css _bg _filter = $create ( "style" ) ; efy _css _bg _filter . classList . add ( "efy_css_bg_filter" ) ; document . head . appendChild ( efy _css _bg _filter ) ; async function efy _bg _filter _fn ( ) {
[ 'blur' , 'brightness' , 'saturate' , 'contrast' , 'hue-rotate' , 'sepia' ] . forEach ( x => { efy _bg _filter [ x ] = $ ( ` .efy_bg_ ${ x } ` ) . value ; if ( x == 'blur' ) { efy _bg _filter [ x ] = efy _bg _filter [ x ] + 'px' } else if ( x == 'hue-rotate' ) { efy _bg _filter [ x ] = efy _bg _filter [ x ] + 'deg' } } ) ;
2022-09-05 18:05:42 +00:00
let string = '' ; Object . keys ( efy _bg _filter ) . forEach ( x => { string = string + ` ${ x } ( ${ efy _bg _filter [ x ] } ) ` } ) ;
let y = ` html:before, html:after {filter: ${ string } !important} ` ;
2022-09-28 18:12:32 +00:00
efy _css _bg _filter . textContent = y ; localStorage . efy _bg _filter = JSON . stringify ( efy _bg _filter ) ; localStorage . efy _bg _filter _css = y }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
if ( localStorage . efy _bg _filter ) { efy _css _bg _filter . textContent = localStorage . efy _bg _filter _css ; let efy _bg _filter = JSON . parse ( localStorage . efy _bg _filter ) ; Object . keys ( efy _bg _filter ) . forEach ( x => $ ( ` .efy_bg_ ${ x } ` ) . value = efy _bg _filter [ x ] . replace ( 'px' , '' ) . replace ( 'deg' , '' ) ) }
$all ( '.efy_bg_filter input' ) . forEach ( x => { x . addEventListener ( "input" , ( ) => { efy _bg _filter _fn ( ) } ) } ) ;
$all ( '.efy_bg_filter [type=reset]' ) . forEach ( x => { x . addEventListener ( "pointerup" , ( ) => { efy _bg _filter _fn ( ) ; localStorage . removeItem ( 'efy_bg_filter' ) ; localStorage . removeItem ( 'efy_bg_filter_css' ) ; efy _css _bg _filter . textContent = '' } ) } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Content Filter*/ let efy _content _filter = { } , efy _css _content _filter = $create ( "style" ) ; efy _css _content _filter . classList . add ( "efy_css_content_filter" ) ; document . head . appendChild ( efy _css _content _filter ) ; async function efy _content _filter _fn ( ) {
[ 'blur' , 'brightness' , 'saturate' , 'contrast' , 'hue-rotate' , 'sepia' ] . forEach ( x => { efy _content _filter [ x ] = $ ( ` .efy_content_ ${ x } ` ) . value ; if ( x == 'blur' ) { efy _content _filter [ x ] = efy _content _filter [ x ] + 'px' } else if ( x == 'hue-rotate' ) { efy _content _filter [ x ] = efy _content _filter [ x ] + 'deg' } } ) ;
2022-09-05 18:05:42 +00:00
let string = '' ; Object . keys ( efy _content _filter ) . forEach ( x => { string = string + ` ${ x } ( ${ efy _content _filter [ x ] } ) ` } ) ;
let y = ` img, video {filter: ${ string } !important} ` ;
2022-09-28 18:12:32 +00:00
efy _css _content _filter . textContent = y ; localStorage . efy _content _filter = JSON . stringify ( efy _content _filter ) ; localStorage . efy _content _filter _css = y }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
if ( localStorage . efy _content _filter ) { efy _css _content _filter . textContent = localStorage . efy _content _filter _css ; let efy _content _filter = JSON . parse ( localStorage . efy _content _filter ) ; Object . keys ( efy _content _filter ) . forEach ( x => $ ( ` .efy_content_ ${ x } ` ) . value = efy _content _filter [ x ] . replace ( 'px' , '' ) . replace ( 'deg' , '' ) ) }
$all ( '.efy_content_filter input' ) . forEach ( x => { x . addEventListener ( "input" , ( ) => { efy _content _filter _fn ( ) } ) } ) ;
$all ( '.efy_content_filter [type=reset]' ) . forEach ( x => { x . addEventListener ( "pointerup" , ( ) => { efy _content _filter _fn ( ) ; localStorage . removeItem ( 'efy_content_filter' ) ; localStorage . removeItem ( 'efy_content_filter_css' ) ; efy _css _content _filter . textContent = '' } ) } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Trans Filter*/ let efy _trans _filter = { } , efy _css _trans _filter = $create ( "style" ) ; efy _css _trans _filter . classList . add ( "efy_css_trans_filter" ) ; document . head . appendChild ( efy _css _trans _filter ) ; async function efy _trans _filter _fn ( ) {
[ 'blur' , 'brightness' , 'saturate' , 'contrast' , 'hue-rotate' , 'sepia' ] . forEach ( x => { efy _trans _filter [ x ] = $ ( ` .efy_trans_ ${ x } ` ) . value ; if ( x == 'blur' ) { efy _trans _filter [ x ] = efy _trans _filter [ x ] + 'px' } else if ( x == 'hue-rotate' ) { efy _trans _filter [ x ] = efy _trans _filter [ x ] + 'deg' } } ) ;
2022-09-05 18:05:42 +00:00
let string = '' ; Object . keys ( efy _trans _filter ) . forEach ( x => { string = string + ` ${ x } ( ${ efy _trans _filter [ x ] } ) ` } ) ;
2022-09-28 18:12:32 +00:00
let y = ` details:not([efy_help]), select, input, textarea, blockquote, pre, article, table, [efy_tabs] [efy_content], [efy_timer], [efy_clock] {backdrop-filter: ${ string } !important; -webkit-backdrop-filter: ${ string } !important} ` ;
efy _css _trans _filter . textContent = y ; localStorage . efy _trans _filter = JSON . stringify ( efy _trans _filter ) ; localStorage . efy _trans _filter _css = y }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
if ( localStorage . efy _trans _filter ) { efy _css _trans _filter . textContent = localStorage . efy _trans _filter _css ; let efy _trans _filter = JSON . parse ( localStorage . efy _trans _filter ) ; Object . keys ( efy _trans _filter ) . forEach ( x => $ ( ` .efy_trans_ ${ x } ` ) . value = efy _trans _filter [ x ] . replace ( 'px' , '' ) . replace ( 'deg' , '' ) ) }
$all ( '.efy_trans_filter input' ) . forEach ( x => { x . addEventListener ( "input" , ( ) => { efy _trans _filter _fn ( ) } ) } ) ;
$all ( '.efy_trans_filter [type=reset]' ) . forEach ( x => { x . addEventListener ( "pointerup" , ( ) => { efy _trans _filter _fn ( ) ; localStorage . removeItem ( 'efy_trans_filter' ) ; localStorage . removeItem ( 'efy_trans_filter_css' ) ; efy _css _trans _filter . textContent = '' } ) } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/* Text Size*/ let efy _text _accessibility = $create ( "style" ) ; efy _text _accessibility . classList . add ( "efy_text_accessibility" ) ; document . head . appendChild ( efy _text _accessibility ) ; $all ( '.efy_text_accessibility input' ) . forEach ( x => x . oninput = ( ) => { efy _text _accessibility . textContent = ` :root {--efy_font_size: ${ $ ( '.efy_ui_zoom' ) . value } px!important;} html {letter-spacing: ${ $ ( '.efy_text_spacing' ) . value } px!important;} ` ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Checkbox Toggles*/ [ "efy_audio_status" , "efy_audio_click" , "efy_audio_hover" , "efy_outline" , 'efy_text_status' , 'efy_bgcol_status' ] . forEach ( x => { if ( localStorage . getItem ( x ) == "on" ) { $ ( "#" + x ) . setAttribute ( "checked" , "1" ) ; } $ ( "#" + x ) . onclick = ( ) => { if ( localStorage . getItem ( x ) == "on" ) { localStorage . setItem ( x , "off" ) ; } else { localStorage . setItem ( x , "on" ) ; } } ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Focus Outline*/ if ( localStorage . efy _outline == 'on' ) { $root . setAttribute ( 'efy_outline' , '1' ) ; } $ ( '#efy_outline' ) . onchange = ( ) => { $root . toggleAttribute ( 'efy_outline' ) }
/*Custom Text Color*/ if ( localStorage . efy _text _status == 'on' ) { $root . setAttribute ( 'efy_color_text' , '1' ) } $ ( '#efy_text_status' ) . onchange = ( ) => { $root . toggleAttribute ( 'efy_color_text' ) }
/*Custom BG Color*/ if ( localStorage . efy _bgcol _status == 'on' ) { $root . setAttribute ( 'efy_color_bgcol' , '1' ) } $ ( '#efy_bgcol_status' ) . onchange = ( ) => { $root . toggleAttribute ( 'efy_color_bgcol' ) }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*EFY Menu Toggles*/ $body . addEventListener ( "click" , ( ) => { if ( event . target . matches ( '[efy_sidebar_btn_open]' ) ) {
$ ( "[efy_sidebar_btn_open]:not([efy_sidebar_btn_open=relative])" ) . style . display = "none" ;
$ ( "[efy_sidebar_btn_close]" ) . style . display = "block" ;
$ ( ".efy_sidebar" ) . classList . toggle ( "efy_toggle_efy_sidebar_panel" ) ;
$ ( "body" ) . classList . toggle ( "efy_toggle_efy_sidebar" ) ;
2022-09-05 18:05:42 +00:00
} } ) ;
2022-09-28 18:12:32 +00:00
/*Close*/ $ ( "[efy_sidebar_btn_close]" ) . onclick = ( ) => { $ ( ".efy_sidebar" ) . classList . toggle ( "efy_toggle_efy_sidebar_panel" ) ; $ ( "body" ) . classList . toggle ( "efy_toggle_efy_sidebar" ) ; $ ( "[efy_sidebar_btn_open]:not([efy_sidebar_btn_open=relative])" ) . style . display = "block" ; $ ( "[efy_sidebar_btn_close]" ) . style . display = "none" ; } ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Change bg image*/ let efy _css _bgimg = $create ( "style" ) ; efy _css _bgimg . classList . add ( "efy_css_bgimg" ) ; document . head . appendChild ( efy _css _bgimg ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Background image*/ let db ; $ ( "#pictureTest" ) . addEventListener ( "change" , efy _add _bgimg ) ;
2022-09-05 18:05:42 +00:00
let request = indexedDB . open ( 'efy' ) ;
request . onerror = ( ) => console . error ( "efy: Can't open db" ) ;
request . onsuccess = e => ( db = e . target . result ) ;
request . onupgradeneeded = e => { let db = e . target . result ; db . createObjectStore ( "images" , { keyPath : "id" , autoIncrement : true } ) ; db . createObjectStore ( "settings" , { keyPath : "id" , autoIncrement : true } ) ; } ;
async function efy _add _bgimg ( e ) { let reader = new FileReader ( ) ; reader . readAsDataURL ( e . target . files [ 0 ] ) ; reader . onload = e => { let ob = { data : e . target . result } ;
db . transaction ( [ "images" ] , "readwrite" ) . objectStore ( "images" ) . add ( ob ) . onerror = e => { console . error ( e ) ; } ;
async function efy _bg _update _fn2 ( ) { let request2 = indexedDB . open ( 'efy' ) ;
request2 . onsuccess = ( ) => { let efy _count _img2 = 0 , transaction2 = request2 . result . transaction ( [ "images" ] , "readonly" ) , invoiceStore2 = transaction2 . objectStore ( "images" ) , getCursorRequest2 = invoiceStore2 . openCursor ( ) ;
getCursorRequest2 . onerror = ( ) => console . error ( "efy: no db entries" ) ;
getCursorRequest2 . onsuccess = e => { let cursor2 = e . target . result ;
if ( cursor2 ) { efy _count _img2 ++ ; cursor2 . continue ( ) ; }
else { /*Set bgimg nr*/ localStorage . efy _bg _nr = efy _count _img2 ;
2022-09-28 18:12:32 +00:00
/*Add Preview*/ let efy _bg _item2 = $create ( "div" ) ; efy _bg _item2 . style . background = 'url(' + reader . result + ')' ; efy _bg _item2 . setAttribute ( "efy_bg_nr" , efy _count _img2 ) ; $ ( ".efy_img_previews" ) . appendChild ( efy _bg _item2 ) ; $all ( '.efy_img_previews [efy_bg_nr]' ) . forEach ( z => z . removeAttribute ( 'efy_active' ) ) ;
/*Restore Background*/ efy _css _bgimg . textContent = ` html:before, html:after {background: url( ${ reader . result } )!important; background-size: cover!important} html {background: var(--efy_text2)!important} ` ; $ ( '.efy_img_previews [efy_bg_nr="' + efy _count _img2 + '"]' ) . setAttribute ( 'efy_active' , 1 ) ;
/*Preview Click*/ let y = $ ( '.efy_img_previews [efy_bg_nr="' + efy _count _img2 + '"]' ) ; y . onclick = ( ) => { efy _css _bgimg . textContent = ` html:before, html:after {background: url( ${ reader . result } )!important; background-size: cover!important} html {background: var(--efy_text2)!important} ` ; localStorage . efy _bg _nr = efy _count _img2 ; $all ( '.efy_img_previews [efy_bg_nr]' ) . forEach ( z => z . removeAttribute ( 'efy_active' ) ) ; y . setAttribute ( 'efy_active' , 1 ) ; } ;
2022-09-05 18:05:42 +00:00
}
} ; } ;
} efy _bg _update _fn2 ( ) ;
} ; }
/*Count images*/ async function efy _bg _update _fn ( ) { request = indexedDB . open ( 'efy' ) ;
request . onsuccess = ( ) => { let efy _count _img = 0 , transaction = request . result . transaction ( [ "images" ] , "readonly" ) , invoiceStore = transaction . objectStore ( "images" ) , getCursorRequest = invoiceStore . openCursor ( ) ;
getCursorRequest . onerror = ( ) => console . error ( "efy: no db entries" ) ;
getCursorRequest . onsuccess = e => { let cursor = e . target . result ;
if ( cursor ) { efy _count _img ++ ; let req = invoiceStore . get ( efy _count _img ) ;
req . onsuccess = e => { let x = e . target . result . data ;
2022-09-28 18:12:32 +00:00
/*Preview Click*/ let efy _bg _item = $create ( "div" ) ; efy _bg _item . style . background = 'url(' + x + ')' ; efy _bg _item . setAttribute ( "efy_bg_nr" , efy _count _img ) ; $ ( ".efy_img_previews" ) . appendChild ( efy _bg _item ) ; let y = $ ( '.efy_img_previews [efy_bg_nr="' + efy _count _img + '"]' ) ; y . onclick = ( ) => { efy _css _bgimg . textContent = ` html:before, html:after {background: url( ${ x } )!important; background-size: cover!important} html {background: var(--efy_text2)!important; background-size: cover!important} ` ; localStorage . efy _bg _nr = e . target . result . id ; $all ( '.efy_img_previews [efy_bg_nr]' ) . forEach ( z => z . removeAttribute ( 'efy_active' ) ) ; y . setAttribute ( 'efy_active' , 1 ) ; } ;
2022-09-05 18:05:42 +00:00
} ; cursor . continue ( ) ;
} else { /*Check bgimg number*/ let bgnr ; if ( localStorage . efy _bg _nr ) { bgnr = JSON . parse ( localStorage . efy _bg _nr ) ; } else { bgnr = 1 ; }
2022-09-28 18:12:32 +00:00
/*Restore Background*/ if ( efy _count _img > 0 ) { invoiceStore . get ( bgnr ) . onsuccess = e => { let x = e . target . result . data , y = e . target . result . id ; efy _css _bgimg . textContent = ` html:before, html:after {background: url( ${ x } )!important; background-size: cover!important} ` ; $ ( '.efy_img_previews [efy_bg_nr="' + y + '"]' ) . setAttribute ( 'efy_active' , 1 ) ; } ; }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Remove BG - Button*/ $all ( ".efy_idb_reset" ) . forEach ( z => { z . onclick = ( ) => { indexedDB . deleteDatabase ( "efy" ) ; location . reload ( ) } } ) ;
2022-09-05 18:05:42 +00:00
}
} ; } ;
} efy _bg _update _fn ( ) ;
/*Export IndexedDB*/ ( async ( ) => { try {
let dbExists = await new Promise ( resolve => { let request = window . indexedDB . open ( 'efy' ) ;
request . onupgradeneeded = e => { e . target . transaction . abort ( ) ; resolve ( false ) ; } ;
request . onerror = ( ) => resolve ( true ) ; request . onsuccess = ( ) => resolve ( true ) ; } ) ;
if ( ! dbExists ) { throw new Error ( "efy: db doesn't exist" ) ; }
let idbDatabase = await new Promise ( ( resolve , reject ) => { let request = window . indexedDB . open ( 'efy' ) ;
request . onerror = ( ) => reject ( "efy: Can't open db" ) ;
request . onsuccess = ( ) => resolve ( request . result ) ; } ) ;
let json = await new Promise ( ( resolve , reject ) => { let exportObject = { } ;
if ( idbDatabase . objectStoreNames . length === 0 ) { resolve ( JSON . stringify ( exportObject ) ) ; }
else { let transaction = idbDatabase . transaction ( idbDatabase . objectStoreNames , "readonly" ) ;
transaction . addEventListener ( "error" , reject ) ;
for ( let storeName of idbDatabase . objectStoreNames ) { let allObjects = [ ] ;
transaction . objectStore ( storeName ) . openCursor ( ) . addEventListener ( "success" , event => { let cursor = event . target . result ;
if ( cursor ) { /*Store data*/ allObjects . push ( cursor . value ) ; cursor . continue ( ) ; }
else { /*Store completed*/ exportObject [ storeName ] = allObjects ;
if ( idbDatabase . objectStoreNames . length === Object . keys ( exportObject ) . length ) { resolve ( JSON . stringify ( exportObject ) ) ; } } } ) ; } } } ) ;
2022-09-28 18:12:32 +00:00
$ ( ".efy_idb_export" ) . onclick = ( ) => { efyaudio . ok4 . cloneNode ( ) . play ( ) ; $ ( ".efy_idb_export" ) . href = "data:application/json," + json ; } ;
2022-09-05 18:05:42 +00:00
} catch ( error ) { console . error ( error ) ; } } ) ( ) ;
2022-09-28 18:12:32 +00:00
/*Import indexedDB*/ let efy _idb _import = $ ( ".efy_idb_import" ) ;
2022-09-05 18:05:42 +00:00
efy _idb _import . addEventListener ( "change" , ( ) => { let file = efy _idb _import . files [ 0 ] , reader = new FileReader ( ) ;
reader . onload = async ( ) => { let data = JSON . parse ( reader . result ) ;
function importIDB ( storename = "images" , storename2 = "settings" , arr = data [ "images" ] , arr2 = data [ "settings" ] ) {
return new Promise ( resolve => { let r = window . indexedDB . open ( "efy" ) ;
r . onupgradeneeded = ( ) => { let idb = r . result ; idb . createObjectStore ( storename , { keyPath : "id" , autoIncrement : true } ) ; idb . createObjectStore ( storename2 , { keyPath : "id" , autoIncrement : true } ) ; } ;
r . onsuccess = ( ) => { let idb = r . result , store = idb . transaction ( storename , "readwrite" ) . objectStore ( storename ) , store2 = idb . transaction ( storename2 , "readwrite" ) . objectStore ( storename2 ) ;
for ( let obj of arr ) { store . put ( obj ) ; }
for ( let obj of arr2 ) { store2 . put ( obj ) ; }
resolve ( idb ) ;
} ; r . onerror = e => console . log ( e . target . errorCode ) ; } ) ; }
await importIDB ( ) ; } ; reader . readAsText ( file ) ; } ) ;
2022-09-28 18:12:32 +00:00
/*Save & Restore Preferences*/ $ ( '.efy_localstorage_export' ) . onclick = ( ) => { let x = '' ; Object . entries ( localStorage ) . forEach ( ( [ k , v ] ) => { if ( k . includes ( 'efy' ) ) { x = x + JSON . stringify ( k , null , 2 ) + ' :' + JSON . stringify ( v , null , 2 ) + ',\n' ; } } ) ; $ ( '.efy_localstorage_export' ) . href = "data:application/json," + '{\n' + x . slice ( 0 , - 2 ) + '\n}' } ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Import Settings*/ let efy _localstorage _import = $ ( '.efy_localstorage_import' ) ; efy _localstorage _import . addEventListener ( 'change' , function ( ) {
2022-09-05 18:05:42 +00:00
let file = efy _localstorage _import . files [ 0 ] , reader = new FileReader ( ) ;
reader . onload = function ( ) { Object . entries ( JSON . parse ( reader . result ) ) . forEach ( ( [ k , v ] ) => localStorage . setItem ( k , v ) ) ; location . reload ( ) }
reader . readAsText ( file ) ; } ) ;
2022-09-28 18:12:32 +00:00
/*Reset Settings*/ $all ( ".efy_localstorage_reset" ) . forEach ( x => { x . onclick = ( ) => { Object . entries ( localStorage ) . forEach ( ( [ k ] ) => { if ( k . includes ( 'efy' ) ) { localStorage . removeItem ( k ) } } ) ; location . reload ( ) } } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Determine Audio Path*/ let audioPath = $css _prop ( '--efy_audio_path' ) ;
2022-09-11 20:32:23 +00:00
2022-09-28 18:12:32 +00:00
/*Audio*/ let efyaudio = { } ; [ 'pop' , 'ok' , 'ok2' , 'ok3' , 'ok4' , 'hover' , 'slide' , 'squish' , 'step' , 'error' , 'disabled' ] . forEach ( x => { efyaudio [ x ] = new Audio ( ` ${ audioPath } / ${ x } .mp3 ` ) } ) ; $body . addEventListener ( "pointerdown" , efyaudio _fn , { once : true } ) ;
2022-09-05 18:05:42 +00:00
async function efyaudio _fn ( ) { if ( localStorage . efy _audio _status == 'on' ) { if ( localStorage . efy _audio _click == 'on' ) {
2022-09-28 18:12:32 +00:00
/*Ok*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( 'button:not([disabled], [type=submit], [type=reset], [efy_tab], .shaka-overflow-menu button, .shaka-overflow-menu-button, .shaka-back-to-overflow-button), .video-grid>div' ) ) { efyaudio . ok . cloneNode ( ) . play ( ) } } ) ;
2022-09-05 18:05:42 +00:00
/*Ok: Online*/ window . addEventListener ( "online" , ( ) => { efyaudio . ok . cloneNode ( ) . play ( ) } ) ;
2022-09-28 18:12:32 +00:00
/*Ok2*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '.efy_img_previews [efy_bg_nr]' ) ) { efyaudio . ok2 . cloneNode ( ) . play ( ) } } ) ;
/*Ok4*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '[type=submit]' ) ) { efyaudio . ok4 . cloneNode ( ) . play ( ) } } ) ;
/*Ok: on Change*/ $body . addEventListener ( "change" , ( ) => { if ( event . target . matches ( 'input, textarea' ) ) { efyaudio . ok . cloneNode ( ) . play ( ) } } ) ;
/*Pop*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( 'summary, select:not([multiple], [disabled]), [efy_tabs] [efy_tab], [efy_alert], [efy_alert] *, .shaka-overflow-menu button, .shaka-overflow-menu-button, .shaka-back-to-overflow-button' ) ) { efyaudio . pop . cloneNode ( ) . play ( ) } } ) ;
/*Slide*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '[efy_sidebar_btn_open], [efy_sidebar_btn_close]' ) ) { efyaudio . slide . cloneNode ( ) . play ( ) } } ) ;
/*Error*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '[type=reset]' ) ) { efyaudio . error . cloneNode ( ) . play ( ) } } ) ;
2022-09-05 18:05:42 +00:00
/*Error: Offline*/ window . addEventListener ( "offline" , ( ) => { efyaudio . error . cloneNode ( ) . play ( ) } ) ;
2022-09-28 18:12:32 +00:00
/*Disabled*/ $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '[disabled]' ) ) { efyaudio . disabled . cloneNode ( ) . play ( ) } } ) ;
/*Step*/ $body . addEventListener ( "pointerdown" , ( ) => { if ( event . target . matches ( 'input:not([type=radio], [type=checkbox], [type=reset], [disabled]), textarea:not([disabled])' ) ) { efyaudio . step . cloneNode ( ) . play ( ) } } ) ;
} /*Hover*/ if ( localStorage . efy _audio _hover == "on" ) { $all ( "summary, select:not([multiple], [disabled]), [type=submit], [type=reset], [efy_sidebar_btn_open], [efy_sidebar_btn_close], .video-grid>div" ) . forEach ( x => x . addEventListener ( "mouseenter" , ( ) => efyaudio . hover . cloneNode ( ) . play ( ) ) ) ; } } }
/*EFY Tabs*/ $all ( '[efy_tabs]' ) . forEach ( z => { let x = '[efy_tabs=' + z . getAttribute ( 'efy_tabs' ) + '] > ' ;
$all ( x + '[efy_tab]' ) . forEach ( y => { let cld = $create ( 'code' ) ; cld . textContent = y . textContent ; y . textContent = '' ; y . appendChild ( cld ) ; y . onclick = e => { let efy _tab = e . target . getAttribute ( 'efy_tab' ) ;
$all ( x + '[efy_tab]' ) . forEach ( y => y . removeAttribute ( 'efy_active' ) ) ; e . target . setAttribute ( 'efy_active' , '1' ) ;
$all ( x + '[efy_content]' ) . forEach ( y => y . removeAttribute ( 'efy_active' ) ) ; $ ( x + ' [efy_content="' + efy _tab + '"]' ) . setAttribute ( 'efy_active' , '1' ) ;
2022-09-05 18:05:42 +00:00
} } ) ; } ) ;
/*Clock & Timer*/ function efy _time _0 ( i ) { if ( i < 10 ) { i = '0' + i } return i ; }
/*Clock*/ function efy _clock ( ) { let t = new Date ( ) , h = t . getHours ( ) , m = t . getMinutes ( ) ; m = efy _time _0 ( m ) ;
2022-09-28 18:12:32 +00:00
$all ( '[efy_clock]' ) . forEach ( x => { x . textContent = h + ':' + m ; } ) ; setTimeout ( efy _clock , 10000 ) ; } efy _clock ( ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Timer*/ $all ( '[efy_timer]' ) . forEach ( y => { $append ( y , $add ( 'div' , { efy _text : '' } , [ '00:00:00' ] ) ) ; $append ( y , $add ( 'button' , { efy _start : '' } ) ) ; $append ( y , $add ( 'button' , { efy _reset : '' } ) ) ;
let x = '[efy_timer=' + y . getAttribute ( 'efy_timer' ) + '] ' , play = $ ( x + '[efy_start]' ) , reset = $ ( x + '[efy_reset]' ) , timer _text = $ ( x + '[efy_text]' ) , interval , [ hour , minute , second , h , m , s ] = [ 0 , 0 , 0 , '00' , '00' , '00' ] ;
2022-09-05 18:05:42 +00:00
play . addEventListener ( "click" , ( ) => { clearInterval ( interval ) ; play . toggleAttribute ( 'efy_active' ) ; if ( play . hasAttribute ( 'efy_active' ) ) { interval = setInterval ( ( ) => { second ++ ;
s = efy _time _0 ( second ) ; if ( second > 59 ) { s = '00' ; second = 0 ; minute ++ ;
m = efy _time _0 ( minute ) ; if ( minute > 59 ) { m = '00' ; minute = 0 ; hour ++ ;
h = efy _time _0 ( hour ) ;
2022-09-28 18:12:32 +00:00
} } timer _text . textContent = h + ':' + m + ':' + s ; } , 1000 ) ; } else { clearInterval ( interval ) ; } } ) ;
reset . addEventListener ( "click" , ( ) => { clearInterval ( interval ) ; [ hour , minute , second , h , m , s ] = [ 0 , 0 , 0 , '00' , '00' , '00' ] ; timer _text . textContent = "00:00:00" ; play . removeAttribute ( 'efy_active' ) ; } ) ; } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Search Filter */ $all ( '[efy_search]' ) . forEach ( a => { let search = a . getAttribute ( 'efy_search' ) , container = ` # ${ a . id } [efy_search=" ${ search } "] ` ;
$all ( container + ' [efy_search_input]' ) . forEach ( z => { z . addEventListener ( 'keyup' , ( ) => { let val = z . value . toLowerCase ( ) ;
$all ( container + ' ' + search ) . forEach ( x => { if ( x . innerHTML . toLowerCase ( ) . includes ( val ) == 0 ) { x . setAttribute ( 'efy_display_none' , '1' ) } else { x . removeAttribute ( 'efy_display_none' ) } } ) } ) } ) } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Alerts*/ $insert ( $body , 'afterbegin' , $add ( 'div' , { efy _alerts : '' } ) ) ; $body . addEventListener ( "pointerup" , ( ) => { if ( event . target . matches ( '[efy_alert]' ) ) { event . target . remove ( ) } } ) ;
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*Online / Offline*/ for ( let a = [ 'offline' , 'online' ] , b = [ "You're OFFLINE" , "You're back ONLINE" ] , c = [ 'Maybe check your internet connection?' , 'Reload the page if needed' ] , i = 0 ; i < a . length ; i ++ ) { window . addEventListener ( a [ i ] , ( ) => { $append ( $ ( '[efy_alerts]' ) , $add ( 'div' , { efy _alert : '' , class : ` efy_alert_ ${ a [ i ] } ` } , [ $add ( 'div' , { } , [ $add ( 'h6' , { } , [ b [ i ] ] ) , $add ( 'p' , { } , [ c [ i ] ] ) ] ) , $add ( 'button' , { efy _btn _square : '' } , [ $add ( 'i' , { efy _icon : 'remove' } ) ] ) ] ) ) } ) }
2022-09-05 18:05:42 +00:00
2022-09-28 18:12:32 +00:00
/*End scope*/ }