Skip to content

Instantly share code, notes, and snippets.

@deeqoo
Created June 14, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeqoo/d8d24c7a10d9731c542a3590e15d9456 to your computer and use it in GitHub Desktop.
Save deeqoo/d8d24c7a10d9731c542a3590e15d9456 to your computer and use it in GitHub Desktop.
var template = function(text) {
return '<p><input type="checkbox"><i class="glyphicon glyphicon-star"></i><span>' + text + '</span><i class="glyphicon glyphicon-remove"></i></p>';
};
var main = function() {
$('form').submit(function() {
var text = $('#todo').val();
var html = template(text);
$('.list').append(html);
$('#todo').val('');
return false;
});
$('.list').on('click', '.glyphicon-star', function() {
$(this).toggleClass('active');
}).on('click', '.glyphicon-remove', function() {
$(this).parent().remove();
});
if (annyang) {
var commands = {
'add *item': add,
};
annyang.addCommands(commands);
annyang.start();
}
var add = function(item) {
var html = template(item);
$('.list').append(html);
};
};
$(document).ready(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment