diff --git a/www/img/logo_64.png b/www/img/logo_64.png new file mode 100644 index 0000000..dc1cb42 Binary files /dev/null and b/www/img/logo_64.png differ diff --git a/www/js/home.js b/www/js/home.js index 2a464bc..136d458 100644 --- a/www/js/home.js +++ b/www/js/home.js @@ -27,6 +27,7 @@ function loadCards(callback) { window.shuffleInstance.remove(window.shuffleInstance.items[i]); } $(".notecard-col").remove(); + var trayitems = []; for (n in notes) { var note = notes[n]; $("#notecards-bin").append('
' @@ -40,7 +41,12 @@ function loadCards(callback) { + '
' + note.html + '
' + '
' + ''); + trayitems.push({ + title: note.title, + id: note.noteid + }); } + console.log(trayitems); var noteElements = document.getElementsByClassName("notecard-col"); window.shuffleInstance.add(noteElements); window.shuffleInstance.sort({ @@ -49,6 +55,7 @@ function loadCards(callback) { return el.getAttribute("data-favorite"); } }); + setTrayMenu(trayitems); if (typeof callback == 'function') { callback(); } diff --git a/www/js/platform.js b/www/js/platform.js index d188a42..b99dd32 100644 --- a/www/js/platform.js +++ b/www/js/platform.js @@ -6,10 +6,16 @@ var platform_type = ""; +var nw_tray = null; + var openBrowser = function (url) { } +var setTrayMenu = function (items) { + +} + function initCordova() { platform_type = "cordova"; @@ -66,6 +72,76 @@ function initNW() { browserwin.menu = browsermenu; }); } + + nw_tray = new nw.Tray({ + title: 'NotePost', + icon: 'www/img/logo_64.png' + }); + + setTrayMenu = function (items) { + var menu = new nw.Menu(); + menu.append(new nw.MenuItem({ + type: 'normal', + label: 'Open NotePost', + click: function () { + nw.Window.get().show(); + } + })); + menu.append(new nw.MenuItem({ + type: 'normal', + label: 'New Note', + click: function () { + router.navigate("/editnote"); + nw.Window.get().show(); + } + })); + menu.append(new nw.MenuItem({ + type: 'separator' + })); + + if (items.length > 0) { + for (i in items) { + console.log(items[i]); + var label_max = 50; + var label = items[i].title; + if (label.length > label_max) { + label = label.substring(0, label_max) + "..."; + } + menu.append(new nw.MenuItem({ + type: 'normal', + label: label, + click: function (id) { + return function () { + editNote(id); + nw.Window.get().show(); + } + }(items[i].id) + })); + ; + } + menu.append(new nw.MenuItem({ + type: 'separator' + })); + } + + menu.append(new nw.MenuItem({ + type: 'normal', + label: 'Exit NotePost', + click: function () { + nw.App.quit(); + } + })); + nw_tray.menu = menu; + } + + nw.Window.get().on('minimize', function () { + nw.Window.get().hide(); + }); + nw_tray.on('click', function () { + nw.Window.get().show(); + }); + + setTrayMenu([]); } function initPlatform() {