Browse Source

Rename notes to todos

master
Nero 5 years ago
parent
commit
52dbc551c8
  1. 4
      app.css
  2. 42
      app.js
  3. 24
      index.html

4
app.css

@ -106,3 +106,7 @@ img.message-image {
#addForm { #addForm {
margin-top: 60px; margin-top: 60px;
} }
.fa-check-circle {
color: green;
}

42
app.js

@ -15,7 +15,7 @@ let kara = new Vue({
chatbox: null, chatbox: null,
isTyping: false, isTyping: false,
askedForName: false, askedForName: false,
takeNote: false, takeTodo: false,
username: '', username: '',
themes: null, themes: null,
activeTheme: 'slate', activeTheme: 'slate',
@ -32,7 +32,7 @@ let kara = new Vue({
username: null, username: null,
location: '' location: ''
}, },
notes: [], todos: [],
answers: [ answers: [
{ {
includeAll: false, includeAll: false,
@ -170,8 +170,8 @@ let kara = new Vue({
// Check commands // Check commands
if (this.askedForName === true) { if (this.askedForName === true) {
this.setName(message); this.setName(message);
} else if (this.takeNote === true) { } else if (this.takeTodo === true) {
this.saveNote(message); this.saveTodo(message);
} else { } else {
let answer = this.getAnswer(message); let answer = this.getAnswer(message);
if (answer) { if (answer) {
@ -187,9 +187,9 @@ let kara = new Vue({
} }
}, },
processCommands(message) { processCommands(message) {
if (this.checkForCommands(message, 'note')) { if (this.checkForCommands(message, 'todo')) {
let noteToSave = this.checkForCommands(message, 'note'); let todoToSave = this.checkForCommands(message, 'todo');
this.saveNote(noteToSave); this.saveTodo(todoToSave);
} }
if (this.checkForCommands(message, 'clear')) { if (this.checkForCommands(message, 'clear')) {
@ -214,7 +214,7 @@ let kara = new Vue({
if (this.checkForCommands(message, 'talk')) { if (this.checkForCommands(message, 'talk')) {
this.talk = !this.talk; this.talk = !this.talk;
alert(this.talk); alertify.notify('Speech ' + this.talk ? 'enabled' : 'disabled');
} }
}, },
checkForCommands(message, commands) { checkForCommands(message, commands) {
@ -319,12 +319,12 @@ let kara = new Vue({
return "Please tell me how i should call you."; return "Please tell me how i should call you.";
} }
if (this.includesAllOf(phrases, ['new', 'note']) || if (this.includesAllOf(phrases, ['new', 'todo']) ||
this.includesAllOf(phrases, ['new', 'task']) || this.includesAllOf(phrases, ['new', 'task']) ||
this.includesAllOf(phrases, ['take', 'note']) || this.includesAllOf(phrases, ['take', 'todo']) ||
this.includesAllOf(phrases, ['save', 'to', 'clipboard']) this.includesAllOf(phrases, ['save', 'to', 'clipboard'])
) { ) {
this.takeNote = true; this.takeTodo = true;
return this.oneOf([ return this.oneOf([
"What do you wan't me to save for you?", "What do you wan't me to save for you?",
"Tell me what you wan't to save.", "Tell me what you wan't to save.",
@ -418,7 +418,7 @@ let kara = new Vue({
localStorage.setItem('activeTheme', this.activeTheme); localStorage.setItem('activeTheme', this.activeTheme);
localStorage.setItem('messages', JSON.stringify(this.messages)); localStorage.setItem('messages', JSON.stringify(this.messages));
localStorage.setItem('answers', JSON.stringify(this.answers)); localStorage.setItem('answers', JSON.stringify(this.answers));
localStorage.setItem('notes', JSON.stringify(this.notes)); localStorage.setItem('todos', JSON.stringify(this.todos));
localStorage.setItem('lastMessage', JSON.stringify(this.lastMessage)); localStorage.setItem('lastMessage', JSON.stringify(this.lastMessage));
localStorage.setItem('location', JSON.stringify(this.location)); localStorage.setItem('location', JSON.stringify(this.location));
}, },
@ -439,8 +439,8 @@ let kara = new Vue({
let savedAnswers = JSON.parse(localStorage.getItem('answers')); let savedAnswers = JSON.parse(localStorage.getItem('answers'));
this.answers = savedAnswers ? savedAnswers : []; this.answers = savedAnswers ? savedAnswers : [];
let savedNotes = JSON.parse(localStorage.getItem('notes')); let savedTodos = JSON.parse(localStorage.getItem('todos'));
this.notes = savedNotes ? savedNotes : []; this.todos = savedTodos ? savedTodos : [];
let savedLastMessage = JSON.parse(localStorage.getItem('lastMessage')); let savedLastMessage = JSON.parse(localStorage.getItem('lastMessage'));
this.lastMessage = savedLastMessage ? savedLastMessage : null; this.lastMessage = savedLastMessage ? savedLastMessage : null;
@ -476,10 +476,10 @@ let kara = new Vue({
]) ])
) )
}, },
saveNote(message) { saveTodo(message) {
this.takeNote = false; this.takeTodo = false;
this.notes.push({ this.todos.push({
time: moment(), time: moment(),
body: message, body: message,
checked: false checked: false
@ -490,16 +490,16 @@ let kara = new Vue({
this.botMessage( this.botMessage(
this.oneOf([ this.oneOf([
"Saved! :)", "Saved! :)",
"You can read and check your notes in the clipboard-section. :)" "You can read and check your todos in the clipboard-section. :)"
]) ])
) )
}, },
clearNotes() { clearTodos() {
this.notes = []; this.todos = [];
this.botMessage( this.botMessage(
this.oneOf([ this.oneOf([
"Notes cleared. 🚮" "Todos cleared. 🚮"
]) ])
); );

24
index.html

@ -11,6 +11,9 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/bootstrap.min.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/bootstrap.min.css"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/semantic.min.css"/>
<link rel="stylesheet" href="css/lightbox.min.css"/> <link rel="stylesheet" href="css/lightbox.min.css"/>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no" name="viewport"> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no" name="viewport">
</head> </head>
@ -22,7 +25,7 @@
<div class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#settingsModal"> <div class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#settingsModal">
<i class="fas fa-sliders-h"></i> <i class="fas fa-sliders-h"></i>
</div> </div>
<div class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#noteModal" v-if="notes.length > 0"> <div class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#todoModal" v-if="todos.length > 0">
<i class="fas fa-clipboard"></i> <i class="fas fa-clipboard"></i>
</div> </div>
<div class="btn btn-sm btn-secondary" @click="scrollDown()"> <div class="btn btn-sm btn-secondary" @click="scrollDown()">
@ -73,33 +76,33 @@
required autofocus> required autofocus>
</div> </div>
<div class="modal fade" id="noteModal" tabindex="-1" role="dialog" aria-labelledby="noteModal" aria-hidden="true"> <div class="modal fade" id="todoModal" tabindex="-1" role="dialog" aria-labelledby="todoModal" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">Notes</h5> <h5 class="modal-title">To-Do</h5>
<div class="float-right"> <div class="float-right">
<button class="btn btn-sm btn-secondary" @click="clearNotes"> <button class="btn btn-sm btn-secondary" @click="clearTodos">
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="modal-body" style="max-height: 800px; overflow-y: scroll"> <div class="modal-body" style="max-height: 800px; overflow-y: scroll">
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item" v-for="note in notes" v-if="!note.checked"> <li class="list-group-item" v-for="todo in todos" v-if="!todo.checked">
<span class="float-right"> <span class="float-right">
<input type="checkbox" v-model="note.checked" @change="updateStorage()"/> <input type="checkbox" v-model="todo.checked" @change="updateStorage()"/>
</span> </span>
{{ note.body }} {{ todo.body }}
</li> </li>
</ul> </ul>
<hr/> <hr/>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item" v-for="note in notes" v-if="note.checked"> <li class="list-group-item" v-for="todo in todos" v-if="todo.checked">
<span class="float-right"> <span class="float-right">
<input type="checkbox" v-model="note.checked" @change="updateStorage()"/> <input type="checkbox" v-model="todo.checked" @change="updateStorage()"/>
</span> </span>
<span style="text-decoration: line-through;">{{ note.body }}</span> <i class="fas fa-check-circle"></i> <span style="text-decoration: line-through;">{{ todo.body }}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -175,6 +178,7 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="js/lightbox.min.js"></script> <script src="js/lightbox.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>

Loading…
Cancel
Save