intval3/app/www/index.html

603 lines
21 KiB
HTML

<!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{
}
.page{
padding: 5px 10% 0 10%;
display: none;
}
.page.selected{
display: block;
}
h2{
font-size: 18px;
text-align: center;
font-weight: normal;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: block;
width: 60px;
height: 34px;
margin: 0 auto;
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #20ce45;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #f32121;
}
input:focus + .slider {
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
input[type=number],
input[type=text],
input[type=password],
select{
width: 100%;
border: 2px solid #fff;
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;
}
option{
color: #212121;
}
button{
width: 100%;
border: 2px solid #fff;
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;
}
button:focus{
background-color: #20ce45;
border-color: #20ce45;
color: #212121;
font-weight: bold;
}
.icon{
display: block;
line-height: 34px;
height: 33px;
opacity: 0.5;
color: #fff;
}
.icon.selected{
opacity: 1.0;
}
#fwdLabel{
float: left;
}
#bwdLabel{
position: absolute;
right: 10%;
}
.label{
text-align: center;
color: #666;
margin-top: 6px;
margin-bottom: 9px;
}
#exposure,
#delay{
width: 70%;
display: inline-block;
}
#scale,
#delayScale{
width: 25%;
display: inline-block;
float: right;
}
#str{
color: #fff;
}
#counter{
text-align: center;
}
</style>
</head>
<body>
<div id="app" class="page selected">
<div>
<div class="label">Counter</div>
<input type="number" id="counter" onclick="setCounter();" value="0" step="1" readonly />
</div>
<div>
<div class="label">Direction</div>
<span id="bwdLabel">BACKWARD</span>
<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>
<button id="seq">START SEQUENCE</button>
</div>
<div>
<button id="frame" onclick="frame();">FRAME</button>
</div>
</div>
<div id="settings" class="page">
<h2>SETTINGS</h2>
<div>
<div class="label">Rex-o-fader</div>
<select id="angle">
<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>
<div id="sequencer" class="page">
<h2>Sequence</h2>
</div>
<div id="mscript" class="page">
<h2>mscript</h2>
</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VMzMS45NjMsMTgsMjcsMTh6IE0yNywzNGMtMy44NTksMC03LTMuMTQxLTctN3MzLjE0MS03LDctNyAgIHM3LDMuMTQxLDcsN1MzMC44NTksMzQsMjcsMzR6IiBmaWxsPSIjRkZGRkZGIi8+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==" />
</div>
<div>
<h1><span onclick="appPage();" id="appIcon" class="icon selected">INTVAL</span></h1>
</div>
<div>
<img src="" id="sequencerIcon" onclick="sequencerPage();" class="icon" />
</div>
<div>
<img id="mscriptIcon" onclick="mscriptPage();" class="icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjMycHgiIGhlaWdodD0iMzJweCIgdmlld0JveD0iMCAwIDUyMi40NjggNTIyLjQ2OSIgc3R5bGU9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z4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
</div>
</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
}
//functions
let frame;
let getState;
let setDir;
let setExposure;
let setDelay;
let setCounter;
//ms
var shutter = function (exposure) {
let fraction = BOLEX.expected / 1000;
let speed;
let corrected;
let str;
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) {
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) {
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 () {
const scale = document.getElementById('scale').value;
const elem = document.getElementById('exposure');
if (scale === 'ms') {
elem.value = STATE.exposure;
} else if (scale === 'sec') {
elem.value = STATE.exposure / 1000;
} else if (scale === 'min') {
elem.value = STATE.exposure / (1000 * 60);
} else if (scale === 'hour') {
elem.value = STATE.exposure / (1000 * 60 * 60);
}
STATE.scale = scale;
};
var setDelayScale = function () {
const scale = document.getElementById('scale').value;
const elem = document.getElementById('delay');
if (scale === 'ms') {
elem.value = STATE.delay;
} else if (scale === 'sec') {
elem.value = STATE.delay / 1000;
} else if (scale === 'min') {
elem.value = STATE.delay / (1000 * 60);
} else if (scale === 'hour') {
elem.value = STATE.delay / (1000 * 60 * 60);
}
STATE.delayScale = scale;
};
var setDirLabel = function (dir) {
const bwdLabel = document.getElementById('bwdLabel');
const fwdLabel = document.getElementById('fwdLabel');
if (dir) {
bwdLabel.classList.remove('selected')
fwdLabel.classList.add('selected')
} else {
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 forceCounter = function (val) {
document.getElementById('counter').value = val;
}
var unsetPages = function () {
const pages = document.getElementsByClassName('page');
const icons = document.getElementsByClassName('icon');
for (let icon of icons) {
if (icon.classList.contains('selected')) icon.classList.remove('selected');
}
for (let page of pages){
if (page.classList.contains('selected')) page.classList.remove('selected');
}
};
var appPage = function () {
unsetPages();
document.getElementById('app').classList.add('selected');
document.getElementById('appIcon').classList.add('selected');
};
var settingsPage = function () {
unsetPages();
document.getElementById('settings').classList.add('selected');
document.getElementById('settingsIcon').classList.add('selected');
};
var sequencerPage = function () {
unsetPages();
document.getElementById('sequencer').classList.add('selected');
document.getElementById('sequencerIcon').classList.add('selected');
};
var mscriptPage = function () {
unsetPages();
document.getElementById('mscript').classList.add('selected');
document.getElementById('mscriptIcon').classList.add('selected');
};
var isNumeric = function (n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
</script>
<script>
'use strict'
const web = {};
web._header = new Headers({ 'content-type' : 'application/json' })
web.frame = function () {
const opts = {
method : 'POST',
headers : web._header
};
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();
console.log(`Frame ${res.dir ? 'forward' : 'backward'} took ${res.len}ms`)
if (res.dir === true) {
incCounter(1);
} else {
incCounter(-1);
}
};
web.setDir = function () {
const dir = !document.getElementById('dir').checked;
const opts = {
method : 'POST',
headers : web._header,
body : JSON.stringify({ dir : dir })
};
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 () {
const opts = {
method : 'GET'
}
fetch('/status', opts)
.then(res => {
return res.json();
})
.then(web.getStateSuccess)
.catch(err => {
console.error('Error getting state');
console.error(err);
});
};
web.getStateSuccess = function (res) {
let exposure;
let scale;
if (res.frame.dir !== true) {
document.getElementById('dir').checked = true;
STATE.dir = res.frame.dir;
setDirLabel(false);
}
document.getElementById('counter').value = res.counter;
STATE.counter = res.counter;
//Exposure
if (res.frame.exposure === 0) {
res.frame.exposure = BOLEX.expected;
}
STATE.exposure = res.frame.exposure;
exposure = shutter(STATE.exposure);
scale = scaleAuto(STATE.exposure);
document.getElementById('str').value = exposure.str;
document.getElementById('scale').value = scale;
setExposureScale();
document.getElementById('delay').value = res.frame.delay;
STATE.delay = res.frame.delay;
};
web.setExposure = function () {
let exposure = document.getElementById('exposure').value;
let scaledExposure;
let opts
if (exposure === '' || exposure === null) {
exposure = 0;
}
scaledExposure = scaleTime(exposure, STATE.scale);
opts = {
method : 'POST',
headers : web._header,
body : JSON.stringify({ exposure : scaledExposure })
}
fetch('/exposure', opts)
.then(web.useJson)
.then(web.setExposureSuccess)
.catch(err => {
console.error('Error setting exposure');
console.error(err);
});
};
web.setExposureSuccess = function (res) {
let exposure;
if (res.exposure < BOLEX.expected) {
res.exposure = BOLEX.expected;
}
STATE.exposure = res.exposure;
exposure = shutter(STATE.exposure);
document.getElementById('str').value = exposure.str;
console.log(`setExposure to ${res.exposure}`);
};
web.setDelay = function () {
const delay = document.getElementById('delay').value;
const scaledDelay = scaleTime(delay, STATE.delayScale)
let opts = {
method : 'POST',
headers : web._header,
body : JSON.stringify({ delay : scaledDelay })
}
fetch('/delay', opts)
.then(web.useJson)
.then(web.setDelaySuccess)
.catch(err => {
console.error('Error setting delay');
console.error(err);
})
};
web.setDelaySuccess = function (res) {
STATE.delay = res.delay;
console.log(`setDelay to ${res.delay}`);
};
web.setCounter = function () {
const counter = document.getElementById('counter').value;
const change = prompt(`Change counter value?`, counter);
if (change === null || !isNumeric(change)) return false;
const opts = {
method : 'POST',
headers : web._header,
body : JSON.stringify({ counter : change })
}
fetch('/counter', opts)
.then(web.useJson)
.then(web.setCounterSuccess)
.catch(err => {
console.error('Error setting counter');
console.error(err);
})
};
web.setCounterSuccess = function (res) {
STATE.counter = res.counter;
forceCounter(res.counter);
console.log(`setCounter to ${res.counter}`);
};
web.useJson = function (res) {
return res.json();
}
web.init = function () {
frame = web.frame;
getState = web.getState;
setDir = web.setDir;
setExposure = web.setExposure;
setCounter = web.setCounter;
web.getState();
};
web.init();
</script>
<script>
var mobile = {};
mobile.init = function () {
'use strict';
};
</script>
</body>
</html>