Bug 997004 - rewrite generating GAIA_APPDIRS code in javascript