lint: add eslint config files and clean all the mess
This commit is contained in:
parent
98f7e9fe2f
commit
fa9b92397f
66 changed files with 446 additions and 449 deletions
|
|
@ -52,7 +52,7 @@ module.exports = {
|
|||
get: function(a, b) {
|
||||
|
||||
var context = b ? a : document,
|
||||
selector = b || a
|
||||
selector = b || a
|
||||
|
||||
if (selector.indexOf('>') == 0) selector = ':scope ' + selector
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ module.exports = {
|
|||
if (!isNaN(element.offsetTop)) {
|
||||
offsetTop += element.offsetTop - element.scrollTop
|
||||
}
|
||||
} while (element = element.offsetParent)
|
||||
} while ((element = element.offsetParent))
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var {updateWidget, incrementWidget} = require('./data-workers'),
|
||||
{Popup} = require('../ui/utils'),
|
||||
{widgets, categories} = require('../widgets/'),
|
||||
{categories} = require('../widgets/'),
|
||||
widgetManager = require('../managers/widgets'),
|
||||
editor = require('./')
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ class ContextMenu {
|
|||
|
||||
if (typeof actions[label] == 'object') {
|
||||
|
||||
var item = DOM.create(`<div class="item has-sub" tabIndex="1">${label}</div>`)
|
||||
let item = DOM.create(`<div class="item has-sub" tabIndex="1">${label}</div>`)
|
||||
menu.appendChild(item)
|
||||
|
||||
this.open(e,actions[label],item)
|
||||
|
|
@ -33,7 +33,7 @@ class ContextMenu {
|
|||
|
||||
} else {
|
||||
|
||||
var item = DOM.create(`<div class="item">${label}</div>`)
|
||||
let item = DOM.create(`<div class="item">${label}</div>`)
|
||||
menu.appendChild(item)
|
||||
item.addEventListener(this.event, (e)=>{
|
||||
e.detail.preventDefault = true
|
||||
|
|
@ -79,7 +79,7 @@ class ContextMenu {
|
|||
|
||||
}
|
||||
|
||||
close() {
|
||||
close() {
|
||||
|
||||
if (this.menu) {
|
||||
|
||||
|
|
@ -147,14 +147,14 @@ var handleClick = function(event) {
|
|||
// right-click menu
|
||||
if (event.type !== 'fast-right-click') return
|
||||
|
||||
if (!event.detail.ctrlKey && editor.selectedWidgets.length <= 1) {
|
||||
if (!event.detail.ctrlKey && editor.selectedWidgets.length <= 1) {
|
||||
editor.select(widget, {multi: event.detail[mod]})
|
||||
}
|
||||
|
||||
if (!editor.selectedWidgets.length) return
|
||||
|
||||
var index = editor.selectedWidgets.map((w) => DOM.index(w.container)).sort((a,b)=>{return b-a}),
|
||||
data = editor.selectedWidgets.map((w) => w.props),
|
||||
var index = editor.selectedWidgets.map((w)=>DOM.index(w.container)).sort((a,b)=>{return b-a}),
|
||||
data = editor.selectedWidgets.map((w)=>w.props),
|
||||
type = editor.selectedWidgets[0].props.type == 'tab' ? 'tab' : 'widget',
|
||||
parent = editor.selectedWidgets[0].parent
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ var handleClick = function(event) {
|
|||
|
||||
wrap.widgets = data
|
||||
|
||||
var minTop = Math.min(...data.map(x => isNaN(x.top) ? x.top == 'auto' ? 0 : Infinity : x.top))
|
||||
var minLeft = Math.min(...data.map(x => isNaN(x.left) ? x.left == 'auto' ? 0 : Infinity : x.left))
|
||||
var minTop = Math.min(...data.map(x=>isNaN(x.top) ? x.top == 'auto' ? 0 : Infinity : x.top))
|
||||
var minLeft = Math.min(...data.map(x=>isNaN(x.left) ? x.left == 'auto' ? 0 : Infinity : x.left))
|
||||
|
||||
wrap.top = minTop === Infinity ? data[0].top : minTop
|
||||
wrap.left= minLeft === Infinity ? data[0].left : minLeft
|
||||
|
|
@ -242,7 +242,7 @@ var handleClick = function(event) {
|
|||
|
||||
if (editor.clipboard !== null) {
|
||||
|
||||
function paste(increment) {
|
||||
var paste = function(increment) {
|
||||
|
||||
var pastedData = JSON.parse(editor.clipboard),
|
||||
minTop = Infinity,
|
||||
|
|
@ -259,7 +259,7 @@ var handleClick = function(event) {
|
|||
}
|
||||
|
||||
var keepPosition = eventData.target.classList.contains('tablink')
|
||||
for (var i in pastedData) {
|
||||
for (let i in pastedData) {
|
||||
|
||||
if (!keepPosition) {
|
||||
if (!isNaN(pastedData[i].top)) pastedData[i].top = pastedData[i].top - minTop + clickY
|
||||
|
|
@ -268,7 +268,7 @@ var handleClick = function(event) {
|
|||
|
||||
}
|
||||
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets = data[0].widgets.concat(pastedData)
|
||||
|
||||
updateWidget(editor.selectedWidgets[0])
|
||||
|
|
@ -298,7 +298,7 @@ var handleClick = function(event) {
|
|||
clone.left = clickX
|
||||
}
|
||||
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets.push(clone)
|
||||
|
||||
updateWidget(editor.selectedWidgets[0])
|
||||
|
|
@ -326,7 +326,7 @@ var handleClick = function(event) {
|
|||
newData.left= clickX
|
||||
}
|
||||
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets.push(newData)
|
||||
updateWidget(editor.selectedWidgets[0])
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ var handleClick = function(event) {
|
|||
if (data.length == 1 && (!data[0].widgets || !data[0].widgets.length) && (data[0].tabs)) {
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add tab'] = ()=>{
|
||||
data[0].tabs = data[0].tabs || []
|
||||
data[0].tabs = data[0].tabs || []
|
||||
data[0].tabs.push({})
|
||||
updateWidget(editor.selectedWidgets[0])
|
||||
}
|
||||
|
|
@ -366,11 +366,11 @@ var handleClick = function(event) {
|
|||
popup.close()
|
||||
|
||||
if (type === 'widget') {
|
||||
for (var i of index) {
|
||||
for (let i of index) {
|
||||
parent.props.widgets.splice(i,1)
|
||||
}
|
||||
} else {
|
||||
for (var i of index) {
|
||||
for (let i of index) {
|
||||
parent.props.tabs.splice(i,1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var {iconify} = require('../ui/utils'),
|
||||
widgetManager = require('../managers/widgets'),
|
||||
var widgetManager = require('../managers/widgets'),
|
||||
resize = require('../events/resize'),
|
||||
stateManager = require('../managers/state'),
|
||||
parser = require('../parser'),
|
||||
|
|
@ -12,7 +11,6 @@ var updateWidget = function(widget, options = {}) {
|
|||
scroll = sidepanel.scrollTop,
|
||||
oldWidgets = widget.childrenHashes.concat(widget.hash),
|
||||
wasSelected = editor.selectedWidgets.includes(widget),
|
||||
oldValueProps = {},
|
||||
wScroll = {}
|
||||
|
||||
stateManager.incrementQueue()
|
||||
|
|
@ -72,7 +70,7 @@ var updateWidget = function(widget, options = {}) {
|
|||
|
||||
}
|
||||
|
||||
var fakeStore = {}
|
||||
var fakeStore = {}
|
||||
|
||||
var incrementWidget = function(data, root){
|
||||
|
||||
|
|
@ -86,7 +84,6 @@ var incrementWidget = function(data, root){
|
|||
}
|
||||
|
||||
var id = data.id,
|
||||
label = data.label,
|
||||
address = data.address
|
||||
|
||||
if (id && address == '/'+id) {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
for (let type of widgetCategories[category]) {
|
||||
input.innerHTML += `<option ${type == widget.props.type ? 'selected' : ''} value="${type}">${type}</option>`
|
||||
}
|
||||
input.innerHTML += `</optgroup>`
|
||||
input.innerHTML += '</optgroup>'
|
||||
}
|
||||
|
||||
var wrapper = DOM.create(`<div class="select-wrapper"></div>`)
|
||||
var wrapper = DOM.create('<div class="select-wrapper"></div>')
|
||||
wrapper.appendChild(input)
|
||||
field.appendChild(wrapper)
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
} else {
|
||||
|
||||
var value = typeof widget.props[propName] !== 'string' ?
|
||||
JSON.stringify(widget.props[propName], null, ' ').replace(/\n\s\s\s\s/g, ' ').replace(/\n\s\s(\}|\])/g, ' $1') : widget.props[propName]
|
||||
JSON.stringify(widget.props[propName], null, ' ').replace(/\n\s\s\s\s/g, ' ').replace(/\n\s\s(\}|\])/g, ' $1') : widget.props[propName]
|
||||
|
||||
input = DOM.create(`<textarea class="input" title="${propName}" rows="${value.split('\n').length}">${value}</textarea>`)
|
||||
|
||||
|
|
@ -58,22 +58,22 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
|
||||
if (typeof defaultValue === 'boolean') {
|
||||
|
||||
var toggle = DOM.create(`
|
||||
var toggle = DOM.create(`
|
||||
<span class="checkbox ${widget.props[propName] ? 'on' : ''}">
|
||||
${icon('check')}
|
||||
</span>
|
||||
`)
|
||||
|
||||
toggle.addEventListener('click', ()=>{
|
||||
input.value = !widget.getProp(propName)
|
||||
DOM.dispatchEvent(input, 'change')
|
||||
})
|
||||
toggle.addEventListener('click', ()=>{
|
||||
input.value = !widget.getProp(propName)
|
||||
DOM.dispatchEvent(input, 'change')
|
||||
})
|
||||
|
||||
field.appendChild(toggle)
|
||||
field.appendChild(toggle)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
field.appendChild(input)
|
||||
field.appendChild(input)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
v = input.value
|
||||
}
|
||||
|
||||
var newWidgets = []
|
||||
var newWidgets = []
|
||||
for (var w of editor.selectedWidgets) {
|
||||
w.props[propName] = v !== '' ? v : JSON.parse(JSON.stringify(defaultValue))
|
||||
newWidgets.push(updateWidget(w, {preventSelect: editor.selectedWidgets.length > 1}))
|
||||
|
|
@ -102,7 +102,7 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
|
||||
|
||||
} else if (
|
||||
(propName === 'widgets' && (!widget.props.tabs ||! widget.props.tabs.length)) ||
|
||||
(propName === 'widgets' && (!widget.props.tabs ||! widget.props.tabs.length)) ||
|
||||
(propName === 'tabs' && (!widget.props.widgets ||! widget.props.widgets.length))
|
||||
) {
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
break
|
||||
|
||||
case 'add':
|
||||
widget.props[propName] = widget.props[propName] || []
|
||||
widget.props[propName] = widget.props[propName] || []
|
||||
widget.props[propName].push({})
|
||||
change = true
|
||||
break
|
||||
|
|
@ -157,8 +157,8 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
var $list = $(list)
|
||||
$list.sortable({
|
||||
items: '.sortables',
|
||||
placeholder: "sortable-placeholder btn small",
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
placeholder: 'sortable-placeholder btn small',
|
||||
start:function(){$(this).sortable( 'refreshPositions' )},
|
||||
update: function(e,ui){
|
||||
var oldindex = $(ui.item).attr('data-index')
|
||||
var index = $(ui.item).index()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var Editor = class Editor {
|
|||
document.body.classList.toggle('no-grid', GRIDWIDTH == 1)
|
||||
|
||||
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue('--grid-width')
|
||||
|
||||
var gridForm = DOM.create(`
|
||||
<div class="form" id="grid-width-form">
|
||||
|
|
@ -67,7 +67,7 @@ var Editor = class Editor {
|
|||
input.value = v
|
||||
GRIDWIDTH = v
|
||||
document.body.classList.toggle('no-grid', GRIDWIDTH == 1)
|
||||
document.documentElement.style.setProperty("--grid-width", GRIDWIDTH)
|
||||
document.documentElement.style.setProperty('--grid-width', GRIDWIDTH)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -168,9 +168,9 @@ var Editor = class Editor {
|
|||
this.form.appendChild(DOM.create(`
|
||||
<div class="separator">
|
||||
${this.selectedWidgets.length > 1 ?
|
||||
'<span class="accent">Multiple Widgets</span>' :
|
||||
'<span>Widget</span>'
|
||||
}
|
||||
'<span class="accent">Multiple Widgets</span>' :
|
||||
'<span>Widget</span>'
|
||||
}
|
||||
</div>
|
||||
`))
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ var Editor = class Editor {
|
|||
element.classList.remove('editing')
|
||||
})
|
||||
|
||||
for (var widget of this.selectedWidgets) {
|
||||
for (let widget of this.selectedWidgets) {
|
||||
DOM.each(document, `[data-widget="${widget.hash}"]`, (item)=>{
|
||||
item.classList.add('editing')
|
||||
})
|
||||
|
|
@ -227,11 +227,10 @@ var Editor = class Editor {
|
|||
|
||||
if (widget.props.height !== undefined || widget.props.width !== undefined) {
|
||||
|
||||
var handleTarget
|
||||
var $container = $(widget.container)
|
||||
let $container = $(widget.container)
|
||||
$container.resizable({
|
||||
handles: 's, e, se',
|
||||
helper: "ui-helper",
|
||||
helper: 'ui-helper',
|
||||
start: (event, ui)=>{
|
||||
handleTarget = $(event.originalEvent.target)
|
||||
},
|
||||
|
|
@ -244,7 +243,7 @@ var Editor = class Editor {
|
|||
var deltaH = ui.size.height - ui.originalSize.height,
|
||||
deltaW = ui.size.width - ui.originalSize.width
|
||||
|
||||
var newWidgets = []
|
||||
var newWidgets = []
|
||||
for (var w of this.selectedWidgets) {
|
||||
var originalW = w === widget ? ui.originalSize.width : w.container.offsetWidth,
|
||||
originalH = w === widget ? ui.originalSize.height : w.container.offsetHeight
|
||||
|
|
@ -267,7 +266,7 @@ var Editor = class Editor {
|
|||
}
|
||||
}
|
||||
|
||||
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w))
|
||||
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w))
|
||||
}
|
||||
if (newWidgets.length > 1) editor.select(newWidgets, {preventSelect: this.selectedWidgets.length > 1})
|
||||
},
|
||||
|
|
@ -277,7 +276,7 @@ var Editor = class Editor {
|
|||
}
|
||||
|
||||
if (widget.props.top !== undefined) {
|
||||
var $container = $(widget.container)
|
||||
let $container = $(widget.container)
|
||||
$container.draggable({
|
||||
cursor:'-webkit-grabbing',
|
||||
drag: (event, ui)=>{
|
||||
|
|
@ -290,7 +289,7 @@ var Editor = class Editor {
|
|||
var deltaX = (ui.helper.position().left + $container.parent().scrollLeft()) / PXSCALE - widget.container.offsetLeft / PXSCALE,
|
||||
deltaY = (ui.helper.position().top + $container.parent().scrollTop()) / PXSCALE - widget.container.offsetTop / PXSCALE
|
||||
|
||||
var newWidgets = []
|
||||
var newWidgets = []
|
||||
for (var w of this.selectedWidgets) {
|
||||
|
||||
var newTop = w.container.offsetTop / PXSCALE + deltaY
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
var {fix} = require('./utils'),
|
||||
supportsPassive = require('./supports-passive')
|
||||
|
||||
var longTouchTimer = false,
|
||||
clearLongTouchTimer = function() {
|
||||
if (longTouchTimer) {
|
||||
|
|
@ -14,7 +11,7 @@ document.body.setAttribute('oncontextmenu', 'return false')
|
|||
document.addEventListener('mousedown', (event)=>{
|
||||
|
||||
if (event.touchPunch) return
|
||||
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) return
|
||||
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) return
|
||||
if (event.button == 2) event.preventDefault()
|
||||
|
||||
var e = event
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const {fix, normalizeDragEvent, resetEventOffset} = require('./utils')
|
||||
const {normalizeDragEvent, resetEventOffset} = require('./utils')
|
||||
|
||||
var targets = {},
|
||||
previousPointers = {}
|
||||
|
|
@ -102,7 +102,7 @@ function mouseMultiWrapper(event) {
|
|||
}
|
||||
|
||||
function mouseDownCapture(event, multitouch) {
|
||||
if ((event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) || event.button == 2) return
|
||||
if ((event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) || event.button == 2) return
|
||||
event.pointerId = 'mouse'
|
||||
event.multitouch = multitouch
|
||||
pointerDownHandler(event)
|
||||
|
|
@ -115,7 +115,7 @@ function mouseMoveCapture(event) {
|
|||
}
|
||||
|
||||
function mouseUpCapture(event){
|
||||
if ((event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) || event.button == 2) return
|
||||
if ((event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) || event.button == 2) return
|
||||
event.pointerId = 'mouse'
|
||||
pointerUpFilter(event)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var WolfyEventEmitter = require('wolfy87-eventemitter'),
|
||||
customEvents = {}
|
||||
customEvents = {}
|
||||
|
||||
customEvents['draginit'] = customEvents['drag'] = customEvents['dragend'] = require('./drag')
|
||||
customEvents['resize'] = require('./resize')
|
||||
|
|
@ -44,7 +44,7 @@ module.exports = class EventEmitter extends WolfyEventEmitter {
|
|||
response = {}
|
||||
|
||||
for (var key in events) {
|
||||
if (key === evtName || key.indexOf(evtNameCheck) > -1) {
|
||||
if (key === evtName || key.indexOf(evtNameCheck) > -1) {
|
||||
response[key] = events[key]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ function checkResizes(context, force){
|
|||
// Iterate over all elements to which the 'resize' event is bound.
|
||||
var resizedElems = [],
|
||||
cachedStyles = []
|
||||
for (var i = elements.length - 1; i >= 0; i--) {
|
||||
for (let i = elements.length - 1; i >= 0; i--) {
|
||||
var elem = elements[i]
|
||||
|
||||
if (!context.contains(elem)) continue
|
||||
|
|
@ -13,18 +13,18 @@ function checkResizes(context, force){
|
|||
width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
|
||||
height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
|
||||
|
||||
if (!width || !height) continue
|
||||
if (!width || !height) continue
|
||||
|
||||
// If element size has changed since the last time, update the element
|
||||
// data store and trigger the 'resize' event.
|
||||
if (force || width != elem.resizedataw || height != elem.resizedatah) {
|
||||
if (force || width != elem.resizedataw || height != elem.resizedatah) {
|
||||
elem.resizedataw = width
|
||||
elem.resizedatah = height
|
||||
resizedElems.push(elem)
|
||||
cachedStyles.push(style)
|
||||
}
|
||||
}
|
||||
for (var i = resizedElems.length - 1; i >= 0; i--) {
|
||||
for (let i = resizedElems.length - 1; i >= 0; i--) {
|
||||
resizedElems[i]._resize_widget.trigger('resize', [{
|
||||
width: resizedElems[i].resizedataw,
|
||||
height: resizedElems[i].resizedatah,
|
||||
|
|
@ -39,26 +39,26 @@ window.addEventListener('resize', ()=>{checkResizes(document)})
|
|||
|
||||
module.exports = {
|
||||
|
||||
setup: function(options) {
|
||||
setup: function(options) {
|
||||
|
||||
if (!options) return
|
||||
if (elements.indexOf(options.element) == -1) {
|
||||
elements.push(options.element)
|
||||
options.element._resize_widget = this
|
||||
}
|
||||
if (!options) return
|
||||
if (elements.indexOf(options.element) == -1) {
|
||||
elements.push(options.element)
|
||||
options.element._resize_widget = this
|
||||
}
|
||||
|
||||
},
|
||||
teardown: function(options) {
|
||||
},
|
||||
teardown: function(options) {
|
||||
|
||||
if (!options) return
|
||||
if (!options) return
|
||||
|
||||
if (elements.indexOf(options.element) != -1) {
|
||||
elements.splice(elements.indexOf(options.element), 1)
|
||||
delete options.element._resize_widget
|
||||
}
|
||||
if (elements.indexOf(options.element) != -1) {
|
||||
elements.splice(elements.indexOf(options.element), 1)
|
||||
delete options.element._resize_widget
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
check: checkResizes
|
||||
check: checkResizes
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
|
||||
|
||||
var supportsPassive = false;
|
||||
|
||||
try {
|
||||
var opts = Object.defineProperty({}, 'passive', {
|
||||
get: function() {
|
||||
supportsPassive = true;
|
||||
}
|
||||
});
|
||||
window.addEventListener("testPassive", null, opts);
|
||||
window.removeEventListener("testPassive", null, opts);
|
||||
} catch (e) {}
|
||||
|
||||
module.exports = supportsPassive
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
const Touch = window.Touch || class Touch {}
|
||||
const Touch = window.Touch || class Touch {}
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, (s,k,v)=>{
|
|||
ARGV[k]=v
|
||||
})
|
||||
|
||||
window.ELECTRON_FULLSCREEN = window.ELECTRON_FULLSCREEN || false
|
||||
window.ELECTRON_FULLSCREEN = window.ELECTRON_FULLSCREEN || false
|
||||
|
||||
window.PACKAGE = require('../../../../app/package.json')
|
||||
document.title = PACKAGE.productName + ' v' + PACKAGE.version
|
||||
|
|
@ -18,7 +18,7 @@ window.EDITING = false
|
|||
window.GRIDWIDTH = 10
|
||||
|
||||
|
||||
window.CANVAS_FRAMERATE = parseFloat(ARGV.framerate || 60)
|
||||
window.CANVAS_FRAMERATE = parseFloat(ARGV.framerate || 60)
|
||||
window.CANVAS_SCALING = parseFloat(ARGV.forceHdpi) || ( ARGV.hdpi ? window.devicePixelRatio : 1 )
|
||||
window.INITIALZOOM = ARGV.zoom ? ARGV.zoom : 1
|
||||
window.PXSCALE = INITIALZOOM
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var utils = require('../ui/utils'),
|
|||
state = require('../managers/state'),
|
||||
editor = require('../editor/')
|
||||
|
||||
var callbacks = module.exports = {
|
||||
module.exports = {
|
||||
|
||||
bundle: function(data) {
|
||||
for (let i in data) {
|
||||
|
|
@ -60,7 +60,7 @@ var callbacks = module.exports = {
|
|||
},
|
||||
|
||||
error: function(data){
|
||||
new utils.Popup({title: utils.icon('exclamation-triangle') + ' Error', content: data, closable:true})
|
||||
new utils.Popup({title: utils.icon('exclamation-triangle') + ' Error', content: data, closable:true})
|
||||
},
|
||||
|
||||
reloadCss: function(){
|
||||
|
|
@ -74,7 +74,7 @@ var callbacks = module.exports = {
|
|||
if (root) root.reCreateWidget()
|
||||
},100)
|
||||
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue('--grid-width')
|
||||
},
|
||||
|
||||
readOnly: function(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ var reconnectInterval = 5000,
|
|||
|
||||
class Ipc extends EventEmitter {
|
||||
|
||||
constructor() {
|
||||
constructor() {
|
||||
|
||||
super()
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ class Ipc extends EventEmitter {
|
|||
this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout)
|
||||
})
|
||||
this.on('ping', ()=>{
|
||||
this.socket.send(`["pong"]`)
|
||||
this.socket.send('["pong"]')
|
||||
})
|
||||
|
||||
this.open()
|
||||
|
|
@ -43,7 +43,7 @@ class Ipc extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
open() {
|
||||
open() {
|
||||
|
||||
this.socket = new WebSocket('ws://' + window.location.host + '/' + uuid)
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class Ipc extends EventEmitter {
|
|||
|
||||
this.hearbeat = setInterval(()=>{
|
||||
if (!this.connected()) return
|
||||
this.socket.send(`["ping"]`)
|
||||
this.socket.send('["ping"]')
|
||||
this.hearbeatTimeout = setTimeout(()=>{
|
||||
if (this.connected()) this.socket.close()
|
||||
}, hearbeatTimeout)
|
||||
|
|
@ -90,7 +90,7 @@ class Ipc extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
connected() {
|
||||
connected() {
|
||||
|
||||
return this.socket && this.socket.readyState == this.socket.OPEN
|
||||
|
||||
|
|
@ -100,9 +100,9 @@ class Ipc extends EventEmitter {
|
|||
|
||||
if (typeof message == 'string') {
|
||||
|
||||
var packet = JSON.parse(message);
|
||||
var packet = JSON.parse(message)
|
||||
|
||||
if (Array.isArray(packet) && typeof packet[0] == "string") {
|
||||
if (Array.isArray(packet) && typeof packet[0] == 'string') {
|
||||
|
||||
this.emit(packet[0], packet[1])
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var ipc = require('../ipc/'),
|
||||
parser = require('../parser'),
|
||||
state = require('./state'),
|
||||
editor = require('../editor/'),
|
||||
lobby = require('../ui/lobby'),
|
||||
{loading, icon, Popup, upload} = require('../ui/utils'),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
var widgetManager = require('./widgets'),
|
||||
{loading, icon, Popup, upload} = require('../ui/utils'),
|
||||
{icon, Popup, upload} = require('../ui/utils'),
|
||||
{saveAs} = require('file-saver')
|
||||
|
||||
|
||||
var StateManager = class StateManager {
|
||||
var StateManager = class StateManager {
|
||||
|
||||
constructor() {
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var WidgetManager = 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=>x.replace(/^>>\s*/, '')).filter(x=>x.indexOf('<<') < 0)
|
||||
}
|
||||
|
||||
var widgetsById = this.getWidgetById(id),
|
||||
|
|
@ -42,7 +42,7 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
// Widget that share the same id will update each other
|
||||
// without sending any extra osc message
|
||||
if (widgetsById.length > 1) {
|
||||
var v = widget.getValue()
|
||||
let v = widget.getValue()
|
||||
for (let i in widgetsById) {
|
||||
if (widgetsById[i] !== widget) {
|
||||
widgetsById[i].setValue(v,{send:false,sync:false})
|
||||
|
|
@ -53,7 +53,7 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
// widgets that share the same linkId will update each other.
|
||||
// Updated widgets will send osc messages normally
|
||||
if (widgetsByLinkId.length > 0) {
|
||||
var v = widget.getValue()
|
||||
let v = widget.getValue()
|
||||
for (let i in widgetsByLinkId) {
|
||||
if (widgetsByLinkId[i] !== widget) {
|
||||
widgetsByLinkId[i].setValue(v,{send:options.send,sync:false})
|
||||
|
|
@ -64,14 +64,15 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
}
|
||||
|
||||
createAddressRef(widget, preArgs, address) {
|
||||
var preArgs = widget ? widget.getProp('preArgs') : preArgs,
|
||||
address = widget ? widget.getProp('address') : address
|
||||
|
||||
preArgs = widget ? widget.getProp('preArgs') : preArgs
|
||||
address = widget ? widget.getProp('address') : address
|
||||
|
||||
if (!Array.isArray(preArgs) && preArgs !== '') preArgs = [preArgs]
|
||||
|
||||
return preArgs && preArgs.length ?
|
||||
address + this.preArgsSeparator + preArgs.join(this.preArgsSeparator)
|
||||
: address
|
||||
address + this.preArgsSeparator + preArgs.join(this.preArgsSeparator)
|
||||
: address
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ var WidgetManager = 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=>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]] = []
|
||||
|
|
@ -219,20 +220,19 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
}
|
||||
|
||||
|
||||
getWidgetBy(key, dict, widgets) {
|
||||
getWidgetBy(key, dict, widgets = []) {
|
||||
|
||||
var widgets = widgets || [],
|
||||
hash, w
|
||||
var hash, w
|
||||
|
||||
if (Array.isArray(key)) {
|
||||
for (var i in key) {
|
||||
for (let i in key) {
|
||||
this.getWidgetBy(key[i], dict, widgets)
|
||||
}
|
||||
return widgets
|
||||
}
|
||||
|
||||
if (dict[key]) {
|
||||
for (var i = dict[key].length-1; i>=0; i--) {
|
||||
for (let i = dict[key].length-1; i>=0; i--) {
|
||||
hash = dict[key][i]
|
||||
w = this.widgets[hash]
|
||||
if (!w) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ var Osc = class Osc extends EventEmitter {
|
|||
super()
|
||||
|
||||
this.syncOnly = false
|
||||
this.remoteControl = ()=>{console.error('remote-control module not loaded')}
|
||||
this.remoteControl = {}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ var Osc = class Osc extends EventEmitter {
|
|||
let widgetTarget = widgets[i].getProp('target')
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
if (!data.target || !widgetTarget || String(widgetTarget) === String(data.target)) {
|
||||
if (!data.target || !widgetTarget || String(widgetTarget) === String(data.target)) {
|
||||
// update matching widgets
|
||||
if (widgets[i] && widgets[i].setValue) widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ var Parser = class Parser {
|
|||
|
||||
getIterator(id) {
|
||||
|
||||
this.iterators[id] = (this.iterators[id] || 0) + 1
|
||||
this.iterators[id] = (this.iterators[id] || 0) + 1
|
||||
return this.iterators[id]
|
||||
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ var Parser = class Parser {
|
|||
// Genrate widget's id, based on its type
|
||||
if (props.id=='auto' || !props.id ) {
|
||||
var id
|
||||
while (!id || widgetManager.getWidgetById(id).length) {
|
||||
while (!id || widgetManager.getWidgetById(id).length) {
|
||||
id=props.type+'_'+this.getIterator(props.type)
|
||||
}
|
||||
props.id = id
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var {updateWidget} = require('./editor/data-workers'),
|
|||
deepExtend = require('deep-extend')
|
||||
|
||||
var callbacks = {
|
||||
'/EDIT': function(args) {
|
||||
'/EDIT': function(args) {
|
||||
|
||||
if (READ_ONLY) return
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ var callbacks = {
|
|||
|
||||
}
|
||||
},
|
||||
'/EDIT/MERGE': function(args) {
|
||||
'/EDIT/MERGE': function(args) {
|
||||
|
||||
if (READ_ONLY) return
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ var callbacks = {
|
|||
|
||||
}
|
||||
},
|
||||
'/EDIT/GET': function(args) {
|
||||
'/EDIT/GET': function(args) {
|
||||
|
||||
var [target, idOrAddress, ...preArgs] = args,
|
||||
widgets = []
|
||||
|
|
@ -142,7 +142,7 @@ var callbacks = {
|
|||
|
||||
if (!Array.isArray(args)) args = [args]
|
||||
|
||||
for (let id of args) {
|
||||
for (let id of args) {
|
||||
let ws = widgetManager.getWidgetById(id)
|
||||
for (let w of ws) {
|
||||
DOM.each(document, `.tablink[data-widget="${w.hash}"]`, (el)=>{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
this.closable = options.closable
|
||||
this.escKey = options.closable || options.escKey
|
||||
this.escKey = options.closable || options.escKey
|
||||
this.enterKey = options.enterKey
|
||||
this.content = options.content
|
||||
this.title = options.title
|
||||
|
|
@ -108,7 +108,7 @@ module.exports = {
|
|||
file = e.target.files[0],
|
||||
loader = module.exports.loading('Uploading file...')
|
||||
|
||||
reader.onerror = reader.onabort = function() {
|
||||
reader.onerror = reader.onabort = function() {
|
||||
loader.close()
|
||||
error()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var Widget = require('../common/widget'),
|
|||
|
||||
class Dropdown extends Widget {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'dropdown',
|
||||
|
|
@ -25,7 +25,7 @@ class Dropdown extends Widget {
|
|||
|
||||
_dropdown:'dropdown',
|
||||
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
values:{'Value 1':1,'Value 2':2},
|
||||
|
||||
_value: 'value',
|
||||
default:'',
|
||||
|
|
@ -46,7 +46,7 @@ class Dropdown extends Widget {
|
|||
|
||||
super({...options, html: '<div class="select"></div>'})
|
||||
|
||||
this.select = this.widget.appendChild(DOM.create(`<select></select>`))
|
||||
this.select = this.widget.appendChild(DOM.create('<select></select>'))
|
||||
|
||||
this.values = []
|
||||
this.keys = []
|
||||
|
|
@ -73,7 +73,7 @@ class Dropdown extends Widget {
|
|||
values = values !== '' ? [values] : []
|
||||
}
|
||||
|
||||
html += `<option value=""></option>`
|
||||
html += '<option value=""></option>'
|
||||
|
||||
this.values = []
|
||||
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ class Push extends Widget {
|
|||
updateValue(){
|
||||
|
||||
this.value = this[this.lastChanged] ?
|
||||
this.getProp('on') != null && this.getProp('on').value !== undefined ? this.getProp('on').value : this.getProp('on')
|
||||
:
|
||||
this.getProp('off') != null && this.getProp('off').value !== undefined ? this.getProp('off').value : this.getProp('off')
|
||||
this.getProp('on') != null && this.getProp('on').value !== undefined ? this.getProp('on').value : this.getProp('on')
|
||||
:
|
||||
this.getProp('off') != null && this.getProp('off').value !== undefined ? this.getProp('off').value : this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var Widget = require('../common/widget'),
|
|||
|
||||
module.exports = class Switch extends Widget {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'switch',
|
||||
|
|
@ -27,7 +27,7 @@ module.exports = class Switch extends Widget {
|
|||
|
||||
horizontal:false,
|
||||
showValues:false,
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
values:{'Value 1':1,'Value 2':2},
|
||||
|
||||
_value: 'value',
|
||||
default:'',
|
||||
|
|
@ -90,7 +90,7 @@ module.exports = class Switch extends Widget {
|
|||
|
||||
while ( (node = node.previousSibling) ) {
|
||||
if (node.nodeType != 3) {
|
||||
index++;
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,8 +105,8 @@ module.exports = class Switch extends Widget {
|
|||
setValue(v, options={}) {
|
||||
|
||||
var i = typeof v == 'object' ?
|
||||
this.stringValues.indexOf(JSON.stringify(v)) :
|
||||
this.values.indexOf(v)
|
||||
this.stringValues.indexOf(JSON.stringify(v)) :
|
||||
this.values.indexOf(v)
|
||||
|
||||
DOM.each(this.widget, '.on', (el)=>{el.classList.remove('on')})
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var Widget = require('../common/widget'),
|
|||
|
||||
class Toggle extends Widget {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'toggle',
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class Canvas extends Widget {
|
|||
|
||||
resizeHandle(event){
|
||||
|
||||
var {width, height, style, checkColors} = event,
|
||||
var {width, height, style} = event,
|
||||
ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
this.height = height
|
||||
|
|
@ -123,7 +123,7 @@ class Canvas extends Widget {
|
|||
|
||||
cacheCanvasStyle(style){
|
||||
|
||||
var style = style || window.getComputedStyle(this.canvas)
|
||||
style = style || window.getComputedStyle(this.canvas)
|
||||
|
||||
this.colors.custom = style.getPropertyValue('--color-custom')
|
||||
this.colors.track = style.getPropertyValue('--color-track')
|
||||
|
|
@ -134,13 +134,13 @@ class Canvas extends Widget {
|
|||
this.colors.faded = style.getPropertyValue('--color-faded')
|
||||
this.colors.light = style.getPropertyValue('--color-light')
|
||||
|
||||
this.fontFamily = style.getPropertyValue("font-family")
|
||||
this.textAlign = style.getPropertyValue("text-align")
|
||||
this.fontSize = parseFloat(style.getPropertyValue("font-size"))
|
||||
this.fontWeight = parseFloat(style.getPropertyValue("font-weight"))
|
||||
this.fontFamily = style.getPropertyValue('font-family')
|
||||
this.textAlign = style.getPropertyValue('text-align')
|
||||
this.fontSize = parseFloat(style.getPropertyValue('font-size'))
|
||||
this.fontWeight = parseFloat(style.getPropertyValue('font-weight'))
|
||||
|
||||
this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
|
||||
this.ctx.textBaseline = "middle"
|
||||
this.ctx.textBaseline = 'middle'
|
||||
this.ctx.textAlign = this.textAlign
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ setTimeout(()=>{
|
|||
|
||||
class Widget extends EventEmitter {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
throw new Error('Calling unimplemented static defaults() method')
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
this.widget = DOM.create(options.html)
|
||||
this.props = options.props
|
||||
this.errors = {}
|
||||
this.errors = {}
|
||||
this.parsers = {}
|
||||
this.parent = options.root ? widgetManager : options.parent
|
||||
this.parentNode = options.parentNode
|
||||
|
|
@ -91,7 +91,7 @@ class Widget extends EventEmitter {
|
|||
})
|
||||
|
||||
widgetManager.on(`prop-changed.${this.hash}`, (e)=>{
|
||||
let {id, widget, prop, options} = e
|
||||
let {id, widget, options} = e
|
||||
if (widget == this) id = 'this'
|
||||
if (widget == this.parent) id = 'parent'
|
||||
if (this.linkedProps[id]) {
|
||||
|
|
@ -114,7 +114,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
var selfLinkedOSCProps = (this.linkedPropsValue['this'] || []).filter(i => OSCProps.indexOf(i) > -1)
|
||||
var selfLinkedOSCProps = (this.linkedPropsValue['this'] || []).filter(i=>OSCProps.indexOf(i) > -1)
|
||||
this.selfLinkedOSCProps = selfLinkedOSCProps.length ? selfLinkedOSCProps : false
|
||||
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ class Widget extends EventEmitter {
|
|||
this.container = DOM.create(`
|
||||
<div class="widget ${options.props.type}-container" id="${this.hash}" data-widget="${this.hash}"></div>
|
||||
`)
|
||||
this.label = DOM.create(`<div class="label"></div>`)
|
||||
this.label = DOM.create('<div class="label"></div>')
|
||||
this.container.appendChild(this.label)
|
||||
this.container.appendChild(this.widget)
|
||||
this.container._widget_instance = this
|
||||
|
|
@ -162,7 +162,7 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
created() {
|
||||
created() {
|
||||
|
||||
this.trigger('widget-created.*', [{
|
||||
id: this.getProp('id'),
|
||||
|
|
@ -223,8 +223,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
static deepCopy(obj, precision){
|
||||
|
||||
var copy = obj,
|
||||
key
|
||||
var copy = obj
|
||||
|
||||
if (obj === null) {
|
||||
return obj
|
||||
|
|
@ -245,10 +244,9 @@ class Widget extends EventEmitter {
|
|||
|
||||
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName) {
|
||||
|
||||
var propValue = propValue !== undefined ? propValue : Widget.deepCopy(this.props[propName]),
|
||||
originalWidget = originalWidget || this,
|
||||
originalPropName = originalPropName || propName,
|
||||
obj
|
||||
propValue = propValue !== undefined ? propValue : Widget.deepCopy(this.props[propName])
|
||||
originalWidget = originalWidget || this
|
||||
originalPropName = originalPropName || propName
|
||||
|
||||
var variables = {},
|
||||
mathscope = {},
|
||||
|
|
@ -256,7 +254,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (typeof propValue == 'string') {
|
||||
|
||||
propValue = propValue.replace(/@\{[^\{]*?(@\{.*?\})?[^\{]*?\}/g, (m, nested)=>{
|
||||
propValue = propValue.replace(/@\{[^{]*?(@\{.*?\})?[^{]*?\}/g, (m, nested)=>{
|
||||
|
||||
if (nested) {
|
||||
m = m.replace(nested, this.resolveProp(propName, nested, false, this))
|
||||
|
|
@ -288,7 +286,7 @@ class Widget extends EventEmitter {
|
|||
if (k === '_value') k = 'value'
|
||||
|
||||
var widgets = id == 'parent' && this.parent ?
|
||||
[this.parent] : id == 'this' ? [this] :
|
||||
[this.parent] : id == 'this' ? [this] :
|
||||
widgetManager.getWidgetById(id)
|
||||
|
||||
if (!widgets.length) {
|
||||
|
|
@ -320,15 +318,15 @@ class Widget extends EventEmitter {
|
|||
|
||||
for (var i in widgets) {
|
||||
|
||||
if (widgets[i].props[k] !== undefined || k === 'value') {
|
||||
if (widgets[i].props[k] !== undefined || k === 'value') {
|
||||
|
||||
if (k !== 'value' && originalPropName == k && widgets[i].props.id == originalWidget.props.id) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var r = k == 'value' ?
|
||||
widgets[i].getValue(true) :
|
||||
widgets[i].resolveProp(k, undefined, storeLinks, originalWidget, originalPropName)
|
||||
widgets[i].getValue(true) :
|
||||
widgets[i].resolveProp(k, undefined, storeLinks, originalWidget, originalPropName)
|
||||
|
||||
if (subk !== undefined && r !== undefined) r = r[subk]
|
||||
|
||||
|
|
@ -346,8 +344,8 @@ class Widget extends EventEmitter {
|
|||
|
||||
})
|
||||
|
||||
propValue = propValue.replace(/OSC\{([^\}]+)\}/g, (m)=>{
|
||||
let [address, value] = m.substr(4, m.length - 5).split(',').map(x => x.trim()),
|
||||
propValue = propValue.replace(/OSC\{([^}]+)\}/g, (m)=>{
|
||||
let [address, value] = m.substr(4, m.length - 5).split(',').map(x=>x.trim()),
|
||||
resolvedAddress = address.replace(/VAR_[0-9]+/g, (m)=>{
|
||||
return typeof variables[m] === 'string' ? variables[m] : JSON.stringify(variables[m])
|
||||
})
|
||||
|
|
@ -371,7 +369,7 @@ class Widget extends EventEmitter {
|
|||
})
|
||||
|
||||
try {
|
||||
propValue = propValue.replace(/#\{(?:[^\}\\]|\\.)+\}/g, (m)=>{
|
||||
propValue = propValue.replace(/#\{(?:[^}\\]|\\.)+\}/g, (m)=>{
|
||||
|
||||
// unescape brackets
|
||||
m = m.replace(/\\(\{|\})/g, '$1')
|
||||
|
|
@ -396,7 +394,7 @@ class Widget extends EventEmitter {
|
|||
})
|
||||
} catch (err) {}
|
||||
|
||||
for (var k in variables) {
|
||||
for (let k in variables) {
|
||||
var v = typeof variables[k] === 'string' ? variables[k] : JSON.stringify(variables[k])
|
||||
propValue = propValue.replace(new RegExp(k, 'g'), v)
|
||||
}
|
||||
|
|
@ -406,7 +404,7 @@ class Widget extends EventEmitter {
|
|||
} catch (err) {}
|
||||
|
||||
} else if (propValue != null && typeof propValue == 'object') {
|
||||
for (var k in propValue) {
|
||||
for (let k in propValue) {
|
||||
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName)
|
||||
}
|
||||
}
|
||||
|
|
@ -495,7 +493,7 @@ class Widget extends EventEmitter {
|
|||
this.setContainerStyles(['css'])
|
||||
this.onPropChanged('color')
|
||||
var re = /width|height|display/
|
||||
if (re.test(oldPropValue) || re.test(this.getProp('css'))) {
|
||||
if (re.test(oldPropValue) || re.test(this.getProp('css'))) {
|
||||
resize.check(this.container)
|
||||
}
|
||||
return
|
||||
|
|
@ -541,7 +539,7 @@ class Widget extends EventEmitter {
|
|||
this.container.style[d] = geometry
|
||||
if (d == 'width') this.container.style.minWidth = geometry
|
||||
if (d == 'height') this.container.style.minHeight = geometry
|
||||
if (d == 'top' || d == 'left') this.container.classList.add('absolute-position')
|
||||
if (d == 'top' || d == 'left') this.container.classList.add('absolute-position')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -554,8 +552,8 @@ class Widget extends EventEmitter {
|
|||
this.container.classList.add('nolabel')
|
||||
} else {
|
||||
var label = this.getProp('label') == 'auto'?
|
||||
this.getProp('id'):
|
||||
iconify(this.getProp('label'))
|
||||
this.getProp('id'):
|
||||
iconify(this.getProp('label'))
|
||||
|
||||
this.label.innerHTML = label
|
||||
}
|
||||
|
|
@ -579,10 +577,10 @@ class Widget extends EventEmitter {
|
|||
|
||||
// fallback for browser that don't allow assigning "style" property
|
||||
css
|
||||
.replace(/\{[^\}]*\}/g, '')
|
||||
.replace(/^[^@#\.]*\:.*/gm, (m) => {
|
||||
unScopedCss += m[m.length - 1] === ';' ? m : m + ';'
|
||||
})
|
||||
.replace(/\{[^}]*\}/g, '')
|
||||
.replace(/^[^@#.]*:.*/gm, (m)=>{
|
||||
unScopedCss += m[m.length - 1] === ';' ? m : m + ';'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -596,7 +594,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (oldStyle) {
|
||||
this.container.replaceChild(style, oldStyle)
|
||||
} else if (scopedCss.length || unScopedCss.length){
|
||||
} else if (scopedCss.length || unScopedCss.length){
|
||||
this.container.insertBefore(style, this.widget)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class Clone extends Widget {
|
|||
|
||||
this.cleanClone()
|
||||
|
||||
this.cloneClass = [...this.cloneTarget.container.classList].filter(i => excludedCloneClasses.indexOf(i) === -1)
|
||||
this.cloneClass = [...this.cloneTarget.container.classList].filter(i=>excludedCloneClasses.indexOf(i) === -1)
|
||||
this.container.classList.remove('empty')
|
||||
this.container.classList.add(...this.cloneClass)
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ module.exports = class Modal extends Panel {
|
|||
// convert dimensions / coordinates to rem
|
||||
var geometry = {}
|
||||
for (var g of ['Width', 'Height', 'Left', 'Top']) {
|
||||
geometry[g] = parseFloat(this.getProp('popup' + g)) == this.getProp('popup' + g) ? parseFloat(this.getProp('popup' + g)) + 'rem' : this.getProp('popup' + g)
|
||||
geometry[g] = parseFloat(this.getProp('popup' + g)) == this.getProp('popup' + g) ? parseFloat(this.getProp('popup' + g)) + 'rem' : this.getProp('popup' + g)
|
||||
}
|
||||
|
||||
this.popup.style.setProperty('--width', geometry.Width)
|
||||
|
|
@ -161,7 +161,7 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
}
|
||||
|
||||
bindEscKey(set) {
|
||||
bindEscKey(set) {
|
||||
|
||||
if (set) {
|
||||
document.addEventListener('keydown', this.escapeKeyHandler)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var Widget = require('../common/widget'),
|
||||
autolayout = require('autolayout/dist/autolayout.kiwi.js'),
|
||||
{iconify} = require('../../ui/utils'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
parser = require('../../parser'),
|
||||
editor
|
||||
|
|
@ -93,7 +92,7 @@ class Panel extends Widget {
|
|||
e.stopPropagation = true
|
||||
})
|
||||
|
||||
this.setValue(this.getProp('value') || 0)
|
||||
this.setValue(this.getProp('value') || 0)
|
||||
|
||||
} else if (this.getProp('widgets') && this.getProp('widgets').length) {
|
||||
|
||||
|
|
@ -171,9 +170,10 @@ class Panel extends Widget {
|
|||
}
|
||||
|
||||
applyLayout() {
|
||||
DOM.each(this.widget, '> .widget', (widget)=>{
|
||||
|
||||
DOM.each(this.widget, '> .widget', (widgetContainer)=>{
|
||||
|
||||
var widget = widgetManager.getWidgetByElement(widget),
|
||||
var widget = widgetManager.getWidgetByElement(widgetContainer),
|
||||
id = widget.getProp('id')
|
||||
|
||||
if (!this.layout.subViews[id]) return
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
var Panel = require('./panel'),
|
||||
{iconify} = require('../../ui/utils'),
|
||||
Tab = require('./tab'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
{iconify} = require('../../ui/utils')
|
||||
|
||||
module.exports = class Root extends Panel {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
var {iconify} = require('../../ui/utils'),
|
||||
Widget = require('../common/widget'),
|
||||
Canvas = require('../common/canvas'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
var Widget = require('../common/widget'),
|
||||
Canvas = require('../common/canvas')
|
||||
|
||||
module.exports = class Input extends Canvas {
|
||||
|
||||
|
|
@ -115,19 +113,19 @@ module.exports = class Input extends Canvas {
|
|||
|
||||
resizeHandle(event){
|
||||
|
||||
super.resizeHandle(event)
|
||||
super.resizeHandle(event)
|
||||
|
||||
if (this.getProp('vertical')){
|
||||
if (this.getProp('vertical')){
|
||||
|
||||
var ratio = CANVAS_SCALING * this.scaling
|
||||
var ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
this.ctx.translate(-this.height * ratio, 0)
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
this.ctx.translate(-this.height * ratio, 0)
|
||||
|
||||
|
||||
if (ratio != 1) this.ctx.scale(ratio, ratio)
|
||||
}
|
||||
if (ratio != 1) this.ctx.scale(ratio, ratio)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -160,7 +158,7 @@ module.exports = class Input extends Canvas {
|
|||
|
||||
this.ctx.fillStyle = this.colors.text
|
||||
|
||||
if (this.textAlign == 'center') {
|
||||
if (this.textAlign == 'center') {
|
||||
this.ctx.fillText(v, Math.round(width/2), Math.round(height/2))
|
||||
} else if (this.textAlign == 'right') {
|
||||
this.ctx.fillText(v, width, Math.round(height/2))
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ module.exports = class Keys extends Widget {
|
|||
this.keydownString = String(this.getProp('keydown'))
|
||||
this.keyupString = String(this.getProp('keyup'))
|
||||
|
||||
if (this.getProp('binding') && (this.keydownString || this.keyupString)) {
|
||||
if (this.getProp('binding') && (this.keydownString || this.keyupString)) {
|
||||
|
||||
this.widget.appendChild(DOM.create(`<span>${this.getProp('binding')}</span>`))
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ module.exports = class Keys extends Widget {
|
|||
|
||||
super.onRemove()
|
||||
|
||||
if (this.getProp('binding') && (this.getProp('keydown') || this.getProp('keyup'))) {
|
||||
if (this.getProp('binding') && (this.getProp('keydown') || this.getProp('keyup'))) {
|
||||
|
||||
keyboardJS.unbind(this.getProp('binding'), this.keydownHandler, this.keyupHandler)
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ module.exports = class Keys extends Widget {
|
|||
|
||||
if (this.getProp('widgetId')) {
|
||||
|
||||
return widgetManager.getWidgetById(this.getProp('widgetId')).pop() || null
|
||||
return widgetManager.getWidgetById(this.getProp('widgetId')).pop() || null
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var Widget = require('../common/widget'),
|
|||
|
||||
module.exports = class Formula extends Widget {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'formula',
|
||||
|
|
@ -74,20 +74,20 @@ module.exports = class Formula extends Widget {
|
|||
|
||||
if (this.formulaString.length) {
|
||||
|
||||
if (this.formulaString.match(/\$\{([^\}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.formulaString.match(/\$\{([^\}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
if (this.formulaString.match(/\$\{([^}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.formulaString.match(/\$\{([^}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
|
||||
}
|
||||
|
||||
if (this.conditionString.length) {
|
||||
|
||||
if (this.conditionString.match(/\$\{([^\}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.conditionString.match(/\$\{([^\}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
if (this.conditionString.match(/\$\{([^}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.conditionString.match(/\$\{([^}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
this.condition = math.compile(this.conditionString.replace(/\$\{([^\}]*)\}/g, '_$1'))
|
||||
this.condition = math.compile(this.conditionString.replace(/\$\{([^}]*)\}/g, '_$1'))
|
||||
delete this.errors.condition
|
||||
|
||||
} catch(err) {
|
||||
|
|
@ -98,7 +98,7 @@ module.exports = class Formula extends Widget {
|
|||
|
||||
try {
|
||||
|
||||
this.formula = math.compile(this.formulaString.replace(/\$\{([^\}]*)\}/g, '_$1'))
|
||||
this.formula = math.compile(this.formulaString.replace(/\$\{([^}]*)\}/g, '_$1'))
|
||||
delete this.errors.formula
|
||||
|
||||
} catch(err) {
|
||||
|
|
@ -125,8 +125,7 @@ module.exports = class Formula extends Widget {
|
|||
|
||||
updateValue(e){
|
||||
|
||||
var variables = {},
|
||||
id, n = 0
|
||||
var variables = {}
|
||||
|
||||
for (let id of this.linkedWidgets) {
|
||||
if (id !== undefined) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var Matrix = require('./matrix'),
|
|||
|
||||
module.exports = class Keyboard extends Matrix {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'keyboard',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
{enableTraversingGestures} = require('../../events/drag')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ module.exports = class Multifader extends Matrix {
|
|||
|
||||
onPropChanged(propName, options, oldPropValue) {
|
||||
|
||||
if (super.onPropChanged(...arguments)) return true
|
||||
if (super.onPropChanged(...arguments)) return true
|
||||
|
||||
switch (propName) {
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var h of this.childrenHashes) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module.exports = (element, callback)=>{
|
|||
eventData = event.detail
|
||||
|
||||
|
||||
if (
|
||||
if (
|
||||
|
||||
tapLength < DOUBLE_TAP_TIME && touchId == eventData.pointerId &&
|
||||
Math.abs(lastTapX - eventData.pageX) < 20 &&
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module.exports = class _fake_fader extends Fader {
|
|||
if (arguments.cancelDraw) this.noDraw = true
|
||||
}
|
||||
|
||||
sendValue() {
|
||||
sendValue() {
|
||||
// disabled
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,24 +67,24 @@ module.exports = class MultiXy extends Pad {
|
|||
this.pointSize = parseInt(this.getProp('pointSize'))
|
||||
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 * this.npoints ?
|
||||
this.getProp('split')
|
||||
: (()=>{
|
||||
var s={},
|
||||
t
|
||||
for (var i=0; i<this.npoints * 2;i=i+2) {
|
||||
t = this.labels ? this.getProp('points')[i/2] : i/2
|
||||
s[i]=this.getProp('address') + '/' + t + '/x'
|
||||
s[i+1]=this.getProp('address') + '/' + t + '/y'
|
||||
};
|
||||
return s
|
||||
})()
|
||||
: false
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 * this.npoints ?
|
||||
this.getProp('split')
|
||||
: (()=>{
|
||||
var s={},
|
||||
t
|
||||
for (var i=0; i<this.npoints * 2;i=i+2) {
|
||||
t = this.labels ? this.getProp('points')[i/2] : i/2
|
||||
s[i]=this.getProp('address') + '/' + t + '/x'
|
||||
s[i+1]=this.getProp('address') + '/' + t + '/y'
|
||||
}
|
||||
return s
|
||||
})()
|
||||
: false
|
||||
|
||||
|
||||
this.pads = []
|
||||
|
||||
for (var i=this.npoints-1;i>=0;i--) {
|
||||
for (let i=this.npoints-1;i>=0;i--) {
|
||||
this.pads[i] = new Xy({props:{
|
||||
...xyDefaults,
|
||||
snap:this.getProp('snap'),
|
||||
|
|
@ -174,7 +174,7 @@ module.exports = class MultiXy extends Pad {
|
|||
|
||||
|
||||
var v = []
|
||||
for (var i=0;i<this.npoints * 2;i=i+2) {
|
||||
for (let i = 0; i < this.npoints * 2; i = i + 2) {
|
||||
[v[i],v[i+1]] = this.pads[i/2].getValue()
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ module.exports = class MultiXy extends Pad {
|
|||
for (var i=0;i<this.npoints;i++) {
|
||||
|
||||
this.padsCoords[i] = [clip(this.pads[i].faders.x.percent,[0,100]) / 100 * (this.width - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE
|
||||
,- clip(this.pads[i].faders.y.percent,[0,100]) / 100 * (this.height - (this.pointSize * 2 + 2) * PXSCALE) - (this.pointSize + 1) * PXSCALE]
|
||||
,- clip(this.pads[i].faders.y.percent,[0,100]) / 100 * (this.height - (this.pointSize * 2 + 2) * PXSCALE) - (this.pointSize + 1) * PXSCALE]
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ module.exports = class MultiXy extends Pad {
|
|||
if (!v || !v.length || v.length!=this.npoints * 2) return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = [v, options]
|
||||
|
||||
for (var i=0;i<this.npoints;i++) {
|
||||
for (let i=0;i<this.npoints;i++) {
|
||||
if (!options.dragged) {
|
||||
this.pads[i].setValue([v[i*2],v[i*2+1]])
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ module.exports = class MultiXy extends Pad {
|
|||
this.updateHandlesPosition()
|
||||
this.batchDraw()
|
||||
|
||||
for (var i=0;i<this.npoints * 2;i=i+2) {
|
||||
for (let i=0;i<this.npoints * 2;i=i+2) {
|
||||
[this.value[i],this.value[i+1]] = this.pads[i/2].getValue()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ module.exports = class Rgb extends Pad {
|
|||
super(options)
|
||||
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 3 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/r', this.getProp('address') + '/g', this.getProp('address') + '/b']
|
||||
: false
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 3 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/r', this.getProp('address') + '/g', this.getProp('address') + '/b']
|
||||
: false
|
||||
|
||||
this.hueWrapper = this.widget.appendChild(DOM.create(`<div class="hue-wrapper"></div>`))
|
||||
this.hueWrapper = this.widget.appendChild(DOM.create('<div class="hue-wrapper"></div>'))
|
||||
|
||||
this.hue = new Fader({props:{
|
||||
...faderDefaults,
|
||||
|
|
@ -95,8 +95,8 @@ module.exports = class Rgb extends Pad {
|
|||
this.wrapper.appendChild(this.pad.widget)
|
||||
|
||||
|
||||
this.value = []
|
||||
this.hsb = {h:0,s:0,b:0}
|
||||
this.value = []
|
||||
this.hsb = {h:0,s:0,b:0}
|
||||
|
||||
this.hue.on('change',(e)=>{
|
||||
e.stopPropagation = true
|
||||
|
|
@ -186,7 +186,7 @@ module.exports = class Rgb extends Pad {
|
|||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
this.update({dragged:options.dragged, nohue:options.nohue || (v[0]==v[1]&&v[1]==v[2])})
|
||||
this.update({dragged:options.dragged, nohue:options.nohue || (v[0]==v[1]&&v[1]==v[2])})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var Pad = require('./pad'),
|
||||
Fader = require('./_fake_fader'),
|
||||
{clip} = require('../utils'),
|
||||
doubletab = require('../mixins/double_tap'),
|
||||
Input = require('../inputs/input'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
|
@ -106,7 +105,7 @@ module.exports = class Xy extends Pad {
|
|||
|
||||
this.faders.x.margin = this.faders.y.margin = this.pointSize + 1
|
||||
|
||||
this.value = [this.faders.x.value, this.faders.y.value]
|
||||
this.value = [this.faders.x.value, this.faders.y.value]
|
||||
|
||||
this.wrapper.appendChild(this.faders.x.widget)
|
||||
this.wrapper.appendChild(this.faders.y.widget)
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ module.exports = function(options,linear,resolution) {
|
|||
var {type, freq, q, gain} = options,
|
||||
Fs = 44100,
|
||||
a0,a1,a2,b1,b2,norm,
|
||||
ymin, ymax, minVal, maxVal,
|
||||
minVal, maxVal,
|
||||
len = resolution
|
||||
|
||||
var V = Math.pow(10, Math.abs(gain) / 20)
|
||||
var K = Math.tan(Math.PI * freq / Fs)
|
||||
switch (type) {
|
||||
case "lowpass":
|
||||
case 'lowpass':
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = K * K * norm
|
||||
a1 = 2 * a0
|
||||
|
|
@ -23,7 +23,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "highpass":
|
||||
case 'highpass':
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = 1 * norm
|
||||
a1 = -2 * a0
|
||||
|
|
@ -32,7 +32,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "bandpass":
|
||||
case 'bandpass':
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = K / q * norm
|
||||
a1 = 0
|
||||
|
|
@ -41,7 +41,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "notch":
|
||||
case 'notch':
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = (1 + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
|
|
@ -50,7 +50,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "peak":
|
||||
case 'peak':
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + 1/q * K + K * K)
|
||||
a0 = (1 + V/q * K + K * K) * norm
|
||||
|
|
@ -68,7 +68,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - V/q * K + K * K) * norm
|
||||
}
|
||||
break
|
||||
case "lowshelf":
|
||||
case 'lowshelf':
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + Math.SQRT2 * K + K * K)
|
||||
a0 = (1 + Math.sqrt(2*V) * K + V * K * K) * norm
|
||||
|
|
@ -86,7 +86,7 @@ module.exports = function(options,linear,resolution) {
|
|||
b2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
|
||||
}
|
||||
break
|
||||
case "highshelf":
|
||||
case 'highshelf':
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + Math.SQRT2 * K + K * K)
|
||||
a0 = (V + Math.sqrt(2*V) * K + K * K) * norm
|
||||
|
|
@ -110,9 +110,9 @@ module.exports = function(options,linear,resolution) {
|
|||
for (var i = 0; i < len; i++) {
|
||||
var w, phi, y
|
||||
if (linear)
|
||||
w = i / (len - 1) * Math.PI; // 0 to pi, linear scale
|
||||
w = i / (len - 1) * Math.PI // 0 to pi, linear scale
|
||||
else
|
||||
w = Math.exp(Math.log(1 / 0.001) * i / (len - 1)) * 0.001 * Math.PI; // 0.001 to 1, times pi, log scale
|
||||
w = Math.exp(Math.log(1 / 0.001) * i / (len - 1)) * 0.001 * Math.PI // 0.001 to 1, times pi, log scale
|
||||
|
||||
phi = Math.pow(Math.sin(w/2), 2)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
Widget = require('../common/widget'),
|
||||
Canvas = require('../common/canvas'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
Canvas = require('../common/canvas')
|
||||
|
||||
module.exports = class _plots_base extends Canvas {
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max
|
||||
}
|
||||
}
|
||||
this.smooth = this.getProp('smooth') === true ? 0.25 : this.getProp('smooth') === false ? 0 : parseFloat(this.getProp('smooth')) || 0
|
||||
this.smooth = this.getProp('smooth') === true ? 0.25 : this.getProp('smooth') === false ? 0 : parseFloat(this.getProp('smooth')) || 0
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +40,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
draw() {
|
||||
draw() {
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
if (this.pips.x) {
|
||||
|
||||
this.ctx.textBaseline = "bottom"
|
||||
this.ctx.textBaseline = 'bottom'
|
||||
this.ctx.textAlign = 'left'
|
||||
this.ctx.fillText(this.pips.x.min,(this.pips.y?12:2)*PXSCALE,this.height)
|
||||
this.ctx.textAlign = 'right'
|
||||
|
|
@ -79,7 +78,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
this.ctx.translate(0, this.height)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
|
||||
this.ctx.textBaseline = "top"
|
||||
this.ctx.textBaseline = 'top'
|
||||
this.ctx.textAlign = 'left'
|
||||
this.ctx.fillText(this.pips.y.min,(this.pips.x?12:2)*PXSCALE,2*PXSCALE)
|
||||
this.ctx.textAlign = 'right'
|
||||
|
|
@ -91,7 +90,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
draw_line() {
|
||||
draw_line() {
|
||||
|
||||
var points = []
|
||||
|
||||
|
|
@ -150,10 +149,9 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
draw_bars() {
|
||||
draw_bars() {
|
||||
|
||||
var points = [],
|
||||
barWidth = Math.round(this.width / this.data.length),
|
||||
var barWidth = Math.round(this.width / this.data.length),
|
||||
offset = Math.round((this.width - barWidth * this.data.length) / 2)
|
||||
|
||||
var origin = mapToScale(this.getProp('origin') || this.rangeY.min,[this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getProp('logScaleY'),true)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var {mapToScale, clip} = require('../utils'),
|
||||
var {clip} = require('../utils'),
|
||||
_biquad_response = require('./_biquad_response'),
|
||||
_plots_base = require('./_plots_base'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
_plots_base = require('./_plots_base')
|
||||
|
||||
module.exports = class Eq extends _plots_base {
|
||||
|
||||
|
|
@ -82,10 +81,10 @@ module.exports = class Eq extends _plots_base {
|
|||
|
||||
var filterResponse
|
||||
|
||||
if (!filters[i].type) filters[i].type = "peak"
|
||||
if (!filters[i].type) filters[i].type = 'peak'
|
||||
|
||||
if (!filters[i].on) {
|
||||
filterResponse = _biquad_response({type:"peak",freq:1,gain:0,q:1},!this.getProp('logScaleX'), this.resolution)
|
||||
filterResponse = _biquad_response({type:'peak',freq:1,gain:0,q:1},!this.getProp('logScaleX'), this.resolution)
|
||||
} else {
|
||||
filterResponse = _biquad_response(filters[i],!this.getProp('logScaleX'), this.resolution)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
Widget = require('../common/widget'),
|
||||
var Widget = require('../common/widget'),
|
||||
ipc = require('../../ipc')
|
||||
|
||||
module.exports = class Led extends Widget {
|
||||
|
|
@ -84,8 +83,8 @@ module.exports = class Led extends Widget {
|
|||
|
||||
if (typeof this.value === 'string' && this.value.length) {
|
||||
|
||||
cache_query = this.getProp('cache') || this.value.indexOf('base64') != -1 ?
|
||||
'' : (this.value.indexOf('?') != -1 ? '&' : '?') + Date.now()
|
||||
cache_query = this.getProp('cache') || this.value.indexOf('base64') != -1 ?
|
||||
'' : (this.value.indexOf('?') != -1 ? '&' : '?') + Date.now()
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +95,7 @@ module.exports = class Led extends Widget {
|
|||
}
|
||||
|
||||
onStreamUpdate(event) {
|
||||
console.log(event)
|
||||
|
||||
var [stream, data] = event
|
||||
if (stream === this.getProp('stream')) {
|
||||
this.setValue('data:image/jpeg;base64,' + data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
Widget = require('../common/widget')
|
||||
|
||||
module.exports = class Led extends Widget {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var Fader = require('../sliders/fader'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
var Fader = require('../sliders/fader')
|
||||
|
||||
module.exports = class Meter extends Fader {
|
||||
|
||||
static defaults() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
_plots_base = require('./_plots_base'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
var _plots_base = require('./_plots_base')
|
||||
|
||||
module.exports = class Plot extends _plots_base {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
var Widget = require('../common/widget'),
|
||||
{clip} = require('../utils')
|
||||
|
||||
module.exports = class Rbgled extends Widget {
|
||||
|
|
@ -67,7 +65,7 @@ module.exports = class Rbgled extends Widget {
|
|||
v[i] = parseInt(clip(v[i],[0,255]))
|
||||
}
|
||||
|
||||
v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1])
|
||||
v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1])
|
||||
|
||||
c = `rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var Widget = require('../common/widget')
|
||||
var morph = require('nanomorph')
|
||||
var Widget = require('../common/widget'),
|
||||
morph = require('nanomorph')
|
||||
|
||||
class Svg extends Widget {
|
||||
|
||||
|
|
@ -55,13 +55,13 @@ class Svg extends Widget {
|
|||
|
||||
updateSvg(){
|
||||
|
||||
if (!this.width || !this.height) return
|
||||
if (!this.width || !this.height) return
|
||||
|
||||
var svg = this.getProp('svg')
|
||||
|
||||
svg = svg.replace(/<\/svg>/gi, 'x')
|
||||
svg = svg.replace(/([0-9\.]+%x)/gi, m => (parseFloat(m) * this.width / 100).toFixed(2))
|
||||
svg = svg.replace(/([0-9\.]+%y)/gi, m => (parseFloat(m) * this.height / 100).toFixed(2))
|
||||
svg = svg.replace(/([0-9.]+%x)/gi, m=>(parseFloat(m) * this.width / 100).toFixed(2))
|
||||
svg = svg.replace(/([0-9.]+%y)/gi, m=>(parseFloat(m) * this.height / 100).toFixed(2))
|
||||
|
||||
|
||||
morph(this.widget, DOM.create('<div class="svg"><svg>' + svg + '</svg></div>'))
|
||||
|
|
@ -76,8 +76,7 @@ class Svg extends Widget {
|
|||
|
||||
resizeHandle(event){
|
||||
|
||||
var {width, height, style} = event,
|
||||
ratio = CANVAS_SCALING * this.scaling
|
||||
var {width, height} = event
|
||||
|
||||
this.height = height
|
||||
this.width = width
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var {iconify} = require('../../ui/utils'),
|
||||
Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
Widget = require('../common/widget')
|
||||
|
||||
module.exports = class Text extends Widget {
|
||||
|
||||
|
|
@ -56,11 +55,11 @@ module.exports = class Text extends Widget {
|
|||
if (this.getProp('align') === 'right') this.widget.classList.add('right')
|
||||
if (this.getProp('wrap')) this.widget.classList.add('wrap')
|
||||
|
||||
this.defaultValue = this.getProp('default') || ( this.getProp('label')===false ?
|
||||
this.getProp('id'):
|
||||
this.getProp('label')=='auto'?
|
||||
this.getProp('id'):
|
||||
this.getProp('label') )
|
||||
this.defaultValue = this.getProp('default') || ( this.getProp('label')===false ?
|
||||
this.getProp('id'):
|
||||
this.getProp('label')=='auto'?
|
||||
this.getProp('id'):
|
||||
this.getProp('label') )
|
||||
|
||||
this.value = this.defaultValue
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var {mapToScale, clip} = require('../utils'),
|
||||
_plots_base = require('./_plots_base'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
var {clip} = require('../utils'),
|
||||
_plots_base = require('./_plots_base')
|
||||
|
||||
module.exports = class Visualizer extends _plots_base {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var {clip, mapToScale} = require('../utils'),
|
||||
var {clip} = require('../utils'),
|
||||
Knob = require('./knob'),
|
||||
Widget = require('../common/widget'),
|
||||
doubletab = require('../mixins/double_tap')
|
||||
|
|
@ -13,7 +13,7 @@ var EncoderKnob = class extends Knob {
|
|||
this.lastOffsetX = e.offsetX
|
||||
this.lastOffsetY = e.offsetY
|
||||
|
||||
if (!(e.traversing || this.getProp('snap'))) return
|
||||
if (!(e.traversing || this.getProp('snap'))) return
|
||||
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY))
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ module.exports = class Encoder extends Widget {
|
|||
|
||||
this.wrapper.addEventListener('mousewheel', (e)=>{
|
||||
|
||||
if (e.wheelDeltaX || e.wheelDelta == 0) return
|
||||
if (e.wheelDeltaX || e.wheelDelta == 0) return
|
||||
|
||||
var direction = e.wheelDelta / Math.abs(e.wheelDelta)
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ module.exports = class Encoder extends Widget {
|
|||
|
||||
setValue(v,options={}) {
|
||||
|
||||
if (this.getProp('snap') || (!this.getProp('snap') && !options.draginit)) {
|
||||
if (this.getProp('snap') || (!this.getProp('snap') && !options.draginit)) {
|
||||
|
||||
var match = true
|
||||
|
||||
|
|
@ -215,13 +215,13 @@ module.exports = class Encoder extends Widget {
|
|||
if (options.sync && match) this.changed(options)
|
||||
if (options.send && match && !(!this.getProp('snap') && options.draginit)) this.sendValue()
|
||||
|
||||
if (options.dragged || options.draginit) this.updateDisplay(options.draginit)
|
||||
if (options.dragged || options.draginit) this.updateDisplay(options.draginit)
|
||||
|
||||
}
|
||||
|
||||
updateDisplay(init){
|
||||
|
||||
if (this.getProp('snap')) {
|
||||
if (this.getProp('snap')) {
|
||||
this.display.setValue(this.knob.value)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var {clip, mapToScale} = require('../utils'),
|
||||
var {clip} = require('../utils'),
|
||||
Slider = require('./slider'),
|
||||
parser = require('../../parser')
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ module.exports = class Fader extends Slider {
|
|||
horizontal:this.getProp('horizontal'),
|
||||
range:this.getProp('range'),
|
||||
logScale:this.getProp('logScale'),
|
||||
address:this.getProp('meterAddress') || this.getProp('address') + '/meter',
|
||||
address:this.getProp('meterAddress') || this.getProp('address') + '/meter',
|
||||
preArgs:this.getProp('preArgs'),
|
||||
color:this.getProp('color'),
|
||||
pips:false,
|
||||
|
|
@ -114,7 +114,7 @@ module.exports = class Fader extends Slider {
|
|||
for (var i=0;i<=100;i++) {
|
||||
if (pipTexts[i]==undefined) continue
|
||||
|
||||
var pos = this.getProp('horizontal')?'left':'bottom';
|
||||
var pos = this.getProp('horizontal')?'left':'bottom'
|
||||
|
||||
var piptext = `<span>${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]}</span>`
|
||||
|
||||
|
|
@ -135,11 +135,11 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
this.percent = clip(this.percent,[0,100])
|
||||
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
|
||||
|
||||
this.percent = this.getProp('horizontal')?
|
||||
(e.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100:
|
||||
(this.height - e.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100
|
||||
(e.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100:
|
||||
(this.height - e.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100
|
||||
|
||||
// this.percent = clip(this.percent,[0,100])
|
||||
|
||||
|
|
@ -171,40 +171,36 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
resizeHandle(event) {
|
||||
|
||||
var {width, height, style} = event,
|
||||
ratio = CANVAS_SCALING * this.scaling
|
||||
var ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
event.height = 1 / ratio
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if (this.getProp('compact') && this.getProp('horizontal')) {
|
||||
event.height = 1 / ratio
|
||||
}
|
||||
|
||||
super.resizeHandle(event)
|
||||
super.resizeHandle(event)
|
||||
|
||||
if (this.getProp('horizontal')){
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
this.ctx.translate(-this.height * ratio, 0)
|
||||
if (this.getProp('horizontal')){
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
this.ctx.translate(-this.height * ratio, 0)
|
||||
|
||||
if (ratio != 1) this.ctx.scale(ratio, ratio)
|
||||
}
|
||||
if (ratio != 1) this.ctx.scale(ratio, ratio)
|
||||
}
|
||||
|
||||
if (this.getProp('gradient')) {
|
||||
var colors = this.getProp('gradient')
|
||||
if (Array.isArray(colors) && colors.length > 1) {
|
||||
try {
|
||||
var grad = this.ctx.createLinearGradient(0, this.getProp('horizontal') ? 0 : this.height, 0, this.getProp('horizontal') ? this.width : 0)
|
||||
for (var i in colors) {
|
||||
grad.addColorStop(i / (colors.length - 1), colors[i])
|
||||
}
|
||||
this.colors.gradient = grad
|
||||
} catch(err) {
|
||||
this.errors.gradient = err
|
||||
if (this.getProp('gradient')) {
|
||||
var colors = this.getProp('gradient')
|
||||
if (Array.isArray(colors) && colors.length > 1) {
|
||||
try {
|
||||
var grad = this.ctx.createLinearGradient(0, this.getProp('horizontal') ? 0 : this.height, 0, this.getProp('horizontal') ? this.width : 0)
|
||||
for (var i in colors) {
|
||||
grad.addColorStop(i / (colors.length - 1), colors[i])
|
||||
}
|
||||
this.colors.gradient = grad
|
||||
} catch(err) {
|
||||
this.errors.gradient = err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -223,11 +219,11 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
this.clear()
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
|
||||
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
|
||||
|
||||
this.ctx.strokeStyle = this.colors.gradient || this.colors.gauge
|
||||
this.ctx.strokeStyle = this.colors.gradient || this.colors.gauge
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(m, o)
|
||||
this.ctx.lineTo(m, d)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var {clip, mapToScale} = require('../utils'),
|
||||
var {clip} = require('../utils'),
|
||||
Slider = require('./slider')
|
||||
|
||||
module.exports = class Knob extends Slider {
|
||||
|
|
@ -80,7 +80,7 @@ module.exports = class Knob extends Slider {
|
|||
this.lastOffsetX = e.offsetX
|
||||
this.lastOffsetY = e.offsetY
|
||||
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
|
||||
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY))
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
dragHandle(e) {
|
||||
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) {
|
||||
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) {
|
||||
|
||||
this.percent = -100 * (e.movementY / e.inertia) / this.height + this.percent
|
||||
|
||||
|
|
@ -125,14 +125,15 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
percentToAngle(percent) {
|
||||
|
||||
var percent = clip(percent, [0, 100])
|
||||
percent = clip(percent, [0, 100])
|
||||
|
||||
return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle
|
||||
+ Math.PI / 2 // quarter circle offset
|
||||
+ Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle
|
||||
|
||||
}
|
||||
|
||||
resizeHandle() {
|
||||
resizeHandle() {
|
||||
|
||||
super.resizeHandle(...arguments)
|
||||
|
||||
|
|
@ -236,7 +237,7 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
var g = this.ctx.createLinearGradient(this.width / 2, this.height / 2 - knobRadius / 2,this.width / 2, this.height / 2 + knobRadius / 2)
|
||||
g.addColorStop(0.5, 'transparent')
|
||||
g.addColorStop(0, this.colors.light || 'transparent')
|
||||
g.addColorStop(0, this.colors.light || 'transparent')
|
||||
|
||||
this.ctx.strokeStyle = g
|
||||
this.ctx.stroke()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ var RangeFader = class RangeFader extends Fader {
|
|||
|
||||
draw() {
|
||||
|
||||
if (this.cancelDraw || !this.parent.faders) return
|
||||
if (this.cancelDraw || !this.parent.faders) return
|
||||
|
||||
var width = this.getProp('horizontal') ? this.height : this.width,
|
||||
height = !this.getProp('horizontal') ? this.height : this.width
|
||||
|
|
@ -42,9 +42,9 @@ var RangeFader = class RangeFader extends Fader {
|
|||
|
||||
this.clear()
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-d2) / height
|
||||
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-d2) / height
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(m, d2)
|
||||
|
|
@ -314,8 +314,8 @@ module.exports = class Range extends Widget {
|
|||
var coord = this.faders[i].percentToCoord(this.faders[i].valueToPercent(this.faders[i].value)) - (this.getProp('horizontal') ? -1 : 1) * (i == 0 ? -20 : 20)
|
||||
|
||||
ndiff = this.getProp('horizontal')?
|
||||
Math.abs(e.offsetX - coord) :
|
||||
Math.abs(e.offsetY - coord)
|
||||
Math.abs(e.offsetX - coord) :
|
||||
Math.abs(e.offsetY - coord)
|
||||
|
||||
if (diff == -1 || ndiff < diff) {
|
||||
id = i
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ class Slider extends Canvas {
|
|||
for (var k in this.getProp('range')) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof this.getProp('range')[k] == 'object'?
|
||||
this.getProp('range')[k][Object.keys(this.getProp('range')[k])[0]]:
|
||||
this.getProp('range')[k],
|
||||
this.getProp('range')[k][Object.keys(this.getProp('range')[k])[0]]:
|
||||
this.getProp('range')[k],
|
||||
label = typeof this.getProp('range')[k] == 'object'?
|
||||
Object.keys(this.getProp('range')[k])[0]:
|
||||
val
|
||||
Object.keys(this.getProp('range')[k])[0]:
|
||||
val
|
||||
|
||||
this.rangeKeys.push(key)
|
||||
this.rangeVals.push(val)
|
||||
|
|
@ -47,10 +47,10 @@ class Slider extends Canvas {
|
|||
this.rangeValsMin = Math.min(...this.rangeVals)
|
||||
|
||||
this.originValue = this.getProp('origin')=='auto'?
|
||||
this.rangeValsMin:
|
||||
clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
|
||||
this.rangeValsMin:
|
||||
clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
this.springValue = this.getProp('default') !== '' ? this.getProp('default') : this.originValue
|
||||
this.springValue = this.getProp('default') !== '' ? this.getProp('default') : this.originValue
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
|
|
@ -105,25 +105,25 @@ class Slider extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
mousewheelHandleProxy() {
|
||||
mousewheelHandleProxy() {
|
||||
|
||||
this.mousewheelHandle(...arguments)
|
||||
|
||||
}
|
||||
|
||||
draginitHandleProxy() {
|
||||
draginitHandleProxy() {
|
||||
|
||||
this.draginitHandle(...arguments)
|
||||
|
||||
}
|
||||
|
||||
dragHandleProxy() {
|
||||
dragHandleProxy() {
|
||||
|
||||
this.dragHandle(...arguments)
|
||||
|
||||
}
|
||||
|
||||
dragendHandleProxy() {
|
||||
dragendHandleProxy() {
|
||||
|
||||
this.dragendHandle(...arguments)
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ class Slider extends Canvas {
|
|||
e.stopPropagation()
|
||||
|
||||
var direction = e.wheelDelta / Math.abs(e.wheelDelta),
|
||||
increment = e.ctrlKey?0.25:1
|
||||
increment = e.ctrlKey?0.25:1
|
||||
|
||||
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.precision + 1)) * direction, [0,100])
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ class Slider extends Canvas {
|
|||
|
||||
cacheCanvasStyle(style) {
|
||||
|
||||
var style = style || window.getComputedStyle(this.canvas)
|
||||
style = style || window.getComputedStyle(this.canvas)
|
||||
|
||||
this.colors.track = style.getPropertyValue('--color-track')
|
||||
this.colors.gauge = style.getPropertyValue('--color-gauge')
|
||||
|
|
@ -204,7 +204,7 @@ class Slider extends Canvas {
|
|||
|
||||
var value = clip(v,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
if ((options.dragged || options.fromLocal) && this.value.toFixed(this.precision) == value.toFixed(this.precision)) options.send = false
|
||||
if ((options.dragged || options.fromLocal) && this.value.toFixed(this.precision) == value.toFixed(this.precision)) options.send = false
|
||||
|
||||
this.value = value
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var Widget = require('../common/widget'),
|
|||
|
||||
module.exports = class _switchers_base extends Widget {
|
||||
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ module.exports = class _switchers_base extends Widget {
|
|||
}
|
||||
|
||||
|
||||
applyState(state, options) {
|
||||
applyState(state, options) {
|
||||
for (var id in state) {
|
||||
var value = state[id],
|
||||
widgets = widgetManager.getWidgetById(id)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var Switcher = require('./switcher'),
|
||||
Fader = require('../sliders/fader'),
|
||||
{mapToScale, clip} = require('../utils')
|
||||
{mapToScale} = require('../utils')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ module.exports = class Crossfader extends Switcher {
|
|||
this.fader = new Fader({props:{
|
||||
...faderDefaults,
|
||||
horizontal: this.getProp('horizontal'),
|
||||
range: {min:{'A':0}, '50%':{" ":0.5},max:{'B':1}},
|
||||
range: {min:{'A':0}, '50%':{' ':0.5},max:{'B':1}},
|
||||
input: false
|
||||
}, parent: this})
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
setValue(v, options={}) {
|
||||
|
||||
var v = v <= 0 || v == 'A' ?
|
||||
'A' :
|
||||
v >= 1 || v == 'B' ?
|
||||
'B' :
|
||||
v
|
||||
v = v <= 0 || v == 'A' ?
|
||||
'A' :
|
||||
v >= 1 || v == 'B' ?
|
||||
'B' :
|
||||
v
|
||||
|
||||
super.setValue(v, options)
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
if (!isNaN(s['A'][i][k])) {
|
||||
|
||||
a[i][k] = mapToScale(v, [0,1], [s['A'][i][k], s['B'][i][k]], false)
|
||||
a[i][k] = mapToScale(v, [0,1], [s['A'][i][k], s['B'][i][k]], false)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
} else if (!isNaN(s['A'][i])) {
|
||||
|
||||
a[i] = mapToScale(v, [0,1], [s['A'][i], s['B'][i]], false)
|
||||
a[i] = mapToScale(v, [0,1], [s['A'][i], s['B'][i]], false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var switchDefaults = Switch.defaults()
|
|||
|
||||
module.exports = class Switcher extends _switchers_base {
|
||||
|
||||
static defaults() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'switcher',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
module.exports = {
|
||||
|
||||
clip: function(value,range) {
|
||||
var value = parseFloat(value)
|
||||
|
||||
value = parseFloat(value)
|
||||
|
||||
if (isNaN(value)) value = range[0]
|
||||
return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
|
||||
|
|
@ -11,24 +12,24 @@ module.exports = {
|
|||
// map a value from a scale to another input and output must be range arrays
|
||||
mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
|
||||
|
||||
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]])
|
||||
value = module.exports.clip(value,[rangeIn[0],rangeIn[1]])
|
||||
|
||||
value = log?
|
||||
revertlog?
|
||||
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
value = log ?
|
||||
revertlog ?
|
||||
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
|
||||
|
||||
if (precision!==false) value = parseFloat(value.toFixed(precision))
|
||||
if (precision !== false) value = parseFloat(value.toFixed(precision))
|
||||
|
||||
|
||||
return value
|
||||
|
||||
},
|
||||
|
||||
hsbToRgb: function (hsb) {
|
||||
hsbToRgb: function(hsb) {
|
||||
var rgb = {}
|
||||
var h = hsb.h
|
||||
var s = hsb.s*255/100
|
||||
|
|
@ -51,7 +52,7 @@ module.exports = {
|
|||
return rgb
|
||||
},
|
||||
|
||||
rgbToHsb: function (rgb) {
|
||||
rgbToHsb: function(rgb) {
|
||||
var hsb = {h: 0, s: 0, b: 0}
|
||||
var min = Math.min(rgb.r, rgb.g, rgb.b)
|
||||
var max = Math.max(rgb.r, rgb.g, rgb.b)
|
||||
|
|
@ -86,12 +87,12 @@ module.exports = {
|
|||
},
|
||||
length: function(x) { return x.length },
|
||||
// basic relationnal to keep alphabetical string comparison (v4 change)
|
||||
equal: function (a, b) { return a == b },
|
||||
unequal: function (a, b) { return a != b },
|
||||
smaller: function (a, b) { return a < b },
|
||||
larger: function (a, b) { return a > b },
|
||||
smallerEq: function (a, b) { return a <= b },
|
||||
largerEq: function (a, b) { return a >= b }
|
||||
equal: function(a, b) { return a == b },
|
||||
unequal: function(a, b) { return a != b },
|
||||
smaller: function(a, b) { return a < b },
|
||||
larger: function(a, b) { return a > b },
|
||||
smallerEq: function(a, b) { return a <= b },
|
||||
largerEq: function(a, b) { return a >= b }
|
||||
}, {override:true})
|
||||
|
||||
// set math's parser array index base to zero
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ require('./app/globals')
|
|||
|
||||
var {loading} = require('./app/ui/utils')
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
document.addEventListener('DOMContentLoaded', function(event) {
|
||||
|
||||
DOM.init()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue