Created
June 14, 2017 14:40
-
-
Save deeqoo/d8d24c7a10d9731c542a3590e15d9456 to your computer and use it in GitHub Desktop.
This file contains 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
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