<?php

namespace FSPoster\App\Providers;

abstract class SocialNetwork
{

	abstract public static function callbackURL();

	protected static function error( $message = '' )
	{
		if( empty( $message ) )
			$message = esc_html__('An error occurred while processing your request! Please close the window and try again!');

		print '<div>' . esc_html( $message ) . '</div>';

		?>
		<script type="application/javascript">
			if( typeof window.opener.compleateOperation == "function" )
			{
				window.opener.fsCode.loading(0);
				window.opener.compleateOperation(false , "<?php print esc_html( $message ); ?>");
				window.close();
			}
		</script>
		<?php

		exit();
	}

	protected static function closeWindow()
	{
		print '<div>' . esc_html__('Loading...') . '</div>';

		?>
		<script type="application/javascript">
			if( typeof window.opener.compleateOperation == "function" )
			{
				window.opener.compleateOperation(true);
				window.close();
			}
		</script>
		<?php

		exit;
	}

}