fantasy1337 adlı üyeden alıntı: mesajı görüntüle
function pbtShortCode(shortCode, key, value) {
  const parts = shortCode.split('$');
  for (let i = 0; i < parts.length; i++) {
    const pair = parts[i].split('=');
    if (pair[0].trim() === key) {
      value = pair[1];
      const match = value.match(/[^{\}]+(?=})/g);
      return match ? String(match).trim() : null;
    }
  }
  return false;
}

function msgError() {
  return '<span class="error-msg"><b>Error:</b>&nbsp;No Results Found</span>';
}

function beforeLoader() {
  return '<div class="loader"></div>';
}

function getFeedUrl(feedType, maxResults, label, url) {
  switch (label) {
    case 'recent':
      url = `/feeds/posts/default?alt=json&max-results=${maxResults}`;
      break;
    default:
      url = feedType === 'comments'
        ? `/feeds/comments/default?alt=json&max-results=${maxResults}`
        : `/feeds/posts/default/-/${label}?alt=json&max-results=${maxResults}`;
  }
  return url;
}

function getPostID(feed, index) {
  const id = feed[index].id.$t;
  return id ? id.split('-').pop() : '';
}

function getPostLink(feed, index) {
  for (let i = 0; i < feed[index].link.length; i++) {
    if (feed[index].link[i].rel === 'alternate') {
      return feed[index].link[i].href;
    }
  }
}

function getPostTitle(feed, index) {
  return feed[index].title.$t || pbtMessages.noTitle;
}

function getPostAuthor(feed, index) {
  const authorLabel = pbtMessages.postAuthorLabel
    ? `<span class="sp">${pbtMessages.postAuthorLabel}</span>`
    : '';
  return pbtMessages.postAuthor
    ? `<span class="entry-author mi">${authorLabel}<span class="author-name">${feed[index].author[0].name.$t}</span></span>`
    : '';
}

function getPostDate(feed, index) {
  const monthNames = [
    'January', 'February', 'March', 'April', 'May', 'June',
    'July', 'August', 'September', 'October', 'November', 'December'
  ];
  const dateFormat = '{m} {d}, {y}';
  const datePublished = feed[index].published.$t;
  const year = datePublished.substring(0, 4);
  const month = datePublished.substring(5, 7);
  const day = datePublished.substring(8, 10);
  const formattedDate = dateFormat
    .replace('{m}', monthNames[parseInt(month, 10) - 1])
    .replace('{d}', day)
    .replace('{y}', year);
  const dateLabel = pbtMessages.postDateLabel
    ? `<span class="sp">${pbtMessages.postDateLabel}</span>`
    : '';

  return [
    pbtMessages.postDate
      ? `<span class="entry-time mi">${dateLabel}<time class="published" datetime="${datePublished}">${formattedDate}</time></span>`
      : '',
    pbtMessages.postDate
      ? `<span class="entry-time mi"><time class="published" datetime="${datePublished}">${formattedDate}</time></span>`
      : ''
  ];
}

function getPostMeta(authorHtml, dateHtml) {
  return [
    (pbtMessages.postAuthor || pbtMessages.postDate)
      ? `<div class="entry-meta">${authorHtml}${dateHtml[0]}</div>`
      : '',
    pbtMessages.postDate
      ? `<div class="entry-meta">${dateHtml[1]}</div>`
      : ''
  ];
}

function getFirstImage(htmlContent) {
  const container = $('<div>').html(htmlContent);
  let imageUrl = container.find('img:first').attr('src');
  const urlParts = imageUrl.split('/');
  const sizeSegment = `/${urlParts.slice(-2)[0]}`;

  if (urlParts.length === 9 && (sizeSegment.match(/\/s[0-9]+/g) || sizeSegment.match(/\/w[0-9]+/g) || sizeSegment === '/d')) {
    imageUrl = imageUrl.replace(sizeSegment, '/w72-h72-p-k-no-nu');
  }
  return imageUrl;
}

function getPostImage(feed, index) {
  const content = feed[index].content ? feed[index].content.$t : '';
  const defaultImage = feed[index].media$thumbnail
    ? feed[index].media$thumbnail.url
    : 'https://resources.blogblog.com/img/blank.gif';

  if (content.includes('www.youtube.com')) {
    if (content.includes('<img')) {
      return content.indexOf('www.youtube.com') < content.indexOf('<img')
        ? defaultImage.replace('img.youtube.com', 'i.ytimg.com').replace('/default.', '/maxresdefault.')
        : getFirstImage(content);
    } else {
      return defaultImage.replace('img.youtube.com', 'i.ytimg.com').replace('/default.', '/maxresdefault.');
    }
  } else {
    return content.includes('<img') ? getFirstImage(content) : 'https://resources.blogblog.com/img/blank.gif';
  }
}

function getPostImageType(imageUrl) {
  return imageUrl.includes('i.ytimg.com') ? 'is-video' : 'is-image';
}

function getPostContent(type, feed, index, total) {
  const postLink = getPostLink(feed, index);
  const postTitle = getPostTitle(feed, index);
  const postAuthor = getPostAuthor(feed, index);
  const postDate = getPostDate(feed, index);
  const postImage = getPostImage(feed, index);
  const postImageType = getPostImageType(postImage);
  const postMeta = getPostMeta(postAuthor, postDate);

  if (type === 'related' && index !== total - 1) {
    return `
      <div class="related-item item-${index}">
        <a title="${postTitle}" class="entry-image-wrap ${postImageType}" href="${postLink}">
          <span class="entry-image" data-image="${postImage}"></span>
        </a>
        <div class="entry-header">
          <h2 class="entry-title">
            <a href="${postLink}" title="${postTitle}">${postTitle}</a>
          </h2>
          ${postMeta[1]}
        </div>
      </div>`;
  }
  return '';
}
buyrun hocam

valla sen adamın ham maddesisin