Parcourir la source

Settings

master
Roderic Day il y a 5 ans
Parent
révision
9fcf66c270
2 fichiers modifiés avec 38 ajouts et 5 suppressions
  1. +1
    -4
      apps/streams.js
  2. +37
    -1
      pico.js

+ 1
- 4
apps/streams.js Voir le fichier

@@ -1,9 +1,6 @@
const VideoConfig = Object.seal({
videoOn: true,
audioOn: true,
get videoCover() {
return params.get('c') === '1'
},
get video() {
return VideoConfig.videoOn
&& params.get('v') !== '0'
@@ -152,7 +149,7 @@ const Video = {
fontSize: 'xxx-large',
}
const styleVideo = {
objectFit: VideoConfig.videoCover ? 'cover' : 'contain',
objectFit: Settings.get('blackBars') ? 'contain' : 'cover',
width: '100%',
height: '100%',
transform: 'scaleX(-1)',

+ 37
- 1
pico.js Voir le fichier

@@ -88,6 +88,42 @@ const connect = (username) => {
* BASE
*
*/
const Settings = {
get(key) {
try {
return JSON.parse(localStorage.getItem(key))
}
catch(error) {
return null
}
},
set(key, value) {
localStorage.setItem(key, JSON.stringify(value))
},
multiField: ([key, options]) => {
let current = Settings.get(key)
if(!options.includes(current)) {
Settings.set(key, options[0])
}
return m('.field',
m('label', key),
options.map(value => {
const style = {
fontWeight: Settings.get(key) == value ? 'bold' : 'unset'
}
const onclick = () => Settings.set(key, value)
return m('button', {style, onclick}, `${value}`)
})
)
},
view() {
return m('.settings',
Object.entries({
blackBars: [true, false],
}).map(Settings.multiField)
)
},
}
const Base = {
oncreate: () => {
const randomName = ('' + Math.random()).substring(2)
@@ -143,7 +179,7 @@ const Base = {
State.isConnected ? [
m(StreamContainer),
m(Chat),
] : null,
] : m(Settings),
)
},
}

Chargement…
Annuler
Enregistrer