#include animate.js #include common.js #include emotes.js #include utility.js #include youare.jsx #include settings/backup.js #include ui/emotes.js #include ui/menus.js #include ui/view.js Umi.UI.Settings = (function() { const items = [ { name: 'interface', title: 'Interface', items: [ { name: 'style', title: 'Style', type: 'select', options: () => Umi.UI.View.AccentColours, }, { name: 'compactView', title: 'Compact view', type: 'checkbox', }, { name: 'autoScroll', title: 'Scroll to latest message', type: 'checkbox', }, { name: 'closeTabConfirm', title: 'Confirm tab close', type: 'checkbox', }, { name: 'showChannelList', title: 'Show channel list', type: 'checkbox', }, { name: 'fancyInfo', title: 'Fancy server messages', type: 'checkbox', }, { name: 'autoCloseUserContext', title: 'Auto-close user menus', type: 'checkbox', }, ], }, { name: 'text', title: 'Text', items: [ { name: 'enableParser', title: 'Parse markup', type: 'checkbox', }, { name: 'enableEmoticons', title: 'Parse emoticons', type: 'checkbox', }, { name: 'autoParseUrls', title: 'Auto detect links', type: 'checkbox', }, { name: 'preventOverflow', title: 'Prevent overflow', type: 'checkbox', }, { name: 'expandTextBox', title: 'Grow input box', type: 'checkbox', }, { name: 'eepromAutoInsert', title: 'Auto-insert uploads', type: 'checkbox', }, { name: 'autoEmbedV1', title: 'Auto-embed media', type: 'checkbox', }, ], }, { name: 'notification', title: 'Notification', items: [ { name: 'flashTitle', title: 'Strobe title on new message', type: 'checkbox', }, { name: 'showServerMsgInTitle', title: 'Show server message in title', type: 'checkbox', }, { name: 'enableNotifications', title: 'Show notifications', type: 'checkbox', }, { name: 'notificationShowMessage', title: 'Show contents of message', type: 'checkbox', }, { name: 'notificationTriggers', title: 'Triggers', type: 'text', }, ], }, { name: 'sounds', title: 'Sound', items: [ { name: 'soundEnable', title: 'Enable sound', type: 'checkbox', }, { name: 'soundPack', title: 'Sound pack', type: 'select', options: () => { const packs = {}; mami.getSoundPacks().forEachPack(function(pack) { packs[pack.getName()] = pack.getTitle(); }); return packs; }, }, { name: 'soundVolume', title: 'Sound volume', type: 'range', }, { name: 'soundEnableJoin', title: 'Play join sound', type: 'checkbox', }, { name: 'soundEnableLeave', title: 'Play leave sound', type: 'checkbox', }, { name: 'soundEnableError', title: 'Play error sound', type: 'checkbox', }, { name: 'soundEnableServer', title: 'Play server message sound', type: 'checkbox', }, { name: 'soundEnableIncoming', title: 'Play receive message sound', type: 'checkbox', }, { name: 'onlySoundOnMention', title: 'Only play receive sound on mention', type: 'checkbox', }, { name: 'soundEnableOutgoing', title: 'Play send message sound', type: 'checkbox', }, { name: 'soundEnablePrivate', title: 'Play private message sound', type: 'checkbox', }, { name: 'soundEnableForceLeave', title: 'Play kick sound', type: 'checkbox', }, { name: 'minecraft', title: 'Minecraft', type: 'select', options: () => { return { 'no': 'No Minecraft', 'yes': 'Yes Minecraft', 'old': 'Old Minecraft', }; }, }, { name: 'playSoundOnConnect', title: 'Play join sound on connect', type: 'checkbox', }, { name: 'windowsLiveMessenger', title: 'Windows Live Messenger', type: 'checkbox', }, { name: 'seinfeld', title: 'Seinfeld', type: 'checkbox', }, ], }, { name: 'misc', title: 'Misc', items: [ { name: 'playJokeSounds', title: 'Run joke triggers', type: 'checkbox', }, { name: 'weeaboo', title: 'Weeaboo', type: 'checkbox', }, { name: 'motivationalImages', title: 'Make images motivational', type: 'checkbox', }, { name: 'motivationalVideos', title: 'Make videos motivational', type: 'checkbox', }, { name: 'osuKeysV2', title: 'osu! keyboard sounds', type: 'select', options: () => { return { 'no': 'Off', 'yes': 'On', 'rng': 'On, random pitch', }; }, }, { name: 'explosionRadius', title: 'Messages to keep on clear', type: 'number', }, { title: 'Reload emoticons', type: 'button', invoke: button => { const emotes = futami.get('emotes'); setTimeout(() => { button.disabled = true; futami.getJson('emotes', true) .then(emotes => { MamiEmotes.clear(); MamiEmotes.loadLegacy(emotes); }) .finally(() => { Umi.UI.Emoticons.Init(); button.disabled = false; }); }, 200); }, }, { title: 'Reload joke triggers', type: 'button', invoke: button => { button.disabled = true; const triggers = mami.getTextTriggers(); triggers.clearTriggers(); if(mami.getSettings().get('playJokeSounds')) futami.getJson('texttriggers', true) .then(trigInfos => triggers.addTriggers(trigInfos)) .finally(() => button.disabled = false); }, }, { title: 'Open compatibility client', type: 'button', invoke: () => { const meow = $e('a', { href: window.AMI_URL, target: '_blank', style: { display: 'none' } }); document.body.appendChild(meow); meow.click(); $r(meow); }, }, ], }, { name: 'settings', title: 'Settings', items: [ { title: 'Import settings', type: 'button', invoke: () => { if(!confirm('Your current settings will be replaced with the ones in the export. Are you sure you want to continue?')) return; (new MamiSettingsBackup(mami.getSettings())).importUpload(document.body); }, }, { title: 'Export settings', type: 'button', invoke: () => { const user = Umi.User.getCurrentUser(); let fileName; if(user !== null) fileName = `${user.getName()}'s settings.mami`; (new MamiSettingsBackup(mami.getSettings())).exportDownload(document.body, fileName); }, }, { title: 'Reset settings', type: 'button', invoke: () => { if(!confirm('This will reset all your settings to their defaults values. Are you sure you want to do this?')) return; mami.getSettings().clear(); }, }, ], }, { name: 'debug', title: 'Debug', collapse: true, warning: "Only touch these settings if you're ABSOLUTELY sure you know what you're doing, you're on your own if you break something.", items: [ { name: 'dumpPackets', title: 'Dump packets to console', type: 'checkbox', }, { name: 'neverUseWorker', title: 'Never use Worker for connection', type: 'checkbox', confirm: "If you're here it likely means that you mistakenly believe that your browser doesn't suck. You may go ahead but if disabling this causes any annoyances for other users you will be expunged.", }, { name: 'forceUseWorker', title: 'Always use Worker for connection', type: 'checkbox', }, { name: 'marqueeAllNames', title: 'Apply marquee on everyone', type: 'checkbox', }, { name: 'tmpDisableOldThemeSys', title: 'Disable Old Theme System', type: 'checkbox', }, { name: 'tmpSkipDomainPopUpThing', title: 'Skip domain pop up thing', type: 'checkbox', }, { title: 'You are an idiot!', type: 'button', invoke: async button => { button.disabled = true; await (new MamiYouAreAnIdiot()).pushOn(mami.getViews()); button.disabled = false; }, }, ], } ]; const createCopyright = function() { return
; }; const createSetting = function(display) { const settings = mami.getSettings(); let setting; if('name' in display) setting = settings.info(display.name); let input = display.type === 'select' ? : ; if(display.disabled === true) input.disabled = true; if(display.type === 'select') { const options = display.options(); for(const name in options) input.appendChild(); } else if(display.type === 'button') { input.value = display.title; input.addEventListener('click', () => display.invoke(input)); } if(setting !== undefined) { if(!input.disabled && setting.immutable) input.disabled = true; if(display.type === 'checkbox') { settings.watch(setting.name, v => input.checked = v); input.addEventListener('change', () => { if(display.confirm !== undefined && input.checked !== setting.fallback && !confirm(display.confirm)) { input.checked = setting.fallback; return; } settings.toggle(setting.name); }); } else { settings.watch(setting.name, v => input.value = v); input.addEventListener('change', () => settings.set(setting.name, input.value)); } } let label = input; if(display.type === 'checkbox') { label = ; } else if(display.type === 'button') { label = ; } else { label = ; } return