intval3/app/www/index.html

555 lines
20 KiB
HTML
Raw Normal View History

2017-08-22 02:49:35 +00:00
<!doctype html>
<html>
<head>
<title>intval 3</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name = "viewport" content = "width = 320, initial-scale = 1.0, user-scalable = no">
<style>
html,body{
background: #212121;
height: 100%;
padding: 0;
margin: 0;
}
*{
color: #fff;
font-family: 'Arial Neue', Helvetical, Arial, sans-serif;
}
body{
}
#app,
#settings{
2017-10-24 00:54:03 +00:00
padding: 5px 10% 0 10%;
2017-10-22 02:13:38 +00:00
}
#settings{
display: none;
}
#settings h2{
font-size: 18px;
text-align: center;
font-weight: normal;
}
2017-10-22 01:22:02 +00:00
/* The switch - the box around the slider */
.switch {
position: relative;
2017-10-22 02:17:32 +00:00
display: block;
2017-10-22 01:22:02 +00:00
width: 60px;
height: 34px;
2017-10-22 02:17:32 +00:00
margin: 0 auto;
2017-10-22 01:22:02 +00:00
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
2017-10-22 01:44:07 +00:00
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #20ce45;
-webkit-transition: .4s;
transition: .4s;
2017-10-22 01:22:02 +00:00
}
.slider:before {
2017-10-22 01:44:07 +00:00
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
2017-10-22 01:22:02 +00:00
}
input:checked + .slider {
2017-10-22 01:44:07 +00:00
background-color: #f32121;
2017-10-22 01:22:02 +00:00
}
input:focus + .slider {
2017-10-22 02:13:38 +00:00
2017-10-22 01:22:02 +00:00
}
input:checked + .slider:before {
2017-10-22 01:44:07 +00:00
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
2017-10-22 01:22:02 +00:00
}
/* Rounded sliders */
.slider.round {
2017-10-22 01:44:07 +00:00
border-radius: 34px;
2017-10-22 01:22:02 +00:00
}
.slider.round:before {
2017-10-22 01:44:07 +00:00
border-radius: 50%;
}
input[type=number],
input[type=text],
input[type=password],
select{
2017-10-22 02:13:38 +00:00
width: 100%;
border: 2px solid #fff;
2017-10-22 01:44:07 +00:00
border-radius: 5px;
color: #fff;
font-size: 18px;
-webkit-appearance: none;
background: transparent;
box-shadow: none;
outline: none;
margin: 5px 0;
padding: 5px 10px;
box-sizing: border-box;
2017-10-22 01:44:07 +00:00
}
option{
color: #212121;
}
2017-10-22 01:44:07 +00:00
button{
2017-10-22 02:13:38 +00:00
width: 100%;
border: 2px solid #fff;
2017-10-22 01:44:07 +00:00
border-radius: 5px;
color: #fff;
font-size: 18px;
background: transparent;
-webkit-appearance: none;
box-shadow: none;
outline: none;
margin: 5px 0;
padding: 5px 0;
text-align: center;
2017-10-22 01:44:07 +00:00
}
button:focus{
background-color: #20ce45;
border-color: #20ce45;
color: #212121;
2017-10-22 02:13:38 +00:00
font-weight: bold;
}
#fwdLabel,#bwdLabel{
display: block;
line-height: 34px;
height: 33px;
color: #444;
}
#fwdLabel.selected,
#bwdLabel.selected{
color: #fff;
}
#fwdLabel{
float: left;
}
#bwdLabel{
2017-10-22 02:17:32 +00:00
position: absolute;
right: 10%;
2017-10-22 02:13:38 +00:00
}
.label{
text-align: center;
2017-10-22 02:13:38 +00:00
color: #666;
2017-10-24 13:56:59 +00:00
margin-top: 6px;
margin-bottom: 9px;
2017-10-22 01:22:02 +00:00
}
2017-11-21 18:50:01 +00:00
.icon{
}
#exposure,
#delay{
width: 70%;
display: inline-block;
}
#scale,
#delayScale{
width: 25%;
display: inline-block;
float: right;
}
#str{
color: #fff;
}
2017-10-24 00:54:03 +00:00
#counter{
text-align: center;
}
</style>
2017-08-22 02:49:35 +00:00
</head>
<body>
<div id="app">
<div>
<div class="label">Counter</div>
2017-10-24 00:41:28 +00:00
<input type="number" id="counter" oninput="setCounter();" value="0" step="1" />
</div>
<div>
2017-10-22 02:13:38 +00:00
<div class="label">Direction</div>
2017-10-22 02:17:32 +00:00
<span id="bwdLabel">BACKWARD</span>
2017-10-22 02:13:38 +00:00
<span id="fwdLabel" class="selected">FORWARD</span>
<label class="switch">
<input type="checkbox" id="dir" onclick="setDir();">
<span class="slider round"></span>
</label>
</div>
<div>
<div class="label">Exposure <span id="str">1/5</span></div>
<input type="number" id="exposure" value="630" min="0" oninput="setExposure();" />
<select id="scale" onchange="setExposureScale();">
<option value="ms" selected>ms</option>
<option value="sec">sec</option>
<option value="min">min</option>
<option value="hour">hour</option>
</select>
</div>
<div>
<div class="label">Delay</div>
<input type="number" id="delay" value="0" min="0" step="1" />
<select id="delayScale" onchange="setDelayScale();">
<option value="ms" selected>ms</option>
<option value="sec">sec</option>
<option value="min">min</option>
<option value="hour">hour</option>
</select>
</div>
<div>
2017-10-22 02:13:38 +00:00
<button id="seq">START SEQUENCE</button>
</div>
<div>
2017-10-22 02:13:38 +00:00
<button id="frame" onclick="frame();">FRAME</button>
</div>
2017-10-22 01:44:07 +00:00
</div>
<div id="settings">
<h2>SETTINGS</h2>
<div>
<div class="label">Rex-o-fader</div>
<select id="angle">
2017-10-24 13:56:59 +00:00
<option value="133" selected>0 (Normal)</option>
<option value="66">1 Stop</option>
<option value="33">2 Stop</option>
</select>
</div>
<h2>BLUETOOTH</h2>
<select id="bluetooth">
<option>N/A</option>
</select>
<h2>WIFI</h2>
<div>
<input type="text" id="ssid" placeholder="Wifi SSID" />
</div>
<div>
<input type="password" id="password" placeholder="Wifi Password" />
</div>
</div>
2017-11-21 18:50:01 +00:00
<footer>
<img id="settingsIcon" onclick="settingsPage();" class="icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+Cjxzd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Mjk0bC0zLjU3Mi0zLjU3MWMtMC4zMDUtMC4zMDUtMC4zMDUtMC44LDAtMS4xMDRsNC41NTMtNC41NTMgICBjMC4zMDQtMC4zMDUsMC43OTktMC4zMDUsMS4xMDQsMGwzLjU3MSwzLjU3MWMxLjE0NywxLjE0NywyLjc5MiwxLjQ3Niw0LjI5NCwwLjg1NEMyMi4wNjgsMTAuODUxLDIzLDkuNDU2LDIzLDcuODMyVjIuNzggICBDMjMsMi4zNSwyMy4zNSwyLDIzLjc4LDJoNi40MzlDMzAuNjUsMiwzMSwyLjM1LDMxLDIuNzh2NS4wNTJjMCwxLjYyNCwwLjkzMiwzLjAxOSwyLjQzMiwzLjY0ICAgYzEuNTAyLDAuNjIyLDMuMTQ2LDAuMjk0LDQuMjk0LTAuODU0bDMuNTcxLTMuNTcxYzAuMzA2LTAuMzA1LDAuODAxLTAuMzA1LDEuMTA0LDBsNC41NTMsNC41NTNjMC4zMDUsMC4zMDUsMC4zMDUsMC44LDAsMS4xMDQgICBsLTMuNTcyLDMuNTcxYy0xLjE0OCwxLjE0OC0xLjQ3NiwyLjc5NC0wLjg1NCw0LjI5NGMwLjYyMSwxLjUsMi4w
<h1 class="selected"><span onclick="appPage();" class="icon">INTVAL</span></h1>
<img src="" id="sequencerIcon" onclick="sequencerPage();" class="icon" />
<img id="mscriptIcon" onclick="mscriptPage();" class="icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0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TUsNTIxLjUxNywyNTYuNTY1LDUxOS42MTQsMjU0LjY2M3oiIGZpbGw9IiNGRkZGRkYiLz4KCTwvZz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
</footer>
<script>
'use strict';
const BOLEX = {
angle : 133,
prism : 0.8,
expected : 630
};
const STATE = {
dir : true,
exposure : 630, //always ms
delay : 0,
scale : 'ms',
delayScale : 'ms',
counter : 0
}
2017-11-21 21:34:07 +00:00
//functions
var frame;
var getState;
var setDir;
var setExposure;
var setDelay;
2017-10-24 00:44:35 +00:00
var setCounter;
//ms
var shutter = function (exposure) {
'use strict';
var fraction = BOLEX.expected / 1000;
var speed;
var corrected;
var str;
2017-10-23 04:33:02 +00:00
if (exposure > BOLEX.expected) {
//if exposure is explicitly set
fraction = exposure / 1000;
speed = fraction;
} else {
speed = fraction * (BOLEX.angle / 360);
}
corrected = speed * BOLEX.prism;
if (corrected < 1.0) {
//less than a second
str = '1/' + Math.round(Math.pow(corrected, -1)) + ' sec';
} else if (corrected >= 1.0 && corrected < 60) {
//greater than a second, less than a minute
str = '' + (Math.round(corrected * 10) / 10) + ' sec'
} else if (corrected >= 60 && corrected < 60 * 60) {
//greater than a minute, less than an hour
str = '' + (Math.round(corrected / 6) / 10) + ' min';
} else if (corrected >= 60 * 60 && corrected < 60 * 60 * 24) {
//greater than an hour, less than a day
str = '' + (Math.round(corrected / (6 * 60)) / 10) + ' hr';
} else if (corrected >= 60 * 60 * 24) {
//greater than a day
str = '' + (Math.round(corrected / (6 * 60 * 24)) / 10) + ' day';
}
return { speed : speed, str : str }
};
var scaleAuto = function (ms) {
'use strict';
if (ms < 1000) {
return 'ms'
} else if (ms >= 1000 && ms < 1000 * 60) {
return 'sec'
} else if (ms >= 1000 * 60 && ms < 1000 * 60 * 60) {
return 'min'
} else if (ms >= 1000 * 60 * 60) {
return 'hour'
}
};
var scaleTime = function (raw, scale) {
'use strict';
if (scale === 'ms') {
return raw
} else if (scale === 'sec') {
return raw * 1000;
} else if (scale === 'min') {
return raw * (1000 * 60);
} else if (scale === 'hour') {
return raw * (1000 * 60 * 60);
}
};
var setExposureScale = function () {
'use strict';
var scale = $('#scale').val();
if (scale === 'ms') {
$('#exposure').val(STATE.exposure);
} else if (scale === 'sec') {
$('#exposure').val(STATE.exposure / 1000);
} else if (scale === 'min') {
$('#exposure').val(STATE.exposure / (1000 * 60));
} else if (scale === 'hour') {
$('#exposure').val(STATE.exposure / (1000 * 60 * 60));
}
STATE.scale = scale;
};
var setDelayScale = function () {
'use strict';
var scale = $('#scale').val();
if (scale === 'ms') {
$('#delay').val(STATE.delay);
} else if (scale === 'sec') {
$('#delay').val(STATE.delay / 1000);
} else if (scale === 'min') {
$('#delay').val(STATE.delay / (1000 * 60));
} else if (scale === 'hour') {
$('#delay').val(STATE.delay / (1000 * 60 * 60));
}
STATE.delayScale = scale;
};
var setDirLabel = function (dir) {
2017-11-21 21:43:56 +00:00
const bwdLabel = document.getElementById('bwdLabel');
const fwdLabel = document.getElementById('fwdLabel');
if (dir) {
2017-11-21 21:43:56 +00:00
bwdLabel.classList.remove('selected')
fwdLabel.classList.add('selected')
} else {
2017-11-21 21:43:56 +00:00
fwdLabel.classList.remove('selected')
bwdLabel.classList.add('selected')
}
};
var incCounter = function (val) {
const elem = document.getElementById('counter');
const current = elem.value;
elem.value = (parseInt(current) + val);
STATE.counter += val;
};
var appPage = function () {
'use strict';
$('#app').show();
$('#settings').hide();
$('#settingsIcon').removeClass('selected');
$('#mscriptIcon').removeClass('selected');
$('#bar h1').addClass('selected');
};
var settingsPage = function () {
'use strict';
$('#settings').show();
$('#app').hide();
$('#bar h1').removeClass('selected');
$('#mscriptIcon').removeClass('selected');
$('#settingsIcon').addClass('selected');
};
</script>
<script>
2017-11-21 21:43:56 +00:00
'use strict'
const web = {};
web._header = new Headers({ 'content-type' : 'application/json' })
web.frame = function () {
const opts = {
method : 'POST',
headers : web._header,
body : JSON.stringify({})
};
fetch('/frame', opts)
.then(res => {
return res.json()
})
.then(web.frameSuccess)
.catch(err => {
console.error('Error triggering frame')
console.error(err)
});
}
web.frameSuccess = function (res) {
document.getElementById('frame').blur();
if (res.dir === true) {
incCounter(1);
} else {
incCounter(-1);
}
};
web.setDir = function () {
2017-11-21 21:55:44 +00:00
const dir = !document.getElementById('dir').checked;
2017-11-21 21:43:56 +00:00
const opts = {
method : 'POST',
headers : web._header,
2017-11-21 21:55:44 +00:00
body : JSON.stringify({ dir : dir })
2017-11-21 18:50:01 +00:00
};
fetch('/dir', opts)
.then(res => {
return res.json()
})
.then(web.setDirSuccess)
.catch(err => {
console.error('Error setting direction')
console.error(err);
});
};
web.setDirSuccess = function (res) {
STATE.dir = res.dir;
setDirLabel(res.dir);
console.log(`setDir to ${res.dir}`);
};
web.getState = function () {
fetch('/status')
.then(res => {
2017-11-21 22:13:07 +00:00
let r = res.json();
console.dir(r);
return r;
})
.then(web.getStateSuccess)
.catch(err => {
console.error('Error getting state');
console.error(err);
});
};
web.getStateSuccess = function (res) {
var exposure;
var scale;
if (res.frame.dir !== true) {
$('#dir').prop('checked', true);
STATE.dir = res.frame.dir;
setDirLabel(false);
}
$('#counter').val(res.counter);
2017-10-24 00:43:16 +00:00
STATE.counter = res.counter;
//Exposure
if (res.frame.exposure === 0) {
res.frame.exposure = BOLEX.expected;
}
STATE.exposure = res.frame.exposure;
exposure = shutter(STATE.exposure);
2017-10-23 04:19:48 +00:00
scale = scaleAuto(STATE.exposure);
$('#str').text(exposure.str);
$('#scale').val(scale);
setExposureScale();
2017-10-23 05:08:18 +00:00
$('#delay').val(res.frame.delay);
STATE.delay = res.frame.delay;
};
web.setExposure = function () {
var exposure = $('#exposure').val();
2017-10-23 05:24:22 +00:00
if (exposure === '' || exposure === null) {
exposure = 0;
}
var scaledExposure = scaleTime(exposure, STATE.scale);
$.ajax({
method : 'POST',
url : '/exposure',
data : JSON.stringify({ exposure : scaledExposure }),
contentType: 'application/json',
dataType : 'json',
success : web.setExposureSuccess
});
2017-11-21 18:50:01 +00:00
};
web.setExposureSuccess = function (res) {
var exposure;
if (res.exposure < BOLEX.expected) {
res.exposure = BOLEX.expected;
}
STATE.exposure = res.exposure;
exposure = shutter(STATE.exposure);
$('#str').text(exposure.str);
console.log('setExposure to ' + res.exposure);
};
web.setDelay = function () {
var delay = $('#delay').val();
var scaledDelay = scaleTime(delay, STATE.delayScale);
$.ajax({
method : 'POST',
url : '/delay',
2017-10-24 00:41:28 +00:00
data : JSON.stringify({ delay : scaledDelay }),
contentType: 'application/json',
dataType : 'json',
success : web.setDelaySuccess
2017-10-24 00:41:28 +00:00
});
};
web.setDelaySuccess = function (res) {
STATE.delay = res.delay;
2017-10-24 00:41:28 +00:00
console.log('setDelay to ' + res.delay);
};
web.setCounter = function () {
var counter = $('#counter').val();
$.ajax({
method : 'POST',
url : '/counter',
data : JSON.stringify({ counter : counter }),
contentType: 'application/json',
dataType : 'json',
success : web.setCounterSuccess
});
};
web.setCounterSuccess = function (res) {
STATE.counter = res.counter;
console.log('setCounter to ' + res.counter);
};
web.init = function () {
frame = web.frame;
getState = web.getState;
setDir = web.setDir;
setExposure = web.setExposure;
2017-10-24 00:41:28 +00:00
setCounter = web.setCounter;
web.getState();
};
web.init();
</script>
<script>
var mobile = {};
mobile.init = function () {
'use strict';
};
</script>
2017-08-22 02:49:35 +00:00
</body>
</html>