Convert all remaining vars to lets

This commit is contained in:
Tamius Han 2021-02-18 22:38:32 +01:00
parent 8475340999
commit 075168ed85
10 changed files with 163 additions and 162 deletions

View File

@ -4,7 +4,7 @@ class ObjectCopy {
static addNew(current, newValues){
// clone target
var out = JSON.parse(JSON.stringify(newValues));
let out = JSON.parse(JSON.stringify(newValues));
if(! current) {
if(Debug.debug) {
@ -14,7 +14,7 @@ class ObjectCopy {
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[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
// sites don't get forgotten)
for(var k in current) {
for(let k in current) {
if (! out[k]) {
out[k] = current[k];
}
@ -47,7 +47,7 @@ class ObjectCopy {
}
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[k] !== undefined) {
// Types and constructors of objects must match. If they don't, we always use the new value.

View File

@ -161,16 +161,16 @@ class ArDetector {
// [2] determine places we'll use to sample our main frame
//
var ncol = this.settings.active.arDetect.sampling.staticCols;
var nrow = this.settings.active.arDetect.sampling.staticRows;
let ncol = this.settings.active.arDetect.sampling.staticCols;
let nrow = this.settings.active.arDetect.sampling.staticRows;
var colSpacing = this.canvas.width / ncol;
var rowSpacing = (this.canvas.height << 2) / nrow;
let colSpacing = this.canvas.width / ncol;
let rowSpacing = (this.canvas.height << 2) / nrow;
this.sampleLines = [];
this.sampleCols = [];
for(var i = 0; i < ncol; i++){
for(let i = 0; i < ncol; i++){
if(i < ncol - 1)
this.sampleCols.push(Math.round(colSpacing * i));
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)
this.sampleLines.push(Math.round(rowSpacing * i));
else{
@ -381,7 +381,7 @@ class ArDetector {
clearTimeout(this.setupTimer);
}
var ths = this;
let ths = this;
this.setupTimer = setTimeout(function(){
ths.setupTimer = null;
try{
@ -419,7 +419,7 @@ class ArDetector {
}
getTimeout(baseTimeout, startTime){
var execTime = (performance.now() - startTime);
let execTime = (performance.now() - startTime);
return baseTimeout;
}
@ -475,12 +475,12 @@ class ArDetector {
// letterbox also needs to be corrected:
// letterbox += [video.zoomedHeight] - [video.unzoomedHeight]
var vbr = this.video.getBoundingClientRect();
let vbr = this.video.getBoundingClientRect();
zoomFactor = 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 ){
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();
}
var startTime = performance.now();
let startTime = performance.now();
let sampleCols = this.sampleCols.slice(0);
//
@ -724,7 +724,7 @@ class ArDetector {
// 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);
@ -737,7 +737,7 @@ class ArDetector {
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");
@ -930,7 +930,7 @@ class ArDetector {
// 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_g = colOffset_r + 1;
colOffset_b = colOffset_r + 2;
@ -966,8 +966,8 @@ class ArDetector {
}
var _ard_console_stop = "background: #000; color: #f41";
var _ard_console_start = "background: #000; color: #00c399";
var _ard_console_change = "background: #000; color: #ff8";
let _ard_console_stop = "background: #000; color: #f41";
let _ard_console_start = "background: #000; color: #00c399";
let _ard_console_change = "background: #000; color: #ff8";
export default ArDetector;

View File

@ -48,8 +48,8 @@ class GuardLine {
}
setBlackbar(bbconf){
var bbTop = bbconf.top - this.settings.active.arDetect.guardLine.edgeTolerancePx;
var bbBottom = bbconf.bottom + this.settings.active.arDetect.guardLine.edgeTolerancePx;
let bbTop = bbconf.top - 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
// this removes any configs with invalid values or values that dont make sense
@ -76,7 +76,7 @@ class GuardLine {
// dejansko testiranje
// 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
// 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 {
blackbarFail: false,
@ -115,27 +115,28 @@ class GuardLine {
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 = [];
var offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
let offenders = [];
let offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
// TODO: implement logo check.
// preglejmo obe vrstici
// check both rows
let edge_lower, edge_upper;
if(! fallbackMode){
var edge_upper = this.blackbar.top;
var edge_lower = this.blackbar.bottom;
edge_upper = this.blackbar.top;
edge_lower = this.blackbar.bottom;
}
else{
else {
// fallback mode is a bit different
edge_upper = 0;
edge_lower = this.aard.canvas.height - 1;
}
var rowStart, rowEnd;
let rowStart, rowEnd;
// <<<=======| checking upper row |========>>>
@ -168,8 +169,8 @@ class GuardLine {
return {success: true};
}
var ret = new Array(offenders.length);
for(var o in offenders){
let ret = new Array(offenders.length);
for(let o in offenders){
ret[o] = offenders[o].x + (offenders[o].width * 0.25);
}
@ -180,7 +181,7 @@ class GuardLine {
if(!this.imageBar.top || !this.imageBar.bottom)
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.
@ -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
// if(fallbackMode){
// var edge_upper = this.settings.active.arDetect.fallbackMode.noTriggerZonePx;
// var edge_lower = this.conf.canvas.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1;
// let edge_upper = this.settings.active.arDetect.fallbackMode.noTriggerZonePx;
// let edge_lower = this.conf.canvas.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1;
// }
// else{
var edge_upper = this.imageBar.top;
var edge_lower = this.imageBar.bottom;
let edge_upper = this.imageBar.top;
let edge_lower = this.imageBar.bottom;
// }
// 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)
// 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)
var successThreshold = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.imageTestThreshold);
var rowStart, rowEnd;
let successThreshold = (this.aard.canvas.width * this.settings.active.arDetect.guardLine.imageTestThreshold);
let rowStart, rowEnd;
// <<<=======| checking upper row |========>>>
@ -210,7 +211,7 @@ class GuardLine {
rowStart = ((edge_upper * this.aard.canvas.width) << 2) + offset;
rowEnd = rowStart + ( this.aard.canvas.width << 2 ) - (offset * 2);
var res = false;
let res = false;
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
// res = this._ti_debugCheckRow(image, rowStart, rowEnd, successThreshold);
@ -242,8 +243,8 @@ class GuardLine {
_gl_rowCheck(image, rowStart, rowEnd, offenders, offenderCount){
var firstOffender = -1;
for(var i = rowStart; i < rowEnd; i+=4){
let firstOffender = -1;
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
// columns to sample
@ -267,8 +268,8 @@ class GuardLine {
}
// _gl_debugRowCheck(image, rowStart, rowEnd, offenders, offenderCount){
// var firstOffender = -1;
// for(var i = rowStart; i < rowEnd; i+=4){
// let firstOffender = -1;
// 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
// // columns to sample
@ -295,7 +296,7 @@ class GuardLine {
// }
_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(successThreshold --<= 0){
return true;
@ -307,7 +308,7 @@ class GuardLine {
}
// _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){
// this.aard.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
// if(successThreshold --<= 0){

View File

@ -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);
var upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
var upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
var lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
var lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
let upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
let upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
let lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
let lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
// if(Debug.debugCanvas.enabled){
// this._columnTest_dbgc(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
@ -236,20 +236,20 @@ class EdgeDetect{
}
edgeDetect(image, samples){
var edgeCandidatesTop = {count: 0};
var edgeCandidatesBottom = {count: 0};
let edgeCandidatesTop = {count: 0};
let edgeCandidatesBottom = {count: 0};
var detections;
var canvasWidth = this.conf.canvas.width;
var canvasHeight = this.conf.canvas.height;
let detections;
let canvasWidth = this.conf.canvas.width;
let canvasHeight = this.conf.canvas.height;
var sampleStart, sampleEnd, loopEnd;
var sampleRow_black, sampleRow_color;
let sampleStart, sampleEnd, loopEnd;
let sampleRow_black, sampleRow_color;
var blackEdgeViolation = false;
let blackEdgeViolation = false;
var topEdgeCount = 0;
var bottomEdgeCount = 0;
let topEdgeCount = 0;
let bottomEdgeCount = 0;
try {
for (const sample of samples.res_top){
@ -350,11 +350,11 @@ class EdgeDetect{
}
edgePostprocess(edges){
var edgesTop = [];
var edgesBottom = [];
var alignMargin = this.conf.canvas.height * this.settings.active.arDetect.allowedMisaligned;
let edgesTop = [];
let edgesBottom = [];
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
// convert objects to array
@ -363,8 +363,8 @@ class EdgeDetect{
delete(edges.edgeCandidatesBottom.count);
if( edges.edgeCandidatesTopCount > 0){
for(var e in edges.edgeCandidatesTop){
var edge = edges.edgeCandidatesTop[e];
for(let e in edges.edgeCandidatesTop){
let edge = edges.edgeCandidatesTop[e];
edgesTop.push({
distance: edge.offset,
absolute: edge.offset,
@ -374,8 +374,8 @@ class EdgeDetect{
}
if( edges.edgeCandidatesBottomCount > 0){
for(var e in edges.edgeCandidatesBottom){
var edge = edges.edgeCandidatesBottom[e];
for(let e in edges.edgeCandidatesBottom){
let edge = edges.edgeCandidatesBottom[e];
edgesBottom.push({
distance: this.conf.canvas.height - edge.offset,
absolute: edge.offset,
@ -403,7 +403,7 @@ class EdgeDetect{
if( 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;
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
@ -430,14 +430,14 @@ class EdgeDetect{
// manj vzorcev kot navaden rob.
if (edgesTop[0].length > 1){
var lowMargin = edgesBottom[0].distance - alignMargin;
var highMargin = edgesBottom[0].distance + alignMargin;
let lowMargin = 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){
// dobili smo dejanski rob. vrnimo ga
// 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;
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){
if(edgesBottom[0].length > 1){
var lowMargin = edgesTop[0].distance - alignMargin;
var highMargin = edgesTop[0].distance + alignMargin;
let lowMargin = 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) {
// dobili smo dejanski rob. vrnimo ga
// 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;
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;
if (edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
for(var edge of edgesBottom){
for(let edge of edgesBottom){
if(edge.count >= edgeDetectionThreshold)
return {
status: EdgeStatus.AR_KNOWN,
@ -511,7 +511,7 @@ class EdgeDetect{
}
}
if (edges.edgeCandidatesTopCount != 0 && edges.edgeCandidatesBottomCount == 0){
for(var edge of edgesTop){
for(let edge of edgesTop){
if(edge.count >= edgeDetectionThreshold)
return {
status: EdgeStatus.AR_KNOWN,
@ -538,22 +538,22 @@ class EdgeDetect{
// roughly centered, we return true. Otherwise we return false.
// 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;
var middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
var middleRowEnd = middleRowStart + this.conf.canvas.width - 1;
let middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
let middleRowEnd = middleRowStart + this.conf.canvas.width - 1;
var rowStart = middleRowStart << 2;
var midpoint = (middleRowStart + (this.conf.canvas.width >> 1)) << 2
var rowEnd = middleRowEnd << 2;
let rowStart = middleRowStart << 2;
let midpoint = (middleRowStart + (this.conf.canvas.width >> 1)) << 2
let rowEnd = middleRowEnd << 2;
var edge_left = -1, edge_right = -1;
let edge_left = -1, edge_right = -1;
// preverimo na levi strani
// 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){
edge_left = (i - rowStart) >> 2;
break;
@ -562,7 +562,7 @@ class EdgeDetect{
// preverimo na desni strani
// 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){
edge_right = this.conf.canvas.width - ((i - rowStart) >> 2);
break;
@ -581,9 +581,9 @@ class EdgeDetect{
return false;
}
var edgeError = this.settings.active.arDetect.pillarTest.allowMisaligned;
var error_low = 1 - edgeError;
var error_hi = 1 + edgeError;
let edgeError = this.settings.active.arDetect.pillarTest.allowMisaligned;
let error_low = 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
// 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 (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
// 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++){
if (colsIn[c].blackFound && colsIn[c].imageFound) {
// če smo našli obe točki, potem ne pregledujemo več.
@ -923,7 +923,7 @@ class EdgeDetect{
}
} else {
// 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++){
if (colsIn[c].blackFound && colsIn[c].imageFound) {
// č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){
// var tmpI;
// let tmpI;
// if(reverseSearchDirection){
// for(var i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
// for(var col of colsIn){
// for(let i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
// for(let col of colsIn){
// tmpI = i + (col << 2);
// if( image[tmpI] > this.blackbarThreshold ||
// image[tmpI + 1] > this.blackbarThreshold ||
// image[tmpI + 2] > this.blackbarThreshold ){
// var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
// let bottom = (i / this.conf.canvasImageDataRowLength) + 1;
// colsOut.push({
// col: col,
// bottom: bottom
@ -1137,8 +1137,8 @@ class EdgeDetect{
// break;
// }
// } else {
// for(var i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
// for(var col of colsIn){
// for(let i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
// for(let col of colsIn){
// tmpI = i + (col << 2);
// if( image[tmpI] > this.blackbarThreshold ||
@ -1168,7 +1168,7 @@ class EdgeDetect{
// }
_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 ||
image[i+1] > this.blackbarThreshold ||
image[i+2] > this.blackbarThreshold ){
@ -1179,7 +1179,7 @@ class EdgeDetect{
}
// _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 ||
// image[i+1] > this.blackbarThreshold ||
// image[i+2] > this.blackbarThreshold ){
@ -1214,9 +1214,9 @@ class EdgeDetect{
}
// _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 ||
// image[i+1] > this.blackbarThreshold ||
// image[i+2] > this.blackbarThreshold ){

View File

@ -111,7 +111,7 @@ class PageInfo {
if(this.rescanTimer){
clearTimeout(this.rescanTimer);
}
for (var video of this.videos) {
for (let video of this.videos) {
try {
(this.comms.unregisterVideo as any)(video.vdid)
video.destroy();
@ -134,7 +134,7 @@ class PageInfo {
}
reset() {
for(var video of this.videos) {
for(let video of this.videos) {
video.destroy();
}
this.rescan(RescanReason.MANUAL);
@ -150,7 +150,7 @@ class PageInfo {
setActionHandler(actionHandler) {
this.actionHandler = actionHandler;
for (var item of this.actionHandlerInitQueue) {
for (let item of this.actionHandlerInitQueue) {
this.actionHandler.registerHandleMouse(item);
}
this.actionHandlerInitQueue = [];
@ -176,7 +176,7 @@ class PageInfo {
const oldVideoCount = this.videos.length;
try{
var vids = this.getVideos(window.location.hostname);
let vids = this.getVideos(window.location.hostname);
if(!vids || vids.length == 0){
this.hasVideos = false;
@ -190,8 +190,8 @@ class PageInfo {
// add new videos
this.hasVideos = false;
var videoExists = false;
var video, v;
let videoExists = false;
let video, v;
for (video of vids) {
// č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);
}
var ths = this;
let ths = this;
this.rescanTimer = setTimeout(function(rescanReason){
ths.rescanTimer = null;
@ -332,7 +332,7 @@ class PageInfo {
clearTimeout(this.urlCheckTimer);
}
var ths = this;
let ths = this;
this.urlCheckTimer = setTimeout(function(){
ths.urlCheckTimer = null;
@ -357,14 +357,14 @@ class PageInfo {
initArDetection(playingOnly){
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if(vd.isPlaying()) {
vd.initArDetection();
}
}
return;
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.initArDetection();
}
}
@ -375,13 +375,13 @@ class PageInfo {
// these need to be called on tab switch
pauseProcessing(playingOnly){
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.pause();
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.pause();
}
}
@ -389,7 +389,7 @@ class PageInfo {
resumeProcessing(resumeAutoar = false, playingOnly = false){
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.resume();
if(resumeAutoar){
@ -398,7 +398,7 @@ class PageInfo {
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.resume();
if(resumeAutoar){
vd.resumeAutoAr();
@ -413,13 +413,13 @@ class PageInfo {
this.logger.log('info', 'debug', '[PageInfo::startArDetection()] starting automatic ar detection!')
}
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.startArDetection();
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.startArDetection();
}
}
@ -427,13 +427,13 @@ class PageInfo {
stopArDetection(playingOnly){
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.stopArDetection();
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.stopArDetection();
}
}
@ -448,7 +448,7 @@ class PageInfo {
this.logger.log('info', 'debug', '[PageInfo::setAr] aspect ratio is auto');
try {
for (var vd of this.videos) {
for (let vd of this.videos) {
if (!playingOnly || vd.isPlaying()) {
vd.resetLastAr();
}
@ -463,13 +463,13 @@ class PageInfo {
// TODO: find a way to only change aspect ratio for one video
if (ar === AspectRatioType.Reset) {
for (var vd of this.videos) {
for (let vd of this.videos) {
if (!playingOnly || vd.isPlaying()) {
vd.resetAr();
}
}
} else {
for (var vd of this.videos) {
for (let vd of this.videos) {
if (!playingOnly || vd.isPlaying()) {
vd.setAr(ar)
}
@ -479,13 +479,13 @@ class PageInfo {
setVideoAlignment(videoAlignment, playingOnly) {
if (playingOnly) {
for(var vd of this.videos) {
for(let vd of this.videos) {
if (vd.isPlaying()) {
vd.setVideoAlignment(videoAlignment)
}
}
} else {
for(var vd of this.videos) {
for(let vd of this.videos) {
vd.setVideoAlignment(videoAlignment)
}
}
@ -493,13 +493,13 @@ class PageInfo {
setPanMode(mode, playingOnly) {
if (playingOnly) {
for(var vd of this.videos) {
for(let vd of this.videos) {
if (vd.isPlaying()) {
vd.setPanMode(mode);
}
}
} else {
for(var vd of this.videos) {
for(let vd of this.videos) {
vd.setPanMode(mode);
}
}
@ -507,13 +507,13 @@ class PageInfo {
restoreAr(playingOnly) {
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.restoreAr();
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.restoreAr();
}
}
@ -523,13 +523,13 @@ class PageInfo {
// TODO: find a way to only change aspect ratio for one video
if (playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (vd.isPlaying()) {
vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
} else {
for(var vd of this.videos){
for(let vd of this.videos){
vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
@ -537,20 +537,20 @@ class PageInfo {
setZoom(zoomLevel, no_announce, playingOnly) {
if (playingOnly) {
for(var vd of this.videos) {
for(let vd of this.videos) {
if (vd.isPlaying()) {
vd.setZoom(zoomLevel, no_announce);
}
}
} else {
for(var vd of this.videos) {
for(let vd of this.videos) {
vd.setZoom(zoomLevel, no_announce);
}
}
}
zoomStep(step, playingOnly) {
for(var vd of this.videos){
for(let vd of this.videos){
if (!playingOnly || vd.isPlaying()) {
vd.zoomStep(step);
}
@ -558,12 +558,12 @@ class PageInfo {
}
markPlayer(name, color) {
for (var vd of this.videos) {
for (let vd of this.videos) {
vd.markPlayer(name,color);
}
}
unmarkPlayer() {
for (var vd of this.videos) {
for (let vd of this.videos) {
vd.unmarkPlayer();
}
}
@ -578,13 +578,13 @@ class PageInfo {
}
setManualTick(manualTick) {
for(var vd of this.videos) {
for(let vd of this.videos) {
vd.setManualTick(manualTick);
}
}
tick() {
for(var vd of this.videos) {
for(let vd of this.videos) {
vd.tick();
}
}

View File

@ -207,7 +207,7 @@ class PlayerData {
this.destroyOverlay();
}
var overlay = document.createElement('div');
let overlay = document.createElement('div');
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.position = 'absolute';

View File

@ -24,7 +24,7 @@ class CssHandler {
}
}
for (var i in styleArray) {
for (let i in styleArray) {
styleArray[i] = styleArray[i].trim();
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
// we dont wanna, because we already center videos on our own
@ -45,7 +45,7 @@ class CssHandler {
static buildStyleString(styleArray) {
let styleString = '';
for(var i in styleArray) {
for(let i in styleArray) {
if(styleArray[i]) {
styleString += styleArray[i] + "; ";
}

View File

@ -104,7 +104,7 @@ class Resizer {
// Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi".
// Približevanje opuščeno.
// 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) {
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
// 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){
ar.ratio = ratioOut > fileAr ? ratioOut : fileAr;
@ -296,7 +296,7 @@ class Resizer {
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);
@ -603,7 +603,7 @@ class Resizer {
}
}
for (var i in styleArray) {
for (let i in styleArray) {
styleArray[i] = styleArray[i].trim();
// some sites do 'top: 50%; left: 50%; transform: <transform>' to center videos.
// we dont wanna, because we already center videos on our own
@ -626,7 +626,7 @@ class Resizer {
buildStyleString(styleArray) {
let styleString = '';
for(var i in styleArray) {
for(let i in styleArray) {
if(styleArray[i]) {
styleString += styleArray[i] + " !important; ";
}

View File

@ -30,7 +30,7 @@ class Scaler {
return ar.ratio;
}
var ratioOut;
let ratioOut;
if (!this.conf.video) {
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
// 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) {
ratioOut > fileAr ? ratioOut : fileAr

View File

@ -47,17 +47,17 @@ class Stretcher {
}
applyConditionalStretch(stretchFactors, actualAr){
var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
var videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
let playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
let videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
if (! actualAr){
actualAr = playerAr;
}
var newWidth = this.conf.video.offsetWidth * stretchFactors.xFactor;
var newHeight = this.conf.video.offsetHeight * stretchFactors.yFactor;
let newWidth = this.conf.video.offsetWidth * stretchFactors.xFactor;
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
if(actualAr < videoAr){
@ -68,11 +68,11 @@ class Stretcher {
actualWidth = newWidth;
}
var 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 minW = 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);
var maxH = this.conf.player.dimensions.height * (1 + this.settings.active.stretch.conditionalDifferencePercent);
let minH = 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) {
stretchFactors.xFactor *= this.conf.player.dimensions.width / actualWidth;
@ -168,7 +168,7 @@ squeezeFactor: ${squeezeFactor}`, '\nvideo', this.conf.video);
actualAr = playerAr;
}
var stretchFactors: any = {
let stretchFactors: any = {
xFactor: 1,
yFactor: 1
};