`;
$(".theContent").html(theContent);
}
$(document).ready(function() {
//close login modal on catagory1=341
//Added by Monu at 05-01-2022
$(".commentdisabled").click(function() {
alert('Please Login to add the Comment');
});
$(".submitComment").click(function() {
var userImg = $("#userImg").val();
var comment = $("#comment").val();
var articleId = $("#articleId").val();
var userId = $("#userId").val();
var formtype = "faq";
if (comment.length<5) {
alert('Please enter at least 5 characters.');
} else {
$.ajax({
type: 'post',
url: '/theme/post/postComment.php',
data: {
comment,
articleId,
userId,
formtype
},
success: function(response) {
console.log(response);
// Create a new Date object
var currentDate = new Date();
// Function to add ordinal suffix to the day
function getOrdinalSuffix(day) {
if (day >= 11 && day <= 13) {
return day + 'th';
}
switch (day % 10) {
case 1: return day + 'st';
case 2: return day + 'nd';
case 3: return day + 'rd';
default: return day + 'th';
}
}
// Get day, month, year, hours, and minutes
var day = currentDate.getDate();
var month = currentDate.toLocaleString('en-US', { month: 'long' });
var year = currentDate.getFullYear();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
// Add ordinal suffix to the day
var dayWithSuffix = getOrdinalSuffix(day);
// Convert hours to 12-hour format
var period = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12; // Convert 0 to 12
// Format the date and time
var dateTime = dayWithSuffix + ' ' + month + ', ' + year + ' ' + hours + ':' + (minutes < 10 ? '0' : '') + minutes + ' ' + period;
if (response. trim() == "success") {
if (userImg . trim() == "")
{
var userimg = `https://www.medtalks.in/theme/beta-theme/img/icons/doctor1.png`;
} else {
if (userImg.trim().includes('http')) {
var userimg = userImg.trim();
} else {
var existsProfile =false;
var fileUrl = '/var/www/html/uploads/user_pics/'+userImg . trim();
checkFileExists(fileUrl, function (exists) {
existsProfile = exists;
});
if (existsProfile) {
var userimg = fileUrl;
}
else{
var userimg =`https://www.medtalks.in/theme/beta-theme/img/icons/doctor1.png`;
}
}
}
var html =
`
`;
$("#commentSection").append(html);
}
$("#comment").val(" ");
}
});
}
});
});
function articleShare(via) {
var faqId = '2437';
var article_type = 'FAQ';
$.ajax({
type: 'post',
url: '/theme/beta-theme/pages/save-share-articles.php',
data: {
via,
faqId,
article_type
},
success: function(response) {
//alert(response);
}
});
}
function checkFileExists(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr.status === 200);
}
};
xhr.open('HEAD', url, true);
xhr.send();
}
Medtalks is India's fastest growing Healthcare Learning and Patient Education Platform designed and developed to help doctors and other medical professionals to cater educational and training needs and to discover, discuss and learn the latest and best practices across 100+ medical specialties. Also find India Healthcare Latest Health News & Updates on the India Healthcare at Medtalks
Please login to comment on this article