summaryrefslogtreecommitdiff
path: root/src/client/scripts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-11-25 21:31:34 +0900
committerGitHub <noreply@github.com>2020-11-25 21:31:34 +0900
commit014440850014ee86d766bb07467c2970b17a1fc6 (patch)
treeffb652fe1db3365d430ed72ec2c62aaacfbe21fb /src/client/scripts
parentフォントレンダリングを調整 (diff)
downloadsharkey-014440850014ee86d766bb07467c2970b17a1fc6.tar.gz
sharkey-014440850014ee86d766bb07467c2970b17a1fc6.tar.bz2
sharkey-014440850014ee86d766bb07467c2970b17a1fc6.zip
nanka iroiro (#6853)
* wip * Update maps.ts * wip * wip * wip * wip * Update base.vue * wip * wip * wip * wip * Update link.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update privacy.vue * wip * wip * wip * wip * Update range.vue * wip * wip * wip * wip * Update profile.vue * wip * Update a.vue * Update index.vue * wip * Update sidebar.vue * wip * wip * Update account-info.vue * Update a.vue * wip * wip * Update sounds.vue * wip * wip * wip * wip * wip * wip * wip * wip * Update account-info.vue * Update account-info.vue * wip * wip * wip * Update d-persimmon.json5 * wip
Diffstat (limited to 'src/client/scripts')
-rw-r--r--src/client/scripts/sound.ts24
-rw-r--r--src/client/scripts/theme.ts13
2 files changed, 27 insertions, 10 deletions
diff --git a/src/client/scripts/sound.ts b/src/client/scripts/sound.ts
new file mode 100644
index 0000000000..13fd9a80f5
--- /dev/null
+++ b/src/client/scripts/sound.ts
@@ -0,0 +1,24 @@
+import { device } from '@/cold-storage';
+
+const cache = new Map<string, HTMLAudioElement>();
+
+export function play(type: string) {
+ const sound = device.get('sound_' + type as any);
+ if (sound.type == null) return;
+ playFile(sound.type, sound.volume);
+}
+
+export function playFile(file: string, volume: number) {
+ const masterVolume = device.get('sound_masterVolume');
+ if (masterVolume === 0) return;
+
+ let audio: HTMLAudioElement;
+ if (cache.has(file)) {
+ audio = cache.get(file);
+ } else {
+ audio = new Audio(`/assets/sounds/${file}.mp3`);
+ cache.set(file, audio);
+ }
+ audio.volume = masterVolume - ((1 - volume) * masterVolume);
+ audio.play();
+}
diff --git a/src/client/scripts/theme.ts b/src/client/scripts/theme.ts
index c1fc88bf0e..c1580c6367 100644
--- a/src/client/scripts/theme.ts
+++ b/src/client/scripts/theme.ts
@@ -15,19 +15,12 @@ export const darkTheme: Theme = require('../themes/_dark.json5');
export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X'));
export const builtinThemes = [
- require('../themes/l-white.json5'),
- require('../themes/l-red.json5'),
- require('../themes/l-green.json5'),
- require('../themes/l-blue.json5'),
+ require('../themes/l-light.json5'),
require('../themes/l-apricot.json5'),
- require('../themes/d-black.json5'),
- require('../themes/d-red.json5'),
- require('../themes/d-green.json5'),
- require('../themes/d-blue.json5'),
+ require('../themes/d-dark.json5'),
require('../themes/d-persimmon.json5'),
-
- require('../themes/d-battery-saver.json5'),
+ require('../themes/d-black.json5'),
] as Theme[];
let timeout = null;