Skip to content
Permalink
Browse files

wires up demo.js

  • Loading branch information...
Daniel Lerch
Daniel Lerch committed May 18, 2018
1 parent 311fe76 commit dcfbbd2d99db66066edb9fc78e6646b4eea2ca22
Showing with 32 additions and 10 deletions.
  1. +32 −10 src/Demo.js
@@ -1,24 +1,26 @@
"use strict";

$(function () {
var taskList = new TaskList();
taskList.createTask("Setup todo list");
taskList.createTask("Buy milk");
taskList.createTask("Read recipe");
taskList.createTask("Invite guests");
taskList.tasks[0].done = true;
var taskList;

$(function () {
if (window.location.hash.length > 16) {
TaskList.load(window.location.hash.substring(1), function (tl) {
taskList = tl;
$('#taskList').html(taskList.render());
});
} else {
taskList = new TaskList();
taskList.createTask('');
$('#taskList').html(taskList.render());
}

$("#createTask").click(function (event) {
event.preventDefault();
var task = taskList.createTask("");
$("#taskList ul").append(task.render());
});

$("#taskList").append(taskList.render());

$("#taskList").on("change", ":checkbox", function () {
// all related code goes in here
if ($(this).is(":checked")) {
$(this)
.closest('li')
@@ -39,4 +41,24 @@ $(function () {
.slideDown();
}
});
$('#saveTasks').click(function (event) {
taskList.save();
});

$('#openList').click(function (event) {
var listId = prompt("Bitte geben Sie die Tasklisten ID an", "demo");
if (listId != null) {
TaskList.load(listId, function (taskList) {
$('#taskList').html(taskList.render());
});
}
});

$('#newList').click(function (event) {
taskList = new TaskList();
taskList.createTask('');
$('#taskList').html(taskList.render());

});

});

0 comments on commit dcfbbd2

Please sign in to comment.
You can’t perform that action at this time.