Skip to content

Commit

Permalink
Merge pull request #584 from AFP-Medialab/583-no-vars
Browse files Browse the repository at this point in the history
Removed vars
  • Loading branch information
Sallaa authored Sep 10, 2024
2 parents 016f851 + 1ef1242 commit c44d484
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/Hooks/useInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const loadImageSize = (resultData, cols) => {
setTimeout(() => {
let colsWidth = 1180 / cols;
if (Array.isArray(resultData) && resultData.length) {
let img = new Image();
const img = new Image();
img.src = resultData[0];
const height = (colsWidth * img.height) / img.width;
if (img.width !== 0 && img.height !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const AssistantVideoResult = () => {
return null;
}

let positionTwo;

switch (input_url_type) {
case KNOWN_LINKS.YOUTUBE:
if (!embedURL.includes("/embed/")) {
Expand All @@ -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." +
Expand Down
18 changes: 9 additions & 9 deletions src/components/NavItems/tools/Analysis/Analysis.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Analysis = () => {
isLoading,
);

var [warning, setWarning] = useState(false);
const [warning, setWarning] = useState(false);

const reprocessToggle = () => {
setReprocess(!reprocess);
Expand All @@ -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());
};
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions src/components/NavItems/tools/Analysis/Results/AnalysisComments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = () => {
Expand Down
16 changes: 8 additions & 8 deletions src/components/NavItems/tools/C2pa/Results/C2paResults.jsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const DeepfakeResultsVideo = (props) => {
}

for (
var i = 0;
let i = 0;
i < results.deepfake_video_report.results.length && shot === -1;
i++
) {
Expand Down
7 changes: 5 additions & 2 deletions src/components/NavItems/tools/Forensic/Hooks/useGetImages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/components/NavItems/tools/Gif/AnimatedGif.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -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";
Expand Down
84 changes: 42 additions & 42 deletions src/components/NavItems/tools/Gif/CheckGif.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 !== "") {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading

0 comments on commit c44d484

Please sign in to comment.