This is the static content for my todo-app tutorial using Apache, OpenID, and Node.
Last active
August 29, 2015 13:59
-
-
Save ryanthejuggler/10998077 to your computer and use it in GitHub Desktop.
To-do app static content
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
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>To-do app</title> | |
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script> | |
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> | |
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.13.0/javascript/semantic.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.13.0/css/semantic.min.css"> | |
<style type='text/css'> | |
@import url(http://fonts.googleapis.com/css?family=Raleway:400,300,700|Open+Sans:400,300); | |
body { | |
background-image: url('http://semantic-ui.com/images/bg.jpg'); | |
max-width: 500px; | |
margin: auto; | |
padding-top: 30px; | |
font-family: Open Sans; | |
} | |
h2 { | |
text-align: center; | |
font-family: Raleway; | |
} | |
label.complete{ | |
text-decoration: line-through; | |
} | |
#new-task { | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="ui form"> | |
<h2>To-do List</h2> | |
<div id="tasks" class="ui piled segment"></div> | |
<div class="field"> | |
<label>Add task</label> | |
<input type="text" id="new-task" /> | |
</div> | |
</div> | |
<script type="template/ejs" id="tasks-tpl"> | |
<div>Welcome, <%- user %>!</div> | |
<hr> | |
<div> | |
<% _.forEach(tasks, function(task, i){ %> | |
<div class="ui field"> | |
<div class="task ui checkbox " data-index=<%- i %>> | |
<input type="checkbox" class="checkbox" id="check<%- i %>" <%- task.isComplete?"checked":"" %>> | |
<label for="check<%- i %>" class="<%- task.isComplete? 'complete': 'incomplete' %>"><%- task.name %></label> | |
</div> | |
</div> | |
<% }); %> | |
</div> | |
</script> | |
<script type='text/javascript'> | |
$(function(){ | |
var todo = [{ | |
name: "Walk the dog", | |
isComplete: true | |
}, { | |
name: "File taxes", | |
isComplete: false | |
}, { | |
name: "Finish to-do app", | |
isComplete: false | |
}]; | |
var tpl = _.template($('#tasks-tpl').html()); | |
$('#new-task').change(function () { | |
addTask($('#new-task').val()); | |
}); | |
displayTasks(todo); | |
// Display the task list in the UI. | |
function displayTasks(tasks) { | |
$('#tasks').html(tpl({ | |
tasks: tasks, | |
user: '[email protected]' | |
})); | |
$('#tasks input').click(updateState); | |
//$('.ui.checkbox').checkbox(); | |
} | |
// Update internal state based on the state of the UI. | |
function updateState() { | |
$('#tasks .task').each(function(){ | |
var i = $(this).attr('data-index'); | |
todo[i].isComplete = $(this).find('input').is(':checked'); | |
}); | |
displayTasks(todo); | |
} | |
// Add a new task | |
function addTask(task){ | |
todo.push({name:task,isComplete:false}); | |
$('#new-task').val(''); | |
displayTasks(todo); | |
} | |
// Save to-do list to the server. | |
function saveTasks(tasks) { | |
} | |
// Read to-do list from the server. | |
function loadTasks(){ | |
} | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment