Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CreateNote() gets called....
  2.  
  3. //------------------------------------------
  4.  
  5. class NoteController {
  6.     constructor() {
  7.         this.store = new NoteStore();
  8.     }
  9.  
  10.     CreateNote() {
  11.         var title = $("#edtNoteTitle").val();
  12.  
  13.         if (title.length < 1) {
  14.             this.CreateToast(false);
  15.             return;
  16.         } else if ($.inArray(title, this.store.notes.map(n => n.title)) >= 0) {
  17.             this.CreateToast(false);
  18.             return;
  19.         }
  20.  
  21.         this.store.AddNote(new Note(title, $("#edtNoteText").val()), this.store);
  22.         this.CreateToast(true);
  23.     }
  24.  
  25.     CreateToast(isValid) {
  26.  
  27.     }
  28. }
  29.  
  30. //------------------------------------------
  31.  
  32. class NoteStore {
  33.     constructor() {
  34.         this.notes = [];
  35.     }
  36.  
  37.     AddNote(note) {
  38.         this.notes.push(note);
  39.     }
  40. }
  41.  
  42. //------------------------------------------
  43.  
  44. class Note {
  45.     constructor(noteTitle, noteText, noteStore) {
  46.         this.title = noteTitle;
  47.         this.text = noteText;
  48.         this.store = noteStore;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement