diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ApplyMods.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ApplyMods.js
index 27189f2..244e214 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ApplyMods.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ApplyMods.js
@@ -26,7 +26,7 @@ export default function getApplyMods(theState) {
return (
);
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js
index 4bd4884..0cdccfc 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js
@@ -122,6 +122,7 @@ export default function getInfoLi() {
checked={props.checked}
id={iddy}
onClick={props.onClick}
+ onChange={props.onChange}
disabled={props.disabled}
/>
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js
index 4f8258f..daafc8f 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js
@@ -21,6 +21,8 @@ export default function getMain(theState) {
const ApplyMods = getApplyMods(theState);
const Notifications = getNotifications(theState);
+ //const addChecks = (arr) => arr.map( (conf) => Object.assign(conf, {ifChecked: Boolean(conf.value)}) );
+
const checksName = 'pacMods';
return class Main extends Component {
@@ -35,6 +37,7 @@ export default function getMain(theState) {
'ownProxies': props.apis.pacKitchen.getOrderedConfigs('ownProxies'),
},
};
+ this.handleModChange = this.handleModChange.bind(this);
}
@@ -64,33 +67,34 @@ export default function getMain(theState) {
}
- handleModCheck(that, {targetConf, targetIndex, targetChildren}) {
+ handleModChange({targetConf, targetIndex, newValue}) {
- const oldCats = that.state.catToOrderedMods;
- const newCats = Object.keys(that.state.catToOrderedMods).reduce((acc, cat) => {
+ const oldCats = this.state.catToOrderedMods;
+ const newCats = Object.keys(this.state.catToOrderedMods).reduce((acc, cat) => {
if (cat !== targetConf.category) {
acc[cat] = oldCats[cat];
} else {
- acc[cat] = oldCats[cat].map(
- (conf, index) => targetIndex === index
- ? Object.assign({}, conf, {value: !targetConf.value})
- : conf
- );
+ acc[cat] = oldCats[cat].map((conf, index) => {
+
+ if (targetIndex !== index) {
+ return conf;
+ }
+ console.log(`${conf.key} := ${newValue}`);
+ return Object.assign({}, conf, {
+ value: newValue
+ });
+
+ });
}
return acc;
}, {});
- that.setState({ catToOrderedMods: newCats });
-
- }
-
- handleModChange(that, event) {
-
- if (event.target.name === checksName) {
- that.setState({ifModsChangesStashed: true});
- }
+ this.setState({
+ catToOrderedMods: newCats,
+ ifModsChangesStashed: true,
+ });
}
@@ -98,14 +102,13 @@ export default function getMain(theState) {
const applyModsEl = createElement(ApplyMods, Object.assign({}, props,
{
- disabled: !this.state.ifModsChangesStashed || props.ifInputsDisabled,
+ ifInputsDisabled: !this.state.ifModsChangesStashed || props.ifInputsDisabled,
onClick: linkEvent(this, this.handleModApply),
}
));
const modsHandlers = {
- onChange: linkEvent(this, this.handleModChange),
- onClick: (...args) => this.handleModCheck(this, ...args),
+ onConfChanged: this.handleModChange,
};
return createElement(TabPanel, {
@@ -127,7 +130,7 @@ export default function getMain(theState) {
Object.assign({}, props, {
orderedConfigs: this.state.catToOrderedMods['ownProxies'],
childrenOfMod: {
- customProxyStringRaw: createElement(ProxyEditor, props),
+ customProxyStringRaw: ProxyEditor,
},
name: checksName,
}, modsHandlers)
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js
index 3a801b9..1bfb365 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js
@@ -1,31 +1,86 @@
-import Inferno from 'inferno';
+import Inferno, {linkEvent} from 'inferno';
+import Component from 'inferno-component';
+import createElement from 'inferno-create-element';
import getInfoLi from './InfoLi';
export default function getModList(theState) {
const InfoLi = getInfoLi(theState);
- return function ModList(props) {
+ return class ModList extends Component {
- return (
-
- {
- props.orderedConfigs.map((conf, index) => (
- ( props.onClick({targetConf: conf, targetIndex: index, targetChildren: props.childrenOfMod})}
- >
- {Boolean(conf.value) && props.childrenOfMod && props.childrenOfMod[conf.key]}
- )
- ))
+ constructor(props) {
+
+ super(props);
+ this.state= {
+ checks: props.orderedConfigs.map((mod) => Boolean(mod.value)),
+ };
+
+ }
+
+ handleCheck(confMeta, ifChecked) {
+
+ console.log('handle CHECK:', ifChecked);
+ this.state.checks[confMeta.index] = ifChecked;
+ if (ifChecked === false || !confMeta.ifChild) {
+ console.log('NO CHILD OR FALSE', confMeta);
+ this.handleNewValue(confMeta, ifChecked);
+ } else {
+ this.setState({
+ checks: this.state.checks.map(
+ (ch, i) => i === confMeta.index ? ifChecked : ch
+ )
+ });
}
-
- );
- };
+ }
+
+ handleNewValue({ conf, index }, newValue) {
+
+ console.log('handle NEW VALUE', conf.key, newValue);
+ this.props.onConfChanged({
+ targetConf: conf,
+ targetIndex: index,
+ newValue: newValue,
+ });
+
+ }
+
+ render(props) {
+
+ return (
+
+ {
+ props.orderedConfigs.map((conf, index) => {
+
+ const ifMayHaveChild = props.childrenOfMod && props.childrenOfMod[conf.key];
+ const confMeta = { conf, index, ifChild: ifMayHaveChild };
+
+ const child = ifMayHaveChild && this.state.checks[index]
+ && createElement(
+ props.childrenOfMod[conf.key],
+ Object.assign({}, props, {conf, onNewValue: (newValue) => this.handleNewValue(confMeta, newValue)})
+ );
+
+ console.log('CHIIIIILD', child);
+ return ( this.handleCheck(confMeta, event.target.checked)}
+ >
+ {child}
+ );
+
+ })
+ }
+
+ );
+
+ }
+
+ }
};
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js
index c9ee179..3026378 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js
@@ -134,7 +134,7 @@ export default function getProxyEditor(theState) {
const SwitchButton = (props) =>
(