|
|
|
|
|
|
|
|
* BASE |
|
|
* 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 = { |
|
|
const Base = { |
|
|
oncreate: () => { |
|
|
oncreate: () => { |
|
|
const randomName = ('' + Math.random()).substring(2) |
|
|
const randomName = ('' + Math.random()).substring(2) |
|
|
|
|
|
|
|
|
State.isConnected ? [ |
|
|
State.isConnected ? [ |
|
|
m(StreamContainer), |
|
|
m(StreamContainer), |
|
|
m(Chat), |
|
|
m(Chat), |
|
|
] : null, |
|
|
|
|
|
|
|
|
] : m(Settings), |
|
|
) |
|
|
) |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |