mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-27 20:03:45 +03:00
Make proxy's 'No' settable in UI. Refactor
This commit is contained in:
parent
ccda45a57c
commit
796681ae5a
|
@ -62,6 +62,9 @@ export default function getExcEditor(theState) {
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const unWild = (inputExpr) => inputExpr.replace(/^\*\./g, '');
|
||||||
|
|
||||||
return class ExcEditor extends Component {
|
return class ExcEditor extends Component {
|
||||||
|
|
||||||
modsToOpts(pacMods) {
|
modsToOpts(pacMods) {
|
||||||
|
@ -85,8 +88,9 @@ export default function getExcEditor(theState) {
|
||||||
const pacMods = props.apis.pacKitchen.getPacMods();
|
const pacMods = props.apis.pacKitchen.getPacMods();
|
||||||
this.state = {
|
this.state = {
|
||||||
trimmedInputValueOrSpace,
|
trimmedInputValueOrSpace,
|
||||||
|
inputHostname: unWild(trimmedInputValueOrSpace),
|
||||||
sortedListOfOptions: this.modsToOpts(pacMods),
|
sortedListOfOptions: this.modsToOpts(pacMods),
|
||||||
ifHostHiddenMap: {}
|
hostToIfHidden: {},
|
||||||
};
|
};
|
||||||
this.handleRadioClick = this.handleRadioClick.bind(this);
|
this.handleRadioClick = this.handleRadioClick.bind(this);
|
||||||
this.handleInputOrClick = this.handleInputOrClick.bind(this);
|
this.handleInputOrClick = this.handleInputOrClick.bind(this);
|
||||||
|
@ -96,11 +100,11 @@ export default function getExcEditor(theState) {
|
||||||
hideAllOptions() {
|
hideAllOptions() {
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
ifHostHiddenMap: this.state.sortedListOfOptions.reduce(
|
hostToIfHidden: this.state.sortedListOfOptions.reduce(
|
||||||
(ifHostHiddenMap, [excHost]) => {
|
(hostToIfHidden, [excHost]) => {
|
||||||
|
|
||||||
ifHostHiddenMap[excHost] = true;
|
hostToIfHidden[excHost] = true;
|
||||||
return ifHostHiddenMap;
|
return hostToIfHidden;
|
||||||
|
|
||||||
},
|
},
|
||||||
{}),
|
{}),
|
||||||
|
@ -121,9 +125,8 @@ export default function getExcEditor(theState) {
|
||||||
|
|
||||||
handleRadioClick(event) {
|
handleRadioClick(event) {
|
||||||
|
|
||||||
let host = this.state.trimmedInputValueOrSpace;
|
const ifWild = this.state.trimmedInputValueOrSpace.startsWith('*.');
|
||||||
const ifWild = host.startsWith('*.');
|
const host = this.state.inputHostname;
|
||||||
host = host.replace(/^\*\./g, '');
|
|
||||||
(() => { // `return` === `preventDefault`.
|
(() => { // `return` === `preventDefault`.
|
||||||
|
|
||||||
if(!this.isHostValid(host)) {
|
if(!this.isHostValid(host)) {
|
||||||
|
@ -212,7 +215,10 @@ export default function getExcEditor(theState) {
|
||||||
const ifInit = !event;
|
const ifInit = !event;
|
||||||
const currentHost = ifTriangleClicked ? '' : (trimmedInput || (ifInit ? '' : ' '));
|
const currentHost = ifTriangleClicked ? '' : (trimmedInput || (ifInit ? '' : ' '));
|
||||||
setInputValue(currentHost);
|
setInputValue(currentHost);
|
||||||
this.setState({trimmedInputValueOrSpace: currentHost});
|
this.setState({
|
||||||
|
trimmedInputValueOrSpace: currentHost,
|
||||||
|
inputHostname: unWild(currentHost),
|
||||||
|
});
|
||||||
|
|
||||||
// Episode 2.
|
// Episode 2.
|
||||||
|
|
||||||
|
@ -281,7 +287,7 @@ export default function getExcEditor(theState) {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
ifHostHiddenMap: hidden,
|
hostToIfHidden: hidden,
|
||||||
sortedListOfOptions: options,
|
sortedListOfOptions: options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -294,7 +300,7 @@ export default function getExcEditor(theState) {
|
||||||
if ( acc !== undefined ) {
|
if ( acc !== undefined ) {
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
return this.state.trimmedInputValueOrSpace === excHost ? (excState || {}).ifProxy : undefined;
|
return this.state.inputHostname === excHost ? (excState || {}).ifProxy : undefined;
|
||||||
|
|
||||||
}, undefined);
|
}, undefined);
|
||||||
|
|
||||||
|
@ -325,7 +331,7 @@ export default function getExcEditor(theState) {
|
||||||
// 2. Space is used in matching so even an empty input (replaced with space) has tooltip with prompts.
|
// 2. Space is used in matching so even an empty input (replaced with space) has tooltip with prompts.
|
||||||
const ifProxy = (excState || {}).ifProxy;
|
const ifProxy = (excState || {}).ifProxy;
|
||||||
return <option
|
return <option
|
||||||
value={ this.state.ifHostHiddenMap[excHost] ? '\n' : excHost + ' ' }
|
value={ this.state.hostToIfHidden[excHost] ? '\n' : excHost + ' ' }
|
||||||
label={ ifProxy === true ? labelIfProxied : (ifProxy === false ? labelIfNotProxied : labelIfAuto) }/>
|
label={ ifProxy === true ? labelIfProxied : (ifProxy === false ? labelIfNotProxied : labelIfAuto) }/>
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user