- moved sessions & presets out of the app folder

This commit is contained in:
jean-emmanuel 2015-09-11 13:03:11 +02:00 • committed by bordun
parent 4b9b019326
commit 4174331a3c
21 changed files with 14 additions and 14 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>OSCGUI</title>
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
<style>
/* Preloading style */
html {
background:#21252b;
overflow: hidden;
}
body {
opacity:0;
}
</style>
<script>
require( __dirname + "/js/browser.js")
</script>
</head>
<body>
<div id="lobby"></div>
<div id="container"></div>
<div id="sidepanel"></div>
</body>
</html>

View file

@ -1,5 +0,0 @@
require(__dirname + '/parser.js') // session file parser
require(__dirname + '/widgets.js') // widgets types and behaviour definition
require(__dirname + '/utils.js') // state managing & inspector
require(__dirname + '/callbacks.js')// calls from mainProcess
require(__dirname + '/init.js') // ...

View file

@ -1,58 +0,0 @@
ipc.on('receiveOsc',function(data){
// fetch id
var path = data.address;
var id = __widgetsIds__[path]
// update
if (__widgets__[id]!=undefined) {
for (i in __widgets__[id]){
__widgets__[id][i].setValue(data.args,false,false)
}
}
})
ipc.on('load',function(preset){
setState(preset)
})
ipc.on('listSessions',function(data){
$('#lobby').append('\
<div class="main">\
<div class="header">\
Session selection\
</div>\
<div class="list"></div>\
</div>')
for (i in data) {
$('#lobby .list').append('<li><a class="btn" data-session="'+i+'">'+data[i]+'<span>'+icon('remove')+'</span></a></li>')
}
$('#lobby .list').append('<a class="btn" data-session="browse">...</a>')
$('#lobby a').click(function(){
ipc.send('loadSession',$(this).data('session'))
})
$('#lobby a span').click(function(e){
ipc.send('removeSessionFromHistory',$(this).parent().data('session'))
$(this).parents('li').hide()
e.stopPropagation()
})
})
ipc.on('openSession',function(data){
TABS=false
require(data)
if (TABS!=false) {
$('#lobby').hide()
$('#container').append('<div id="loading"><div class="spinner"></div></div>')
setTimeout(function(){
init(function(){$('#loading').hide()});
},1)
} else {
console.log('ERROR: invalid session file (TABS must be defined)')
}
})

View file

@ -1,132 +0,0 @@
init = function(callback) {
parsetabs(TABS,false,false)
// Widget Synchronization : widget that share the same id will update each other
// without sending any extra osc message (they must be of the same type as well)
$.each(__widgets__,function(i,widget) {
if (widget.length>1) {
var script ='';
var closureSync = function(x) {
return function() {
var v = widget[x].getValue()
for (k=0;k<widget.length;k++) {
if (x!=k) {
widget[k].setValue(v,false,false)
}
}
}
}
for (j in widget) {
widget[j].on('sync',closureSync(j))
}
}
})
// Tabs...
$('.tablist a').click(function(){
var id = $(this).data('tab');
$(id).siblings('.on').removeClass('on');
$(id).addClass('on');
$(this).parents('ul').find('.on').removeClass('on');
$(this).addClass('on');$(this).parent().addClass('on');
})
// Activate first tabs
$('.tablist li:first-child a').click();
// horizontal scrolling with mousewheel
// if shift is pressed (native), or if there is no vertical scrollbar,
// or if mouse is on h-scrollbar
$('.tab').on('mousewheel',function(e) {
// console.log(e)
var h = $('#container').innerHeight()-10-$(this).parents('.tab').length*5;
if ($(this).get(0).scrollHeight+10 == $(this).height()) {
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
e.preventDefault();
} else if (e.pageY>=h) {
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
e.preventDefault()
}
});
// sidepanel
$('#container').append('\
<a id="open-toggle">'+icon('navicon')+'</a>\
')
$('#sidepanel').append(createMenu([
{
label:'Save',
click:saveState,
icon:'save'
},
{
label:'Load',
click:loadState,
icon:'folder-open'
},
{
label:'Send all',
click:sendState,
icon:'feed'
},
{
label:'Fullscreen',
click:function(){ipc.send('fullscreen')},
icon:'tv'
},
{
label:'Preferences',
icon:'gears',
click:configPanel
},
{
html:'<div class="inspector btn">\
Inspector\
<div class="result"><em>Click on a widges\'s label to inspect</em></div>\
</div>',
icon:'terminal'
}
]))
$('#open-toggle').click(function(){
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open');
})
$('.widget .label').click(function(){
if (!$('#sidepanel').hasClass('sidepanel-open')){return}
var data = String(JSON.stringify($(this).data('papers'),null,2)).split('\n').join('<br/>&nbsp;&nbsp;')
$('.inspector .result').html(data);
})
if (callback) callback()
}

View file

@ -1,81 +0,0 @@
parsetabs = function(tabs,parent,sub){
if (!sub) {
var nav = $(document.createElement('div')).addClass('main navigation'),
navtabs = $(document.createElement('ul')).addClass('tablist'),
content = $(document.createElement('div')).addClass('content');
nav.append(navtabs)
$('#container').append(nav).append(content);
} else {
var nav = $(document.createElement('div')).addClass('sub navigation'),
navtabs = $(document.createElement('ul')).addClass('tablist'),
content = $(document.createElement('div')).addClass('content hastabs');
nav.append(navtabs);
parent.append(nav).append(content);
}
for (i in tabs) {
var tabData = tabs[i],
id = parent?parent.attr('id')+tabData.id:tabData.id
label= tabData.label||tabData.id
navtabs.append('<li><a data-tab="#'+id+'"><span>'+label+'</span></a></li>');
var tabContent = $(document.createElement('div')).addClass('tab').attr('id',id);
if (tabData.tabs) {
parsetabs(tabData.tabs,parent=tabContent,sub=true);
} else {
parsewidgets(tabData.widgets,tabContent)
}
content.append(tabContent);
// console.log('OK parsing tab ' + title )
}
}
__widgets__ = {}
__widgetsIds__ = {}
parsewidgets = function(widgets,parent) {
for (i in widgets) {
var widgetData = widgets[i],
id = widgetData.id,
label = widgetData.label || id,
type = widgetData.type || 'fader',
path = widgetData.path || '/' + id,
color = '',
accentclass = '';
if (widgetData.color && widgetData.color=='accent') {
accentclass = 'accent'
} else if (widgetData.color) {
color = 'style="color:'+widgetData.color+'"'
}
var widget = $('\
<div class="widget" widgetType="'+type+'" widgetId="'+id+'" path="'+path+'">\
<div class="label '+accentclass+'" '+color+'>'+label+'</div>\
</div>\
');
// create widget
var widgetInner = createWidget[type](widgetData,parent)
widgetInner.type = type
widget.find('.label').data('papers',widgetData)
// store widget reference for cross widget sync
widget.append(widgetInner)
if (__widgets__[id]==undefined) {
__widgets__[id] = []
}
__widgets__[id].push(widgetInner)
// store path vs widget id for faster cross-app sync
__widgetsIds__[widgetData.path ] = id
parent.append(widget);
}
}

View file

@ -1,198 +0,0 @@
saveState = function () {
var data = getState()
ipc.send('save',data.join('\n'))
}
getState = function (){
var data = []
$.each(__widgets__,function(i,widget) {
data.push(widget[0].type+':'+i+':'+widget[0].getValue())
})
return data
}
loadState = function() {
ipc.send('load')
}
sendState = function(){
var data = getState().join('\n')
setState(data)
}
setState = function(preset){
$.each(preset.split('\n'),function(i,d) {
var data = d.split(':')
setTimeout(function(){
if (__widgets__[data[1]]!=undefined) {
__widgets__[data[1]][0].setValue(data[2].split(','),true,true)
}
},i)
})
}
// // inspector
// findNode = function(searchID, obj) {
// var result=false;
// for (i in obj) {
//
// if
//
//
//
//
// // if (id==searchID) {
// // result = searchObject[id]
// // return false
// // } else if (typeof searchObject[id] === 'object'){
// // result = findNode(searchID, searchObject[id])
// // }
// // if (result !== false) {return false}
// }
// return result
// }
icon = function(i) {
return '<i class="fa fa-fw fa-'+i+'"></i>'
}
createMenu = function(template) {
var menu = $('<ul id="options"></ul>')
var closureClick = function(item) {
return function() {
item.click();
return false
};
}
for (i in template) {
var item = template[i],
label = item.label || 'undefined',
classname = item.class || '',
wrapper = $('<li></li>'),
html
if (!item.html) {
html = $('<a class="'+classname+' btn">'+label+'</a>')
} else {
html = $(item.html)
}
if (item.icon) html.prepend(icon(item.icon)+'&nbsp;')
if (item.click) html.on('click',closureClick(item))
wrapper.append(html)
menu.append(wrapper)
}
return menu
}
createPopup = function(title,content) {
var popup = $('\
<div class="popup">\
<div class="popup-wrapper">\
<div class="popup-title">'+title+'<span class="closer">'+icon('remove')+'</span></div>\
<div class="popup-content"></div>\
</div>\
</div>'),
closer = popup.find('.popup-title .closer')
closer.click(function(){
popup.close()
})
popup.close = function(){
$(document).unbind('keydown.popup')
popup.remove()
}
popup.find('.popup-content').append(content)
$('body').append(popup)
$(document).on('keydown.popup', function(e){
if (e.keyCode==27) popup.close()
})
return popup
}
var remote = require('remote');
configPanel = function(){
var readEditableConfig = remote.getGlobal('readEditableConfig')
var writeConfig = remote.getGlobal('writeConfig')
var config = readEditableConfig()
var form = $('<form></form>')
$.each(config,function(i) {
var item = $('<div>\
<label for="'+i+'">'+i+'</label>\
<p class="info">'+config[i].info+'</p>\
</div>')
var input = $('<input name="'+i+'" value="'+config[i].value+'"/>')
input.change(function(){
var v = input.val().trim().replace(/[\s]+/,' ')
input.val(v)
console.log([v,v.match(config[i].match)])
if (v.match(config[i].match)==null) {
input.addClass('invalid')
} else {
input.removeClass('invalid')
};
})
item.append(input)
form.append(item)
})
var submit = $('<a class="btn submit">'+icon('save')+'&nbsp;Save</a>')
form.append(submit)
popup = createPopup(icon('gear')+'&nbsp;Preferences',form)
submit.click(function(e){
e.preventDefault()
if ($('input.invalid').length>0) {
return
}
var data = form.serializeArray(),
newconfig = {}
for (i in data) {
newconfig[data[i].name] = data[i].value
}
writeConfig(newconfig)
popup.close();
})
}

