<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Ryserg Tung">
    <!--<link rel="icon" href="../../favicon.ico">-->
    <title>Vòng đua kỳ thú</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this website -->
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- Custom fonts for this website -->
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>

<body>
    <nav class="navbar navbar-default navbar-fixed-top header-nav" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                      <span class="sr-only">Toggle navigation</span>
                      <span class="icon-bar"></span>
                      <span class="icon-bar"></span>
                      <span class="icon-bar"></span>
                  </button>
                <!-- Logo -->
                <a style="padding-top:10px; padding-left:15px;" class="navbar-brand" href="http://nghemoigioi.vn/" title="Nghemoigioi.vn – Chia sẻ thông tin, chia sẻ lợi nhuận" rel="home">
                    <img src="http://nghemoigioi.vn/wp-content/uploads/2017/01/LOGO-NGHEMOIGIOI.png" alt="Nghemoigioi.vn – Chia sẻ thông tin, chia sẻ lợi nhuận">
                </a>
            </div>
            <ul class="login-register">
                <li class="snlogin">
                    <a href="#" onclick="fakeLogin()">Đăng nhập</a>
                </li>
            </ul>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div id="bs-example-navbar-collapse-1" class="collapse navbar-collapse">
                <ul id="menu-menu-1" class="nav navbar-nav navbar-right">
                    <li id="menu-item-1584" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-1584 dropdown"><a title="GIỚI THIỆU" href="#" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true">GIỚI THIỆU <i class="fa fa-angle-down fa-lg"></i></a>
                        <ul role="menu" class=" dropdown-menu">
                            <li id="menu-item-1873" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1873"><a title="Về chúng tôi" href="http://nghemoigioi.vn/ve-chung-toi/">Về chúng tôi</a></li>
                            <li id="menu-item-1587" class="menu-item menu-item-type-taxonomy menu-item-object-blog-category menu-item-1587"><a title="Tin tức" href="http://nghemoigioi.vn/blog-category/tin-tuc/">Tin tức</a></li>
                        </ul>
                    </li>
                    <li id="menu-item-641" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-641"><a title="Quyền lợi" href="http://nghemoigioi.vn/quyen-loi/">Quyền lợi</a></li>
                    <li id="menu-item-714" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-714"><a title="Kho dự án" href="http://nghemoigioi.vn/kho-du-an/">Kho dự án</a></li>
                    <li id="menu-item-3553" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-3553 dropdown"><a title="Đối tác" href="http://nghemoigioi.vn/chu-dau-tu/" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true">Đối tác <i class="fa fa-angle-down fa-lg"></i></a>
                        <ul role="menu" class=" dropdown-menu">
                            <li id="menu-item-3554" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3554"><a title="Chủ đầu tư" href="http://nghemoigioi.vn/chu-dau-tu/">Chủ đầu tư</a></li>
                            <li id="menu-item-3579" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3579"><a title="Đại lý" href="http://nghemoigioi.vn/dai-ly/">Đại lý</a></li>
                        </ul>
                    </li>
                    <li id="menu-item-3605" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3605"><a title="Đào Tạo" href="http://nghemoigioi.vn/coming-soon-elearning-nghemoigioi-vn/">Đào Tạo</a></li>
                    <li id="menu-item-686" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-686"><a title="Sự Kiện" href="http://nghemoigioi.vn/lich-mo-ban/">Sự Kiện</a></li>
                </ul>
            </div>
        </div>
        <!-- /.container-fluid -->
    </nav>

    <div class="main-content">
        <div class="main-title">
            <h1>Cách thức tham gia</h1>
        </div>
        <div class="container" style="padding-top: 50px;">
            <div class="steps clearfix">
                <div class="number col-lg-2 col-md-2 col-sm-12 col-xs-12">
                    <p style="padding-top: 10px;">
                        Bước
                    </p>
                    <p>
                        <img src="images/number1.png" />
                    </p>
                </div>
                <div class="desc col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <p>
                        Chụp ảnh Selfie cùng tôi và post ảnh lên facebook cùng “vongduakythu”
                    </p>
                </div>
                <div class="step-img col-lg-4 col-md-4 col-sm-12 col-xs-12">
                    <img src="images/mazda-green-1-widescreen-car-wallpaper.png" />
                </div>
            </div>
            <div class="steps clearfix">
                <div class="number col-lg-2 col-md-2 col-sm-12 col-xs-12">
                    <p style="padding-top: 10px;">
                        Bước
                    </p>
                    <p>
                        <img src="images/22.png" />
                    </p>
                </div>
                <div class="desc col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <p>
                        Giúp tôi chiến thắng mini game www.vongduakythu.vn
                    </p>
                </div>
                <div class="step-img col-lg-4 col-md-4 col-sm-12 col-xs-12">
                    <img src="images/ghep phoi canh.png" />
                </div>
                <div class="col-lg-offset-1 col-md-offset-1 col-lg-10 col-md-10 col-sm-12 col-xs-12">
                    <div id="gameContainer" class="games">
                        <div id="c2canvasdiv" class="c2canvasClass">
							<canvas id="c2canvas" width="1280" height="768">
								<!-- This text is displayed if the visitor's browser does not support HTML5.
								You can change it, but it is a good idea to link to a description of a browser
								and provide some links to download some popular HTML5-compatible browsers. -->
								<h1>Your browser does not appear to support HTML5.  Try upgrading your browser to the latest version.  <a href="http://www.whatbrowser.org">What is a browser?</a>
								<br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>
								<a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>
								<a href="http://www.google.com/chrome/">Google Chrome</a><br/>
								<a href="http://www.apple.com/safari/download/">Apple Safari</a><br/>
								<a href="http://www.google.com/chromeframe">Google Chrome Frame for Internet Explorer</a><br/></h1>
							</canvas>
							
						</div>
                    </div>
                </div>
            </div>
            <div class="steps clearfix">
                <div class="number col-lg-2 col-md-2 col-sm-12 col-xs-12">
                    <p style="padding-top: 10px;">
                        Bước
                    </p>
                    <p>
                        <img src="images/33.png" />
                    </p>
                </div>
                <div class="desc col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <p style="float: left;">
                        Rinh quà:
                    </p>
                    <ul>
                        <li>
                            - Nội dung giới thiệu cơ cấu giải thưởng 01
                        </li>
                        <li>
                            - Nội dung giới thiệu cơ cấu giải thưởng 02
                        </li>
                        <li>
                            - Nội dung giới thiệu cơ cấu giải thưởng 03
                        </li>
                    </ul>
                </div>
                <div class="step-img col-lg-4 col-md-4 col-sm-12 col-xs-12">
                    <img src="images/wpid-screenshot_2014-12-24-07-53-57-1.png" />
                </div>
            </div>
        </div>
        <div class="ads1">
          <img src="images/Layer 6.png" />
        </div>
        <div class="ads2">
          <img src="images/skyscraper-save-for-web.png" />
        </div>
    </div>

    <div id="footer">
        <div class="container">
            <div class="row">
                <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3 class_center">
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                            <img class="logo_nghemoigioi" src="http://nghemoigioi.vn/wp-content/themes/larx/assets/img/custom/logo-footer.png" alt="">
                        </div>
                    </div>
                    <div class="row bottom_footer" style="display:none;">
                        <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 class_center">
                            <p class="copyright">
                                © 2016 Cenland
                            </p>
                        </div>
                        <div class="col-xs-12 col-sm-6 col-md-6 class_center" style="display:none;">
                            <!-- Social Icons -->
                            <ul class="footer-social">
                                <li><a target="_blank" href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-facebook fa-stack-1x fa-inverse"></i></span></a></li>
                                <li><a target="_blank" href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-twitter fa-stack-1x fa-inverse"></i></span></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
                    <section>
                        <h3>Công ty cổ phần dịch vụ Bất động sản <br>Ngôi Sao Toàn Cầu <br>(Thành viên của Cenland)</h3>
                        <div class="content_footer">
                            <p>
                                Số ĐKKD 0106887166 do Sở Kế hoạch và Đầu tư TP Hà Nội cấp ngày 24 tháng 06 năm 2015
                            </p>
                        </div>
                    </section>
                </div>
                <div class="col-xs-12 col-sm-5 col-md-5 col-lg-5">
                    <div class="row">
                        <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                            <section>
                                <h3>Giấy phép TMĐT</h3>
                                <div class="content_footer">
                                    <a href="http://online.gov.vn/HomePage/CustomWebsiteDisplay.aspx?DocId=27572"><img style="width: 180px; height: 70px;" class="logo_nghemoigioi" src="http://nghemoigioi.vn/wp-content/uploads/2016/09/20150827110756-dathongbao.png" alt=""></a>
                                    <p>
                                        <a href="http://nghemoigioi.vn/chinh-sach-hoat-dong-nghemoigioi-vn/">Chính Sách Hoạt Động </a> </p>
                                </div>
                            </section>
                        </div>
                        <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                            <section>
                                <div class="content_footer">
                                    <span><h3>Liên hệ</h3></span>
                                    <p>
                                        ĐT: <span>1900 60 88</span>
                                    </p>
                                    <p>
                                        Email: <span>hotro@nghemoigioi.vn</span>
                                    </p>
                                </div>
                            </section>
                            <div class="class_center" style="display:none;">
                                <!-- Social Icons -->
                                <ul class="footer-social">
                                    <li><a target="_blank" href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-facebook fa-stack-1x fa-inverse"></i></span></a></li>
                                    <li><a target="_blank" href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-twitter fa-stack-1x fa-inverse"></i></span></a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /row -->
            <p class="copyright">
                © 2016 Cenland
            </p>
        </div>
        <!-- /container -->
    </div>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery-3.1.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
	<script src="c2runtime.js"></script>
	<script>
		// Start the Construct 2 project running on window load.
		jQuery(document).ready(function ()
		{			
			BMGsetSize = true;
			BMGsetW = document.getElementById("gameContainer").clientWidth;
			BMGsetH = document.getElementById("gameContainer").clientHeight;
			cr_createRuntime("c2canvas");
		});
	</script>
	<script>
	var _user = {
			user_id : '',
			fullname : '',
			username : '',
			email : '',
			total_time : 0,
			total_point : 0,
			total_game : 0,
	};
	var time_start;
	function timeFormat(){
		var timestamp = 1293683278;
		var date = new Date(timestamp*1000);
		var iso = date.toISOString().match(/(\d{4}\-\d{2}\-\d{2})T(\d{2}:\d{2}:\d{2})/)
		return (iso[1] + ' ' + iso[2]);
	}
	var sysAPI = {
		api_key : "No9OIh0vOPBRzUYeRYHPuQoclfzx69MX",
		getLogin : function(){
			$.get( "http://localhost/mini_game/api/apiGame/getUpdateGame",
				{
					api_key: this.api_key,
				},
				function( response ) {
					if (response.errorCode == 0){
						_user.user_id = response['data'][0];
					} else {
						log(response.errorCode);
					}
				}
			);
		},
		getUserInfo : function(){
			$.get( "http://localhost/mini_game/api/apiGame/getUpdateGame",
				{
					api_key: this.api_key,
					user_id:_user.user_id
				},
				function( response ) {
					if (response.errorCode == 0){
						_user.user_id 		= response['data'][0];
						_user.fullname		= response['data'][1];
						_user.username 		= response['data'][2];
						_user.email 		= response['data'][3];
						_user.total_time 	= response['data'][4];
						_user.total_point 	= response['data'][5];
						_user.total_game 	= response['data'][6];
					} else {
						log(response.errorCode);
					}
				}
			);
		},
		submit : function(){
			$.get( "http://localhost/mini_game/api/apiGame/postUpdateGame",
				{
					api_key: this.api_key,
					user_id:_user.user_id,
					time : _user.total_time,
					point : _user.total_point,
					time_play_2 : time_start
				},
				function( response ) {
					if (response.errorCode == 0){
						log("complete");
					} else {
						log(response.errorCode);
					}
				}
			);
		}
	};
	function fakeLogin(){
		FB.login(function(response) {
			 if ((response.status === 'connected') && (response.authResponse)) {
				log('### FB login');
				FB.api(
					  '/me',
					  'GET',
					  {"fields":"email,name,id"},
					  function(response) {
						_user.user_id = response.id;
						_user.fullname = _user.username = response.name;
						_user.email = response.email;
					  }
				);
			  } else {
				
			  }
			}, {scope: 'public_profile,email',auth_type: 'rerequest'});
		var _strVar = JSON.stringify(_user);
		log(_strVar);
		localStorage.setItem("user",_strVar);
		log("Login success !");
		log(_user);
	}
	var BMG = {
		READY : function(){
			sysAPI.getLogin();
			sysAPI.getUserInfo();
		},
		START : function(){
			time_start = timeFormat();
			if (_user.user_id == ""){
			// Should login first.
			cr_setSuspended(true);
			var r = confirm("Bạn phải đăng nhập trước");
				if (r == true) {
					location.reload();
				}
			}
		},
		FINISH : function(_score,_time,_abc){
			_user.total_point = _score;
			_user.total_time = _time;
			sysAPI.submit();
		},
		CLOSE : function(){
			shareFB();
		}
	};
	
	function log(_str){
		console.log(_str);
	}
	function shareFB(){
		var _title = _user.username+" vừa đạt "+_user.total_point+"!";
		var _img = "https://fb-img.mini-games.io/ugc-img/"+strIMG+".png";
		FB.ui({
		method: 'feed',  
		link: 'https://silverportal-7eefe.firebaseapp.com/',
		name: _title,
		caption: 'Vòng đua kỳ thú !',
		description: 'Vừa qua chướng ngại vật và hoàn thành vòng đua trong thời gian ngắn nhất',
		picture: _img,
		message: 'Giúp tôi chiến thắng mini game #VongDuaKyThu ',
		display: 'popup'
		},
		function(response) {
			
		}
		);
	}
	var strIMG;
	function uploadIMG(){
		strIMG = "";
		var _name = "vd_"+_user.user_id+"_"+Date.now();
		console.log("### POST TO SERVER ###");
		console.log("### IMAGE UPLOAD READY ###");
		var IMGData = KenCanvasData;
		var tmpSTR = IMGData.split("base64,");
		IMGData = tmpSTR[1];
		$.ajax({
			type: "POST",
			url: "https://fb-img.mini-games.io/upload.php",
			data: { img_data:IMGData, name:_name },
			cache: false,
			contentType: "application/x-www-form-urlencoded",
			success: function (result) {
			$.get("https://fb-img.mini-games.io/ugc_meta.php?data="+_name, function(data, status){
				//if (status == "success")
				strIMG = _name;
				console.log("### UploadIMG COMPLETED :"+strIMG);
			});
		}
		});
		console.log("### POST TO SERVER ### END");
	}
	</script>
	<script>
	window.fbAsyncInit = function() {
		FB.init({
		  appId      : 733778786783938,
		  xfbml      : true,
		  version    : 'v2.1'
		});
		};
		(function(d, s, id){
		 var js, fjs = d.getElementsByTagName(s)[0];
		 if (d.getElementById(id)) {return;}
		 js = d.createElement(s); js.id = id;
		 js.src = "//connect.facebook.net/en_US/sdk.js";
		 fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
	</script>
</body>

</html>