             checked:  viewstate.showtray
             click: -> action 'toggleshowtray'
         }
-    ]
-    #
-    if platform == 'darwin'
-        tmpl.push {
-            label: 'Hide Dock icon'
-            type: 'checkbox'
-            enabled: viewstate.showtray
-            checked:  viewstate.hidedockicon
-            click: -> action 'togglehidedockicon'
-        }
-    tmpl
-
-templateWindow = (viewstate, platform) -> [
+        if isDarwin
+            {
+                label: 'Hide Dock icon'
+                type: 'checkbox'
+                enabled: viewstate.showtray
+                checked:  viewstate.hidedockicon
+                click: -> action 'togglehidedockicon'
+            }
+    ].filter (n) -> n != undefined
+
+templateWindow = (viewstate) -> [
     {
         label: 'Minimize'
-        accelerator: acceleratorMap['minimize'][platform]
-        selector: 'performMiniaturize:' if platform == 'darwin'
+        accelerator: getAccelerator('minimize')
+        selector: 'performMiniaturize:' if isDarwin
     }, {
         label: 'Close'
-        accelerator: acceleratorMap['close'][platform]
-        selector: 'performClose:' if platform == 'darwin'
+        accelerator: getAccelerator('close')
+        selector: 'performClose:' if isDarwin
     }, {
         type: 'separator'
     }, {
         label: 'Bring All to Front',
-        selector: 'arrangeInFront:' if platform == 'darwin'
+        selector: 'arrangeInFront:' if isDarwin
     }
 ]
 
+# note: electron framework currently does not support undefined Menu
+#  entries, which requires a filter for undefined at menu/submenu entry
+#  to remove them
+#
+#  [.., undefined, ..., undefined,.. ].filter (n) -> n != undefined
+#
 templateMenu = (viewstate) ->
-    platform = if require('os').platform() == 'darwin' then 'darwin' else
-        'others'
-
-    tmpl = [{
+    [
+        {
             label: 'YakYak'
-            submenu: templateYakYak viewstate, platform
+            submenu: templateYakYak viewstate
         }, {
             label: 'Edit'
-            submenu: templateEdit viewstate, platform
+            submenu: templateEdit viewstate
         },{
             label: 'View'
-            submenu: templateView viewstate, platform
-        }
-    ]
-    if platform == 'darwin'
-        tmpl.push {
-            label: 'Window'
-            submenu: templateWindow viewstate, platform
-        }
-    tmpl
+            submenu: templateView viewstate
+        }
+        if isDarwin
+            {
+                label: 'Window'
+                submenu: templateWindow viewstate
+            }
+    ].filter (n) -> n != undefined
 
 module.exports = (viewstate) ->
     Menu.setApplicationMenu Menu.buildFromTemplate templateMenu(viewstate)

remote = require('electron').remote
Menu = remote.Menu

acceleratorMap = {
    hideyakyak:           {others: 'Control+H', darwin:'Command+H'}
    hideothers:           {others: '', darwin:'Command+Shift+H'}
    showall:              {others: '', darwin:''}
    openinspector:        {others: 'Control+Alt+I', darwin:'Command+Alt+I'}
    quit:                 {others: 'Control+Q', darwin:'Command+Q'}
    undo:                 {others: 'Control+Z', darwin:'Command+Z'}
    redo:                 {others: 'Control+Shift+Z', darwin:'Command+Shift+Z'}
    cut:                  {others: '', darwin:'Command+X'}
    copy:                 {others: '', darwin:'Command+C'}
    paste:                {others: '', darwin:'Command+V'}
    selectall:            {others: '', darwin:'Command+A'}
    togglefullscreen:     {others: 'Control+Alt+F', darwin:'Command+Control+F'}
    zoomin:               {others: 'Control+Plus', darwin:'Command+Plus'}
    zoomout:              {others: 'Control+-', darwin:'Command+-'}
    resetzoom:            {others: 'Control+0', darwin:'Command+0'}
    previousconversation: {others: 'Control+K', darwin:'Command+Shift+Tab'}
    nextconversation:     {others: 'Control+J', darwin:'Command+Tab'}
    conversation1:        {others: 'Alt+1', darwin:'Command+1'}
    conversation2:        {others: 'Alt+2', darwin:'Command+2'}
    conversation3:        {others: 'Alt+3', darwin:'Command+3'}
    conversation4:        {others: 'Alt+4', darwin:'Command+4'}
    conversation5:        {others: 'Alt+5', darwin:'Command+5'}
    conversation6:        {others: 'Alt+6', darwin:'Command+6'}
    conversation7:        {others: 'Alt+7', darwin:'Command+7'}
    conversation8:        {others: 'Alt+8', darwin:'Command+8'}
    conversation9:        {others: 'Alt+9', darwin:'Command+9'}
    minimize:             {others: '', darwin:'Command+M'}
    close:                {others: '', darwin:'Command+W'}
}

templateYakYak = (viewstate, platform) ->
    tmpl = []
    if platform == 'darwin'
        tmpl.push.apply tmpl,  [
            { label: 'About YakYak', selector: 'orderFrontStandardAboutPanel:' }
            #{ type: 'separator' }
            # { label: 'Preferences...', accelerator: 'Command+,',
            # click: => delegate.openConfig() }
            { type: 'separator' }
        ]
    tmpl.push {
        label: 'Hide YakYak'
        accelerator: acceleratorMap['hideyakyak'][platform]
        selector: 'hide:' if platform == 'darwin'
        role: 'minimize' if platform == 'others'
    }

    if platform == 'darwin'
        tmpl.push.apply tmpl, [{
                label: 'Hide Others'
                accelerator: acceleratorMap['hideother'][platform]
                selector: 'hideOtherApplications:' if platform == 'darwin'
            }
            {
                label: 'Show All'
                selector: 'unhideAllApplications:' if platform == 'darwin'
            }
        ]
    tmpl.push.apply tmpl, [
        { type: 'separator' }
        {
            label: 'Open Inspector'
            accelerator: acceleratorMap['openinspector'][platform]
            click: -> action 'devtools'
        }
        { type: 'separator' }

        }
        {
            label: 'Quit'
            accelerator: getAccelerator('quit')
            click: -> action 'quit'
        }
    ].filter (n) -> n != undefined

templateEdit = (viewstate) ->
    [
        {
          label: 'Undo'
          accelerator: getAccelerator('undo')
          selector: 'undo:' if isDarwin
          role: 'undo' if isNotDarwin
        }
        {
          label: 'Redo'
          accelerator: getAccelerator('redo')
          selector: 'redo:' if isDarwin
          role: 'redo' if isNotDarwin
        }
        if isDarwin
            { type: 'separator' }
            {
              label: 'Cut'
              accelerator: getAccelerator('cut')
              selector: 'cut:' if isDarwin
              role: 'cut' if isNotDarwin
            }
            {
              label: 'Copy'
              accelerator: getAccelerator('copy')
              selector: 'copy:' if isDarwin
              role: 'copy' if isNotDarwin
            }
            {
              label: 'Paste'
              accelerator: getAccelerator('paste')
              selector: 'paste:' if isDarwin
              role: 'paste' if isNotDarwin
            }
            {
              label: 'Select All'
              accelerator: getAccelerator('selectall')
              selector: 'selectAll:' if isDarwin
              role: 'selectall' if isNotDarwin
            }
    ].filter (n) -> n != undefined

templateView = (viewstate) ->
    [
        {
            label: 'Conversation List'
            submenu: [
