mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(config) fillTemplate: forEach -> squad, map
This commit is contained in:
parent
09059a0fe8
commit
74e351475e
1 changed files with 19 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ require('../../css/config.css');
|
|||
const rendy = require('rendy');
|
||||
const exec = require('execon');
|
||||
const currify = require('currify/legacy');
|
||||
const squad = require('squad');
|
||||
const input = require('../input');
|
||||
|
||||
const Images = require('../dom/images');
|
||||
|
|
@ -26,6 +27,16 @@ const showLoad = () => {
|
|||
Images.show.load('top');
|
||||
};
|
||||
|
||||
const addKey = currify((fn, input) => {
|
||||
Events.addKey(input, fn);
|
||||
return input;
|
||||
});
|
||||
|
||||
const addChange = currify((fn, input) => {
|
||||
Events.add('change', input, fn);
|
||||
return input;
|
||||
});
|
||||
|
||||
CloudCmd.Config = ConfigProto;
|
||||
|
||||
let Loading = true;
|
||||
|
|
@ -166,23 +177,20 @@ function fillTemplate(error, template) {
|
|||
});
|
||||
|
||||
const inputs = document.querySelectorAll('input, select', Element);
|
||||
const inputFirst = inputs[0];
|
||||
const [inputFirst] = inputs;
|
||||
|
||||
let afterShow;
|
||||
if (inputFirst) {
|
||||
onAuthChange(inputFirst.checked);
|
||||
|
||||
afterShow = () => {
|
||||
inputFirst.focus();
|
||||
};
|
||||
afterShow = inputFirst.focus.bind(inputFirst);
|
||||
}
|
||||
|
||||
[...inputs].forEach((input) => {
|
||||
Events.addKey(input, onKey)
|
||||
.add('change', input, ({target}) => {
|
||||
onChange(target);
|
||||
});
|
||||
});
|
||||
const getTarget = ({target}) => target;
|
||||
const handleChange = squad(onChange, getTarget);
|
||||
|
||||
[...inputs]
|
||||
.map(addKey(onKey))
|
||||
.map(addChange(handleChange));
|
||||
|
||||
const autoSize = true;
|
||||
CloudCmd.View.show(Element, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue