dsg
INSERT INTO `cp_filejs` (`id`,`app`,`path`,`modul`,`file_name`,`content`) VALUES ('266','2','u6/driver','waste','js/waste-view.js--','import app from \\\\\\\"./app.js\\\\\\\"\r\nimport {\r\n getWasteById\r\n} from \\\\\\\"./api/waste.js\\\\\\\"\r\nimport {\r\n formatPostDate\r\n} from \\\\\\\"./utils.js\\\\\\\"\r\nimport store from \\\\\\\"./store.js\\\\\\\"\r\nvar $ = Dom7\r\n\r\nexport function renderWaste(waste) {\r\n const user = store.getters.user.value\r\n\r\n let waste_actions = `\r\n
\r\n
\r\n ${waste.is_liked ? \\\\\\\\\\\\\\\'heart_fill\\\\\\\\\\\\\\\' : \\\\\\\\\\\\\\\'heart\\\\\\\\\\\\\\\'}\r\n
\r\n
\r\n chat_bubble\r\n
\r\n
\r\n paperplane\r\n
\r\n `\r\n\r\n if (waste.user_id == user.id) {\r\n waste_actions += `\r\n
\r\n gear_alt\r\n
\r\n `\r\n }\r\n\r\n waste_actions += `
`\r\n\r\n const date = formatPostDate(waste.create_at)\r\n const maxDescriptionLength = 10; // Set your character limit here\r\n const isLongDescription = waste.caption.length > maxDescriptionLength;\r\n const shortDescription = isLongDescription ? waste.caption.slice(0, maxDescriptionLength) : waste.caption;\r\n let imageHeight = 400;\r\n\r\n if (waste.media.length > 0) {\r\n imageHeight = waste.media[0].media_height;\r\n\r\n if (imageHeight > 400) {\r\n imageHeight = \\\\\\\\\\\\\\\'auto\\\\\\\\\\\\\\\';\r\n }\r\n }\r\n\r\n let profile_link;\r\n\r\n if (waste.user_id == user.id) {\r\n profile_link = `\r\n \r\n
\r\n
${waste.username}
\r\n
`\r\n } else {\r\n profile_link = `\r\n \r\n
\r\n
${waste.username}
\r\n
`\r\n }\r\n\r\n const wasteItem = `\r\n
\r\n
\r\n
\r\n ${profile_link}\r\n
${date}
\r\n
\r\n
\r\n
\r\n
\r\n ${waste.media.map(mediaItem => `\r\n
\r\n ${mediaItem.media_type === \\\\\\\\\\\\\\\'video\\\\\\\\\\\\\\\' ? `\r\n \r\n ` : `\r\n \\\\\\\"${mediaItem.media_alt}\\\\\\\"\r\n `}\r\n
\r\n `).join(\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\')}\r\n
\r\n
\r\n
\r\n
\r\n ${waste_actions}\r\n
${waste.likes_count} likes
\r\n
\r\n ${waste.username}
${shortDescription}\r\n ${waste.caption}\r\n ${isLongDescription ? `... more` : \\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'}\r\n
\r\n ${waste.comments_count > 0 ? `
View ${waste.comments_count} comments
` : \\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'}\r\n
\r\n
`\r\n\r\n return wasteItem\r\n}\r\n\r\nexport function displayWaste(waste) {\r\n const wastesContainer = document.getElementById(\\\\\\\\\\\\\\\'waste-view-container\\\\\\\\\\\\\\\')\r\n wastesContainer.innerHTML = \\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\' // Clear any existing wastes\r\n\r\n const user = store.getters.user.value\r\n\r\n let waste_actions = `\r\n
\r\n
\r\n ${waste.is_liked ? \\\\\\\\\\\\\\\'heart_fill\\\\\\\\\\\\\\\' : \\\\\\\\\\\\\\\'heart\\\\\\\\\\\\\\\'}\r\n
\r\n
\r\n chat_bubble\r\n
\r\n
\r\n paperplane\r\n
\r\n `\r\n\r\n if (waste.user_id == user.id) {\r\n waste_actions += `\r\n
\r\n gear_alt\r\n
\r\n `\r\n }\r\n\r\n waste_actions += `
`\r\n\r\n const date = formatPostDate(waste.create_at)\r\n const maxDescriptionLength = 10; // Set your character limit here\r\n const isLongDescription = waste.caption.length > maxDescriptionLength;\r\n const shortDescription = isLongDescription ? waste.caption.slice(0, maxDescriptionLength) : waste.caption;\r\n let imageHeight = 400;\r\n\r\n if (waste.media.length > 0) {\r\n imageHeight = waste.media[0].media_height;\r\n\r\n if (imageHeight > 800) {\r\n imageHeight = \\\\\\\\\\\\\\\'auto\\\\\\\\\\\\\\\';\r\n }\r\n }\r\n\r\n let profile_link;\r\n\r\n if (waste.user_id == user.id) {\r\n profile_link = `\r\n \r\n
\r\n
${waste.username}
\r\n
`\r\n } else {\r\n profile_link = `\r\n \r\n
\r\n
${waste.username}
\r\n
`\r\n }\r\n\r\n const wasteItem = `\r\n
\r\n
\r\n
\r\n ${profile_link}\r\n
${date}
\r\n
\r\n
\r\n
\r\n
\r\n ${waste.media.map(mediaItem => `\r\n
\r\n ${mediaItem.media_type === \\\\\\\\\\\\\\\'video\\\\\\\\\\\\\\\' ? `\r\n \r\n ` : `\r\n \\\\\\\"${mediaItem.media_alt}\\\\\\\"\r\n `}\r\n
\r\n `).join(\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\')}\r\n
\r\n
\r\n
\r\n
\r\n ${waste_actions}\r\n
${waste.likes_count} likes
\r\n
\r\n ${waste.username}
${shortDescription}\r\n ${waste.caption}\r\n ${isLongDescription ? `... more` : \\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'}\r\n
\r\n ${waste.comments_count > 0 ? `
View ${waste.comments_count} comments
` : \\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'}\r\n
\r\n
`\r\n\r\n wastesContainer.insertAdjacentHTML(\\\\\\\\\\\\\\\'beforeend\\\\\\\\\\\\\\\', wasteItem)\r\n}\r\n\r\n$(document).on(\\\\\\\\\\\\\\\'page:beforein\\\\\\\\\\\\\\\', \\\\\\\\\\\\\\\'.page[data-name=\\\\\\\"waste-view\\\\\\\"]\\\\\\\\\\\\\\\', async function (e) {\r\n var pathStore = store.getters.getPathData\r\n\r\n var wasteId = e.detail.route.params.id\r\n var query = e.detail.route.query\r\n\r\n let commentId;\r\n\r\n if (query && query.commentId) {\r\n commentId = query.commentId\r\n }\r\n\r\n if (!wasteId || wasteId === \\\\\\\\\\\\\\\'-1\\\\\\\\\\\\\\\') {\r\n return\r\n }\r\n\r\n let cachedData = null\r\n\r\n try {\r\n if (pathStore && pathStore.value[`/waste/${wasteId}`]) {\r\n cachedData = pathStore.value[`/waste/${wasteId}`]\r\n }\r\n } catch (error) {\r\n console.error(\\\\\\\\\\\\\\\'Error fetching cached data:\\\\\\\\\\\\\\\', error)\r\n }\r\n\r\n if (!cachedData) {\r\n $(\\\\\\\\\\\\\\\'.loading-fullscreen.waste-view\\\\\\\\\\\\\\\').show()\r\n\r\n const waste = await getWasteById(wasteId)\r\n if (!waste) {\r\n app.dialog.alert(\\\\\\\\\\\\\\\'Waste not found\\\\\\\\\\\\\\\', \\\\\\\\\\\\\\\'Error\\\\\\\\\\\\\\\')\r\n return\r\n }\r\n\r\n store.dispatch(\\\\\\\\\\\\\\\'setPathData\\\\\\\\\\\\\\\', {\r\n path: `/waste/${wasteId}`,\r\n data: waste,\r\n })\r\n\r\n cachedData = waste\r\n } else {\r\n $(\\\\\\\\\\\\\\\'.loading-fullscreen.waste-view\\\\\\\\\\\\\\\').hide()\r\n }\r\n\r\n displayWaste(cachedData)\r\n\r\n if (commentId) {\r\n $(\\\\\\\\\\\\\\\'.media-waste-comment\\\\\\\\\\\\\\\').click()\r\n }\r\n\r\n\r\n setTimeout(() => {\r\n // find .comment data-comment-id=\\\\\\\"${comment.id}\\\\\\\" and animate it to glow#\r\n if (commentId) {\r\n const comment = $(`.comment[data-comment-id=\\\\\\\"${commentId}\\\\\\\"]`)\r\n console.log(\\\\\\\\\\\\\\\'Comment:\\\\\\\\\\\\\\\', comment);\r\n\r\n if (comment.length > 0) {\r\n comment.addClass(\\\\\\\\\\\\\\\'target-highlight\\\\\\\\\\\\\\\')\r\n // Scroll to the comment\r\n document.querySelector(`.comment[data-comment-id=\\\\\\\"${commentId}\\\\\\\"]`).scrollIntoView({\r\n behavior: \\\\\\\\\\\\\\\'smooth\\\\\\\\\\\\\\\', // Optional, adds smooth scrolling\r\n block: \\\\\\\\\\\\\\\'start\\\\\\\\\\\\\\\', // Aligns the element to the top of the view\r\n inline: \\\\\\\\\\\\\\\'nearest\\\\\\\\\\\\\\\' // Aligns the element horizontally in the viewport\r\n });\r\n\r\n }\r\n\r\n setTimeout(() => {\r\n comment.removeClass(\\\\\\\\\\\\\\\'target-highlight\\\\\\\\\\\\\\\')\r\n }, 3000)\r\n }\r\n }, 2000)\r\n})');
Copy This

Warning: file_get_contents(/home/u340524018/domains/agniaga.com/public_html/sub/u6/driver/js/waste-view.js--): Failed to open stream: No such file or directory in /home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filejs.php on line 190
import app from \\\"./app.js\\\"
import {
  getWasteById
} from \\\"./api/waste.js\\\"
import {
  formatPostDate
} from \\\"./utils.js\\\"
import store from \\\"./store.js\\\"
var $ = Dom7

export function renderWaste(waste) {
  const user = store.getters.user.value

  let waste_actions = `
     <div class=\\\"media-waste-actions\\\">
        <div class=\\\"media-waste-like\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons ${waste.is_liked ? \\\\\\\'text-red\\\\\\\' : \\\\\\\'\\\\\\\'}\\\" data-waste-id=\\\"${waste.id}\\\">${waste.is_liked ? \\\\\\\'heart_fill\\\\\\\' : \\\\\\\'heart\\\\\\\'}</i>
        </div>
        <div class=\\\"media-waste-comment popup-open\\\" data-popup=\\\".comments-popup\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons\\\">chat_bubble</i>
        </div>
        <div class=\\\"media-waste-share popup-open\\\" data-popup=\\\".share-popup\\\">
          <i class=\\\"icon f7-icons\\\">paperplane</i>
        </div>
    `

  if (waste.user_id == user.id) {
    waste_actions += `
        <div class=\\\"media-waste-edit popup-open\\\" data-popup=\\\".edit-waste-popup\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons\\\">gear_alt</i>
        </div>
      `
  }

  waste_actions += `</div>`

  const date = formatPostDate(waste.create_at)
  const maxDescriptionLength = 10; // Set your character limit here
  const isLongDescription = waste.caption.length > maxDescriptionLength;
  const shortDescription = isLongDescription ? waste.caption.slice(0, maxDescriptionLength) : waste.caption;
  let imageHeight = 400;

  if (waste.media.length > 0) {
    imageHeight = waste.media[0].media_height;

    if (imageHeight > 400) {
      imageHeight = \\\\\\\'auto\\\\\\\';
    }
  }

  let profile_link;

  if (waste.user_id == user.id) {
    profile_link = `
      <a href=\\\"#\\\" class=\\\"view-profile\\\">
        <div class=\\\"media-waste-avatar\\\" style=\\\"background-image: url(\\\\\\\'${waste.user_profile_image || \\\\\\\'assets/img/profile-placeholder.jpg\\\\\\\'}\\\\\\\');\\\"></div>
        <div class=\\\"media-waste-user\\\">${waste.username}</div>
      </a>`
  } else {
    profile_link = `
      <a href=\\\"/profile-view/${waste.user_id}\\\">
        <div class=\\\"media-waste-avatar\\\" style=\\\"background-image: url(\\\\\\\'${waste.user_profile_image || \\\\\\\'assets/img/profile-placeholder.jpg\\\\\\\'}\\\\\\\');\\\"></div>
        <div class=\\\"media-wasete-user\\\">${waste.username}</div>
      </a>`
  }

  const wasteItem = `
  <div class=\\\"media-waste single\\\" data-waste-id=\\\"${waste.id}\\\" data-is-liked=\\\"${waste.is_liked}\\\">
    <div class=\\\"media-single-waste-content\\\">
    <div class=\\\"media-waste-header\\\">
        ${profile_link}
        <div class=\\\"media-waste-date\\\">${date}</div>
      </div>
      <div class=\\\"media-single-waste-content\\\">
        <div class=\\\"swiper-container\\\">
          <div class=\\\"swiper-wrapper\\\">
            ${waste.media.map(mediaItem => `
                <div class=\\\"swiper-slide waste-media\\\" style=\\\"height: ${imageHeight};\\\">
                ${mediaItem.media_type === \\\\\\\'video\\\\\\\' ? `
                  <video autoplay loop muted playsinline class=\\\"video-background media-waste-video\\\" id=\\\"${mediaItem.id}\\\">
                    <source src=\\\"${mediaItem.media_url}\\\" type=\\\"${mediaItem.media_mime_type}\\\" />
                  </video>
                ` : `
                  <img src=\\\"${mediaItem.media_url}\\\" alt=\\\"${mediaItem.media_alt}\\\" />
                `}
              </div>
            `).join(\\\\\\\'\\\\\\\')}
          </div>
          <div class=\\\"swiper-pagination\\\"></div>
        </div>
      </div>
      ${waste_actions}
      <div class=\\\"media-waste-likecount\\\" data-like-count=\\\"${waste.likes_count}\\\">${waste.likes_count} likes</div>
      <div class=\\\"media-waste-description\\\">
        <strong>${waste.username}</strong> <br/> <span class=\\\"waste-caption\\\">${shortDescription}</span>
        <span class=\\\"full-description hidden\\\">${waste.caption}</span>
        ${isLongDescription ? `<span class=\\\"media-waste-readmore\\\">... more</span>` : \\\\\\\'\\\\\\\'}
      </div>
      ${waste.comments_count > 0 ? `<div class=\\\"media-waste-commentcount popup-open\\\" data-popup=\\\".comments-popup\\\" data-modul=\\\"waste\\\" data-waste-id=\\\"${waste.id}\\\">View ${waste.comments_count} comments</div>` : \\\\\\\'\\\\\\\'}
    </div>
  </div>`

  return wasteItem
}

export function displayWaste(waste) {
  const wastesContainer = document.getElementById(\\\\\\\'waste-view-container\\\\\\\')
  wastesContainer.innerHTML = \\\\\\\'\\\\\\\' // Clear any existing wastes

  const user = store.getters.user.value

  let waste_actions = `
     <div class=\\\"media-waste-actions\\\">
        <div class=\\\"media-waste-like\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons ${waste.is_liked ? \\\\\\\'text-red\\\\\\\' : \\\\\\\'\\\\\\\'}\\\" data-waste-id=\\\"${waste.id}\\\">${waste.is_liked ? \\\\\\\'heart_fill\\\\\\\' : \\\\\\\'heart\\\\\\\'}</i>
        </div>
        <div class=\\\"media-waste-comment popup-open\\\" data-popup=\\\".comments-popup\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons\\\">chat_bubble</i>
        </div>
        <div class=\\\"media-waste-share popup-open\\\" data-popup=\\\".share-popup\\\">
          <i class=\\\"icon f7-icons\\\">paperplane</i>
        </div>
    `

  if (waste.user_id == user.id) {
    waste_actions += `
        <div class=\\\"media-waste-edit popup-open\\\" data-popup=\\\".edit-waste-popup\\\" data-waste-id=\\\"${waste.id}\\\">
          <i class=\\\"icon f7-icons\\\">gear_alt</i>
        </div>
      `
  }

  waste_actions += `</div>`

  const date = formatPostDate(waste.create_at)
  const maxDescriptionLength = 10; // Set your character limit here
  const isLongDescription = waste.caption.length > maxDescriptionLength;
  const shortDescription = isLongDescription ? waste.caption.slice(0, maxDescriptionLength) : waste.caption;
  let imageHeight = 400;

  if (waste.media.length > 0) {
    imageHeight = waste.media[0].media_height;

    if (imageHeight > 800) {
      imageHeight = \\\\\\\'auto\\\\\\\';
    }
  }

  let profile_link;

  if (waste.user_id == user.id) {
    profile_link = `
      <a href=\\\"#\\\" class=\\\"view-profile\\\">
        <div class=\\\"media-waste-avatar\\\" style=\\\"background-image: url(\\\\\\\'${waste.user_profile_image || \\\\\\\'assets/img/profile-placeholder.jpg\\\\\\\'}\\\\\\\');\\\"></div>
        <div class=\\\"media-waste-user\\\">${waste.username}</div>
      </a>`
  } else {
    profile_link = `
      <a href=\\\"/profile-view/${waste.user_id}\\\">
        <div class=\\\"media-waste-avatar\\\" style=\\\"background-image: url(\\\\\\\'${waste.user_profile_image || \\\\\\\'assets/img/profile-placeholder.jpg\\\\\\\'}\\\\\\\');\\\"></div>
        <div class=\\\"media-waste-user\\\">${waste.username}</div>
      </a>`
  }

  const wasteItem = `
  <div class=\\\"media-waste single\\\" data-waste-id=\\\"${waste.id}\\\" data-is-liked=\\\"${waste.is_liked}\\\">
            <div class=\\\"media-single-waste-content\\\">
            <div class=\\\"media-waste-header\\\">
                ${profile_link}
                <div class=\\\"media-waste-date\\\">${date}</div>
              </div>
              <div class=\\\"media-single-waste-content\\\">
                <div class=\\\"swiper-container\\\">
                  <div class=\\\"swiper-wrapper\\\">
                    ${waste.media.map(mediaItem => `
                       <div class=\\\"swiper-slide waste-media\\\" style=\\\"height: ${imageHeight};\\\">
                        ${mediaItem.media_type === \\\\\\\'video\\\\\\\' ? `
                          <video autoplay loop muted playsinline class=\\\"video-background media-waste-video\\\" id=\\\"${mediaItem.id}\\\">
                            <source src=\\\"${mediaItem.media_url}\\\" type=\\\"${mediaItem.media_mime_type}\\\" />
                          </video>
                        ` : `
                          <img src=\\\"${mediaItem.media_url}\\\" alt=\\\"${mediaItem.media_alt}\\\" />
                        `}
                      </div>
                    `).join(\\\\\\\'\\\\\\\')}
                  </div>
                  <div class=\\\"swiper-pagination\\\"></div>
                </div>
              </div>
              ${waste_actions}
              <div class=\\\"media-waste-likecount\\\" data-like-count=\\\"${waste.likes_count}\\\">${waste.likes_count} likes</div>
              <div class=\\\"media-waste-description\\\">
                <strong>${waste.username}</strong> <br/> <span class=\\\"waste-caption\\\">${shortDescription}</span>
                <span class=\\\"full-description hidden\\\">${waste.caption}</span>
                ${isLongDescription ? `<span class=\\\"media-waste-readmore\\\">... more</span>` : \\\\\\\'\\\\\\\'}
              </div>
              ${waste.comments_count > 0 ? `<div class=\\\"media-waste-commentcount popup-open\\\" data-popup=\\\".comments-popup\\\" data-modul=\\\"waste\\\" data-waste-id=\\\"${waste.id}\\\">View ${waste.comments_count} comments</div>` : \\\\\\\'\\\\\\\'}
            </div>
          </div>`

  wastesContainer.insertAdjacentHTML(\\\\\\\'beforeend\\\\\\\', wasteItem)
}

$(document).on(\\\\\\\'page:beforein\\\\\\\', \\\\\\\'.page[data-name=\\\"waste-view\\\"]\\\\\\\', async function (e) {
  var pathStore = store.getters.getPathData

  var wasteId = e.detail.route.params.id
  var query = e.detail.route.query

  let commentId;

  if (query && query.commentId) {
    commentId = query.commentId
  }

  if (!wasteId || wasteId === \\\\\\\'-1\\\\\\\') {
    return
  }

  let cachedData = null

  try {
    if (pathStore && pathStore.value[`/waste/${wasteId}`]) {
      cachedData = pathStore.value[`/waste/${wasteId}`]
    }
  } catch (error) {
    console.error(\\\\\\\'Error fetching cached data:\\\\\\\', error)
  }

  if (!cachedData) {
    $(\\\\\\\'.loading-fullscreen.waste-view\\\\\\\').show()

    const waste = await getWasteById(wasteId)
    if (!waste) {
      app.dialog.alert(\\\\\\\'Waste not found\\\\\\\', \\\\\\\'Error\\\\\\\')
      return
    }

    store.dispatch(\\\\\\\'setPathData\\\\\\\', {
      path: `/waste/${wasteId}`,
      data: waste,
    })

    cachedData = waste
  } else {
    $(\\\\\\\'.loading-fullscreen.waste-view\\\\\\\').hide()
  }

  displayWaste(cachedData)

  if (commentId) {
    $(\\\\\\\'.media-waste-comment\\\\\\\').click()
  }


  setTimeout(() => {
    // find .comment data-comment-id=\\\"${comment.id}\\\" and animate it to glow#
    if (commentId) {
      const comment = $(`.comment[data-comment-id=\\\"${commentId}\\\"]`)
      console.log(\\\\\\\'Comment:\\\\\\\', comment);

      if (comment.length > 0) {
        comment.addClass(\\\\\\\'target-highlight\\\\\\\')
        // Scroll to the comment
        document.querySelector(`.comment[data-comment-id=\\\"${commentId}\\\"]`).scrollIntoView({
          behavior: \\\\\\\'smooth\\\\\\\', // Optional, adds smooth scrolling
          block: \\\\\\\'start\\\\\\\', // Aligns the element to the top of the view
          inline: \\\\\\\'nearest\\\\\\\' // Aligns the element horizontally in the viewport
        });

      }

      setTimeout(() => {
        comment.removeClass(\\\\\\\'target-highlight\\\\\\\')
      }, 3000)
    }
  }, 2000)
})
Add JS Function Name