View file

@ -1,639 +0,0 @@
sendOsc = function(data){
// Unpack args for osc sending function
if (data[0]) {
ipc.send('sendOsc', {target:data[0],path:data[1],args:data[2]});
}
}
createWidget= {}
createWidget.stack = function(widgetData) {
var widget = $('\
<div class="stack">\
</div>\
');
parsewidgets(widgetData.widgets,widget)
widget.getValue = function(){return}
widget.setValue = function(){return}
return widget;
}
createWidget.toggle = createWidget.button = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="toggle">\
<div class="value"><p><span>'+widgetData.off+'</span></p></div>\
</div>\
');
widget.value = widget.find('span')
widget.click(function(){
var newVal = widget.hasClass('on')?widgetData.off:widgetData.on
widget.setValue(newVal,true)
})
widget.getValue = function() {
return widget.hasClass('on')?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
var on = widgetData.on,
off= widgetData.off
if (v==on) {
widget.addClass('on')
widget.value.text(on)
if (send) widget.sendValue(v)
} else if (v==off) {
widget.removeClass('on')
widget.value.text(off)
if (send) widget.sendValue(v)
}
if (send) widget.trigger('sync')
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
widget.setValue()
return widget;
}
createWidget.switch = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="switch">\
</div>\
');
for (v in widgetData.values) {
widget.append('<div class="value" data-value="'+widgetData.values[v]+'"><span>'+widgetData.values[v]+'</span></div>')
}
widget.find('.value').click(function(){
if ($(this).hasClass('on')) return;
var newVal = $(this).data('value')
widget.setValue(newVal,true,true)
})
widget.getValue = function() {
return widget.find('.on').data('value')
}
widget.setValue = function(v,send,sync) {
var e = widget.find('.value[data-value="'+v+'"]')
if (e.length) {
widget.find('.on').removeClass('on')
e.addClass('on')
if (send) widget.sendValue(v)
if (sync) widget.trigger('sync')
}
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
return widget;
}
createWidget.xy = function(widgetData) {
var widget = $('\
<div class="xy-wrapper">\
<div class="xy">\
<div class="handle"><span></span></div>\
</div>\
<div class="value">\
<input disabled value="X"></input><input disabled value="Y"></input>\
<input type="number" class="x"></input><input type="number" class="y"></input>\
</div>\
</div>\
'),
handle = widget.find('.handle'),
pad = widget.find('.xy'),
value = {x:widget.find('.x'),y:widget.find('.y')}
widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
handle.drag('init',function(){
offX = handle.width()
})
handle.drag(function( ev, dd ){
var h = (pad.innerHeight()-dd.offsetY)*100/pad.innerHeight(),
w = (dd.deltaX+offX)*100/pad.innerWidth()
handle.css({'height':h+'%','width':w+'%'})
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widget.getValue = function() {
var x = mapToScale(handle.width(),[0,pad.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
y = mapToScale(handle.height(),[0,pad.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max])
return [x,y]
}
widget.setValue = function(v,send,sync) {
if (v[1]==undefined) var v = [v,v]
var w = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,100])
h = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,100]),
handle.css({'height':h+'%','width':w+'%'})
widget.showValue(v)
if (sync) widget.trigger('sync')
if (send) widget.sendValue(v);
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
widget.showValue = function(v) {
value.x.val(v[0])
value.y.val(v[1])
}
value.x.change(function(){
var v = widget.getValue();
v[0] = clip(value.x.val(),[widgetData.range.x.min,widgetData.range.x.max])
widget.setValue(v,true,true)
})
value.y.change(function(){
var v = widget.getValue();
v[1] = clip(value.y.val(),[widgetData.range.y.min,widgetData.range.y.max])
widget.setValue(v,true,true)
})
widget.setValue(widgetData.range.x.min,widgetData.range.y.min)
return widget;
}
var hsbToRgb = function (hsb) {
var rgb = {};
var h = hsb.h;
var s = hsb.s*255/100;
var v = hsb.b*255/100;
if(s == 0) {
rgb.r = rgb.g = rgb.b = v;
} else {
var t1 = v;
var t2 = (255-s)*v/255;
var t3 = (t1-t2)*(h%60)/60;
if(h==360) h = 0;
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
else {rgb.r=0; rgb.g=0; rgb.b=0}
}
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
};
var 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);
var delta = max - min;
hsb.b = max;
hsb.s = max != 0 ? 255 * delta / max : 0;
if (hsb.s != 0) {
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta;
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta;
else hsb.h = 4 + (rgb.r - rgb.g) / delta;
} else hsb.h = -1;
hsb.h *= 60;
if (hsb.h < 0) hsb.h += 360;
hsb.s *= 100/255;
hsb.b *= 100/255;
return hsb;
};
var clip = function(value,range) {
var max = Math.max,
min = Math.min
return max(min(range[0],range[1]),min(parseFloat(value),max(range[0],range[1])))
}
// map a value from a scale to another input and output must be range arrays
var mapToScale = function(value,rangeIn,rangeOut,reverse) {
var max = Math.max,
min = Math.min,
round = Math.round
value = max(min(rangeIn[0],rangeIn[1]),min(parseFloat(value),max(rangeIn[0],rangeIn[1])))
value = ((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
if (reverse) value = max(rangeOut[0],rangeOut[1])+min(rangeOut[0],rangeOut[1])-value
value = max(min(rangeOut[0],rangeOut[1]),min(value,max(rangeOut[0],rangeOut[1])))
value = round(value*100)/100
return value
}
createWidget.rgb = function(widgetData) {
var widget = $('\
<div class="xy-wrapper rgb-wrapper">\
<div class="xy rgb">\
<div class="handle"><span></span></div>\
</div>\
<div class="hue">\
<div class="handle"><span></span></div>\
</div>\
<div class="value">\
<input disabled value="R"></input><input disabled value="G"></input><input disabled value="B"></input>\
<input class="r" type="number"></input><input class="g" type="number"></input><input class="b" type="number"></input>\
</div>\
</div>'),
rgbHandle = widget.find('.rgb .handle'),
hueHandle = widget.find('.hue .handle'),
pad = widget.find('.xy'),
value = {r:widget.find('input.r'),g:widget.find('input.g'),b:widget.find('input.b')}
widgetData.range = {r:{min:0,max:255},g:{min:0,max:255},b:{min:255}}
rgbHandle.drag('init',function(){
rgbOffX = rgbHandle.width()
})
rgbHandle.drag(function( ev, dd ){
var h = (pad.innerHeight()-dd.offsetY)*100/pad.innerHeight(),
w = (dd.deltaX+rgbOffX)*100/pad.innerWidth()
rgbHandle.css({'height':h+'%','width':w+'%'})
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
hueHandle.drag('init',function(){
rgbOffX = hueHandle.width()
})
hueHandle.drag(function( ev, dd ){
var w = (dd.deltaX+rgbOffX)*100/pad.innerWidth()
hueHandle.css({'width':w+'%'})
var h = parseFloat(hueHandle.width())/pad.innerWidth()*360,
rgb = hsbToRgb({h:h,s:100,b:100}),
v = widget.getValue();
pad.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widget.getValue = function() {
var s = mapToScale(rgbHandle.width(),[0,pad.innerWidth()],[0,100]),
l = mapToScale(rgbHandle.height(),[0,pad.innerHeight()],[0,100]),
h = mapToScale(hueHandle.width(),[0,pad.innerWidth()],[0,360]),
rgb = hsbToRgb({h:h,s:s,b:l})
return [rgb.r,rgb.g,rgb.b]
}
widget.setValue = function(v,send,sync) {
if (v[1]==undefined && v[2]==undefined) var v = [v,v,v]
if (v[2]==undefined) var v = [v[0],v[1],v[1]]
for (i in [0,1,2]) {
if (!0<=v[i]<=255) {v[i]=Math.min(255,Math.max(0,v[i]))}
}
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
var w = mapToScale(hsb.s,[0,100],[0,pad.innerWidth()]),
h = mapToScale(hsb.b,[0,100],[0,pad.innerHeight()]),
hueW = mapToScale(hsb.h,[0,360],[0,pad.innerWidth()])
rgbHandle.css({'height':h+'px','width':w+'px'})
hueHandle.css({'width':hueW+'px'})
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
pad.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.showValue(v);
if (sync) widget.trigger('sync');
if (send) widget.sendValue(v);
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
widget.showValue = function(v) {
value.r.val(v[0])
value.g.val(v[1])
value.b.val(v[2])
}
value.r.change(function(){
var r = clip(value.r.val(),[0,255])
var v = widget.getValue()
widget.setValue([r,v[1],v[2]],true,true)
})
value.g.change(function(){
var g = clip(value.g.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],g,v[2]],true,true)
})
value.b.change(function(){
var b = clip(value.b.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],v[1],b],true,true)
})
widget.setValue(0)
return widget;
}
createWidget.fader = function(widgetData,parent){
var widget = $('\
<div class="fader-wrapper-outer">\
<div class="fader-wrapper">\
<div class="fader">\
<div class="handle"></div>\
<div class="pips"></div>\
</div>\
</div>\
<input></input>\
</div>\
'),
handle = widget.find('.handle'),
fader = widget.find('.fader'),
pips = widget.find('.pips'),
input = widget.find('input'),
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
dimension = parent.hasClass('stack')?'width':'height';
handle.size = function() {
return (dimension=='height')?handle.height():handle.width()
}
fader.size = function() {
return (dimension=='height')?fader.height():fader.width()
}
var offX=0
if (dimension=='width') {
handle.drag('init',function(){
offX = handle.size()
})
}
handle.drag(function( ev, dd ){
var d = (dimension=='height')?fader.size()-dd.offsetY:dd.deltaX+offX
d = d*100/fader.size()
handle.css(dimension, d+'%')
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widgetData.range = widgetData.range || {'min':0,'max':1}
widgetData.range = (widgetData.range=='db')?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'71%':-6,'78%':-3,'85%':0,'92%':3,'max': 6}:widgetData.range;
var range = {}
for (k in widgetData.range) {
if (k=='min') {
range[0]=widgetData.range[k]
} else if (k=='max') {
range[100]=widgetData.range[k]
} else {
range[parseInt(k)]=widgetData.range[k]
}
}
var scale = []
for (var i=0;i<=100;i++) {scale.push(i)}
for (i in scale) {
var pip = $('<div class="pip"></div>')
if (range[i]!=undefined) {
pip.addClass('val').append('<span>'+range[i]+'</span>')
}
pips.append(pip)
}
if (dimension=='height') {
pips.append(pips.find('.pip').get().reverse())
}
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
widget.getValue = function(){
var v
var h = handle.size() * 100 / fader.size()
for (var i=0;i<rangeKeys.length-1;i++) {
if (h <= rangeKeys[i+1] && h >= rangeKeys[i]) {
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]])
}
}
}
widget.setValue = function(v,send,sync) {
var h,
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
for (var i=0;i<rangeVals.length-1;i++) {
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]])
break
}
}
handle.css(dimension,h+'%')
widget.showValue(v);
if (sync) widget.trigger('sync');
if (send) widget.sendValue(v);
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
widget.showValue = function(v) {
input.val(v+unit)
}
input.change(function(){
widget.setValue(input.val(),true,true)
})
widget.setValue(rangeVals[0])
return widget
}
// get rotation plugin (@Ivo Renkema)
$.fn.getRotation = function () {
var matrix = this.css("transform")
if(typeof matrix === 'string' && matrix !== 'none') {
var values = matrix.split('(')[1].split(')')[0].split(',');
var a = values[0];
var b = values[1];
var angle = Math.round(Math.atan2(b, a) * (180/Math.PI));
} else { var angle = 0; }
if (angle<0) angle = 360+angle
return angle;
};
createWidget.knob = function(widgetData,parent) {
var widget = $('\
<div class="knob-wrapper-outer">\
<div class="knob-wrapper">\
<div class="knob-mask">\
<div class="knob"></div>\
</div>\
<div class="pip min"></div>\
<div class="pip max"></div>\
</div>\
<input></input>\
</div>\
'),
knob = widget.find('.knob'),
input = widget.find('input'),
range = widgetData.range || {min:0,max:1},
unit = widgetData.unit?' '+widgetData.unit.trim(): '';
widget.find('.pip.min').text(range.min)
widget.find('.pip.max').text(range.max)
knob.css('transform','rotate(45deg)').drag('init',function(){
offR = knob.getRotation()
})
knob.drag(function( ev, dd ){
var r = clip(-dd.deltaY+offR,[0,270])
knob.css('transform', 'rotateZ('+r+'deg)')
if (r>180) {
knob.addClass('d3')
} else if (r>90) {
knob.removeClass('d3').addClass('d2')
} else {
knob.removeClass('d3 d2')
}
var v = widget.getValue()
widget.sendValue(v);
widget.trigger('sync')
widget.showValue(v)
},{ relative:true });
widget.getValue = function() {
return mapToScale(knob.getRotation(),[0,270],[range.min,range.max])
}
widget.showValue = function(v) {
input.val(v+unit)
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
widget.setValue = function(v,send,sync) {
var r = mapToScale(v,[range.min,range.max],[0,270])
if (r>180) {
knob.addClass('d3')
} else if (r>90) {
knob.removeClass('d3').addClass('d2')
} else {
knob.removeClass('d3 d2')
}
knob.css('transform', 'rotateZ('+r+'deg)')
var v = widget.getValue() || v
widget.showValue(v);
if (sync) widget.trigger('sync');
if (send) widget.sendValue(v);
}
input.change(function(){
widget.setValue(input.val(),true,true)
})
widget.setValue(range.min)
return widget
}

View file

@ -1,46 +0,0 @@
// mainProcess & renderProcess communication engine
ipc = require('ipc');
// filesystem
fs = require('fs');
// jquery
window.$ = window.jQuery = require( __dirname + "/jquery/jquery.min.js")
// third-party js libraries
require( __dirname + "/jquery/jquery.event.drag-2.2.js")
// main js
require( __dirname + "/app/app.js")
// Sass (add stylesheets to var styles)
var Sass = require( __dirname + "/sass/sass.js")
Sass.setWorkerUrl(__dirname + "/sass/sass.worker.js");
var sass = new Sass()
sass.options({style: Sass.style.compact})
var styles = ["/../css/style.scss"]
, stylesdata = ''
, done = 0;
for (i in styles) {
fs.readFile(__dirname + styles[i], 'utf8', function (err,data) {
if (err) {return console.log(err);}
stylesdata += "\n" + data;
done += 1;
if (done==styles.length) {
sass.compile(stylesdata,function(d){
$('body').append('<style>'+d.text+'<\/style>')
ipc.send('ready');
})
}
});
}

View file

@ -1,402 +0,0 @@
/*!
* jquery.event.drag - v 2.2
* Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
* Open Source MIT License - http://threedubmedia.com/code/license
*/
// Created: 2008-06-04
// Updated: 2012-05-21
// REQUIRES: jquery 1.7.x
;(function( $ ){
// add the jquery instance method
$.fn.drag = function( str, arg, opts ){
// figure out the event type
var type = typeof str == "string" ? str : "",
// figure out the event handler...
fn = $.isFunction( str ) ? str : $.isFunction( arg ) ? arg : null;
// fix the event type
if ( type.indexOf("drag") !== 0 )
type = "drag"+ type;
// were options passed
opts = ( str == fn ? arg : opts ) || {};
// trigger or bind event handler
return fn ? this.bind( type, opts, fn ) : this.trigger( type );
};
// local refs (increase compression)
var $event = $.event,
$special = $event.special,
// configure the drag special event
drag = $special.drag = {
// these are the default settings
defaults: {
which: 1, // mouse button pressed to start drag sequence
distance: 0, // distance dragged before dragstart
not: ':input', // selector to suppress dragging on target elements
handle: null, // selector to match handle target elements
relative: false, // true to use "position", false to use "offset"
drop: true, // false to suppress drop events, true or selector to allow
click: false // false to suppress click events after dragend (no proxy)
},
// the key name for stored drag data
datakey: "dragdata",
// prevent bubbling for better performance
noBubble: true,
// count bound related events
add: function( obj ){
// read the interaction data
var data = $.data( this, drag.datakey ),
// read any passed options
opts = obj.data || {};
// count another realted event
data.related += 1;
// extend data options bound with this event
// don't iterate "opts" in case it is a node
$.each( drag.defaults, function( key, def ){
if ( opts[ key ] !== undefined )
data[ key ] = opts[ key ];
});
},
// forget unbound related events
remove: function(){
$.data( this, drag.datakey ).related -= 1;
},
// configure interaction, capture settings
setup: function(){
// check for related events
if ( $.data( this, drag.datakey ) )
return;
// initialize the drag data with copied defaults
var data = $.extend({ related:0 }, drag.defaults );
// store the interaction data
$.data( this, drag.datakey, data );
// bind the mousedown event, which starts drag interactions
$event.add( this, "touchstart mousedown", drag.init, data );
// prevent image dragging in IE...
if ( this.attachEvent )
this.attachEvent("ondragstart", drag.dontstart );
},
// destroy configured interaction
teardown: function(){
var data = $.data( this, drag.datakey ) || {};
// check for related events
if ( data.related )
return;
// remove the stored data
$.removeData( this, drag.datakey );
// remove the mousedown event
$event.remove( this, "touchstart mousedown", drag.init );
// enable text selection
drag.textselect( true );
// un-prevent image dragging in IE...
if ( this.detachEvent )
this.detachEvent("ondragstart", drag.dontstart );
},
// initialize the interaction
init: function( event ){
// sorry, only one touch at a time
if ( drag.touched )
return;
// the drag/drop interaction data
var dd = event.data, results;
// check the which directive
if ( event.which != 0 && dd.which > 0 && event.which != dd.which )
return;
// check for suppressed selector
if ( $( event.target ).is( dd.not ) )
return;
// check for handle selector
if ( dd.handle && !$( event.target ).closest( dd.handle, event.currentTarget ).length )
return;
drag.touched = event.type == 'touchstart' ? this : null;
dd.propagates = 1;
dd.mousedown = this;
dd.interactions = [ drag.interaction( this, dd ) ];
dd.target = event.target;
dd.pageX = event.pageX;
dd.pageY = event.pageY;
dd.dragging = null;
// handle draginit event...
results = drag.hijack( event, "draginit", dd );
// early cancel
if ( !dd.propagates )
return;
// flatten the result set
results = drag.flatten( results );
// insert new interaction elements
if ( results && results.length ){
dd.interactions = [];
$.each( results, function(){
dd.interactions.push( drag.interaction( this, dd ) );
});
}
// remember how many interactions are propagating
dd.propagates = dd.interactions.length;
// locate and init the drop targets
if ( dd.drop !== false && $special.drop )
$special.drop.handler( event, dd );
// disable text selection
drag.textselect( false );
// bind additional events...
if ( drag.touched )
$event.add( drag.touched, "touchmove touchend", drag.handler, dd );
else
$event.add( document, "mousemove mouseup", drag.handler, dd );
// helps prevent text selection or scrolling
if ( !drag.touched || dd.live )
return false;
},
// returns an interaction object
interaction: function( elem, dd ){
var offset = $( elem )[ dd.relative ? "position" : "offset" ]() || { top:0, left:0 };
return {
drag: elem,
callback: new drag.callback(),
droppable: [],
offset: offset
};
},
// handle drag-releatd DOM events
handler: function( event ){
// read the data before hijacking anything
var dd = event.data;
// handle various events
switch ( event.type ){
// mousemove, check distance, start dragging
case !dd.dragging && 'touchmove':
event.preventDefault();
case !dd.dragging && 'mousemove':
// drag tolerance, x<> + y<> = distance<63>
if ( Math.pow( event.pageX-dd.pageX, 2 ) + Math.pow( event.pageY-dd.pageY, 2 ) < Math.pow( dd.distance, 2 ) )
break; // distance tolerance not reached
event.target = dd.target; // force target from "mousedown" event (fix distance issue)
drag.hijack( event, "dragstart", dd ); // trigger "dragstart"
if ( dd.propagates ) // "dragstart" not rejected
dd.dragging = true; // activate interaction
// mousemove, dragging
case 'touchmove':
event.preventDefault();
case 'mousemove':
if ( dd.dragging ){
// trigger "drag"
drag.hijack( event, "drag", dd );
if ( dd.propagates ){
// manage drop events
if ( dd.drop !== false && $special.drop )
$special.drop.handler( event, dd ); // "dropstart", "dropend"
break; // "drag" not rejected, stop
}
event.type = "mouseup"; // helps "drop" handler behave
}
// mouseup, stop dragging
case 'touchend':
case 'mouseup':
default:
if ( drag.touched )
$event.remove( drag.touched, "touchmove touchend", drag.handler ); // remove touch events
else
$event.remove( document, "mousemove mouseup", drag.handler ); // remove page events
if ( dd.dragging ){
if ( dd.drop !== false && $special.drop )
$special.drop.handler( event, dd ); // "drop"
drag.hijack( event, "dragend", dd ); // trigger "dragend"
}
drag.textselect( true ); // enable text selection
// if suppressing click events...
if ( dd.click === false && dd.dragging )
$.data( dd.mousedown, "suppress.click", new Date().getTime() + 5 );
dd.dragging = drag.touched = false; // deactivate element
break;
}
},
// re-use event object for custom events
hijack: function( event, type, dd, x, elem ){
// not configured
if ( !dd )
return;
// remember the original event and type
var orig = { event:event.originalEvent, type:event.type },
// is the event drag related or drog related?
mode = type.indexOf("drop") ? "drag" : "drop",
// iteration vars
result, i = x || 0, ia, $elems, callback,
len = !isNaN( x ) ? x : dd.interactions.length;
// modify the event type
event.type = type;
// remove the original event
event.originalEvent = null;
// initialize the results
dd.results = [];
// handle each interacted element
do if ( ia = dd.interactions[ i ] ){
// validate the interaction
if ( type !== "dragend" && ia.cancelled )
continue;
// set the dragdrop properties on the event object
callback = drag.properties( event, dd, ia );
// prepare for more results
ia.results = [];
// handle each element
$( elem || ia[ mode ] || dd.droppable ).each(function( p, subject ){
// identify drag or drop targets individually
callback.target = subject;
// force propagtion of the custom event
event.isPropagationStopped = function(){ return false; };
// handle the event
result = subject ? $event.dispatch.call( subject, event, callback ) : null;
// stop the drag interaction for this element
if ( result === false ){
if ( mode == "drag" ){
ia.cancelled = true;
dd.propagates -= 1;
}
if ( type == "drop" ){
ia[ mode ][p] = null;
}
}
// assign any dropinit elements
else if ( type == "dropinit" )
ia.droppable.push( drag.element( result ) || subject );
// accept a returned proxy element
if ( type == "dragstart" )
ia.proxy = $( drag.element( result ) || ia.drag )[0];
// remember this result
ia.results.push( result );
// forget the event result, for recycling
delete event.result;
// break on cancelled handler
if ( type !== "dropinit" )
return result;
});
// flatten the results
dd.results[ i ] = drag.flatten( ia.results );
// accept a set of valid drop targets
if ( type == "dropinit" )
ia.droppable = drag.flatten( ia.droppable );
// locate drop targets
if ( type == "dragstart" && !ia.cancelled )
callback.update();
}
while ( ++i < len )
// restore the original event & type
event.type = orig.type;
event.originalEvent = orig.event;
// return all handler results
return drag.flatten( dd.results );
},
// extend the callback object with drag/drop properties...
properties: function( event, dd, ia ){
var obj = ia.callback;
// elements
obj.drag = ia.drag;
obj.proxy = ia.proxy || ia.drag;
// starting mouse position
obj.startX = dd.pageX;
obj.startY = dd.pageY;
// current distance dragged
obj.deltaX = event.pageX - dd.pageX;
obj.deltaY = event.pageY - dd.pageY;
// original element position
obj.originalX = ia.offset.left;
obj.originalY = ia.offset.top;
// adjusted element position
obj.offsetX = obj.originalX + obj.deltaX;
obj.offsetY = obj.originalY + obj.deltaY;
// assign the drop targets information
obj.drop = drag.flatten( ( ia.drop || [] ).slice() );
obj.available = drag.flatten( ( ia.droppable || [] ).slice() );
return obj;
},
// determine is the argument is an element or jquery instance
element: function( arg ){
if ( arg && ( arg.jquery || arg.nodeType == 1 ) )
return arg;
},
// flatten nested jquery objects and arrays into a single dimension array
flatten: function( arr ){
return $.map( arr, function( member ){
return member && member.jquery ? $.makeArray( member ) :
member && member.length ? drag.flatten( member ) : member;
});
},
// toggles text selection attributes ON (true) or OFF (false)
textselect: function( bool ){
$( document )[ bool ? "unbind" : "bind" ]("selectstart", drag.dontstart )
.css("MozUserSelect", bool ? "" : "none" );
// .attr("unselectable", bool ? "off" : "on" )
document.unselectable = bool ? "off" : "on";
},
// suppress "selectstart" and "ondragstart" events
dontstart: function(){
return false;
},
// a callback instance contructor
callback: function(){}
};
// callback methods
drag.callback.prototype = {
update: function(){
if ( $special.drop && this.available.length )
$.each( this.available, function( i ){
$special.drop.locate( this, i );
});
}
};
// patch $.event.$dispatch to allow suppressing clicks
var $dispatch = $event.dispatch;
$event.dispatch = function( event ){
if ( $.data( this, "suppress."+ event.type ) - new Date().getTime() > 0 ){
$.removeData( this, "suppress."+ event.type );
return;
}
return $dispatch.apply( this, arguments );
};
// event fix hooks for touch events...
var touchHooks =
$event.fixHooks.touchstart =
$event.fixHooks.touchmove =
$event.fixHooks.touchend =
$event.fixHooks.touchcancel = {
props: "clientX clientY pageX pageY screenX screenY".split( " " ),
filter: function( event, orig ) {
if ( orig ){
var touched = ( orig.touches && orig.touches[0] )
|| ( orig.changedTouches && orig.changedTouches[0] )
|| null;
// iOS webkit: touchstart, touchmove, touchend
if ( touched )
$.each( touchHooks.props, function( i, prop ){
event[ prop ] = touched[ prop ];
});
}
return event;
}
};
// share the same special event configuration with related events...
$special.draginit = $special.dragstart = $special.dragend = drag;
})( jQuery );

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -1,202 +0,0 @@
/*! sass.js - v0.9.2 (e355668) - built 2015-06-14
providing libsass 3.2.5 (0e6b4a2)
via emscripten 1.33.1 (ae2f801)
*/
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Sass = factory();
}
}(this, function () {/*global document*/
// identify the path sass.js is located at in case we're loaded by a simple
// <script src="path/to/sass.js"></script>
// this path can be used to identify the location of
// * sass.worker.js from sass.js
// * libsass.js.mem from sass.sync.js
// see https://github.com/medialize/sass.js/pull/32#issuecomment-103142214
// see https://github.com/medialize/sass.js/issues/33
var SASSJS_RELATIVE_PATH = (function() {
'use strict';
// in Node things are rather simple
if (typeof __dirname !== 'undefined') {
return __dirname;
}
// we can only run this test in the browser,
// so make sure we actually have a DOM to work with.
if (typeof document === 'undefined' || !document.getElementsByTagName) {
return null;
}
// http://www.2ality.com/2014/05/current-script.html
var currentScript = document.currentScript || (function() {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
var path = currentScript && currentScript.src;
if (!path) {
return null;
}
// [worker] make sure we're not running in some concatenated thing
if (path.slice(-8) === '/sass.js') {
return path.slice(0, -8);
}
// [sync] make sure we're not running in some concatenated thing
if (path.slice(-13) === '/sass.sync.js') {
return path.slice(0, -13);
}
return null;
})() || '.';
/*global Worker, SASSJS_RELATIVE_PATH*/
'use strict';
var noop = function(){};
var slice = [].slice;
// defined upon first Sass.initialize() call
var globalWorkerUrl;
function Sass(workerUrl) {
if (!workerUrl && !globalWorkerUrl) {
/*jshint laxbreak:true */
throw new Error(
'Sass needs to be initialized with the URL of sass.worker.js - '
+ 'either via Sass.setWorkerUrl(url) or by new Sass(url)'
);
/*jshint laxbreak:false */
}
if (!globalWorkerUrl) {
globalWorkerUrl = workerUrl;
}
// bind all functions
// we're doing this because we used to have a single hard-wired instance that allowed
// [].map(Sass.removeFile) and we need to maintain that for now (at least until 1.0.0)
for (var key in this) {
if (typeof this[key] === 'function') {
this[key] = this[key].bind(this);
}
}
this._callbacks = {};
this._worker = new Worker(workerUrl || globalWorkerUrl);
this._worker.addEventListener('message', this._handleWorkerMessage, false);
}
// allow setting the workerUrl before the first Sass instance is initialized,
// where registering the global workerUrl would've happened automatically
Sass.setWorkerUrl = function(workerUrl) {
globalWorkerUrl = workerUrl;
};
Sass.style = {
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
Sass.comments = {
'none': 0,
'default': 1
};
Sass.prototype = {
style: Sass.style,
comments: Sass.comments,
destroy: function() {
this._worker && this._worker.terminate();
this._worker = null;
this._callbacks = {};
this._importer = null;
},
_handleWorkerMessage: function(event) {
if (event.data.command) {
this[event.data.command](event.data.args);
}
this._callbacks[event.data.id] && this._callbacks[event.data.id](event.data.result);
delete this._callbacks[event.data.id];
},
_dispatch: function(options, callback) {
if (!this._worker) {
throw new Error('Sass worker has been terminated');
}
options.id = 'cb' + Date.now() + Math.random();
this._callbacks[options.id] = callback;
this._worker.postMessage(options);
},
_importerInit: function(args) {
// importer API done callback pushing results
// back to the worker
var done = function done(result) {
this._worker.postMessage({
command: '_importerFinish',
args: [result]
});
}.bind(this);
try {
this._importer(args[0], done);
} catch(e) {
done({ error: e.message });
throw e;
}
},
importer: function(importerCallback, callback) {
if (typeof importerCallback !== 'function' && importerCallback !== null) {
throw new Error('importer callback must either be a function or null');
}
// callback is executed in the main EventLoop
this._importer = importerCallback;
// tell worker to activate importer callback
this._worker.postMessage({
command: 'importer',
args: [Boolean(importerCallback)]
});
callback && callback();
},
};
var commands = 'writeFile readFile listFiles removeFile clearFiles lazyFiles preloadFiles options compile compileFile';
commands.split(' ').forEach(function(command) {
Sass.prototype[command] = function() {
var callback = slice.call(arguments, -1)[0];
var args = slice.call(arguments, 0, -1);
if (typeof callback !== 'function') {
args.push(callback);
callback = noop;
}
this._dispatch({
command: command,
args: args
}, callback);
};
});
// automatically set the workerUrl in case we're loaded by a simple
// <script src="path/to/sass.js"></script>
// see https://github.com/medialize/sass.js/pull/32#issuecomment-103142214
Sass.setWorkerUrl(SASSJS_RELATIVE_PATH + '/sass.worker.js');
return Sass;
}));

File diff suppressed because one or more lines are too long