|
|
|
@ -1,26 +1,41 @@
|
|
|
|
|
import Note from './Note.js';
|
|
|
|
|
|
|
|
|
|
function App(){
|
|
|
|
|
return {
|
|
|
|
|
view: function(vnode){
|
|
|
|
|
// const {bin, notes} = vnode.attrs;
|
|
|
|
|
const bin = {id: 'egf35'};
|
|
|
|
|
const notes = [
|
|
|
|
|
{id: 'aaa', text: 'Note one'},
|
|
|
|
|
{id: 'bbb', text: 'Note two'},
|
|
|
|
|
{id: 'ccc', text: 'Note three'},
|
|
|
|
|
{id: 'ddd', text: 'Note four'},
|
|
|
|
|
{id: 'eee', text: 'Note five'},
|
|
|
|
|
{id: 'fff', text: 'Note six'},
|
|
|
|
|
{id: 'ggg', text: 'Note seven'},
|
|
|
|
|
{id: 'hhh', text: 'Note eight'}
|
|
|
|
|
{id: 'aaa', text: 'Note one', modified: 1},
|
|
|
|
|
{id: 'bbb', text: 'Note two', modified: 1},
|
|
|
|
|
{id: 'ccc', text: 'Note three', modified: 1},
|
|
|
|
|
{id: 'ddd', text: 'Note four', modified: 1},
|
|
|
|
|
{id: 'eee', text: 'Note five', modified: 1},
|
|
|
|
|
{id: 'fff', text: 'Note six', modified: 1},
|
|
|
|
|
{id: 'ggg', text: 'Note seven', modified: 1},
|
|
|
|
|
{id: 'hhh', text: 'Note eight', modified: 1}
|
|
|
|
|
];
|
|
|
|
|
let search_term = '';
|
|
|
|
|
let count = 9;
|
|
|
|
|
const new_note_handler = function(){
|
|
|
|
|
count++;
|
|
|
|
|
// TODO: make immutable-style:
|
|
|
|
|
notes.push({id: ''+count, text: '', modified: Date.now()});
|
|
|
|
|
};
|
|
|
|
|
const search_term_change_handler = function(e){
|
|
|
|
|
if(e.code === 'Enter'){
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
search_term = e.target.value;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const sorting_change_handler = function(){
|
|
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
view: function(vnode){
|
|
|
|
|
return m('.app', {key: 'app'}, [
|
|
|
|
|
m('.top', {key: 'top'}, [
|
|
|
|
|
m('.top-left', {key: 'top-left'}, [
|
|
|
|
|
m('button', {key: 'button'}, 'New Note...'),
|
|
|
|
|
m('input.search', {key: 'search', value: ''}),
|
|
|
|
|
m('select.sorting', {key: 'sorting'}, [
|
|
|
|
|
m('button', {key: 'button', onclick: new_note_handler}, 'New Note...'),
|
|
|
|
|
m('input.search', {key: 'search', value: search_term, onkeyup: search_term_change_handler}),
|
|
|
|
|
m('select.sorting', {key: 'sorting', onchange: sorting_change_handler}, [
|
|
|
|
|
m('option', {key: 'new-old'}, 'Newest -> Oldest'),
|
|
|
|
|
m('option', {key: 'old-new'}, 'Oldest -> Newest')
|
|
|
|
|
])
|
|
|
|
|