From f91e5fe8382a0f9feba7570d86ed60d5fb8077ec Mon Sep 17 00:00:00 2001 From: Valentin Porcellini Date: Tue, 10 Sep 2024 11:48:58 +0200 Subject: [PATCH] Removed vars --- src/Hooks/useInput.jsx | 2 +- .../AssistantVideoResult.jsx | 4 +- .../NavItems/tools/Analysis/Analysis.jsx | 18 ++-- .../Analysis/Results/AnalysisComments.jsx | 20 ++--- .../tools/C2pa/Results/C2paResults.jsx | 16 ++-- .../tools/Deepfake/Hooks/useGetDeepfake.jsx | 3 +- .../Deepfake/Results/DeepfakeResultsVideo.jsx | 6 +- .../tools/Forensic/Hooks/useGetImages.jsx | 7 +- .../NavItems/tools/Gif/AnimatedGif.jsx | 4 +- .../NavItems/tools/Gif/CheckGif.jsx | 84 +++++++++---------- .../tools/Gif/Hooks/useGetHomographics.jsx | 10 +-- .../Keyframes/Hooks/useVideoSimilarity.jsx | 2 +- .../NavItems/tools/OCR/Results/OcrResult.jsx | 6 +- .../NavItems/tools/Thumbnails/Thumbnails.jsx | 16 ++-- src/components/PopUp/PopUp.jsx | 14 ++-- .../GoogleAnalytics/GoogleAnalytics.jsx | 21 ++--- .../ReverseSearch/engines/google-lens.jsx | 16 ++-- 17 files changed, 128 insertions(+), 121 deletions(-) diff --git a/src/Hooks/useInput.jsx b/src/Hooks/useInput.jsx index 346c9a470..47758c14e 100644 --- a/src/Hooks/useInput.jsx +++ b/src/Hooks/useInput.jsx @@ -28,7 +28,7 @@ export const loadImageSize = (resultData, cols) => { let height = 0; let colsWidth = 1180 / cols; if (Array.isArray(resultData) && resultData.length) { - var img = new Image(); + const img = new Image(); img.src = resultData[0]; height = (colsWidth * img.height) / img.width; if (img.width !== 0 && img.height !== 0) { diff --git a/src/components/NavItems/Assistant/AssistantScrapeResults/AssistantVideoResult.jsx b/src/components/NavItems/Assistant/AssistantScrapeResults/AssistantVideoResult.jsx index 11954d0ab..1f79a3e26 100644 --- a/src/components/NavItems/Assistant/AssistantScrapeResults/AssistantVideoResult.jsx +++ b/src/components/NavItems/Assistant/AssistantScrapeResults/AssistantVideoResult.jsx @@ -56,6 +56,8 @@ const AssistantVideoResult = () => { return null; } + let positionTwo; + switch (input_url_type) { case KNOWN_LINKS.YOUTUBE: if (!embedURL.includes("/embed/")) { @@ -72,7 +74,7 @@ const AssistantVideoResult = () => { case KNOWN_LINKS.VIMEO: stringToMatch = "vimeo.com/"; positionOne = processUrl.indexOf(stringToMatch); - var positionTwo = positionOne + stringToMatch.length; + positionTwo = positionOne + stringToMatch.length; embedURL = embedURL.slice(0, positionOne) + "player." + diff --git a/src/components/NavItems/tools/Analysis/Analysis.jsx b/src/components/NavItems/tools/Analysis/Analysis.jsx index 6f8f71ab9..940fd1065 100644 --- a/src/components/NavItems/tools/Analysis/Analysis.jsx +++ b/src/components/NavItems/tools/Analysis/Analysis.jsx @@ -70,7 +70,7 @@ const Analysis = () => { isLoading, ); - var [warning, setWarning] = useState(false); + const [warning, setWarning] = useState(false); const reprocessToggle = () => { setReprocess(!reprocess); @@ -86,12 +86,12 @@ const Analysis = () => { ); const submitForm = () => { /*trackEvent( - "submission", - "analysis", - "video caa analysis", - input.trim(), - client_id - );*/ + "submission", + "analysis", + "video caa analysis", + input.trim(), + client_id + );*/ setSubmittedUrl(input.trim()); dispatch(cleanAnalysisState()); }; @@ -155,8 +155,8 @@ const Analysis = () => { setInput(e.target.value); const regex = /fb.watch\//g; //const regex1 = /www.facebook.com\/watch\//g; - var found = e.target.value.match(regex); - //var found1 =e.target.value.match(regex1); + const found = e.target.value.match(regex); + //const found1 =e.target.value.match(regex1); //if(found!==null || found1!==null ){ if (found !== null) { setWarning(true); diff --git a/src/components/NavItems/tools/Analysis/Results/AnalysisComments.jsx b/src/components/NavItems/tools/Analysis/Results/AnalysisComments.jsx index 1e3c2c976..73197ec8c 100644 --- a/src/components/NavItems/tools/Analysis/Results/AnalysisComments.jsx +++ b/src/components/NavItems/tools/Analysis/Results/AnalysisComments.jsx @@ -32,19 +32,19 @@ const CommentsPanel = (props) => { const classes = props.classes; const keyword = props.keyword; - var nextPage = props.report.pagination.next; - var totalPage = Math.ceil(props.nb_comments / 10); + const nextPage = props.report.pagination.next; + const totalPage = Math.ceil(props.nb_comments / 10); const url = useState(nextPage); - var last_page_all_comments; + let last_page_all_comments; if (props.nb_comments !== 0) { last_page_all_comments = totalPage; } else { last_page_all_comments = 1; } - var index = 0; - var real; + let index = 0; + let real; - for (var i = 0; i < url[0].length; i++) { + for (let i = 0; i < url[0].length; i++) { if (url[0][i] === "=") { index = index + 1; if (index === 2) { @@ -53,22 +53,22 @@ const CommentsPanel = (props) => { } } } - var next_page_comments = + const next_page_comments = url[0].substring(0, real + 1) + (count_comments + 1) + "&type=" + props.com_type; - var previous_page_comments = + const previous_page_comments = url[0].substring(0, real + 1) + (count_comments - 1) + "&type=" + props.com_type; - var last_page_all_comments1 = + const last_page_all_comments1 = url[0].substring(0, real + 1) + last_page_all_comments + "&type=" + props.com_type; - var first_page_all_comments1 = + const first_page_all_comments1 = url[0].substring(0, real + 1) + 1 + "&type=" + props.com_type; const handleClick_first_page = () => { diff --git a/src/components/NavItems/tools/C2pa/Results/C2paResults.jsx b/src/components/NavItems/tools/C2pa/Results/C2paResults.jsx index c3d267793..903230ff8 100644 --- a/src/components/NavItems/tools/C2pa/Results/C2paResults.jsx +++ b/src/components/NavItems/tools/C2pa/Results/C2paResults.jsx @@ -1,19 +1,19 @@ import { + Accordion, + AccordionDetails, + AccordionSummary, Alert, Box, + Button, Card, CardContent, CardHeader, Divider, Grid, - Stack, - Typography, IconButton, - Button, - Accordion, - AccordionDetails, - AccordionSummary, + Stack, Tooltip, + Typography, } from "@mui/material"; import { @@ -26,7 +26,7 @@ import { useDispatch, useSelector } from "react-redux"; import { c2paCurrentImageIdSet } from "redux/reducers/tools/c2paReducer"; import moment from "moment"; import { i18nLoadNamespace } from "components/Shared/Languages/i18nLoadNamespace"; -import { MapContainer, Marker, Popup, TileLayer } from "react-leaflet"; +import { MapContainer, Marker, TileLayer } from "react-leaflet"; import { Icon as GeoIcon } from "leaflet"; import { useEffect, useState } from "react"; import MapIcon from "@mui/icons-material/Map"; @@ -76,7 +76,7 @@ const C2paResults = (props = { result, handleClose }) => { }; useEffect(() => { - var testImage = new Image(); + const testImage = new Image(); testImage.src = url; testImage.onload = function () { setIsImage(true); diff --git a/src/components/NavItems/tools/Deepfake/Hooks/useGetDeepfake.jsx b/src/components/NavItems/tools/Deepfake/Hooks/useGetDeepfake.jsx index 1112ad592..e49d3e846 100644 --- a/src/components/NavItems/tools/Deepfake/Hooks/useGetDeepfake.jsx +++ b/src/components/NavItems/tools/Deepfake/Hooks/useGetDeepfake.jsx @@ -63,9 +63,10 @@ async function UseGetDeepfake( } try { + let bodyFormData; switch (type) { case "local": - var bodyFormData = new FormData(); + bodyFormData = new FormData(); bodyFormData.append("file", mediaFile); res = await axios.post(baseURL + modeURL + "jobs", bodyFormData, { method: "post", diff --git a/src/components/NavItems/tools/Deepfake/Results/DeepfakeResultsVideo.jsx b/src/components/NavItems/tools/Deepfake/Results/DeepfakeResultsVideo.jsx index 69c1b9ac2..d39b16af9 100644 --- a/src/components/NavItems/tools/Deepfake/Results/DeepfakeResultsVideo.jsx +++ b/src/components/NavItems/tools/Deepfake/Results/DeepfakeResultsVideo.jsx @@ -93,8 +93,8 @@ const DeepfakeResultsVideo = (props) => { ); useEffect(() => { - var prediction = results.deepfake_video_report.prediction; - var shot = -1; + const prediction = results.deepfake_video_report.prediction; + let shot = -1; if ( !results || @@ -105,7 +105,7 @@ const DeepfakeResultsVideo = (props) => { } for ( - var i = 0; + let i = 0; i < results.deepfake_video_report.results.length && shot === -1; i++ ) { diff --git a/src/components/NavItems/tools/Forensic/Hooks/useGetImages.jsx b/src/components/NavItems/tools/Forensic/Hooks/useGetImages.jsx index cf90aedea..d615a0abc 100644 --- a/src/components/NavItems/tools/Forensic/Hooks/useGetImages.jsx +++ b/src/components/NavItems/tools/Forensic/Hooks/useGetImages.jsx @@ -2,9 +2,9 @@ import { useEffect } from "react"; import axios from "axios"; import { useDispatch } from "react-redux"; import { + setForensicDisplayItem, setForensicsLoading, setForensicsResult, - setForensicDisplayItem, } from "../../../../../redux/actions/tools/forensicActions"; import { setError } from "redux/reducers/errorReducer"; @@ -73,9 +73,12 @@ const useGetImages = (url, type, keyword) => { const configService = (type) => { const services = "adq1,blk,cagi,cfa,cmfd,dct,ela,fusion,ghost,laplacian,mantranet,median,rcmfd,splicebuster,wavelet,zero,mmfusion,trufor,omgfuser"; + + let bodyFormData; + switch (type) { case "local": - var bodyFormData = new FormData(); + bodyFormData = new FormData(); bodyFormData.append("file", url); return { diff --git a/src/components/NavItems/tools/Gif/AnimatedGif.jsx b/src/components/NavItems/tools/Gif/AnimatedGif.jsx index 5ed5091a0..66e6648d5 100644 --- a/src/components/NavItems/tools/Gif/AnimatedGif.jsx +++ b/src/components/NavItems/tools/Gif/AnimatedGif.jsx @@ -41,7 +41,7 @@ const AnimatedGif = ({ setIntervalVar(setInterval(() => animateImages(), speed)); } else { setIntervalVar(null); - var x = document.getElementById("gifFilterElement"); + const x = document.getElementById("gifFilterElement"); x.style.display = "none"; } @@ -77,7 +77,7 @@ const AnimatedGif = ({ function animateImages() { //console.log("Loop function" + interval); //DEBUG //console.log(interval); //DEBUG - var x = document.getElementById("gifFilterElement"); + const x = document.getElementById("gifFilterElement"); if (x.style.display === "none") { x.style.display = "block"; diff --git a/src/components/NavItems/tools/Gif/CheckGif.jsx b/src/components/NavItems/tools/Gif/CheckGif.jsx index 3ad2a666e..62809c3c3 100644 --- a/src/components/NavItems/tools/Gif/CheckGif.jsx +++ b/src/components/NavItems/tools/Gif/CheckGif.jsx @@ -125,7 +125,7 @@ const CheckGif = () => { //Load by drop const handleDrop = (files) => { //console.log(files);//DEBUG - var urlFile = URL.createObjectURL(files[0]); + const urlFile = URL.createObjectURL(files[0]); setImageDropped1(urlFile); setSelectedFile1(files[0]); setShowDropZone1(false); @@ -134,7 +134,7 @@ const CheckGif = () => { //Load by Click const handleInput = (event) => { //console.log(event);//DEBUG - var urlFile = URL.createObjectURL(event.target.files[0]); + const urlFile = URL.createObjectURL(event.target.files[0]); setImageDropped1(urlFile); setSelectedFile1(event.target.files[0]); setShowDropZone1(false); @@ -145,7 +145,7 @@ const CheckGif = () => { //Load by drop const handleDrop2 = (files) => { //console.log(files);//DEBUG - var urlFile = URL.createObjectURL(files[0]); + const urlFile = URL.createObjectURL(files[0]); setImageDropped2(urlFile); setSelectedFile2(files[0]); setShowDropZone2(false); @@ -154,7 +154,7 @@ const CheckGif = () => { //Load by clikc const handleInput2 = (event) => { //console.log(event);//DEBUG - var urlFile = URL.createObjectURL(event.target.files[0]); + const urlFile = URL.createObjectURL(event.target.files[0]); setImageDropped2(urlFile); setSelectedFile2(event.target.files[0]); setShowDropZone2(false); @@ -182,15 +182,15 @@ const CheckGif = () => { //Code to enable the button to upload the images /* if (toolState === 22 && imageURL1 !== "" && imageURL2 !== "") { - //console.log("Ready to send"); //DEBUG - dispatch(setStateReady()); - }*/ + //console.log("Ready to send"); //DEBUG + dispatch(setStateReady()); + }*/ //Code to enable the button to upload the images /* if (toolState === 21 && imageDropped1 !== null && imageDropped2 !== null) { - //console.log("Ready to send"); //DEBUG - dispatch(setStateReady()); - }*/ + //console.log("Ready to send"); //DEBUG + dispatch(setStateReady()); + }*/ useEffect(() => { if (toolState === 22 && imageURL1 !== "" && imageURL2 !== "") { @@ -242,23 +242,23 @@ const CheckGif = () => { setEventUrl2(imageURL2); setEventUrlType2("url original image"); /*trackEvent( - "submission", - "checkgif", - "url fake image", - imageURL1, - client_id, - uid - ); - trackEvent( - "submission", - "checkgif", - "url original image", - imageURL2, - client_id, - uid - );*/ + "submission", + "checkgif", + "url fake image", + imageURL1, + client_id, + uid + ); + trackEvent( + "submission", + "checkgif", + "url original image", + imageURL2, + client_id, + uid + );*/ /*submissionEvent(imageURL1); - submissionEvent(imageURL2);*/ + submissionEvent(imageURL2);*/ const files = { url_0: imageURL1, url_1: imageURL2, @@ -273,23 +273,23 @@ const CheckGif = () => { setEventUrl2(selectedFile2); setEventUrlType2("file original image"); /* trackEvent( - "submission", - "checkgif", - "file fake image", - selectedFile1, - client_id, - uid - ); - trackEvent( - "submission", - "checkgif", - "file original image", - selectedFile2, - client_id, - uid - );*/ + "submission", + "checkgif", + "file fake image", + selectedFile1, + client_id, + uid + ); + trackEvent( + "submission", + "checkgif", + "file original image", + selectedFile2, + client_id, + uid + );*/ /*submissionEvent(selectedFile1); - submissionEvent(selectedFile2);*/ + submissionEvent(selectedFile2);*/ const files = { file1: selectedFile1, file2: selectedFile2, diff --git a/src/components/NavItems/tools/Gif/Hooks/useGetHomographics.jsx b/src/components/NavItems/tools/Gif/Hooks/useGetHomographics.jsx index 4e21ee2c4..21d9d3200 100644 --- a/src/components/NavItems/tools/Gif/Hooks/useGetHomographics.jsx +++ b/src/components/NavItems/tools/Gif/Hooks/useGetHomographics.jsx @@ -1,9 +1,9 @@ import { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { + setStateError, setStateLoading, setStateShow, - setStateError, } from "../../../../../redux/reducers/tools/gifReducer"; import { setError } from "redux/reducers/errorReducer"; import useAuthenticatedRequest from "../../../../Shared/Authentication/useAuthenticatedRequest"; @@ -50,8 +50,8 @@ const useGetHomographics = (files, mode, keyword) => { handleError("error_server"); } } else { - var homoImage1 = baseURL + response.data.results.output0; - var homoImage2 = baseURL + response.data.results.output1; + const homoImage1 = baseURL + response.data.results.output0; + const homoImage2 = baseURL + response.data.results.output1; dispatch( setStateShow({ @@ -70,7 +70,7 @@ const useGetHomographics = (files, mode, keyword) => { //console.log(files.file1); //console.log(files.file2); - var bodyFormData = new FormData(); + const bodyFormData = new FormData(); bodyFormData.append("file_0", files.file1); bodyFormData.append("file_1", files.file2); @@ -97,7 +97,7 @@ const useGetHomographics = (files, mode, keyword) => { //console.log(files.file1); //console.log(files.file2); - var bodyUrlFormData = new URLSearchParams(); + const bodyUrlFormData = new URLSearchParams(); bodyUrlFormData.append("url_0", files.url_0); bodyUrlFormData.append("url_1", files.url_1); diff --git a/src/components/NavItems/tools/Keyframes/Hooks/useVideoSimilarity.jsx b/src/components/NavItems/tools/Keyframes/Hooks/useVideoSimilarity.jsx index cf581ede5..b620e358c 100644 --- a/src/components/NavItems/tools/Keyframes/Hooks/useVideoSimilarity.jsx +++ b/src/components/NavItems/tools/Keyframes/Hooks/useVideoSimilarity.jsx @@ -15,7 +15,7 @@ export const useVideoSimilarity = (url, keyword) => { .get(dbkfApiUrl) .then((response) => { //console.log(response); - var resultData = []; + const resultData = []; Object.values(response.data).forEach((value) => { resultData.push(value); diff --git a/src/components/NavItems/tools/OCR/Results/OcrResult.jsx b/src/components/NavItems/tools/OCR/Results/OcrResult.jsx index 234867725..106005fd5 100644 --- a/src/components/NavItems/tools/OCR/Results/OcrResult.jsx +++ b/src/components/NavItems/tools/OCR/Results/OcrResult.jsx @@ -60,8 +60,8 @@ const OcrResult = () => { const mainImageId = "ocrMainImageId"; /* if (!scripts) { - dispatch(loadOcrScripts()) - }*/ + dispatch(loadOcrScripts()) + }*/ const handleScriptChange = (event) => { dispatch(setSelectedScript(event.target.value)); @@ -166,7 +166,7 @@ const OcrResult = () => { dispatch(resetOcrState()); } }, [fail, errorKey]); - var ro = new ResizeObserver(() => { + const ro = new ResizeObserver(() => { handleImageResizing(); }); // when the result comes in, draw the bounding boxes and add the event listener for changes to image size diff --git a/src/components/NavItems/tools/Thumbnails/Thumbnails.jsx b/src/components/NavItems/tools/Thumbnails/Thumbnails.jsx index eeb166db7..f90daa171 100644 --- a/src/components/NavItems/tools/Thumbnails/Thumbnails.jsx +++ b/src/components/NavItems/tools/Thumbnails/Thumbnails.jsx @@ -54,7 +54,7 @@ const Thumbnails = () => { const [showResult, setShowResult] = useState(false); const [input, setInput] = useState(resultUrl); const [urlDetected, setUrlDetected] = useState(false); - var cols = 3; + const cols = 3; const dispatch = useDispatch(); @@ -141,13 +141,13 @@ const Thumbnails = () => { if (url !== null && url !== "" && isYtUrl(url)) { setEventUrl(url); /*trackEvent( - "submission", - "thumbnails", - "youtube thumbnail", - url, - client_id, - uid - );*/ + "submission", + "thumbnails", + "youtube thumbnail", + url, + client_id, + uid + );*/ let images = get_images(url); dispatch( setThumbnailsResult({ diff --git a/src/components/PopUp/PopUp.jsx b/src/components/PopUp/PopUp.jsx index e523fea20..4aed2d893 100644 --- a/src/components/PopUp/PopUp.jsx +++ b/src/components/PopUp/PopUp.jsx @@ -28,13 +28,13 @@ const PopUp = () => { const createScript = () => { let script = - 'var images = document.getElementsByTagName("img")\n' + - "var image_meta = document.querySelector('meta[property=\"og:image\"]') \n" + - "var video_meta = document.querySelector('meta[property=\"og:video\"]') \n" + - "var text_meta = document.querySelector('meta[property=\"og:title\"]') \n" + - 'var text_found = text_meta ? text_meta.content : ""\n' + - 'var video_found = video_meta ? video_meta.content : ""\n' + - 'var image = image_meta ? image_meta.content : ""\n' + + 'const images = document.getElementsByTagName("img")\n' + + "const image_meta = document.querySelector('meta[property=\"og:image\"]') \n" + + "const video_meta = document.querySelector('meta[property=\"og:video\"]') \n" + + "const text_meta = document.querySelector('meta[property=\"og:title\"]') \n" + + 'const text_found = text_meta ? text_meta.content : ""\n' + + 'const video_found = video_meta ? video_meta.content : ""\n' + + 'const image = image_meta ? image_meta.content : ""\n' + "results;\n"; return script; }; diff --git a/src/components/Shared/GoogleAnalytics/GoogleAnalytics.jsx b/src/components/Shared/GoogleAnalytics/GoogleAnalytics.jsx index 568732f7c..d2f644e57 100644 --- a/src/components/Shared/GoogleAnalytics/GoogleAnalytics.jsx +++ b/src/components/Shared/GoogleAnalytics/GoogleAnalytics.jsx @@ -1,7 +1,7 @@ import { history } from "../History/History"; export function submissionEvent(payload) { - var pathname = history.location.pathname; + const pathname = history.location.pathname; console.log("pathname ", pathname); let events = [ { @@ -27,10 +27,10 @@ export function submissionEvent(payload) { }; matomoCall(actions); /*ReactGA.event({ - category: 'Submission', - action: 'Submitted from ' + history.location.pathname, - label: payload - });*/ + category: 'Submission', + action: 'Submitted from ' + history.location.pathname, + label: payload + });*/ } export function reverseSearchClick() { @@ -45,15 +45,16 @@ export function reverseSearchClick() { // }, // ]; /* ReactGA.event({ - category: 'Reverse search', - action: 'Reverse search ' + history.location.pathname + " for " + payload, - label: payload - });*/ + category: 'Reverse search', + action: 'Reverse search ' + history.location.pathname + " for " + payload, + label: payload + });*/ return true; } + export function loadPage(path) { history.push(path.pathname); - var pathname = history.location.pathname; + const pathname = history.location.pathname; console.log(path); console.log(pathname); diff --git a/src/components/Shared/ReverseSearch/engines/google-lens.jsx b/src/components/Shared/ReverseSearch/engines/google-lens.jsx index d6e1b3737..cdd634168 100644 --- a/src/components/Shared/ReverseSearch/engines/google-lens.jsx +++ b/src/components/Shared/ReverseSearch/engines/google-lens.jsx @@ -51,14 +51,14 @@ export const reverseImageSearchGoogleLens = ( //return response.text(); }) /*.then((body) => { - var tabUrl = body.match(/(?<= { console.error(error); })