From a91fb5ce2de3dbcbdf20bc880537e61379c5ff38 Mon Sep 17 00:00:00 2001 From: apiiphim Date: Fri, 9 Aug 2024 04:57:38 +0700 Subject: [PATCH] =?UTF-8?q?C=E1=BA=ADp=20nh=E1=BA=ADt=20n=C3=BAt=20t?= =?UTF-8?q?=E1=BA=A1o=20slug=20phim=20nhanh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Donateeeeeeeeeeeee đi ae -_-! --- application/admin/view/vod/info.html | 48 ++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/application/admin/view/vod/info.html b/application/admin/view/vod/info.html index 1414002..9907431 100644 --- a/application/admin/view/vod/info.html +++ b/application/admin/view/vod/info.html @@ -89,16 +89,18 @@ -
+
-
+
+
+
@@ -1197,8 +1199,48 @@ getExtend('{$info.type_id}') },1000); {/if} + + $(document).ready(function() { + $('#generate-vod-sub').click(function() { + const name = $('#vod_name').val(); + const slug = generateSlug(name); + $('#vod_sub').val(slug); + }); + + // Function to generate slug + function generateSlug(text) { + text = removeVietnameseTones(text); + text = text.replace(/[^a-zA-Z0-9\-\_]/g, '-'); + text = text.replace(/-+/g, '-').replace(/^-+|-+$/g, ''); + return text.toLowerCase(); + } + + function removeVietnameseTones(str) { + str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a"); + str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e"); + str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i"); + str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o"); + str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u"); + str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y"); + str = str.replace(/đ/g, "d"); + str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, "A"); + str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, "E"); + str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g, "I"); + str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g, "O"); + str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, "U"); + str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, "Y"); + str = str.replace(/Đ/g, "D"); + str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // ̀ ́ ̃ ̉ ̣ + str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // ˆ ̆ ̛ + str = str.replace(/ + /g, " "); + str = str.trim(); + str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, " "); + return str; + } +}); + - \ No newline at end of file +