<commit_before>/* ==========================================
 * SonarBeamer.js
 * https://github.com/adibas03/SonarBeamer
 * ==========================================
 * Copyright 2016 <NAME>.
 *
 * Licensed under the MIT license
 * http://opensource.org/licenses/MIT
 * ========================================== */

(function() {
	"use strict";

	function SonarBeamer(opts) {
    var errors = [];
    if(!opts.graphicsArray || opts.graphicsArray.length <1 || (typeof(opts.graphicsArray) != 'object' && typeof(opts.graphicsArray) != 'array'))
    errors.push('Unset or invalid Graphics Array');
    else this.graphicsArray = opts.graphicsArray;

		if(!opts.game)
		errors.push('Phaserjs Game was not referenced');
		else this.game = opts.game;

    this.grow = 200;
    if(opts.grow)this.grow = parseFloat(opts.grow);

		this.loop = true;
		if(typeof(opts.loop) != 'undefined')this.loop = opts.loop;

		this.fade = true;
		if(typeof(opts.fade) != 'undefined')this.fade = opts.fade;

		if(opts.duration)this.duration = opts.duration;

		this.stweens = [];

		if(errors.length > 0){
			console.log(errors);
			return false;
		}

		this.reset();
	}

	SonarBeamer.prototype = {
		reset: function() {
			if (this.timer) {
				this.timer.stop();
			}

			for(i in this.graphicsArray){
			var anchor_x = this.graphicsArray[i].width;
			var anchor_y = this.graphicsArray[i].height;


			//this.graphicsArray[i].anchor.setTo(anchor_x,anchor_y);
			this.graphicsArray[i].pivot.set(anchor_x,anchor_y);
			this.graphicsArray[i].scale.setTo(1,1);
		  }

			var self = this;
			this.hasFinished = true;

			this.timer = this.game.time.create(true);
			this.timer.add(0,beam,this);

				this.timer.onComplete.add(function() {
					self.hasFinished = true;
					if (self.onComplete) {
						self.onComplete();
					}
				});


		},

		setTime: function(seconds) {
			this.duration = seconds;
			this.reset();
		},

		start: function() {
			this.reset();
			this.timer.start();
		},

		stop: function() {
			this.timer.stop();
			for(i in this.stweens){
				if(this.stweens[i])this.stweens[i].stop();
			}
			for(i in this.graphicsArray){
			this.graphicsArray[i].scale.setTo(1,1);
			this.graphicsArray[i].alpha = 1;
			}
		},

		pause: function() {
			this.timer.pause();
			for(i in this.stweens){
				if(this.stweens[i])this.stweens[i].pause();
			}
		},

		resume: function() {
			this.timer.resume();
			for(i in this.stweens){
				if(this.stweens[i])this.stweens[i].resume();
			}
		},

	};


	function beam() {

	var rep = this.loop?(this.duration?this.duration:-1):0;
	var del = 0;var speed = 1000;

		for(i in this.graphicsArray){
			var twn = this.game.add.tween(this.graphicsArray[i].scale).to( { x:this.grow/100, y:this.grow/100 }, speed, Phaser.Easing.Linear.None, true, del, rep, false);
			this.stweens.push(twn);
		if(this.fade)var twn = this.game.add.tween(this.graphicsArray[i]).to( { alpha: 0.01 }, speed, Phaser.Easing.Linear.None, true, del, rep, false);
		this.stweens.push(twn);

		del+=500;
		}<commit_msg>Minor corrections<commit_after>/* ==========================================
 * SonarBeamer.js
 * https://github.com/adibas03/SonarBeamer
 * ==========================================
 * Copyright 2016 <NAME>.
 *
 * Licensed under the MIT license
 * http://opensource.org/licenses/MIT
 * ========================================== */

(function() {
	"use strict";

	function SonarBeamer(opts) {
    var errors = [];
    if(!opts.graphicsArray || opts.graphicsArray.length <1 || (typeof(opts.graphicsArray) != 'object' && typeof(opts.graphicsArray) != 'array'))
    errors.push('Unset or invalid Graphics Array');
    else this.graphicsArray = opts.graphicsArray;

		if(!opts.game)
		errors.push('Phaserjs Game was not referenced');
		else this.game = opts.game;

    this.grow = 200;
    if(opts.grow)this.grow = parseFloat(opts.grow);

		this.loop = true;
		if(typeof(opts.loop) != 'undefined')this.loop = opts.loop;

		this.fade = true;
		if(typeof(opts.fade) != 'undefined')this.fade = opts.fade;

		if(opts.duration)this.duration = opts.duration;

		this.stweens = [];

		if(errors.length > 0){
			console.log(errors);
			return false;
		}

		this.reset();
	}

	SonarBeamer.prototype = {
		reset: function() {
			if (this.timer) {
				this.timer.stop();
			}

			for(var i in this.graphicsArray){
			var anchor_x = this.graphicsArray[i].width;
			var anchor_y = this.graphicsArray[i].height;

			this.graphicsArray[i].pivot.set(anchor_x,anchor_y);
			this.graphicsArray[i].scale.setTo(1,1);
		  }

			var self = this;
			this.hasFinished = true;

			this.timer = this.game.time.create(true);
			this.timer.add(0,beam,this);

				this.timer.onComplete.add(function() {
					self.hasFinished = true;
					if (self.onComplete) {
						self.onComplete();
					}
				});


		},

		setTime: function(seconds) {
			this.duration = seconds;
			this.reset();
		},

		start: function() {
			this.reset();
			this.timer.start();
		},

		stop: function() {
			this.timer.stop();
			for(var i in this.stweens){
				if(this.stweens[i])this.stweens[i].stop();
			}
			for(var i in this.graphicsArray){
			this.graphicsArray[i].scale.setTo(1,1);
			this.graphicsArray[i].alpha = 1;
			}
		},

		pause: function() {
			this.timer.pause();
			for(i in this.stweens){
				if(this.stweens[i])this.stweens[i].pause();
			}
		},

		resume: function() {
			this.timer.resume();
			for(i in this.stweens){
				if(this.stweens[i])this.stweens[i].resume();
			}
		},

	};


	function beam() {

	var rep = this.loop?(this.duration?this.duration:-1):0;
	var del = 0;var speed = 1000;

		for(var i in this.graphicsArray){
			var twn = this.game.add.tween(this.graphicsArray[i].scale).to( { x:this.grow/100, y:this.grow/100 }, speed, Phaser.Easing.Linear.None, true, del, rep, false);
			this.stweens.push(twn);
		if(this.fade)var twn = this.game.add.tween(this.graphicsArray[i]).to( { alpha: 0.01 }, speed, Phaser.Easing.Linear.None, true, del, rep, false);
		this.stweens.push(twn);

		del+=500;
		}
{'fraction_non_alphanumeric': 0.2101485561675847, 'fraction_numerical': 0.012018027040560842, 'mean_word_length': 3.4984984984984986, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '1300487', 'n_tokens_mistral': 2511, 'n_tokens_neox': 2123, 'n_words': 348}