Convert all remaining var
s to let
s
This commit is contained in:
parent
8475340999
commit
075168ed85
@ -4,7 +4,7 @@ class ObjectCopy {
|
|||||||
static addNew(current, newValues){
|
static addNew(current, newValues){
|
||||||
|
|
||||||
// clone target
|
// clone target
|
||||||
var out = JSON.parse(JSON.stringify(newValues));
|
let out = JSON.parse(JSON.stringify(newValues));
|
||||||
|
|
||||||
if(! current) {
|
if(! current) {
|
||||||
if(Debug.debug) {
|
if(Debug.debug) {
|
||||||
@ -14,7 +14,7 @@ class ObjectCopy {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var k in out) {
|
for(let k in out) {
|
||||||
// if current key exist, replace it with existing value. Take no action otherwise.
|
// if current key exist, replace it with existing value. Take no action otherwise.
|
||||||
if(current[k]) {
|
if(current[k]) {
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class ObjectCopy {
|
|||||||
|
|
||||||
// add the values that would otherwise be deleted back to our object. (We need that so user-defined
|
// add the values that would otherwise be deleted back to our object. (We need that so user-defined
|
||||||
// sites don't get forgotten)
|
// sites don't get forgotten)
|
||||||
for(var k in current) {
|
for(let k in current) {
|
||||||
if (! out[k]) {
|
if (! out[k]) {
|
||||||
out[k] = current[k];
|
out[k] = current[k];
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ class ObjectCopy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static overwrite(current, newValues){
|
static overwrite(current, newValues){
|
||||||
for(var k in newValues) {
|
for(let k in newValues) {
|
||||||
// if current key exist, replace it with existing value. Take no action otherwise.
|
// if current key exist, replace it with existing value. Take no action otherwise.
|
||||||
if (current[k] !== undefined) {
|
if (current[k] !== undefined) {
|
||||||
// Types and constructors of objects must match. If they don't, we always use the new value.
|
// Types and constructors of objects must match. If they don't, we always use the new value.
|
||||||
|
@ -161,16 +161,16 @@ class ArDetector {
|
|||||||
// [2] determine places we'll use to sample our main frame
|
// [2] determine places we'll use to sample our main frame
|
||||||
//
|
//
|
||||||
|
|
||||||
var ncol = this.settings.active.arDetect.sampling.staticCols;
|
let ncol = this.settings.active.arDetect.sampling.staticCols;
|
||||||
var nrow = this.settings.active.arDetect.sampling.staticRows;
|
let nrow = this.settings.active.arDetect.sampling.staticRows;
|
||||||
|
|
||||||
var colSpacing = this.canvas.width / ncol;
|
let colSpacing = this.canvas.width / ncol;
|
||||||
var rowSpacing = (this.canvas.height << 2) / nrow;
|
let rowSpacing = (this.canvas.height << 2) / nrow;
|
||||||
|
|
||||||
this.sampleLines = [];
|
this.sampleLines = [];
|
||||||
this.sampleCols = [];
|
this.sampleCols = [];
|
||||||
|
|
||||||
for(var i = 0; i < ncol; i++){
|
for(let i = 0; i < ncol; i++){
|
||||||
if(i < ncol - 1)
|
if(i < ncol - 1)
|
||||||
this.sampleCols.push(Math.round(colSpacing * i));
|
this.sampleCols.push(Math.round(colSpacing * i));
|
||||||
else{
|
else{
|
||||||
@ -178,7 +178,7 @@ class ArDetector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < nrow; i++){
|
for(let i = 0; i < nrow; i++){
|
||||||
if(i < ncol - 5)
|
if(i < ncol - 5)
|
||||||
this.sampleLines.push(Math.round(rowSpacing * i));
|
this.sampleLines.push(Math.round(rowSpacing * i));
|
||||||
else{
|
else{
|
||||||
@ -381,7 +381,7 @@ class ArDetector {
|
|||||||
clearTimeout(this.setupTimer);
|
clearTimeout(this.setupTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ths = this;
|
let ths = this;
|
||||||
this.setupTimer = setTimeout(function(){
|
this.setupTimer = setTimeout(function(){
|
||||||
ths.setupTimer = null;
|
ths.setupTimer = null;
|
||||||
try{
|
try{
|
||||||
@ -419,7 +419,7 @@ class ArDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTimeout(baseTimeout, startTime){
|
getTimeout(baseTimeout, startTime){
|
||||||
var execTime = (performance.now() - startTime);
|
let execTime = (performance.now() - startTime);
|
||||||
|
|
||||||
return baseTimeout;
|
return baseTimeout;
|
||||||
}
|
}
|
||||||
@ -475,12 +475,12 @@ class ArDetector {
|
|||||||
// letterbox also needs to be corrected:
|
// letterbox also needs to be corrected:
|
||||||
// letterbox += [video.zoomedHeight] - [video.unzoomedHeight]
|
// letterbox += [video.zoomedHeight] - [video.unzoomedHeight]
|
||||||
|
|
||||||
var vbr = this.video.getBoundingClientRect();
|
let vbr = this.video.getBoundingClientRect();
|
||||||
|
|
||||||
zoomFactor = vbr.height / this.video.clientHeight;
|
zoomFactor = vbr.height / this.video.clientHeight;
|
||||||
letterbox += vbr.height - this.video.clientHeight;
|
letterbox += vbr.height - this.video.clientHeight;
|
||||||
|
|
||||||
var trueHeight = this.canvas.height * zoomFactor - letterbox;
|
let trueHeight = this.canvas.height * zoomFactor - letterbox;
|
||||||
|
|
||||||
if(edges.top > 1 && edges.top <= this.settings.active.arDetect.fallbackMode.noTriggerZonePx ){
|
if(edges.top > 1 && edges.top <= this.settings.active.arDetect.fallbackMode.noTriggerZonePx ){
|
||||||
this.logger.log('info', 'arDetect', `%c[ArDetect::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`)
|
this.logger.log('info', 'arDetect', `%c[ArDetect::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`)
|
||||||
@ -549,7 +549,7 @@ class ArDetector {
|
|||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
var startTime = performance.now();
|
let startTime = performance.now();
|
||||||
let sampleCols = this.sampleCols.slice(0);
|
let sampleCols = this.sampleCols.slice(0);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -724,7 +724,7 @@ class ArDetector {
|
|||||||
|
|
||||||
// blackSamples -> {res_top, res_bottom}
|
// blackSamples -> {res_top, res_bottom}
|
||||||
|
|
||||||
var edgePost = this.edgeDetector.findBars(imageData, sampleCols, EdgeDetectPrimaryDirection.VERTICAL, EdgeDetectQuality.IMPROVED, guardLineOut, bfanalysis);
|
let edgePost = this.edgeDetector.findBars(imageData, sampleCols, EdgeDetectPrimaryDirection.VERTICAL, EdgeDetectQuality.IMPROVED, guardLineOut, bfanalysis);
|
||||||
|
|
||||||
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost);
|
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost);
|
||||||
|
|
||||||
@ -737,7 +737,7 @@ class ArDetector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newAr = this.calculateArFromEdges(edgePost);
|
let newAr = this.calculateArFromEdges(edgePost);
|
||||||
|
|
||||||
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Triggering aspect ration change! new ar: ${newAr}`, "color: #aaf");
|
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Triggering aspect ration change! new ar: ${newAr}`, "color: #aaf");
|
||||||
|
|
||||||
@ -930,7 +930,7 @@ class ArDetector {
|
|||||||
|
|
||||||
// detect black level. if currentMax comes above blackbar + blackbar threshold, we know we aren't letterboxed
|
// detect black level. if currentMax comes above blackbar + blackbar threshold, we know we aren't letterboxed
|
||||||
|
|
||||||
for (var i = 0; i < sampleCols.length; ++i){
|
for (let i = 0; i < sampleCols.length; ++i){
|
||||||
colOffset_r = sampleCols[i] << 2;
|
colOffset_r = sampleCols[i] << 2;
|
||||||
colOffset_g = colOffset_r + 1;
|
colOffset_g = colOffset_r + 1;
|
||||||
colOffset_b = colOffset_r + 2;
|
colOffset_b = colOffset_r + 2;
|
||||||
@ -966,8 +966,8 @@ class ArDetector {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ard_console_stop = "background: #000; color: #f41";
|
let _ard_console_stop = "background: #000; color: #f41";
|
||||||
var _ard_console_start = "background: #000; color: #00c399";
|
let _ard_console_start = "background: #000; color: #00c399";
|
||||||
var _ard_console_change = "background: #000; color: #ff8";
|
let _ard_console_change = "background: #000; color: #ff8";
|
||||||
|
|
||||||
export default ArDetector;
|
export default ArDetector;
|
||||||
|
@ -48,8 +48,8 @@ class GuardLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setBlackbar(bbconf){
|
setBlackbar(bbconf){
|
||||||
var bbTop = bbconf.top - this.settings.active.arDetect.guardLine.edgeTolerancePx;
|
let bbTop = bbconf.top - this.settings.active.arDetect.guardLine.edgeTolerancePx;
|
||||||
var bbBottom = bbconf.bottom + this.settings.active.arDetect.guardLine.edgeTolerancePx;
|
let bbBottom = bbconf.bottom + this.settings.active.arDetect.guardLine.edgeTolerancePx;
|
||||||
|
|
||||||
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
|
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
|
||||||
// this removes any configs with invalid values or values that dont make sense
|
// this removes any configs with invalid values or values that dont make sense
|
||||||
@ -76,7 +76,7 @@ class GuardLine {
|
|||||||
|
|
||||||
// dejansko testiranje
|
// dejansko testiranje
|
||||||
// actual checks
|
// actual checks
|
||||||
var guardLineResult = this.guardLineCheck(image, fallbackMode);
|
let guardLineResult = this.guardLineCheck(image, fallbackMode);
|
||||||
|
|
||||||
// Zaznali smo kršitev črnega dela, zato nam ni treba preveriti, ali je slika
|
// Zaznali smo kršitev črnega dela, zato nam ni treba preveriti, ali je slika
|
||||||
// prisotna. Vemo namreč, da se je razmerje stranic zmanjšalo.
|
// prisotna. Vemo namreč, da se je razmerje stranic zmanjšalo.
|
||||||
@ -91,7 +91,7 @@ class GuardLine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageCheckResult = this.imageCheck(image, fallbackMode);
|
let imageCheckResult = this.imageCheck(image, fallbackMode);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
blackbarFail: false,
|
blackbarFail: false,
|
||||||
@ -115,27 +115,28 @@ class GuardLine {
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
var offset = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
let offset = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
||||||
|
|
||||||
var offenders = [];
|
let offenders = [];
|
||||||
var offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
|
let offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
|
||||||
|
|
||||||
// TODO: implement logo check.
|
// TODO: implement logo check.
|
||||||
|
|
||||||
// preglejmo obe vrstici
|
// preglejmo obe vrstici
|
||||||
// check both rows
|
// check both rows
|
||||||
|
let edge_lower, edge_upper;
|
||||||
|
|
||||||
if(! fallbackMode){
|
if(! fallbackMode){
|
||||||
var edge_upper = this.blackbar.top;
|
edge_upper = this.blackbar.top;
|
||||||
var edge_lower = this.blackbar.bottom;
|
edge_lower = this.blackbar.bottom;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
// fallback mode is a bit different
|
// fallback mode is a bit different
|
||||||
edge_upper = 0;
|
edge_upper = 0;
|
||||||
edge_lower = this.aard.canvas.height - 1;
|
edge_lower = this.aard.canvas.height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rowStart, rowEnd;
|
let rowStart, rowEnd;
|
||||||
|
|
||||||
// <<<=======| checking upper row |========>>>
|
// <<<=======| checking upper row |========>>>
|
||||||
|
|
||||||
@ -168,8 +169,8 @@ class GuardLine {
|
|||||||
return {success: true};
|
return {success: true};
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = new Array(offenders.length);
|
let ret = new Array(offenders.length);
|
||||||
for(var o in offenders){
|
for(let o in offenders){
|
||||||
ret[o] = offenders[o].x + (offenders[o].width * 0.25);
|
ret[o] = offenders[o].x + (offenders[o].width * 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ class GuardLine {
|
|||||||
if(!this.imageBar.top || !this.imageBar.bottom)
|
if(!this.imageBar.top || !this.imageBar.bottom)
|
||||||
return { success: false };
|
return { success: false };
|
||||||
|
|
||||||
var offset = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
let offset = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
||||||
|
|
||||||
// TODO: implement logo check.
|
// TODO: implement logo check.
|
||||||
|
|
||||||
@ -189,20 +190,20 @@ class GuardLine {
|
|||||||
// check both rows - by the rules and definitions, we shouldn't go out of bounds here. no need to check, then
|
// check both rows - by the rules and definitions, we shouldn't go out of bounds here. no need to check, then
|
||||||
|
|
||||||
// if(fallbackMode){
|
// if(fallbackMode){
|
||||||
// var edge_upper = this.settings.active.arDetect.fallbackMode.noTriggerZonePx;
|
// let edge_upper = this.settings.active.arDetect.fallbackMode.noTriggerZonePx;
|
||||||
// var edge_lower = this.conf.canvas.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1;
|
// let edge_lower = this.conf.canvas.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1;
|
||||||
// }
|
// }
|
||||||
// else{
|
// else{
|
||||||
var edge_upper = this.imageBar.top;
|
let edge_upper = this.imageBar.top;
|
||||||
var edge_lower = this.imageBar.bottom;
|
let edge_lower = this.imageBar.bottom;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// koliko pikslov rabimo zaznati, da je ta funkcija uspe. Tu dovoljujemo tudi, da so vsi piksli na enem
|
// koliko pikslov rabimo zaznati, da je ta funkcija uspe. Tu dovoljujemo tudi, da so vsi piksli na enem
|
||||||
// robu (eden izmed robov je lahko v celoti črn)
|
// robu (eden izmed robov je lahko v celoti črn)
|
||||||
// how many non-black pixels we need to consider this check a success. We only need to detect enough pixels
|
// how many non-black pixels we need to consider this check a success. We only need to detect enough pixels
|
||||||
// on one edge (one of the edges can be black as long as both aren't)
|
// on one edge (one of the edges can be black as long as both aren't)
|
||||||
var successThreshold = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.imageTestThreshold);
|
let successThreshold = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.imageTestThreshold);
|
||||||
var rowStart, rowEnd;
|
let rowStart, rowEnd;
|
||||||
|
|
||||||
|
|
||||||
// <<<=======| checking upper row |========>>>
|
// <<<=======| checking upper row |========>>>
|
||||||
@ -210,7 +211,7 @@ class GuardLine {
|
|||||||
rowStart = ((edge_upper * this.aard.canvas.width) << 2) + offset;
|
rowStart = ((edge_upper * this.aard.canvas.width) << 2) + offset;
|
||||||
rowEnd = rowStart + ( this.aard.canvas.width << 2 ) - (offset * 2);
|
rowEnd = rowStart + ( this.aard.canvas.width << 2 ) - (offset * 2);
|
||||||
|
|
||||||
var res = false;
|
let res = false;
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
||||||
// res = this._ti_debugCheckRow(image, rowStart, rowEnd, successThreshold);
|
// res = this._ti_debugCheckRow(image, rowStart, rowEnd, successThreshold);
|
||||||
@ -242,8 +243,8 @@ class GuardLine {
|
|||||||
|
|
||||||
|
|
||||||
_gl_rowCheck(image, rowStart, rowEnd, offenders, offenderCount){
|
_gl_rowCheck(image, rowStart, rowEnd, offenders, offenderCount){
|
||||||
var firstOffender = -1;
|
let firstOffender = -1;
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(let i = rowStart; i < rowEnd; i+=4){
|
||||||
|
|
||||||
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
||||||
// columns to sample
|
// columns to sample
|
||||||
@ -267,8 +268,8 @@ class GuardLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _gl_debugRowCheck(image, rowStart, rowEnd, offenders, offenderCount){
|
// _gl_debugRowCheck(image, rowStart, rowEnd, offenders, offenderCount){
|
||||||
// var firstOffender = -1;
|
// let firstOffender = -1;
|
||||||
// for(var i = rowStart; i < rowEnd; i+=4){
|
// for(let i = rowStart; i < rowEnd; i+=4){
|
||||||
|
|
||||||
// // we track sections that go over what's supposed to be a black line, so we can suggest more
|
// // we track sections that go over what's supposed to be a black line, so we can suggest more
|
||||||
// // columns to sample
|
// // columns to sample
|
||||||
@ -295,7 +296,7 @@ class GuardLine {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
_ti_checkRow(image, rowStart, rowEnd, successThreshold): boolean {
|
_ti_checkRow(image, rowStart, rowEnd, successThreshold): boolean {
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(let i = rowStart; i < rowEnd; i+=4){
|
||||||
if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
||||||
if(successThreshold --<= 0){
|
if(successThreshold --<= 0){
|
||||||
return true;
|
return true;
|
||||||
@ -307,7 +308,7 @@ class GuardLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _ti_debugCheckRow(image, rowStart, rowEnd, successThreshold) {
|
// _ti_debugCheckRow(image, rowStart, rowEnd, successThreshold) {
|
||||||
// for(var i = rowStart; i < rowEnd; i+=4){
|
// for(let i = rowStart; i < rowEnd; i+=4){
|
||||||
// if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
// if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
||||||
// this.aard.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
// this.aard.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
||||||
// if(successThreshold --<= 0){
|
// if(successThreshold --<= 0){
|
||||||
|
@ -128,10 +128,10 @@ class EdgeDetect{
|
|||||||
|
|
||||||
this.logger.log('info', 'arDetect', '[EdgeDetect::findCandidates] searching for candidates on ranges', upper_top, '<->', upper_bottom, ';', lower_top, '<->', lower_bottom);
|
this.logger.log('info', 'arDetect', '[EdgeDetect::findCandidates] searching for candidates on ranges', upper_top, '<->', upper_bottom, ';', lower_top, '<->', lower_bottom);
|
||||||
|
|
||||||
var upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
|
let upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
|
||||||
var upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
|
let upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
|
||||||
var lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
|
let lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
|
||||||
var lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
|
let lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
// if(Debug.debugCanvas.enabled){
|
// if(Debug.debugCanvas.enabled){
|
||||||
// this._columnTest_dbgc(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
// this._columnTest_dbgc(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
||||||
@ -236,20 +236,20 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
edgeDetect(image, samples){
|
edgeDetect(image, samples){
|
||||||
var edgeCandidatesTop = {count: 0};
|
let edgeCandidatesTop = {count: 0};
|
||||||
var edgeCandidatesBottom = {count: 0};
|
let edgeCandidatesBottom = {count: 0};
|
||||||
|
|
||||||
var detections;
|
let detections;
|
||||||
var canvasWidth = this.conf.canvas.width;
|
let canvasWidth = this.conf.canvas.width;
|
||||||
var canvasHeight = this.conf.canvas.height;
|
let canvasHeight = this.conf.canvas.height;
|
||||||
|
|
||||||
var sampleStart, sampleEnd, loopEnd;
|
let sampleStart, sampleEnd, loopEnd;
|
||||||
var sampleRow_black, sampleRow_color;
|
let sampleRow_black, sampleRow_color;
|
||||||
|
|
||||||
var blackEdgeViolation = false;
|
let blackEdgeViolation = false;
|
||||||
|
|
||||||
var topEdgeCount = 0;
|
let topEdgeCount = 0;
|
||||||
var bottomEdgeCount = 0;
|
let bottomEdgeCount = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const sample of samples.res_top){
|
for (const sample of samples.res_top){
|
||||||
@ -350,11 +350,11 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
edgePostprocess(edges){
|
edgePostprocess(edges){
|
||||||
var edgesTop = [];
|
let edgesTop = [];
|
||||||
var edgesBottom = [];
|
let edgesBottom = [];
|
||||||
var alignMargin = this.conf.canvas.height * this.settings.active.arDetect.allowedMisaligned;
|
let alignMargin = this.conf.canvas.height * this.settings.active.arDetect.allowedMisaligned;
|
||||||
|
|
||||||
var missingEdge = edges.edgeCandidatesTopCount == 0 || edges.edgeCandidatesBottomCount == 0;
|
let missingEdge = edges.edgeCandidatesTopCount == 0 || edges.edgeCandidatesBottomCount == 0;
|
||||||
|
|
||||||
// pretvorimo objekt v tabelo
|
// pretvorimo objekt v tabelo
|
||||||
// convert objects to array
|
// convert objects to array
|
||||||
@ -363,8 +363,8 @@ class EdgeDetect{
|
|||||||
delete(edges.edgeCandidatesBottom.count);
|
delete(edges.edgeCandidatesBottom.count);
|
||||||
|
|
||||||
if( edges.edgeCandidatesTopCount > 0){
|
if( edges.edgeCandidatesTopCount > 0){
|
||||||
for(var e in edges.edgeCandidatesTop){
|
for(let e in edges.edgeCandidatesTop){
|
||||||
var edge = edges.edgeCandidatesTop[e];
|
let edge = edges.edgeCandidatesTop[e];
|
||||||
edgesTop.push({
|
edgesTop.push({
|
||||||
distance: edge.offset,
|
distance: edge.offset,
|
||||||
absolute: edge.offset,
|
absolute: edge.offset,
|
||||||
@ -374,8 +374,8 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( edges.edgeCandidatesBottomCount > 0){
|
if( edges.edgeCandidatesBottomCount > 0){
|
||||||
for(var e in edges.edgeCandidatesBottom){
|
for(let e in edges.edgeCandidatesBottom){
|
||||||
var edge = edges.edgeCandidatesBottom[e];
|
let edge = edges.edgeCandidatesBottom[e];
|
||||||
edgesBottom.push({
|
edgesBottom.push({
|
||||||
distance: this.conf.canvas.height - edge.offset,
|
distance: this.conf.canvas.height - edge.offset,
|
||||||
absolute: edge.offset,
|
absolute: edge.offset,
|
||||||
@ -403,7 +403,7 @@ class EdgeDetect{
|
|||||||
if( edgesTop[0].distance >= edgesBottom[0].distance - alignMargin &&
|
if( edgesTop[0].distance >= edgesBottom[0].distance - alignMargin &&
|
||||||
edgesTop[0].distance <= edgesBottom[0].distance + alignMargin ){
|
edgesTop[0].distance <= edgesBottom[0].distance + alignMargin ){
|
||||||
|
|
||||||
var blackbarWidth = edgesTop[0].distance > edgesBottom[0].distance ?
|
let blackbarWidth = edgesTop[0].distance > edgesBottom[0].distance ?
|
||||||
edgesTop[0].distance : edgesBottom[0].distance;
|
edgesTop[0].distance : edgesBottom[0].distance;
|
||||||
|
|
||||||
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
||||||
@ -430,14 +430,14 @@ class EdgeDetect{
|
|||||||
// manj vzorcev kot navaden rob.
|
// manj vzorcev kot navaden rob.
|
||||||
|
|
||||||
if (edgesTop[0].length > 1){
|
if (edgesTop[0].length > 1){
|
||||||
var lowMargin = edgesBottom[0].distance - alignMargin;
|
let lowMargin = edgesBottom[0].distance - alignMargin;
|
||||||
var highMargin = edgesBottom[0].distance + alignMargin;
|
let highMargin = edgesBottom[0].distance + alignMargin;
|
||||||
|
|
||||||
for (var i = 1; i < edgesTop.length; i++){
|
for (let i = 1; i < edgesTop.length; i++){
|
||||||
if(edgesTop[i].distance >= lowMargin && edgesTop[i].distance <= highMargin){
|
if(edgesTop[i].distance >= lowMargin && edgesTop[i].distance <= highMargin){
|
||||||
// dobili smo dejanski rob. vrnimo ga
|
// dobili smo dejanski rob. vrnimo ga
|
||||||
// we found the actual edge. let's return that.
|
// we found the actual edge. let's return that.
|
||||||
var blackbarWidth = edgesTop[i].distance > edgesBottom[0].distance ?
|
let blackbarWidth = edgesTop[i].distance > edgesBottom[0].distance ?
|
||||||
edgesTop[i].distance : edgesBottom[0].distance;
|
edgesTop[i].distance : edgesBottom[0].distance;
|
||||||
|
|
||||||
if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
||||||
@ -461,14 +461,14 @@ class EdgeDetect{
|
|||||||
edgesBottom[0].count < this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoThreshold){
|
edgesBottom[0].count < this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoThreshold){
|
||||||
|
|
||||||
if(edgesBottom[0].length > 1){
|
if(edgesBottom[0].length > 1){
|
||||||
var lowMargin = edgesTop[0].distance - alignMargin;
|
let lowMargin = edgesTop[0].distance - alignMargin;
|
||||||
var highMargin = edgesTop[0].distance + alignMargin;
|
let highMargin = edgesTop[0].distance + alignMargin;
|
||||||
|
|
||||||
for(var i = 1; i < edgesBottom.length; i++){
|
for(let i = 1; i < edgesBottom.length; i++){
|
||||||
if (edgesBottom[i].distance >= lowMargin && edgesTop[i].distance <= highMargin) {
|
if (edgesBottom[i].distance >= lowMargin && edgesTop[i].distance <= highMargin) {
|
||||||
// dobili smo dejanski rob. vrnimo ga
|
// dobili smo dejanski rob. vrnimo ga
|
||||||
// we found the actual edge. let's return that.
|
// we found the actual edge. let's return that.
|
||||||
var blackbarWidth = edgesBottom[i].distance > edgesTop[0].distance ?
|
let blackbarWidth = edgesBottom[i].distance > edgesTop[0].distance ?
|
||||||
edgesBottom[i].distance : edgesTop[0].distance;
|
edgesBottom[i].distance : edgesTop[0].distance;
|
||||||
|
|
||||||
if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|
||||||
@ -497,7 +497,7 @@ class EdgeDetect{
|
|||||||
const edgeDetectionThreshold = this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold;
|
const edgeDetectionThreshold = this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold;
|
||||||
|
|
||||||
if (edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
|
if (edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
|
||||||
for(var edge of edgesBottom){
|
for(let edge of edgesBottom){
|
||||||
if(edge.count >= edgeDetectionThreshold)
|
if(edge.count >= edgeDetectionThreshold)
|
||||||
return {
|
return {
|
||||||
status: EdgeStatus.AR_KNOWN,
|
status: EdgeStatus.AR_KNOWN,
|
||||||
@ -511,7 +511,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (edges.edgeCandidatesTopCount != 0 && edges.edgeCandidatesBottomCount == 0){
|
if (edges.edgeCandidatesTopCount != 0 && edges.edgeCandidatesBottomCount == 0){
|
||||||
for(var edge of edgesTop){
|
for(let edge of edgesTop){
|
||||||
if(edge.count >= edgeDetectionThreshold)
|
if(edge.count >= edgeDetectionThreshold)
|
||||||
return {
|
return {
|
||||||
status: EdgeStatus.AR_KNOWN,
|
status: EdgeStatus.AR_KNOWN,
|
||||||
@ -538,22 +538,22 @@ class EdgeDetect{
|
|||||||
// roughly centered, we return true. Otherwise we return false.
|
// roughly centered, we return true. Otherwise we return false.
|
||||||
// we also return true if we detect too much black
|
// we also return true if we detect too much black
|
||||||
|
|
||||||
var blackbarThreshold, upper, lower;
|
let blackbarThreshold, upper, lower;
|
||||||
blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
||||||
|
|
||||||
|
|
||||||
var middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
|
let middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
|
||||||
var middleRowEnd = middleRowStart + this.conf.canvas.width - 1;
|
let middleRowEnd = middleRowStart + this.conf.canvas.width - 1;
|
||||||
|
|
||||||
var rowStart = middleRowStart << 2;
|
let rowStart = middleRowStart << 2;
|
||||||
var midpoint = (middleRowStart + (this.conf.canvas.width >> 1)) << 2
|
let midpoint = (middleRowStart + (this.conf.canvas.width >> 1)) << 2
|
||||||
var rowEnd = middleRowEnd << 2;
|
let rowEnd = middleRowEnd << 2;
|
||||||
|
|
||||||
var edge_left = -1, edge_right = -1;
|
let edge_left = -1, edge_right = -1;
|
||||||
|
|
||||||
// preverimo na levi strani
|
// preverimo na levi strani
|
||||||
// let's check for edge on the left side
|
// let's check for edge on the left side
|
||||||
for(var i = rowStart; i < midpoint; i+=4){
|
for(let i = rowStart; i < midpoint; i+=4){
|
||||||
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
||||||
edge_left = (i - rowStart) >> 2;
|
edge_left = (i - rowStart) >> 2;
|
||||||
break;
|
break;
|
||||||
@ -562,7 +562,7 @@ class EdgeDetect{
|
|||||||
|
|
||||||
// preverimo na desni strani
|
// preverimo na desni strani
|
||||||
// check on the right
|
// check on the right
|
||||||
for(var i = rowEnd; i > midpoint; i-= 4){
|
for(let i = rowEnd; i > midpoint; i-= 4){
|
||||||
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
||||||
edge_right = this.conf.canvas.width - ((i - rowStart) >> 2);
|
edge_right = this.conf.canvas.width - ((i - rowStart) >> 2);
|
||||||
break;
|
break;
|
||||||
@ -581,9 +581,9 @@ class EdgeDetect{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var edgeError = this.settings.active.arDetect.pillarTest.allowMisaligned;
|
let edgeError = this.settings.active.arDetect.pillarTest.allowMisaligned;
|
||||||
var error_low = 1 - edgeError;
|
let error_low = 1 - edgeError;
|
||||||
var error_hi = 1 + edgeError;
|
let error_hi = 1 + edgeError;
|
||||||
|
|
||||||
// če sta 'edge_left' in 'edge_right' podobna/v mejah merske napake, potem vrnemo true — lahko da smo našli logo na sredini zaslona
|
// če sta 'edge_left' in 'edge_right' podobna/v mejah merske napake, potem vrnemo true — lahko da smo našli logo na sredini zaslona
|
||||||
// if 'edge_left' and 'edge_right' are similar enough to each other, we return true. If we found a logo in a black frame, we could
|
// if 'edge_left' and 'edge_right' are similar enough to each other, we return true. If we found a logo in a black frame, we could
|
||||||
@ -869,7 +869,7 @@ class EdgeDetect{
|
|||||||
if (reverseSearchDirection) {
|
if (reverseSearchDirection) {
|
||||||
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
||||||
// todo: remove gradient detection code from this branch
|
// todo: remove gradient detection code from this branch
|
||||||
for(var i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
for(let i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
||||||
for(let c = 0; c < colsIn.length; c++){
|
for(let c = 0; c < colsIn.length; c++){
|
||||||
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
||||||
// če smo našli obe točki, potem ne pregledujemo več.
|
// če smo našli obe točki, potem ne pregledujemo več.
|
||||||
@ -923,7 +923,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// anti-gradient detection
|
// anti-gradient detection
|
||||||
for(var i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
for(let i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
||||||
for(let c = 0; c < colsIn.length; c++){
|
for(let c = 0; c < colsIn.length; c++){
|
||||||
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
||||||
// če smo našli obe točki, potem ne pregledujemo več.
|
// če smo našli obe točki, potem ne pregledujemo več.
|
||||||
@ -1111,17 +1111,17 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _columnTest_dbgc(image, top, bottom, colsIn, colsOut, reverseSearchDirection){
|
// _columnTest_dbgc(image, top, bottom, colsIn, colsOut, reverseSearchDirection){
|
||||||
// var tmpI;
|
// let tmpI;
|
||||||
// if(reverseSearchDirection){
|
// if(reverseSearchDirection){
|
||||||
// for(var i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
// for(let i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
||||||
// for(var col of colsIn){
|
// for(let col of colsIn){
|
||||||
// tmpI = i + (col << 2);
|
// tmpI = i + (col << 2);
|
||||||
|
|
||||||
// if( image[tmpI] > this.blackbarThreshold ||
|
// if( image[tmpI] > this.blackbarThreshold ||
|
||||||
// image[tmpI + 1] > this.blackbarThreshold ||
|
// image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
// image[tmpI + 2] > this.blackbarThreshold ){
|
// image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
// var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
// let bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
||||||
// colsOut.push({
|
// colsOut.push({
|
||||||
// col: col,
|
// col: col,
|
||||||
// bottom: bottom
|
// bottom: bottom
|
||||||
@ -1137,8 +1137,8 @@ class EdgeDetect{
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// for(var i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
// for(let i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
||||||
// for(var col of colsIn){
|
// for(let col of colsIn){
|
||||||
// tmpI = i + (col << 2);
|
// tmpI = i + (col << 2);
|
||||||
|
|
||||||
// if( image[tmpI] > this.blackbarThreshold ||
|
// if( image[tmpI] > this.blackbarThreshold ||
|
||||||
@ -1168,7 +1168,7 @@ class EdgeDetect{
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
_blackbarTest(image, start, end){
|
_blackbarTest(image, start, end){
|
||||||
for(var i = start; i < end; i += 4){
|
for(let i = start; i < end; i += 4){
|
||||||
if( image[i ] > this.blackbarThreshold ||
|
if( image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarThreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarThreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
@ -1179,7 +1179,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _blackbarTest_dbg(image, start, end){
|
// _blackbarTest_dbg(image, start, end){
|
||||||
// for(var i = start; i < end; i += 4){
|
// for(let i = start; i < end; i += 4){
|
||||||
// if( image[i ] > this.blackbarThreshold ||
|
// if( image[i ] > this.blackbarThreshold ||
|
||||||
// image[i+1] > this.blackbarThreshold ||
|
// image[i+1] > this.blackbarThreshold ||
|
||||||
// image[i+2] > this.blackbarThreshold ){
|
// image[i+2] > this.blackbarThreshold ){
|
||||||
@ -1214,9 +1214,9 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _imageTest_dbg(image, start, end, sampleOffset, edgeCandidates){
|
// _imageTest_dbg(image, start, end, sampleOffset, edgeCandidates){
|
||||||
// var detections = 0;
|
// let detections = 0;
|
||||||
|
|
||||||
// for(var i = start; i < end; i += 4){
|
// for(let i = start; i < end; i += 4){
|
||||||
// if( image[i ] > this.blackbarThreshold ||
|
// if( image[i ] > this.blackbarThreshold ||
|
||||||
// image[i+1] > this.blackbarThreshold ||
|
// image[i+1] > this.blackbarThreshold ||
|
||||||
// image[i+2] > this.blackbarThreshold ){
|
// image[i+2] > this.blackbarThreshold ){
|
||||||
|
@ -111,7 +111,7 @@ class PageInfo {
|
|||||||
if(this.rescanTimer){
|
if(this.rescanTimer){
|
||||||
clearTimeout(this.rescanTimer);
|
clearTimeout(this.rescanTimer);
|
||||||
}
|
}
|
||||||
for (var video of this.videos) {
|
for (let video of this.videos) {
|
||||||
try {
|
try {
|
||||||
(this.comms.unregisterVideo as any)(video.vdid)
|
(this.comms.unregisterVideo as any)(video.vdid)
|
||||||
video.destroy();
|
video.destroy();
|
||||||
@ -134,7 +134,7 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
for(var video of this.videos) {
|
for(let video of this.videos) {
|
||||||
video.destroy();
|
video.destroy();
|
||||||
}
|
}
|
||||||
this.rescan(RescanReason.MANUAL);
|
this.rescan(RescanReason.MANUAL);
|
||||||
@ -150,7 +150,7 @@ class PageInfo {
|
|||||||
|
|
||||||
setActionHandler(actionHandler) {
|
setActionHandler(actionHandler) {
|
||||||
this.actionHandler = actionHandler;
|
this.actionHandler = actionHandler;
|
||||||
for (var item of this.actionHandlerInitQueue) {
|
for (let item of this.actionHandlerInitQueue) {
|
||||||
this.actionHandler.registerHandleMouse(item);
|
this.actionHandler.registerHandleMouse(item);
|
||||||
}
|
}
|
||||||
this.actionHandlerInitQueue = [];
|
this.actionHandlerInitQueue = [];
|
||||||
@ -176,7 +176,7 @@ class PageInfo {
|
|||||||
const oldVideoCount = this.videos.length;
|
const oldVideoCount = this.videos.length;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
var vids = this.getVideos(window.location.hostname);
|
let vids = this.getVideos(window.location.hostname);
|
||||||
|
|
||||||
if(!vids || vids.length == 0){
|
if(!vids || vids.length == 0){
|
||||||
this.hasVideos = false;
|
this.hasVideos = false;
|
||||||
@ -190,8 +190,8 @@ class PageInfo {
|
|||||||
|
|
||||||
// add new videos
|
// add new videos
|
||||||
this.hasVideos = false;
|
this.hasVideos = false;
|
||||||
var videoExists = false;
|
let videoExists = false;
|
||||||
var video, v;
|
let video, v;
|
||||||
|
|
||||||
for (video of vids) {
|
for (video of vids) {
|
||||||
// če najdemo samo en video z višino in širino, to pomeni, da imamo na strani veljavne videe
|
// če najdemo samo en video z višino in širino, to pomeni, da imamo na strani veljavne videe
|
||||||
@ -314,7 +314,7 @@ class PageInfo {
|
|||||||
clearTimeout(this.rescanTimer);
|
clearTimeout(this.rescanTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ths = this;
|
let ths = this;
|
||||||
|
|
||||||
this.rescanTimer = setTimeout(function(rescanReason){
|
this.rescanTimer = setTimeout(function(rescanReason){
|
||||||
ths.rescanTimer = null;
|
ths.rescanTimer = null;
|
||||||
@ -332,7 +332,7 @@ class PageInfo {
|
|||||||
clearTimeout(this.urlCheckTimer);
|
clearTimeout(this.urlCheckTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ths = this;
|
let ths = this;
|
||||||
|
|
||||||
this.urlCheckTimer = setTimeout(function(){
|
this.urlCheckTimer = setTimeout(function(){
|
||||||
ths.urlCheckTimer = null;
|
ths.urlCheckTimer = null;
|
||||||
@ -357,14 +357,14 @@ class PageInfo {
|
|||||||
|
|
||||||
initArDetection(playingOnly){
|
initArDetection(playingOnly){
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if(vd.isPlaying()) {
|
if(vd.isPlaying()) {
|
||||||
vd.initArDetection();
|
vd.initArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.initArDetection();
|
vd.initArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,13 +375,13 @@ class PageInfo {
|
|||||||
// these need to be called on tab switch
|
// these need to be called on tab switch
|
||||||
pauseProcessing(playingOnly){
|
pauseProcessing(playingOnly){
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.pause();
|
vd.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.pause();
|
vd.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ class PageInfo {
|
|||||||
|
|
||||||
resumeProcessing(resumeAutoar = false, playingOnly = false){
|
resumeProcessing(resumeAutoar = false, playingOnly = false){
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.resume();
|
vd.resume();
|
||||||
if(resumeAutoar){
|
if(resumeAutoar){
|
||||||
@ -398,7 +398,7 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.resume();
|
vd.resume();
|
||||||
if(resumeAutoar){
|
if(resumeAutoar){
|
||||||
vd.resumeAutoAr();
|
vd.resumeAutoAr();
|
||||||
@ -413,13 +413,13 @@ class PageInfo {
|
|||||||
this.logger.log('info', 'debug', '[PageInfo::startArDetection()] starting automatic ar detection!')
|
this.logger.log('info', 'debug', '[PageInfo::startArDetection()] starting automatic ar detection!')
|
||||||
}
|
}
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.startArDetection();
|
vd.startArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.startArDetection();
|
vd.startArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,13 +427,13 @@ class PageInfo {
|
|||||||
|
|
||||||
stopArDetection(playingOnly){
|
stopArDetection(playingOnly){
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.stopArDetection();
|
vd.stopArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.stopArDetection();
|
vd.stopArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ class PageInfo {
|
|||||||
this.logger.log('info', 'debug', '[PageInfo::setAr] aspect ratio is auto');
|
this.logger.log('info', 'debug', '[PageInfo::setAr] aspect ratio is auto');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var vd of this.videos) {
|
for (let vd of this.videos) {
|
||||||
if (!playingOnly || vd.isPlaying()) {
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.resetLastAr();
|
vd.resetLastAr();
|
||||||
}
|
}
|
||||||
@ -463,13 +463,13 @@ class PageInfo {
|
|||||||
|
|
||||||
// TODO: find a way to only change aspect ratio for one video
|
// TODO: find a way to only change aspect ratio for one video
|
||||||
if (ar === AspectRatioType.Reset) {
|
if (ar === AspectRatioType.Reset) {
|
||||||
for (var vd of this.videos) {
|
for (let vd of this.videos) {
|
||||||
if (!playingOnly || vd.isPlaying()) {
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.resetAr();
|
vd.resetAr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var vd of this.videos) {
|
for (let vd of this.videos) {
|
||||||
if (!playingOnly || vd.isPlaying()) {
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.setAr(ar)
|
vd.setAr(ar)
|
||||||
}
|
}
|
||||||
@ -479,13 +479,13 @@ class PageInfo {
|
|||||||
|
|
||||||
setVideoAlignment(videoAlignment, playingOnly) {
|
setVideoAlignment(videoAlignment, playingOnly) {
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.setVideoAlignment(videoAlignment)
|
vd.setVideoAlignment(videoAlignment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
vd.setVideoAlignment(videoAlignment)
|
vd.setVideoAlignment(videoAlignment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,13 +493,13 @@ class PageInfo {
|
|||||||
|
|
||||||
setPanMode(mode, playingOnly) {
|
setPanMode(mode, playingOnly) {
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.setPanMode(mode);
|
vd.setPanMode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
vd.setPanMode(mode);
|
vd.setPanMode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -507,13 +507,13 @@ class PageInfo {
|
|||||||
|
|
||||||
restoreAr(playingOnly) {
|
restoreAr(playingOnly) {
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.restoreAr();
|
vd.restoreAr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.restoreAr();
|
vd.restoreAr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,13 +523,13 @@ class PageInfo {
|
|||||||
// TODO: find a way to only change aspect ratio for one video
|
// TODO: find a way to only change aspect ratio for one video
|
||||||
|
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.setStretchMode(stretchMode, fixedStretchRatio)
|
vd.setStretchMode(stretchMode, fixedStretchRatio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
vd.setStretchMode(stretchMode, fixedStretchRatio)
|
vd.setStretchMode(stretchMode, fixedStretchRatio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,20 +537,20 @@ class PageInfo {
|
|||||||
|
|
||||||
setZoom(zoomLevel, no_announce, playingOnly) {
|
setZoom(zoomLevel, no_announce, playingOnly) {
|
||||||
if (playingOnly) {
|
if (playingOnly) {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
if (vd.isPlaying()) {
|
if (vd.isPlaying()) {
|
||||||
vd.setZoom(zoomLevel, no_announce);
|
vd.setZoom(zoomLevel, no_announce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
vd.setZoom(zoomLevel, no_announce);
|
vd.setZoom(zoomLevel, no_announce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomStep(step, playingOnly) {
|
zoomStep(step, playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(let vd of this.videos){
|
||||||
if (!playingOnly || vd.isPlaying()) {
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.zoomStep(step);
|
vd.zoomStep(step);
|
||||||
}
|
}
|
||||||
@ -558,12 +558,12 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
markPlayer(name, color) {
|
markPlayer(name, color) {
|
||||||
for (var vd of this.videos) {
|
for (let vd of this.videos) {
|
||||||
vd.markPlayer(name,color);
|
vd.markPlayer(name,color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unmarkPlayer() {
|
unmarkPlayer() {
|
||||||
for (var vd of this.videos) {
|
for (let vd of this.videos) {
|
||||||
vd.unmarkPlayer();
|
vd.unmarkPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,13 +578,13 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setManualTick(manualTick) {
|
setManualTick(manualTick) {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
vd.setManualTick(manualTick);
|
vd.setManualTick(manualTick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
for(var vd of this.videos) {
|
for(let vd of this.videos) {
|
||||||
vd.tick();
|
vd.tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ class PlayerData {
|
|||||||
this.destroyOverlay();
|
this.destroyOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
var overlay = document.createElement('div');
|
let overlay = document.createElement('div');
|
||||||
overlay.style.width = '100%';
|
overlay.style.width = '100%';
|
||||||
overlay.style.height = '100%';
|
overlay.style.height = '100%';
|
||||||
overlay.style.position = 'absolute';
|
overlay.style.position = 'absolute';
|
||||||
|
@ -24,7 +24,7 @@ class CssHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i in styleArray) {
|
for (let i in styleArray) {
|
||||||
styleArray[i] = styleArray[i].trim();
|
styleArray[i] = styleArray[i].trim();
|
||||||
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
|
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
|
||||||
// we dont wanna, because we already center videos on our own
|
// we dont wanna, because we already center videos on our own
|
||||||
@ -45,7 +45,7 @@ class CssHandler {
|
|||||||
static buildStyleString(styleArray) {
|
static buildStyleString(styleArray) {
|
||||||
let styleString = '';
|
let styleString = '';
|
||||||
|
|
||||||
for(var i in styleArray) {
|
for(let i in styleArray) {
|
||||||
if(styleArray[i]) {
|
if(styleArray[i]) {
|
||||||
styleString += styleArray[i] + "; ";
|
styleString += styleArray[i] + "; ";
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class Resizer {
|
|||||||
// Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi".
|
// Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi".
|
||||||
// Približevanje opuščeno.
|
// Približevanje opuščeno.
|
||||||
// handles "legacy" options, such as 'fit to widht', 'fit to height' and AspectRatioType.Reset. No zoom tho
|
// handles "legacy" options, such as 'fit to widht', 'fit to height' and AspectRatioType.Reset. No zoom tho
|
||||||
var ratioOut;
|
let ratioOut;
|
||||||
|
|
||||||
if (!this.conf.video) {
|
if (!this.conf.video) {
|
||||||
this.logger.log('info', 'debug', "[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData");
|
this.logger.log('info', 'debug', "[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData");
|
||||||
@ -126,7 +126,7 @@ class Resizer {
|
|||||||
// IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're
|
// IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're
|
||||||
// setting a static aspect ratio (even if the function is called from here or ArDetect).
|
// setting a static aspect ratio (even if the function is called from here or ArDetect).
|
||||||
|
|
||||||
var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
let fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
||||||
|
|
||||||
if (ar.type === AspectRatioType.FitWidth){
|
if (ar.type === AspectRatioType.FitWidth){
|
||||||
ar.ratio = ratioOut > fileAr ? ratioOut : fileAr;
|
ar.ratio = ratioOut > fileAr ? ratioOut : fileAr;
|
||||||
@ -296,7 +296,7 @@ class Resizer {
|
|||||||
|
|
||||||
this.stretcher.chromeBugMitigation(stretchFactors);
|
this.stretcher.chromeBugMitigation(stretchFactors);
|
||||||
|
|
||||||
var translate = this.computeOffsets(stretchFactors);
|
let translate = this.computeOffsets(stretchFactors);
|
||||||
|
|
||||||
|
|
||||||
console.log("aspect ratio will be set. stretch factors:", stretchFactors, "translate:", translate);
|
console.log("aspect ratio will be set. stretch factors:", stretchFactors, "translate:", translate);
|
||||||
@ -603,7 +603,7 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i in styleArray) {
|
for (let i in styleArray) {
|
||||||
styleArray[i] = styleArray[i].trim();
|
styleArray[i] = styleArray[i].trim();
|
||||||
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
|
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
|
||||||
// we dont wanna, because we already center videos on our own
|
// we dont wanna, because we already center videos on our own
|
||||||
@ -626,7 +626,7 @@ class Resizer {
|
|||||||
buildStyleString(styleArray) {
|
buildStyleString(styleArray) {
|
||||||
let styleString = '';
|
let styleString = '';
|
||||||
|
|
||||||
for(var i in styleArray) {
|
for(let i in styleArray) {
|
||||||
if(styleArray[i]) {
|
if(styleArray[i]) {
|
||||||
styleString += styleArray[i] + " !important; ";
|
styleString += styleArray[i] + " !important; ";
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class Scaler {
|
|||||||
return ar.ratio;
|
return ar.ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ratioOut;
|
let ratioOut;
|
||||||
|
|
||||||
if (!this.conf.video) {
|
if (!this.conf.video) {
|
||||||
this.logger.log('error', 'debug', "[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData");
|
this.logger.log('error', 'debug', "[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData");
|
||||||
@ -51,7 +51,7 @@ class Scaler {
|
|||||||
// IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're
|
// IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're
|
||||||
// setting a static aspect ratio (even if the function is called from here or ArDetect).
|
// setting a static aspect ratio (even if the function is called from here or ArDetect).
|
||||||
|
|
||||||
var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
let fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
||||||
|
|
||||||
if (ar.type === AspectRatioType.FitWidth) {
|
if (ar.type === AspectRatioType.FitWidth) {
|
||||||
ratioOut > fileAr ? ratioOut : fileAr
|
ratioOut > fileAr ? ratioOut : fileAr
|
||||||
|
@ -47,17 +47,17 @@ class Stretcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyConditionalStretch(stretchFactors, actualAr){
|
applyConditionalStretch(stretchFactors, actualAr){
|
||||||
var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
|
let playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
|
||||||
var videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
let videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
|
||||||
|
|
||||||
if (! actualAr){
|
if (! actualAr){
|
||||||
actualAr = playerAr;
|
actualAr = playerAr;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newWidth = this.conf.video.offsetWidth * stretchFactors.xFactor;
|
let newWidth = this.conf.video.offsetWidth * stretchFactors.xFactor;
|
||||||
var newHeight = this.conf.video.offsetHeight * stretchFactors.yFactor;
|
let newHeight = this.conf.video.offsetHeight * stretchFactors.yFactor;
|
||||||
|
|
||||||
var actualWidth, actualHeight;
|
let actualWidth, actualHeight;
|
||||||
|
|
||||||
// determine the dimensions of the video (sans black bars) after scaling
|
// determine the dimensions of the video (sans black bars) after scaling
|
||||||
if(actualAr < videoAr){
|
if(actualAr < videoAr){
|
||||||
@ -68,11 +68,11 @@ class Stretcher {
|
|||||||
actualWidth = newWidth;
|
actualWidth = newWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
var minW = this.conf.player.dimensions.width * (1 - this.settings.active.stretch.conditionalDifferencePercent);
|
let minW = this.conf.player.dimensions.width * (1 - this.settings.active.stretch.conditionalDifferencePercent);
|
||||||
var maxW = this.conf.player.dimensions.width * (1 + this.settings.active.stretch.conditionalDifferencePercent);
|
let maxW = this.conf.player.dimensions.width * (1 + this.settings.active.stretch.conditionalDifferencePercent);
|
||||||
|
|
||||||
var minH = this.conf.player.dimensions.height * (1 - this.settings.active.stretch.conditionalDifferencePercent);
|
let minH = this.conf.player.dimensions.height * (1 - this.settings.active.stretch.conditionalDifferencePercent);
|
||||||
var maxH = this.conf.player.dimensions.height * (1 + this.settings.active.stretch.conditionalDifferencePercent);
|
let maxH = this.conf.player.dimensions.height * (1 + this.settings.active.stretch.conditionalDifferencePercent);
|
||||||
|
|
||||||
if (actualWidth >= minW && actualWidth <= maxW) {
|
if (actualWidth >= minW && actualWidth <= maxW) {
|
||||||
stretchFactors.xFactor *= this.conf.player.dimensions.width / actualWidth;
|
stretchFactors.xFactor *= this.conf.player.dimensions.width / actualWidth;
|
||||||
@ -168,7 +168,7 @@ squeezeFactor: ${squeezeFactor}`, '\nvideo', this.conf.video);
|
|||||||
actualAr = playerAr;
|
actualAr = playerAr;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stretchFactors: any = {
|
let stretchFactors: any = {
|
||||||
xFactor: 1,
|
xFactor: 1,
|
||||||
yFactor: 1
|
yFactor: 1
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user