(function(back) {
  let settings = require('Storage').readJSON('draguboard.json',1)||{};
  const colors = {
      4095: /*LANG*/"White",
      4080: /*LANG*/"Yellow",
      3840: /*LANG*/"Red",
      3855: /*LANG*/"Magenta",
      255: /*LANG*/"Cyan",
      240: /*LANG*/"Green",
      15: /*LANG*/"Blue",
      0: /*LANG*/"Black",
      '-1': /*LANG*/"Default"
  };

  const save = () => require('Storage').write('draguboard.json', settings);
  function colorMenu(key) {
    let menu = {'': {title: key}, '< Back': () => E.showMenu(appMenu)};
    Object.keys(colors).forEach(color => {
      var label = colors[color];
      menu[label] = {
        value: settings[key] == color,
        onchange: () => {
          if (color >= 0) {
            settings[key] = color;
          } else {
            delete settings[key];
          }
          save();
          setTimeout(E.showMenu, 10, appMenu);
        }
      };
    });
    return menu;
  }

  const appMenu = {
      '': {title: 'draguboard'}, '< Back': back,
      /*LANG*/'ABC Color': () => E.showMenu(colorMenu("ABC")),
      /*LANG*/'Num Color': () => E.showMenu(colorMenu("Num")),
      /*LANG*/'Highlight Color': () => E.showMenu(colorMenu("Highlight"))
  };

  E.showMenu(appMenu);
});