forked from cameramanben/LUTCalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlutcalc.js
121 lines (121 loc) · 3.63 KB
/
lutcalc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* lutcalc.js
* Master Javascript file for the LUTCalc Web App.
* 7th October 2014
*
* LUTCalc generates 1D and 3D Lookup Tables (LUTs) for video cameras that shoot log gammas,
* principally the Sony CineAlta line.
*
* By Ben Turley, http://turley.tv
* First License: GPLv2
* Github: https://github.com/cameramanben/LUTCalc
*/
// Declare variables
var titFootHeight,
lutCalcForm,
lutTests,
lutMessage,
lutFile,
left,
lutCameraBox,
lutTweaksBox,
right,
lutPreview,
lutBox,
lutGenerate,
lutInfoBox;
document.addEventListener("DOMContentLoaded", function() {
// Housekeeping
titFootHeight = parseInt(document.getElementById('titlebar').clientHeight) + parseInt(document.getElementById('footer').clientHeight);
lutCalcForm = document.getElementById('lutcalcform');
// Browser feature tests
lutTests = new LUTTests(lutInputs);
// Build UI
lutMessage = new LUTMessage(lutInputs);
lutTests.isTransTest(lutMessage.getWorker());
lutFile = new LUTFile(lutInputs);
lutFormats = new LUTFormats(lutInputs, lutMessage, lutFile);
document.getElementById('version').appendChild(document.createTextNode(lutInputs.version));
// Create HTML Structure
left = fieldSet(lutCalcForm,false,'left');
lutCameraBox = new LUTCameraBox(fieldSet(left,true), lutInputs, lutMessage);
lutGammaBox = new LUTGammaBox(fieldSet(left,true), lutInputs, lutMessage);
lutTweaksBox = new LUTTweaksBox(fieldSet(left,true), lutInputs, lutMessage, lutFile, lutFormats);
right = fieldSet(lutCalcForm,false,'right');
lutBox = new LUTLutBox(fieldSet(right,true), lutInputs, lutMessage, lutFormats);
lutGenerate = new LUTGenerateBox(fieldSet(right,false), lutInputs, lutMessage, lutFile, lutFormats);
lutPreview = new LUTPreview(fieldSet(right,true), lutInputs, lutMessage, lutFile);
lutPreview.uiExternal(lutGenerate.getBox());
lutInfoBox = new LUTInfoBox(fieldSet(right,true),lutInputs, lutMessage);
document.getElementById('main').appendChild(modalBox);
modalBox.className = 'modalbox';
// Set Up Data
lutMessage.gaTx(0,5,{});
lutMessage.gtTx(0,5,{});
lutMessage.gtTx(0,11,{});
lutGammaBox.oneOrThree();
// Set Up Events
window.onresize = function(){
maxHeights();
};
});
// Window resize adjustments
function maxHeights() {
var winHeight = isNaN(window.innerHeight) ? window.clientHeight : window.innerHeight;
var mainHeight = winHeight - titFootHeight - 12;
var camGam = parseInt(lutCameraBox.getHeight()) + parseInt(lutGammaBox.getHeight());
var tweakHeight = mainHeight - camGam;
lutTweaksBox.setMaxHeight(tweakHeight);
if (mainHeight < 420) {
mainHeight = 420;
}
left.style.height = mainHeight.toString() + 'px';
right.style.height = mainHeight.toString() + 'px';
}
// Helper Functions
function lutcalcReady(p) {
if (lutInputs.isReady(p)) {
lutFormats.events();
lutCameraBox.events();
lutGammaBox.events();
lutTweaksBox.events();
lutBox.events();
lutGenerate.events();
lutPreview.events();
lutInfoBox.events();
splash.style.display = 'none';
modalBox.className = 'modalbox-hide';
lutMessage.setReady();
lutMessage.gtSetParams();
lutMessage.gaSetParams();
}
}
function fieldSet(parentElement,shadow,id) {
var box = document.createElement('fieldset');
if (id) {
box.id = id;
}
if (shadow) {
box.setAttribute('class','shadowbox');
}
parentElement.appendChild(box);
return box;
}
function notifyUser(title,message) {
if (lutInputs.canChromeNotify) {
chrome.notifications.create(
'lutcalc-' + Math.random().toString(),
{
type: 'basic',
iconUrl: 'img/logo64.png',
title: title,
message: message,
priority: 0
},
function(id) {
timer = setTimeout(function(){
chrome.notifications.clear(id);
}, 2500);
}
);
}
}