";
string += item;
});
$('#dup'+dataId).html(string);
},
error: function (request, error) {
}
});//End ajax
$.ajax({
type: "post",
url: "/checkDuplicateHandmadev",
dataType: "json",
data: {'image': dataimage},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function (data) {
console.log(data);
sameLink = '';
$.each(data['link'], function(index, value){
length = 0;
scoreClass = '';
if (value['imagestep'] && Array.isArray(value['imagestep'])) {
length = value['imagestep'].length + 1;
if(value['score']>=0.87){ scoreClass = 'heighScore'};
sameLink += `${value['score']} : ${value['slug']}${length} `;
sameLink += '';
$.each(value['imagestep'], function (key, valueImg) {
sameLink += '';
})
sameLink += ' ';
}
});
$('#dupHandmadev'+dataId).html(sameLink);
},
error: function (request, error) {
}
});//End ajax
});
},
getlanguage:function(){
// lấy ngôn ngữ của ảnh.
$('.getLanguage').click(function(){
let divGetLanguage = $(this);
dataimage = $(this).attr('dataimage');
dataId = $(this).attr('data');
$(this).text('Loading...');
$.ajax({
type: "post",
url: "/getLanguage",
dataType: "json",
data: {'dataimage': dataimage, 'dataId': dataId},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function (data) {
$('#datalang'+dataId).text(data.result);
divGetLanguage.text('lang');
},
error: function (request, error) {
}
});//End ajax
})
},
saveLangName:function(){
$('.langName').change(function () {
let dataId = $(this).attr('data-id');
let value = $(this).val();
$('#langCode'+dataId).val($(this).attr('data-code'));
$('#langName'+dataId).val(value);
console.log(dataId)
console.log(value)
//thiết lập lang cho button gettitle
$('.getLangButton'+dataId).attr('datalang',value);
$.ajax({
type: "post",
url: "/tiktok/saveLangName",
dataType: "json",
data: {'dataId': dataId, 'value': value},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function (msg) {
console.log(msg);
},
error: function (request, error) {
tiktokList.showtoast(error.message);
}
});//End ajax
});
},
showtoast:function(text){
$.toast({
text: text, // Text that is to be shown in the toast
heading: 'Note', // Optional heading to be shown on the toast
icon: 'success', // Type of toast icon
showHideTransition: 'fade', // fade, slide or plain
allowToastClose: true, // Boolean value true or false
hideAfter: 5000, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
stack: 10, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
position: 'top-center', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
textAlign: 'left', // Text alignment i.e. left, right or center
loader: true, // Whether to show loader or not. True by default
loaderBg: '#9EC600', // Background color of the toast loader
});
},
getDuplicateSequential: function(){
const self = this;
const tdElements = $('td');
let currentIndex = 0;
function processNextTd() {
if (currentIndex >= tdElements.length) {
console.log('Đã xử lý xong tất cả td');
return;
}
const currentTd = $(tdElements[currentIndex]);
const getDupElement = currentTd.find('.getDup:first');
if (getDupElement.length === 0) {
currentIndex++;
processNextTd();
return;
}
const dataimage = getDupElement.attr('dataimage');
const dataId = getDupElement.attr('data');
console.log(`Đang xử lý td ${currentIndex + 1}/${tdElements.length}, dataId: ${dataId}`);
// Gọi ajax đầu tiên
$.ajax({
type: "post",
url: "/getDuplicateTikIns",
dataType: "json",
data: {'image': dataimage},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function (data) {
console.log('Ajax 1 completed for:', dataId);
// Xử lý kết quả ajax 1 (code cũ của bạn)
let string = '';
$.each(data, function(index, value){
let item = "