Merge branch 'master' of github.com:jean-emmanuel/open-stage-control

This commit is contained in:
bordun 2020-07-06 13:26:00 +02:00
commit bc2e5578fd
9 changed files with 91 additions and 11 deletions

View file

@ -171,11 +171,12 @@ var incrementWidget = function(data, root){
var id = data.id,
address = data.address
if (id && address == '/'+id) {
if (id && address == '/' + id) {
data.address = 'auto'
} else if (address){
} else if (address !== 'auto') {
var addressref
while (fakeStore.address.indexOf(address) != -1 || widgetManager.getWidgetByAddress(addressref).length) {
address = address.replace(/([0-9]*)$/,function(m){

View file

@ -9,6 +9,8 @@ var {updateWidget, incrementWidget} = require('./data-workers'),
UiInspector = require('../ui/ui-inspector'),
UiTree = require('../ui/ui-tree'),
UiDragResize = require('../ui/ui-dragresize'),
notifications = require('../ui/notifications'),
locales = require('../locales'),
{leftUiSidePanel, rightUiSidePanel} = require('../ui/'),
ipc = require('../ipc'),
sessionManager
@ -27,17 +29,44 @@ class Editor {
this.inspector.on('update', (event)=>{
var {propName, value} = event,
newWidgets = []
newWidgets = [],
error = false
for (var w of this.selectedWidgets) {
if ((propName === 'label' || propName === 'popupLabel') && value === true) {
let previousValue = w.props[propName]
if ((propName === '' || propName === 'popupLabel') && value === true) {
w.props[propName] = 'auto'
} else {
w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type][propName].value)
}
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
try {
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
} catch (e) {
w.props[propName] = previousValue
updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
notifications.add({
class: 'error',
message: locales('inspector_error'),
duration: 7000
})
console.error(
`Error while setting ${propName} to: ${JSON.stringify(value)}.`,
'It\'s probably a bug, please a new bug ticket with these informations (https://github.com/jean-emmanuel/open-stage-control/issues).'
)
console.error(e)
error = true
}
}
if (error) return
this.pushHistory()
if (newWidgets.length > 1) this.select(newWidgets)

View file

@ -40,6 +40,7 @@ module.exports = {
// inspector
inspector_color_confirm: 'Confirm',
inspector_color_apply: 'Apply',
inspector_error: 'An error just occured, open F12 to read more.',
// nosleep
nosleep: 'Prevent sleep',

View file

@ -40,6 +40,7 @@ module.exports = {
// inspector
inspector_color_confirm: 'Confirmer',
inspector_color_apply: 'Appliquer',
inspector_error: 'Une erreur vient de survenir, appuyez sur F12 pour en savoir plus.',
// nosleep
nosleep: 'Empêcher la veille',

View file

@ -41,7 +41,7 @@ class WidgetManager extends EventEmitter {
if (linkId) {
if (!Array.isArray(linkId)) linkId = [linkId]
linkId = linkId.map(x=>x.replace(/^>>\s*/, '')).filter(x=>x.indexOf('<<') < 0)
linkId = linkId.map(x=>String(x).replace(/^>>\s*/, '')).filter(x=>x.indexOf('<<') < 0)
linkId = linkId.filter(x=>this.linkIdLock.indexOf(x)<0)
this.linkIdLock = this.linkIdLock.concat(linkId)
this.linkIdLockDepth++
@ -118,7 +118,7 @@ class WidgetManager extends EventEmitter {
if (linkId) {
if (!Array.isArray(linkId)) linkId = [linkId]
linkId = linkId.map(x=>x.replace(/^<<\s*/, '')).filter(x=>x.indexOf('>>') < 0)
linkId = linkId.map(x=>String(x).replace(/^<<\s*/, '')).filter(x=>x.indexOf('>>') < 0)
for (var i in linkId) {
if (linkId[i]) {
if (!this.linkIdRoute[linkId[i]]) this.linkIdRoute[linkId[i]] = []
@ -185,6 +185,7 @@ class WidgetManager extends EventEmitter {
if (scroll && this.scrollingWidgets.indexOf(hash) != -1) this.scrollingWidgets.splice(this.scrollingWidgets.indexOf(hash), 1)
if (!Array.isArray(linkId)) linkId = [linkId]
linkId = linkId.map(x=>String(x))
for (var i in linkId) {
if (linkId[i] && this.linkIdRoute[linkId[i]] && this.linkIdRoute[linkId[i]].indexOf(hash) != -1) this.linkIdRoute[linkId[i]].splice(this.linkIdRoute[linkId[i]].indexOf(hash), 1)
}

View file

@ -223,8 +223,8 @@ class Panel extends Container() {
if (!s) {
return [this.widget.scrollLeft, this.widget.scrollTop]
} else {
this.widget.scrollLeft = s[0]
this.widget.scrollTop = s[1]
if (s[0] !== undefined) this.widget.scrollLeft = s[0]
if (s[1] !== undefined) this.widget.scrollTop = s[1]
}
}

View file

@ -147,6 +147,32 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.getScroll = (id)=>{
var widgets = this.resolveId(id)
for (var i = widgets.length - 1; i >= 0; i--) {
if (widgets[i].scroll) return widgets[i].scroll()
}
return []
}
this.sandbox.contentWindow.setScroll = (id, x, y)=>{
var widgets = this.resolveId(id)
for (var i = widgets.length - 1; i >= 0; i--) {
if (widgets[i].scroll) widgets[i].scroll([x, y])
}
}
this.sandbox.contentWindow.httpGet = (url, callback)=>{
var parser = urlParser(url),
@ -286,7 +312,7 @@ class ScriptVm extends Vm {
}
for (var imports of ['set', 'get', 'getProp', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'unfocus']) {
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'unfocus', 'setScroll', 'getScroll']) {
this.sanitize(this.sandbox.contentWindow[imports])
}