HEX
Server: Apache
System: Linux www3.pit.tblive.com 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64
User: awaldron (1020)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/awaldron/public_html/aw/math/js/math.js
$(document).ready(function() {

	var ctr = 0;
	var rightCtr = 0;
	var timeExp = false;
	
	$('.reload').click(function() {

		var interval_id = window.setInterval("", 9999); // Get a reference to the last // interval +1
		for (var i = 1; i < interval_id; i++) window.clearInterval(i);
        
		var opout = '';
		var op = 'mlt';
		
		var n1 = 0;
		var n2 = 0;
		var ans = 0;
		
		var f1type = $('#f1type').val();
		var f2type = $('#f2type').val();
		var f1a = parseInt($('#f1a').val());
		var f1b = parseInt($('#f1b').val());
		var f2a = parseInt($('#f2a').val());
		var f2b = parseInt($('#f2b').val());
		var timeout = $('#timeout').val();
		var addOn = $( "#addOn:checked" ).length;
		var subOn = $( "#subOn:checked" ).length;
		var mltOn = $( "#mltOn:checked" ).length;
		var divOn = $( "#divOn:checked" ).length;
		
		var opsOn = [];
		
		if (addOn == 1) opsOn[opsOn.length] = 'add';
		if (subOn == 1) opsOn[opsOn.length] = 'sub';
		if (mltOn == 1) opsOn[opsOn.length] = 'mlt';
		if (divOn == 1) opsOn[opsOn.length] = 'div';
		
		var selOp = getRandomInt( 0, opsOn.length - 1 );
		op = opsOn[selOp];
		
		timeExp = false;
		
		if (f1type == 'r') { n1 = getRandomInt(f1a, f1b); } else { n1 = f1a; }
		if (f2type == 'r') { n2 = getRandomInt(f2a, f2b); } else { n2 = f2a; }
		
		
		if (op == 'add') {
			if (n2 > n1) {
				tmp = n1;
				n1 = n2;
				n2 = tmp;
			}
			ans = n1 + n2;
			opout = "+";
		}
		if (op == 'mlt') {
			ans = n1 * n2;
			opout = "x";
		}
		if (op == 'sub') {
			if (n2 > n1) {
				tmp = n1;
				n1 = n2;
				n2 = tmp;
			}
			ans = n1 - n2;
			opout = "-";
		}
		if (op == 'div') {
			if (n2 == 0) {
				tmp = n2;
				n2 = n1;
				n1 = tmp;
			}
			ans = n1 * n2;
			tmp = n1;
			n1 = ans;
			ans = tmp;
			opout = "&divide;";
		}
		
		clearInterval(interval);
		$('#theAnswer').val(ans);
		$('#n1out').html(n1);
		$('#n2out').html(n2);
		$('#opout').html(opout);
		$('#myAnswer').val('').removeAttr('disabled');
		$('#ansCorrect, #ansWrong, #ansTimeout, #nextLink').hide();
		$('#timer').html(timeout);
		$('#response').removeClass('respRight').removeClass('respAgain');
		
		console.log(ctr+': '+n1+' x '+n2+' = '+ans+' ('+timeout+')');

		var alen = ans.toString().length;
		//alert(alen);
	
		var counter = 0;
		var interval = setInterval(function() {
		    counter++;
		    // Display 'counter' wherever you want to display it.
		    var timer = timeout - counter;
		    $('#timer').html(timer);
		    if (counter == timeout) {
		        // Display a login box
		        clearInterval(interval);
		        $('#myAnswer').val(ans).attr('disabled','disabled');
				$('#ansCorrect, #ansWrong').hide();
				$('#ansTimeout, #nextLink').show();
				$('#response').removeClass('respRight').addClass('respAgain');
				timeExp = true;
				ctr++;
				$('#scRight').html(rightCtr);
				$('#scTotal').html(ctr);
				$('#scPct').html( Math.floor(rightCtr / ctr * 100) );
		    }
		}, 1000);
	
	
		$('#myAnswer').keyup(function() {
			var myAnswer = $(this).val();
			//console.log($(this).val().length + '==' + alen);
				if (myAnswer.length < alen) {
					$('#ansCorrect, #ansWrong, #ansTimeout, #nextLink').hide();
					$('#response').removeClass('respRight').removeClass('respAgain');
				} else if (myAnswer == ans) {
					clearInterval(interval);
					$('#ansWrong, #ansTimeout').hide();
					$('#ansCorrect, #nextLink').show();
					$('#response').addClass('respRight').removeClass('respAgain');
					$('#myAnswer').blur();
					ctr++;
					rightCtr++;
					$('#scRight').html(rightCtr);
					$('#scTotal').html(ctr);
					$('#scPct').html( Math.floor(rightCtr / ctr * 100) );
					timeExp = true;
				} else {
					//clearInterval(interval);
					$('#ansCorrect, #ansTimeout, #nextLink').hide();
					$('#ansWrong').show();
					$('#response').removeClass('respRight').addClass('respAgain');
				}
		});
		
		
		
		return false;

	});
	
	$('.numBtn').click(function() {
		var theID = $(this).attr('id').substr(5);
		var theNum = $(this).html();
		var theAns = $('#myAnswer').val();
		
		if (theID == "S") {
			$('#settings').slideDown();
		} else {
			if (theID == "X") {
				theAns = theAns.substr(0, theAns.length - 1);	
			} else {
				theAns = theAns + theNum;			
			}
			if (!timeExp) $('#myAnswer').val(theAns).keyup();
		}

	});

	$('#close-settings').click(function() {
		$('#settings').slideUp();
	});
	$('#open-settings').click(function() {
		$('#settings').slideDown();
	});
	$('#start-game').click(function() {
		$('#game, #stats').show();
		$('#welcome').hide();
		$('.reload').click();
	});
	
	$("#f1type, #f2type").change(function() {
		var thisId = $(this).attr('id').substr(0,2);
		if ( $(this).val() == 'f' ) {
			$('#'+thisId+'b').hide();
		} else {
			$('#'+thisId+'b').show();
		}
	});
	
	var ww = $(window).width();
	var wh = $(window).height();
	var sh =  wh / 750;
	//alert(ww+' '+wh+' '+sh);
	var zoom = 0;
	//$('.zoom').width( ww ).height( wh );
	$('.zoom').css('transform','scale('+sh+')');
	
	$('body').css('top', -(document.documentElement.scrollTop) + 'px')
         .addClass('noscroll');
         
    $('.bg-preview').click(function() {
    	var thisFile = $(this).attr('id');
    	$('body').css('background-image','url(img/'+thisFile+'.jpg)');
    });
         
});

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

$(window).resize(function() {
	var ww = $(window).width();
	var wh = $(window).height();
	var sh =  wh / 750;
	//alert(ww+' '+wh+' '+sw+' '+sh);
	var zoom = 0;
	//$('.zoom').width( ww ).height( wh );
	$('.zoom').css('transform','scale('+sh+')');
});