2018-02-01 19:55:20 +00:00
|
|
|
/* jslint esversion: 6*/
|
|
|
|
|
|
|
|
const gui = {};
|
2016-06-19 00:13:33 +00:00
|
|
|
|
|
|
|
//GUI
|
|
|
|
gui.fmtZero = function (val, len) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
const raw = val;
|
|
|
|
let str = val + '';
|
|
|
|
let output = '';
|
2016-06-19 00:13:33 +00:00
|
|
|
if (raw < 0) {
|
|
|
|
output = '-' + Array(len - (str.length - 1)).join('0') + str.replace('-', '');
|
|
|
|
} else {
|
|
|
|
if (str.length < len) {
|
|
|
|
output = Array(len - str.length).join('0') + str;
|
|
|
|
} else if (str.length >= len) {
|
|
|
|
str = parseInt(str) + '';
|
|
|
|
output = Array(len - str.length).join('0') + str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
};
|
|
|
|
gui.counterFormat = function (t, normal, prevent) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
const raw = t.value;
|
2016-06-19 00:13:33 +00:00
|
|
|
t.value = gui.fmtZero(raw, 6);
|
|
|
|
if (typeof normal !== 'undefined' && parseInt(raw) !== normal) {
|
|
|
|
$(t).addClass('changed');
|
|
|
|
} else {
|
|
|
|
$(t).removeClass('changed');
|
|
|
|
}
|
|
|
|
};
|
2019-03-31 00:29:01 +00:00
|
|
|
gui.counterUpdate = function (which, raw) {
|
|
|
|
'use strict';
|
2019-05-28 16:28:45 +00:00
|
|
|
const formattedVal = gui.fmtZero(raw, 6);
|
2019-03-31 00:29:01 +00:00
|
|
|
$(`.${which} .count`).val(formattedVal);
|
|
|
|
};
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.notify = function (title, message) {
|
|
|
|
'use strict';
|
|
|
|
notifier.notify({
|
|
|
|
title: title,
|
|
|
|
message: message,
|
|
|
|
//icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
|
|
|
|
sound: true, // Only Notification Center or Windows Toasters
|
|
|
|
wait: true // Wait with callback, until user action is taken against notification
|
|
|
|
}, function (err, response) {
|
|
|
|
// Response is response from notification
|
|
|
|
});
|
|
|
|
};
|
|
|
|
gui.updateCam = function (t) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
const val = t.value;
|
|
|
|
let change;
|
|
|
|
|
2019-03-31 00:29:01 +00:00
|
|
|
if (parseInt(val) === cam.pos) {
|
2018-02-01 19:55:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
change = confirm(`Are you sure you want to set camera counter to ${val}?`);
|
|
|
|
|
2016-06-19 00:13:33 +00:00
|
|
|
if (change) {
|
2019-03-31 00:29:01 +00:00
|
|
|
cam.pos = parseInt(val);
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.updateState();
|
|
|
|
} else {
|
2019-03-31 00:29:01 +00:00
|
|
|
t.value = cam.pos;
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.counterFormat(t);
|
|
|
|
}
|
|
|
|
};
|
2019-04-19 01:58:11 +00:00
|
|
|
gui.updateCam2 = function (t) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
const val = t.value;
|
|
|
|
let change;
|
2019-04-19 01:58:11 +00:00
|
|
|
|
2019-03-31 00:29:01 +00:00
|
|
|
if (parseInt(val) === cam.pos) {
|
2018-02-01 19:55:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-19 01:58:11 +00:00
|
|
|
change = confirm(`Are you sure you want to set second camera counter to ${val}?`);
|
|
|
|
|
|
|
|
if (change) {
|
|
|
|
cam.second.pos = parseInt(val);
|
|
|
|
gui.updateState();
|
|
|
|
} else {
|
|
|
|
t.value = cam.second.pos;
|
|
|
|
gui.counterFormat(t);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
gui.updateProj = function (t) {
|
|
|
|
'use strict';
|
|
|
|
const val = t.value;
|
|
|
|
let change;
|
|
|
|
if (parseInt(val) === proj.pos) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-01 19:55:20 +00:00
|
|
|
change = confirm(`Are you sure you want to set projector counter to ${val}?`);
|
2016-06-19 00:13:33 +00:00
|
|
|
if (change) {
|
2019-03-31 00:29:01 +00:00
|
|
|
proj.pos = parseInt(val);
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.updateState();
|
|
|
|
} else {
|
2019-03-31 00:29:01 +00:00
|
|
|
t.value = proj.pos;
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.counterFormat(t);
|
|
|
|
}
|
2019-02-24 03:19:03 +00:00
|
|
|
proj.setValue(t.value);
|
2016-06-19 00:13:33 +00:00
|
|
|
};
|
2019-04-19 01:58:11 +00:00
|
|
|
gui.updateProj2 = function (t) {
|
|
|
|
'use strict';
|
|
|
|
const val = t.value;
|
|
|
|
let change;
|
|
|
|
if (parseInt(val) === proj.second.pos) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
change = confirm(`Are you sure you want to set second projector counter to ${val}?`);
|
|
|
|
if (change) {
|
|
|
|
proj.second.pos = parseInt(val);
|
|
|
|
gui.updateState();
|
|
|
|
} else {
|
|
|
|
t.value = proj.second.pos;
|
|
|
|
gui.counterFormat(t);
|
|
|
|
}
|
|
|
|
proj.setValue(t.value);
|
|
|
|
};
|
|
|
|
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.updateState = function () {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
2019-03-31 00:29:01 +00:00
|
|
|
const cpos = cam.pos;
|
|
|
|
const ppos = proj.pos;
|
2019-04-20 14:15:28 +00:00
|
|
|
|
2019-04-19 01:58:11 +00:00
|
|
|
const p2pos = proj.second.pos;
|
|
|
|
const c2pos = cam.second.pos;
|
2016-06-19 00:13:33 +00:00
|
|
|
|
|
|
|
$('#seq_cam_count').val(cpos).change();
|
|
|
|
$('#seq_proj_count').val(ppos).change();
|
|
|
|
|
2019-04-19 01:58:11 +00:00
|
|
|
$('#seq_cam_count_2').val(c2pos).change();
|
|
|
|
$('#seq_proj_count_2').val(p2pos).change();
|
2016-06-19 00:13:33 +00:00
|
|
|
};
|
2018-02-01 02:45:19 +00:00
|
|
|
gui.spinnerCfg = {
|
|
|
|
lines: 11, // The number of lines to draw
|
|
|
|
length: 15, // The length of each line
|
|
|
|
width: 7, // The line thickness
|
|
|
|
radius: 20, // The radius of the inner circle
|
|
|
|
corners: 1, // Corner roundness (0..1)
|
|
|
|
rotate: 0, // The rotation offset
|
|
|
|
direction: 1, // 1: clockwise, -1: counterclockwise
|
|
|
|
color: '#F2F2F1', // #rgb or #rrggbb or array of colors
|
|
|
|
speed: 1, // Rounds per second
|
|
|
|
trail: 60, // Afterglow percentage
|
|
|
|
shadow: true, // Whether to render a shadow
|
|
|
|
hwaccel: true, // Whether to use hardware acceleration
|
|
|
|
className: 'spinner', // The CSS class to assign to the spinner
|
|
|
|
zIndex: 2e9, // The z-index (defaults to 2000000000)
|
|
|
|
top: '50%', // Top position relative to parent
|
|
|
|
left: '50%' // Left position relative to parent
|
2018-02-01 19:55:20 +00:00
|
|
|
};
|
2019-03-18 23:42:12 +00:00
|
|
|
gui.spinner = function (state, msg, progress, cancel) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
let target;
|
|
|
|
let spinner;
|
|
|
|
if (msg && msg !== '') {
|
|
|
|
gui.spinnerMsg(msg);
|
2018-02-01 02:45:19 +00:00
|
|
|
}
|
|
|
|
if (state && !$('#spinner').hasClass('created')) {
|
2016-06-19 00:13:33 +00:00
|
|
|
target = document.getElementById('spinner');
|
2018-02-01 02:45:19 +00:00
|
|
|
spinner = new Spinner(gui.spinnerCfg).spin(target);
|
2018-03-15 03:17:59 +00:00
|
|
|
$('#spinnerProgress').hide();
|
2018-02-01 02:45:19 +00:00
|
|
|
$('#spinner').addClass('created');
|
|
|
|
} else if (state) {
|
|
|
|
$('#spinner').show();
|
|
|
|
} else if (!state) {
|
2016-06-19 00:13:33 +00:00
|
|
|
$('#spinner').hide();
|
2018-02-01 19:55:20 +00:00
|
|
|
gui.spinnerMsg('');
|
2018-03-15 03:17:59 +00:00
|
|
|
}
|
|
|
|
if (progress) {
|
2019-03-31 00:29:01 +00:00
|
|
|
$('#spinnerProgress').show();
|
|
|
|
} else {
|
|
|
|
$('#spinnerProgress').hide();
|
2016-06-19 00:13:33 +00:00
|
|
|
}
|
2019-03-18 23:42:12 +00:00
|
|
|
if (cancel) {
|
|
|
|
$('#spinnerCancel').show();
|
|
|
|
} else {
|
|
|
|
$('#spinnerCancel').hide();
|
|
|
|
}
|
2016-06-19 00:13:33 +00:00
|
|
|
};
|
2018-02-01 02:45:19 +00:00
|
|
|
gui.spinnerMsg = function (msg) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
|
|
|
$('#spinnerMsg').text(msg);
|
|
|
|
};
|
2016-06-19 00:13:33 +00:00
|
|
|
gui.overlay = function (state) {
|
2018-02-01 19:55:20 +00:00
|
|
|
'use strict';
|
2016-06-19 00:13:33 +00:00
|
|
|
if (state) {
|
|
|
|
$('#overlay').show();
|
|
|
|
} else {
|
|
|
|
$('#overlay').hide();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
gui.info = function (title, message) {
|
|
|
|
'use strict';
|
2018-02-01 19:55:20 +00:00
|
|
|
const config = {
|
2016-06-19 00:13:33 +00:00
|
|
|
type : 'info',
|
|
|
|
buttons : ['Ok'],
|
|
|
|
title: title,
|
|
|
|
message : message
|
|
|
|
};
|
|
|
|
dialog.showMessageBox(config);
|
|
|
|
};
|
|
|
|
gui.confirm = function () {};
|
|
|
|
gui.warn = function (title, message) {
|
|
|
|
'use strict';
|
2018-02-01 19:55:20 +00:00
|
|
|
const config = {
|
2016-06-19 00:13:33 +00:00
|
|
|
type : 'warning',
|
|
|
|
buttons : ['Ok'],
|
|
|
|
title: title,
|
|
|
|
message : message
|
|
|
|
};
|
|
|
|
dialog.showMessageBox(config);
|
|
|
|
};
|
|
|
|
gui.error = function () {};
|
|
|
|
|
|
|
|
module.exports = gui;
|