Skip to content

Commit

Permalink
adding date converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Arasteh authored Dec 1, 2024
1 parent c51effc commit e85cdde
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<div v-if="filteredWords.length > 0" class="results-grid">
<div class="movie-card" v-for="(word, index) in filteredWords" :key="index">
<img :src="getImageUrl(word)" :alt="word.filmLabel" class="movie-image" />
<div class="movie-title" v-html="word.filmLabel" v-html="word.publicationYear"></div>
<div class="movie-title" v-html="word.filmLabel"></div><div class="movie-title" v-html="word.publicationYear"></div> <div class="movie-title">{{ getMovieTitleWithYear(word) }}</div>
<div class="movie-links">
<a :href="getImdbLink(word.imdbID)" target="_blank">T</a>
<a :href="getWikidataLink(word.film)" target="_blank">Q</a>
Expand Down Expand Up @@ -139,7 +139,18 @@
'غ': '[عغ]', 'ف': '[فق]', 'ق': '[فق]', 'ک': '[کگ]',
'گ': '[کگ]'
};

const toPersianYear = (gregorianYear) => {
const gYear = parseInt(gregorianYear, 10);
if (isNaN(gYear)) return null;
return gYear - 621;
};

const getMovieTitleWithYear = (word) => {
const shamsiYear = toPersianYear(word.publicationYear);
return shamsiYear ? `${word.filmLabel} (${shamsiYear})` : word.filmLabel;
};

const filteredWords = computed(() => {
if (searchTerm.value.length < 2) return [];
let modifiedSearchTerm = searchTerm.value;
Expand Down Expand Up @@ -188,7 +199,7 @@
const getImdbLink = (imdbID) => `https://www.imdb.com/title/${imdbID}`;
const getWikidataLink = (film) => film;

return { searchTerm, combineSimilarChars, posterMode, filteredWords, getImageUrl, getImdbLink, getWikidataLink };
return { searchTerm, combineSimilarChars, posterMode, filteredWords, getImageUrl, getImdbLink, getWikidataLink, getMovieTitleWithYear };
}
}).mount('#app');
</script>
Expand Down

0 comments on commit e85cdde

Please sign in to comment.