<!doctype html>
<html>
<!-- Uncomment this to generate the CSP error
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'none';">
</head>
-->
<body>
<canvas id="test1" width="256" height="64" style="border:1px solid #c3c3c3; background-color:#F00000"></canvas>
<script type="text/javascript">
console.log("CSP: javascript works!");
var canvas = document.getElementById("test1");
var ctx = canvas.getContext("2d");
const color_TEXT = "#000000";
const color_BACKGND = "#FFFFFF";
//canvas.style = "background-color:" + color_OK;
ctx.fillStyle = color_BACKGND;
ctx.fillRect(0, 0, 256, 64);
ctx.fillStyle = color_TEXT;
ctx.fillText("CSP: javascript works!", 11, 53);
// For simple check - call the functions once,
// don't check if anything is valid (transition names, started replay buffer etc).
var current_access_level = "UNKNOWN";
window.obsstudio.getControlLevel(function (level) {
console.log("obs control level:" + level);
if (level == 0) {
current_access_level = "NONE";
} else if (level == 1) {
current_access_level = "READ_OBS (OBS data)";
window.obsstudio.getStatus(function (status) {
console.log("obs status: " + status);
ctx.fillText("Recording started: " + status.recording, 11, 25);
})
} else if (level == 2) {
current_access_level = "READ_USER (User data)";
window.obsstudio.getCurrentScene(function(scene) {
console.log("obs scene: " + scene);
ctx.fillText("Current scene: " + scene.name, 11, 25);
})
} else if (level == 3) {
current_access_level = "BASIC";
window.obsstudio.saveReplayBuffer()
console.log("obs save replay buffer");
ctx.fillText("Replay buffer saved", 11, 25);
} else if (level == 4) {
current_access_level = "ADVANCED";
window.obsstudio.getCurrentTransition(function (transition) {
console.log("obs current transition: " + transition);
if (transition != "Cut") { // Any but Cut
window.obsstudio.setCurrentTransition("Cut");
window.obsstudio.setCurrentTransition(transition);
ctx.fillText("Transition changed: " + transition + "->Cut->" + transition, 11, 25);
} else { // Cut
window.obsstudio.setCurrentTransition("Fade");
window.obsstudio.setCurrentTransition(transition);
ctx.fillText("Transition changed: Cut->Fade->Cut", 11, 25);
}
})
} else if (level == 5) {
current_access_level = "ALL";
window.obsstudio.pauseRecording();
console.log("obs pause recording");
window.obsstudio.unpauseRecording();
console.log("obs unpause recording");
ctx.fillText("Recording Paused/Unpaused", 11, 25);
}
ctx.fillText("ACCESS: " + current_access_level, 11, 11);
})
</script>
</body>
</html>