<commit_before>'use strict';

angular.module('emuwebApp')
	.directive('epg', function (viewState) {
		return {
			template: '<div class="emuwebapp-twoDimCanvasContainer"><canvas width="256" height="256"></canvas></div>',
			restrict: 'E',
			replace: true,
			link: function postLink(scope, element, attrs) {
				// element.text('this is the epg directive');
				var canvas = element.find('canvas')[0];

				var tr, col, sRaSt;

				////////////////////
				// watches

				scope.$watch('vs.curViewPort', function (newValue, oldValue) {
					if (!$.isEmptyObject(scope.cps.vals)) {
						if (!$.isEmptyObject(scope.ssffds.data)) {
							if (scope.ssffds.data.length !== 0) {
								if (oldValue.sS !== newValue.sS || oldValue.eS !== newValue.eS) {
									drawEpgGrid(scope);
								}
							}
						}
					}
				}, true);

				scope.$watch('vs.curMousePosSample', function (newValue, oldValue) {
					if (!$.isEmptyObject(scope.cps.vals)) {
						if (!$.isEmptyObject(scope.ssffds.data)) {
							if (scope.ssffds.data.length !== 0) {
								drawEpgGrid(scope);
							}
						}
					}
				}, true);

				//
				////////////////////

				/**
				 * drawing method to drawEpgGrid
				 */

				function drawEpgGrid(scope) {

					tr = scope.cps.getSsffTrackConfig('EPG'); // SIC SIC SIC hardcoded for now although it might stay that way because it only is allowed to draw epg data anyway
					col = scope.ssffds.getColumnOfTrack(tr.name, tr.columnName);
					sRaSt = scope.ssffds.getSampleRateAndStartTimeOfTrack(tr.name);

					var ctx = canvas.getContext('2d');
					ctx.clearRect(0, 0, canvas.width, canvas.height);

					ctx.fillStyle = 'green';
					ctx.strokeStyle = scope.cps.vals.colors.osciColor;
					ctx.font = (scope.cps.vals.font.fontPxSize + 'px' + ' ' + scope.cps.vals.font.fontType);

					var gridWidth = canvas.width / 8;
					var gridHeight = canvas.height / 8;

					var sInterv = 1 / sRaSt.sampleRate - sRaSt.startTime;
					var curFrame = Math.round((scope.vs.curMousePosSample / scope.shs.wavJSO.SampleRate) / sInterv);


					var binValStrArr;
					col.values[curFrame].forEach(function (el, elIdx) {
						binValStrArr = el.toString(2).split('').reverse();
						while (binValStrArr.length < 8) {
							binValStrArr.push('0');
						}

						binValStrArr.forEach(function (binStr, binStrIdx) {
							if (binStr === '1') {
								ctx.fillStyle = 'grey';
								ctx.fillRect(binStrIdx * gridWidth + 5, gridHeight * elIdx + 5, gridWidth - 10, gridHeight - 10);
							} else {<commit_msg>last frame error fix with angular.forEach<commit_after>'use strict';

angular.module('emuwebApp')
	.directive('epg', function (viewState) {
		return {
			template: '<div class="emuwebapp-twoDimCanvasContainer"><canvas width="256" height="256"></canvas></div>',
			restrict: 'E',
			replace: true,
			link: function postLink(scope, element, attrs) {
				// element.text('this is the epg directive');
				var canvas = element.find('canvas')[0];

				var tr, col, sRaSt;

				////////////////////
				// watches

				scope.$watch('vs.curViewPort', function (newValue, oldValue) {
					if (!$.isEmptyObject(scope.cps.vals)) {
						if (!$.isEmptyObject(scope.ssffds.data)) {
							if (scope.ssffds.data.length !== 0) {
								if (oldValue.sS !== newValue.sS || oldValue.eS !== newValue.eS) {
									drawEpgGrid(scope);
								}
							}
						}
					}
				}, true);

				scope.$watch('vs.curMousePosSample', function (newValue, oldValue) {
					if (!$.isEmptyObject(scope.cps.vals)) {
						if (!$.isEmptyObject(scope.ssffds.data)) {
							if (scope.ssffds.data.length !== 0) {
								drawEpgGrid(scope);
							}
						}
					}
				}, true);

				//
				////////////////////

				/**
				 * drawing method to drawEpgGrid
				 */

				function drawEpgGrid(scope) {

					tr = scope.cps.getSsffTrackConfig('EPG'); // SIC SIC SIC hardcoded for now although it might stay that way because it only is allowed to draw epg data anyway
					col = scope.ssffds.getColumnOfTrack(tr.name, tr.columnName);
					sRaSt = scope.ssffds.getSampleRateAndStartTimeOfTrack(tr.name);

					var ctx = canvas.getContext('2d');
					ctx.clearRect(0, 0, canvas.width, canvas.height);

					ctx.fillStyle = 'green';
					ctx.strokeStyle = scope.cps.vals.colors.osciColor;
					ctx.font = (scope.cps.vals.font.fontPxSize + 'px' + ' ' + scope.cps.vals.font.fontType);

					var gridWidth = canvas.width / 8;
					var gridHeight = canvas.height / 8;

					var sInterv = 1 / sRaSt.sampleRate - sRaSt.startTime;
					var curFrame = Math.round((scope.vs.curMousePosSample / scope.shs.wavJSO.SampleRate) / sInterv);


					var binValStrArr;
					angular.forEach(col.values[curFrame], function (el, elIdx) {
						binValStrArr = el.toString(2).split('').reverse();
						while (binValStrArr.length < 8) {
							binValStrArr.push('0');
						}

						binValStrArr.forEach(function (binStr, binStrIdx) {
							if (binStr === '1') {
								ctx.fillStyle = 'grey';
								ctx.fillRect(binStrIdx * gridWidth + 5, gridHeight * elIdx + 5, gridWidth - 10, gridHeight - 10);
							} else {
{'fraction_non_alphanumeric': 0.16439976345357776, 'fraction_numerical': 0.009856100926473488, 'mean_word_length': 2.573239436619718, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4485654', 'n_tokens_mistral': 2254, 'n_tokens_neox': 1679, 'n_words': 332}