<?php
/**
 * Project:        M.VuiZ.Net
 * Author:         nampt.me <admin@vuiz.net>
 * Copyright:      © 2025 vuiz.net All rights reserved.
 */

	$key = 'Tool Rút gọn Link ,Url Shortener TinyUrl.Com, Ouo.Io, Shorte.St, Shink.In, Bit.Ly';
	$mkey = 'Tool Rút gọn Link ,Url Shortener rút gọn link nhanh chóng và hiện đại';
	include '../../template/header.php';
?>

	<div class="col-right-xs">
		<div class="mainblok">
			<div class="phdr">
					<div vocab="https://schema.org/" typeof="BreadcrumbList">
						<span property="itemListElement" typeof="ListItem">
							<a href="/"  property="item" typeof="WebPage">
								<i class="fa fa-home"></i> <span property="name">Home</span>
							</a>
							<meta property="position" content="1">
						</span>
						<i class="fa fa-angle-right"></i>
						<span property="itemListElement" typeof="ListItem">
							<a href="/tools/"  property="item" typeof="WebPage">
								<i class="fa fa-wrench"></i> <span property="name">Công cụ</span>
							</a>
							<meta property="position" content="2">
						</span>
						<i class="fa fa-angle-right"></i>
						<span property="itemListElement" typeof="ListItem">
							<span property="name">Tool Rút gọn Link ,Url Shortener</span>
							<meta property="position" content="3">
						</span>
					</div>
			</div>
			<div class="menu">Tool Rút gọn Link ,Url Shortener TinyUrl.Com, Ouo.Io, Shorte.St, Shink.In, Bit.Ly. Công cụ rút gọn link nhanh chóng, thuận tiện chỉ cần 1 click.</div>
			<div class="menu">
				<form id="form" method="post" onSubmit="return false;">
					<input type="text" name="link" id="link" placeholder="Thí chủ có link không!?" autofocus>
					<input type="submit" id="submit" value="ShortURL" name="submit" />
				</form>
			</div>
			<div id="shortLink"></div>
		</div>
	</div>
	<div class="col-left-xs">
<?php require '../toolslist.php'; ?>
	</div>
	<div class="clear"></div>

<script>
	$(document).ready(function(){
		$("#submit").click(function(){
			$("#submit").addClass('disabled');
			$("#shortLink").hide();
			$("#shortLink").html('<div class="gmenu" style="text-align: center;"><img src="/template/images/loading.svg" /></div>').slideDown('slow');
			var form = $('#form')[0];
			var formData = new FormData(form);
			$.ajax({
				url: "shorturl.php",
				type: "POST",
				data:  formData,
				contentType: false,
				cache: false,
				processData:false,
				success: function(rs)
				{
					res = JSON.parse(rs);
					if(res.error){
						$("#submit").removeClass('disabled');
						$("#shortLink").hide();
						$("#shortLink").html('<div class="rmenu" style="text-align:center">Thí chủ chưa nhập link!</div>').slideDown('slow');
					}
					else {
						$("#submit").removeClass('disabled');
						$("#shortLink").hide();
						var html = '';
						$.each (res, function (key, item){
							html +=  '<div class="menu">';
							html +=  '<b>Link ';
							html +=  item['site'];
							html +=  '</b>: ';
							html +=  '<a class="download"  href="';
							html +=  item['link'];
							html +=  '">';
							html +=  item['link'];
							html +=  '</a>';
							html +=  '</div>';
						});
						$("#shortLink").html(html).slideDown('slow');
					}
				},
				error: function() 
				{
					$("#submit").removeClass('disabled');
					$("#shortLink").hide();
					$("#shortLink").html('<div class="gmenu" style="text-align: center;"><i style="color:red">Có lỗi hệ thống, vui lòng kiểm tra lại!</i></div>').slideDown('slow');
				}           
			});
		});
	});
</script>
<?php
include '../../template/footer.php';
?>