| Total Complexity | 6 | 
| Complexity/F | 1.5 | 
| Lines of Code | 44 | 
| Function Count | 4 | 
| Duplicated Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import { getGlobalStorageProvider } from "../browserApi/storageProvider"; | ||
| 2 | import { assigned } from "../utils/helpers"; | ||
| 3 | |||
| 4 | // website | ||
| 5 | export const SETTINGS_websiteDisplayQuickSearch = 'websiteDisplayQuickSearch'; | ||
| 6 | export const SETTINGS_websiteShowNotificationsCountInTab = 'websiteShowNotificationsCountInTab'; | ||
| 7 | export const SETTINGS_websiteHideUnusedTabs = 'websiteHideUnusedTabs'; | ||
| 8 | export const SETTINGS_websiteOptimizeListAppearance = 'websiteOptimizeListAppearance'; | ||
| 9 | // anime | ||
| 10 | export const SETTINGS_animeLanguageDisplay = 'animeLanguageDisplay'; | ||
| 11 | // requests | ||
| 12 | export const SETTINGS_requestBeautifyPage = 'requestBeautifyPage'; | ||
| 13 | // player | ||
| 14 | export const SETTINGS_playerAutoplayAfterScreenshot = 'playerAutoplayAfterScreenshot'; | ||
| 15 | // w2g | ||
| 16 | export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter'; | ||
| 17 | class Configuration { | ||
| 18 |     constructor() { | ||
| 19 | this.settingsCache = new Map(); | ||
| 20 | } | ||
| 21 | |||
| 22 |     getProperty(key, callback) { | ||
| 23 |         if (this.settingsCache.has(key)) { | ||
| 24 | callback(this.settingsCache.get(key)); | ||
| 25 | } | ||
| 26 |         else { | ||
| 27 | // OOOPS // currently all settings are default true. This isn´t a problem but there should be much better soloutions after migration to typescript.... | ||
| 28 |             getGlobalStorageProvider().getData(key, true, value => { | ||
| 29 | this.settingsCache.set(key, value); | ||
| 30 | callback(value); | ||
| 31 | }); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | let __globalConfig; | ||
| 37 | |||
| 38 | export function getGlobalConfiguration() { | ||
| 39 |     if (!assigned(__globalConfig)) { | ||
| 40 | __globalConfig = new Configuration(); | ||
| 41 | } | ||
| 42 | |||
| 43 | return __globalConfig; | ||
|  | |||
| 44 | } |