             ]
         }, {
             label: 'Toggle Full Screen',
-            accelerator: acceleratorMap['togglefullscreen'][platform],
+            accelerator: getAccelerator('togglefullscreen'),
             click: -> action 'togglefullscreen'
         }, {
             # seee https://github.com/atom/electron/issues/1507
             label: 'Zoom In',
-            accelerator: acceleratorMap['zoomin'][platform],
+            accelerator: getAccelerator('zoomin'),
             click: -> action 'zoom', +0.25
         }, {
             label: 'Zoom Out',
-            accelerator: acceleratorMap['zoomout'][platform],
+            accelerator: getAccelerator('zoomout'),
             click: -> action 'zoom', -0.25
         }, {
             label: 'Reset Zoom',
-            accelerator: acceleratorMap['resetzoom'][platform],
+            accelerator: getAccelerator('resetzoom'),
             click: -> action 'zoom'
         }, {
             type: 'separator'
         }, {
             label: 'Previous Conversation',
-            accelerator: acceleratorMap['previousconversation'][platform]
+            accelerator: getAccelerator('previousconversation')
             enabled: viewstate.loggedin
             click: -> action 'selectNextConv', -1
         }, {
             label: 'Next Conversation',
-            accelerator: acceleratorMap['nextconversation'][platform]
+            accelerator: getAccelerator('nextconversation')
             enabled: viewstate.loggedin
             click: -> action 'selectNextConv', +1
         }, {

        }
        {
            label: 'Quit'
            accelerator: acceleratorMap['quit'][platform]
            click: -> action 'quit'
        }
    ]
    tmpl

templateEdit = (viewstate, platform) ->
    tmpl = [
        {
          label: 'Undo'
          accelerator: acceleratorMap['undo'][platform]
          selector: 'undo:' if platform == 'darwin'
          role: 'undo' if platform == 'others'
        }
        {
          label: 'Redo'
          accelerator: acceleratorMap['redo'][platform]
          selector: 'redo:' if platform == 'darwin'
          role: 'redo' if platform == 'others'
        }
    ]
    if platform == 'darwin'
        tmpl.push.apply tmpl, [
          { type: 'separator' }
          {
            label: 'Cut'
            accelerator: acceleratorMap['cut'][platform]
            selector: 'cut:' if platform == 'darwin'
            role: 'cut' if platform == 'others'
          }
          {
            label: 'Copy'
            accelerator: acceleratorMap['copy'][platform]
            selector: 'copy:' if platform == 'darwin'
            role: 'copy' if platform == 'others'
          }
          {
            label: 'Paste'
            accelerator: acceleratorMap['paste'][platform]
            selector: 'paste:' if platform == 'darwin'
            role: 'paste' if platform == 'others'
          }
          {
            label: 'Select All'
            accelerator: acceleratorMap['selectall'][platform]
            selector: 'selectAll:' if platform == 'darwin'
            role: 'selectall' if platform == 'others'
          }
        ]
    tmpl

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

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

platform = require('os').platform()
# to reduce number of == comparisons
isDarwin = platform == 'darwin'
isNotDarwin = platform != 'darwin'

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

getAccelerator = (key) ->
    if (retVal = acceleratorMap[key][platform])?
        retVal
    else
        acceleratorMap[key]['default']

templateYakYak = (viewstate) ->

    [
        { label: 'About YakYak', selector: 'orderFrontStandardAboutPanel:' } if isDarwin
        #{ type: 'separator' }
        # { label: 'Preferences...', accelerator: 'Command+,',
        # click: => delegate.openConfig() }
        { type: 'separator' } if isDarwin
        {
            label: 'Hide YakYak'
            accelerator: getAccelerator('hideyakyak')
            selector: 'hide:' if isDarwin
            role: 'minimize' if isNotDarwin
        }
        if isDarwin
            {
                label: 'Hide Others'
                accelerator: getAccelerator('hideother')
                selector: 'hideOtherApplications:' if isDarwin
            }

            {
                label: 'Show All'
                selector: 'unhideAllApplications:' if isDarwin
            }
        { type: 'separator' }
        {
            label: 'Open Inspector'
            accelerator: getAccelerator('openinspector')
            click: -> action 'devtools'
        }
        { type: 'separator' }
