| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // Generated by CoffeeScript 1.3.3
- (function() {
- var STORAGE_NAME, setall, visible;
- STORAGE_NAME = 'tvgids-channels';
- visible = localStorage.hasOwnProperty(STORAGE_NAME) ? localStorage.getItem(STORAGE_NAME).split(',') : _.pluck(CHANNELS, 'id');
- _.each(CHANNELS, function(channel) {
- var elem, input, is_visible;
- is_visible = _.contains(visible, channel.id);
- input = $('<input type="checkbox" name="channels[]" value="' + channel.id + '">');
- input.attr('checked', is_visible);
- input.change(function() {
- return $(this).parent().toggleClass('disabled', !$(this).is(':checked'));
- });
- input.change(function() {
- return $('#select-channels').submit();
- });
- elem = $('<label/>').html(channel.name);
- elem.prepend(input);
- elem.toggleClass('disabled', !is_visible);
- return elem.appendTo('#select-channels .options');
- });
- $('#select-channels').submit(function(e) {
- var i, selected;
- e.preventDefault();
- selected = (function() {
- var _i, _len, _ref, _results;
- _ref = $('input', this);
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- i = _ref[_i];
- if ($(i).is(':checked')) {
- _results.push($(i).val());
- }
- }
- return _results;
- }).call(this);
- return localStorage.setItem(STORAGE_NAME, selected.join(','));
- });
- setall = function(c) {
- return $('#select-channels input').prop('checked', c).change();
- };
- $('#select-all').click(function() {
- return setall(true);
- });
- $('#select-none').click(function() {
- return setall(false);
- });
- }).call(this);
|