Skip to content

Commit

Permalink
😎 Words & Attachments are more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Aug 7, 2022
1 parent 61b1290 commit d5492db
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
29 changes: 24 additions & 5 deletions components/Data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1573,11 +1573,11 @@ export default function Data(props: any): JSX.Element {
toast(
<div className="Toastify__toast-body_">
<span className="font-bold text-lg text-black dark:text-white">
{data?.dataFile ? "Their" : "Your"} total
{data?.dataFile ? "Their " : "Your "}
attachment
{data.messages.oldestMessages.length === 1
? " is"
: "s are"}
? ""
: "s"}
:
</span>
<br />
Expand All @@ -1586,7 +1586,26 @@ export default function Data(props: any): JSX.Element {
(f: any, i: number) => {
return (
<li key={i}>
<b>{f}</b>
<a
target="_blank"
rel="noreferrer"
href={f}
id={f}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={f}
alt="attachment"
className="max-h-[200px] max-w-[600px] py-1"
onError={() => {
const img: any =
document.getElementById(f);
if (img)
img.innerHTML = `<p class="text-black dark:text-white font-bold py-1">${f}</p>`;
img.href = "#";
}}
/>
</a>
</li>
);
}
Expand Down Expand Up @@ -8910,7 +8929,7 @@ export default function Data(props: any): JSX.Element {
{data?.dataFile ? "Their" : "Your"} Discord Bots
</span>
</div>
<div className="grid xl:grid-cols-8 xl2:grid-cols-6 lg:grid-cols-6 md1:grid-cols-4 xl1:grid-cols-4 grid-cols-6 justify-items-center">
<div className="grid xl:grid-cols-8 xl2:grid-cols-6 xl3:grid-cols-8 lg:grid-cols-6 md1:grid-cols-4 xl1:grid-cols-4 grid-cols-6 justify-items-center">
{data?.bots && data?.bots?.length > 0
? data.bots
.sort((a: any, b: any) => {
Expand Down
28 changes: 16 additions & 12 deletions components/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ export default function Upload(): ReactElement {

const favoriteWords = Utils.getFavoriteWords(words);
const curseWords = Utils.getCursedWords(
words.filter((w: any) => w.length < 10)
words.filter((w: any) => w.length < 10 && !/[^\w\s]/g.test(w))
);
const topCursed = curseWords;
const links = Utils.getTopLinks(words);
Expand Down Expand Up @@ -1145,7 +1145,7 @@ export default function Upload(): ReactElement {
});
const favoriteWords = Utils.getFavoriteWords(words);
const curseWords = Utils.getCursedWords(
words.filter((w: any) => w.length < 10)
words.filter((w: any) => w.length < 10 && !/[^\w\s]/g.test(w))
);
const topCursed = curseWords;
const links = Utils.getTopLinks(words);
Expand Down Expand Up @@ -1291,7 +1291,7 @@ export default function Upload(): ReactElement {

const favoriteWords = Utils.getFavoriteWords(words);
const curseWords = Utils.getCursedWords(
words.filter((w: any) => w.length < 10)
words.filter((w: any) => w.length < 10 && !/[^\w\s]/g.test(w))
);
const topCursed = curseWords;
const links = Utils.getTopLinks(words);
Expand Down Expand Up @@ -1513,7 +1513,7 @@ export default function Upload(): ReactElement {

const favoriteWords = Utils.getFavoriteWords(words);
const curseWords = Utils.getCursedWords(
words.filter((w: any) => w.length < 10)
words.filter((w: any) => w.length < 10 && !/[^\w\s]/g.test(w))
);
const topCursed = curseWords;
const links = Utils.getTopLinks(words);
Expand Down Expand Up @@ -1733,16 +1733,20 @@ export default function Upload(): ReactElement {
return regex.test(word);
});

//remove everything before the http and after the extension example .pmg
const attachmentsClean = attachments.map(
// replace everything before and after the regex with ""
const attachmentsCleaned = attachments.map(
(attachment: any) => {
return attachment.replace(
/(https?:\/\/.*\.(?:png|jpg|jpeg|gif|mp4|pdf|zip|wmv|mp3|nitf|doc|docx))/gi,
"$1"
);
const mtch = regex.test(attachment)
? attachment.match(regex)[0]
: null;

if (mtch && mtch.length > 25) return mtch;
}
);
return attachmentsClean;

return attachmentsCleaned.filter(
(s: Array<any>) => s && s.length > 0
);
})
.flat();

Expand Down Expand Up @@ -2125,7 +2129,7 @@ export default function Upload(): ReactElement {
setPercent(76);

const curseWords = Utils.getCursedWords(
words.filter((w: any) => w.length < 10)
words.filter((w: any) => w.length < 10 && !/[^\w\s]/g.test(w))
);
data.messages.topCursed = curseWords;
if (isDebug)
Expand Down
1 change: 1 addition & 0 deletions pages/styles/toastify.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
xl: "1310px",
xl1: "1278px",
xl2: "1400px",
xl3: "1669px",
...defaultTheme.screens,
},
},
Expand Down

1 comment on commit d5492db

@vercel
Copy link

@vercel vercel bot commented on d5492db Aug 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.