1
0

contribute.js 650 B

1234567891011121314151617181920212223
  1. var _ = require('lodash');
  2. var util = require('../util');
  3. module.exports = function(drivers) {
  4. var DOM = drivers.DOM;
  5. function input(elem) {
  6. return DOM.get('#'+elem, 'input').map(function(ev) { return ev.target.value }).startWith('');
  7. }
  8. var labels = ['inputWord'].concat([0,1,2,3,4].map(function(item) { return 'taboo'+item }));
  9. var streams = labels.map(input);
  10. var textFields$ = util.asObject(_.zipObject(labels, streams));
  11. var submit$ = DOM.get('#cardForm', 'submit').doOnNext(function(ev) { ev.preventDefault() });
  12. var form$ = util.sync(submit$, textFields$);
  13. return {
  14. fields$: textFields$,
  15. form$: form$
  16. };
  17. }