<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

namespace BlackSheepResearch\Component\UserPoints\Site\Viewers;

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;

class RegisterqrcodeHTML extends UserView {

    function display($tpl = null) {

        $document = Factory::getDocument();
        // $document->addStyleSheet(Uri::base(true) . '/components/com_userpoints/assets/css/userpoints.css');
        //HTMLHelpler::_('behavior.mootools');

        $scriptCheckUsername = "	window.addEvent('domready', function(){
						$('login').addEvent('keyup', function(e){
							// stop the default link event
							new Event(e).stop();
							var url = '" . Uri::base(true) . "/components/com_userpoints/assets/ajax/checkusername.php?n=' + $('login').value;
							var myAjax = new Request({
									url:url,
									method: 'get',
									onComplete: function(responseText) {
										$('statusUSR').set('html', responseText);
									}
								});
						myAjax.send();
						});
						});";

        $document->addScriptDeclaration($scriptCheckUsername);

        HTMLHelper::_('behavior.formvalidation');

        parent::display($tpl);
    }

    function displayResult($tpl = null) {

        parent::display($tpl);
    }
}
