Created
March 19, 2016 20:27
-
-
Save colwem/ec521089c4c97a6d039a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| riot.tag2('cron-time', ' <select onchange="{_update}">\n <option each="{hours}" value="{hour}" __selected="{selected}">{hour}</option>\n </select>\n', '', '', function(opts) { | |
| const self = this; | |
| function range(start, end) { | |
| return Array.apply(Array, Array(1 + end - start)).map((_, i) => { | |
| return i + start; | |
| }); | |
| } | |
| this.hours = range(opts.dayStart + 1, 24).map((hour) => { | |
| return { | |
| hour: hour, | |
| selected: opts.cronTime === hour ? true : false | |
| }; | |
| }); | |
| let url = '/users/update'; | |
| this._update = function(e) { | |
| $.post(url, | |
| { | |
| cronTime: e.target.value | |
| }, | |
| (data, status) => { | |
| console.log(data); | |
| console.log(status); | |
| } | |
| ); | |
| }.bind(this) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| cron-time | |
| select(onchange='{ _update }') | |
| option(each="{ hours }", value='{ hour }', selected="{ selected }") { hour } | |
| script. | |
| const self = this; | |
| function range(start, end) { | |
| return Array.apply(Array, Array(1 + end - start)).map((_, i) => { | |
| return i + start; | |
| }); | |
| } | |
| this.hours = range(opts.dayStart + 1, 24).map((hour) => { | |
| return { | |
| hour: hour, | |
| selected: opts.cronTime === hour ? true : false | |
| }; | |
| }); | |
| let url = '/users/update'; | |
| _update(e) { | |
| $.post(url, | |
| { | |
| cronTime: e.target.value | |
| }, | |
| (data, status) => { | |
| console.log(data); | |
| console.log(status); | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment