<?php $__env->startSection('content'); ?>
	<iframe id="frame" class="frame" src="https://app.purechat.com"></iframe>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<style>
		.frame {
			width: 100%;
			min-height: 100vh;
			border: none;
		}
		body {
			margin: 0;
			padding: 0;
			overflow: hidden;
		}
	</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('bottom'); ?>
	<?php 
		$now = strtotime('now');
		$six = strtotime('today 5:45pm');

		if($now >= $six) {
			$six = strtotime('tomorrow 5:45pm');
		}

		$remaining = $six - $now;
	?>
	<script>
		var frame = document.getElementById('frame');
		var secondsRemaining = <?php echo e($remaining); ?>;
		var localTime = new Date();
		var serverTime = new Date(<?php echo e(strtotime('now')); ?>*1000);
		var difference = localTime.getTime()-serverTime.getTime();
		var goTime = new Date(localTime.getTime()+((secondsRemaining*1000)-difference));

		console.log("<?php echo e($remaining); ?> Seconds Until Logout");

		console.log('Computer Time: '+localTime.toTimeString());
		console.log('Server Time: '+serverTime.toTimeString());
		console.log('Millisecond Difference: '+difference);
		console.log('Logout Time: '+goTime.toTimeString());

		setTimeout(check,5000);

		function check() {
			let now = new Date();
			if(now.getTime() >= goTime.getTime()) {
				frame.src = "https://api.purechat.com/account/logout";
				setTimeout(refresh, 5000);
			}
			else {
				console.log(((goTime.getTime()-now.getTime())/1000)+' Seconds Until Logout');
				//console.log(document.getElementById("frame").contentWindow.document);
				setTimeout(check,60000);
			}
		}

		function refresh() {
			alert('You have been logged out of Pure Chat. Webpage refresh required.');
			self.location = window.location.href;
		}
	</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('residential.templates.embed', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>