mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 20:52:40 +00:00
Display number of SCRIPT tags detected in brew
This commit is contained in:
@@ -16,14 +16,15 @@ const BrewLookup = createClass({
|
|||||||
foundBrew : null,
|
foundBrew : null,
|
||||||
searching : false,
|
searching : false,
|
||||||
error : null,
|
error : null,
|
||||||
checkForScript : false
|
checkForScript : false,
|
||||||
|
scriptCount : undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleChange(e){
|
handleChange(e){
|
||||||
this.setState({ query: e.target.value });
|
this.setState({ query: e.target.value });
|
||||||
},
|
},
|
||||||
lookup(){
|
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}`)
|
request.get(`/admin/lookup/${this.state.query}`)
|
||||||
.then((res)=>this.setState({ foundBrew: res.body }))
|
.then((res)=>this.setState({ foundBrew: res.body }))
|
||||||
@@ -35,7 +36,8 @@ const BrewLookup = createClass({
|
|||||||
const brew = this.state.foundBrew;
|
const brew = this.state.foundBrew;
|
||||||
const scriptCheck = brew.text.match(/(<\/?s)cript/);
|
const scriptCheck = brew.text.match(/(<\/?s)cript/);
|
||||||
this.setState({
|
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}`)
|
request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`)
|
||||||
.then((res)=>this.setState({ foundBrew: res.body }))
|
.then((res)=>this.setState({ foundBrew: res.body }))
|
||||||
.catch((err)=>this.setState({ error: err }))
|
.catch((err)=>this.setState({ error: err }))
|
||||||
.finally(()=>this.setState({ checkForScript: false }));
|
.finally(()=>this.setState({ checkForScript: false, scriptCount: 0 }));
|
||||||
},
|
},
|
||||||
|
|
||||||
renderFoundBrew(){
|
renderFoundBrew(){
|
||||||
@@ -71,6 +73,7 @@ const BrewLookup = createClass({
|
|||||||
<dd>{brew.views}</dd>
|
<dd>{brew.views}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<button onClick={this.checkForScript}>Scan for SCRIPTs</button>
|
<button onClick={this.checkForScript}>Scan for SCRIPTs</button>
|
||||||
|
{(typeof this.state.scriptCount == 'number') && <p>Number of SCRIPT tags found: {this.state.scriptCount}</p>}
|
||||||
{this.state.checkForScript && <button onClick={this.cleanScript}>CLEAN BREW</button>}
|
{this.state.checkForScript && <button onClick={this.cleanScript}>CLEAN BREW</button>}
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user