From d3cc5c890ba95a050d7b51cf9c6cf3eb69bb179a Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 24 Oct 2024 17:20:55 +1300 Subject: [PATCH] Display number of SCRIPT tags detected in brew --- client/admin/brewUtils/brewLookup/brewLookup.jsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/admin/brewUtils/brewLookup/brewLookup.jsx b/client/admin/brewUtils/brewLookup/brewLookup.jsx index 180e46b72..fa5784501 100644 --- a/client/admin/brewUtils/brewLookup/brewLookup.jsx +++ b/client/admin/brewUtils/brewLookup/brewLookup.jsx @@ -16,14 +16,15 @@ const BrewLookup = createClass({ foundBrew : null, searching : false, error : null, - checkForScript : false + checkForScript : false, + scriptCount : undefined }; }, handleChange(e){ this.setState({ query: e.target.value }); }, lookup(){ - this.setState({ searching: true, error: null, checkForScript: false }); + this.setState({ searching: true, error: null, checkForScript: false, scriptCount: undefined }); request.get(`/admin/lookup/${this.state.query}`) .then((res)=>this.setState({ foundBrew: res.body })) @@ -35,7 +36,8 @@ const BrewLookup = createClass({ const brew = this.state.foundBrew; const scriptCheck = brew.text.match(/(<\/?s)cript/); this.setState({ - checkForScript : !!scriptCheck + checkForScript : !!scriptCheck, + scriptCount : scriptCheck?.length || 0 }); }, @@ -45,7 +47,7 @@ const BrewLookup = createClass({ request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`) .then((res)=>this.setState({ foundBrew: res.body })) .catch((err)=>this.setState({ error: err })) - .finally(()=>this.setState({ checkForScript: false })); + .finally(()=>this.setState({ checkForScript: false, scriptCount: 0 })); }, renderFoundBrew(){ @@ -71,6 +73,7 @@ const BrewLookup = createClass({
{brew.views}
+ {(typeof this.state.scriptCount == 'number') &&

Number of SCRIPT tags found: {this.state.scriptCount}

} {this.state.checkForScript && } ; },