
const templates = require('./_templates.js'),
        config = require('../config.js');

module.exports.exec = function(req, res) {
    if (!req.account.cguReadAndAccepted) {
        if (config.allowNewAccounts)
            return {
                status: 200,
                body: templates.header("Mimou - CGU", ["style.css"])
                    + `<section class="maci-wrapper fixed-width"><div class="maci-content">
                    <header id="cguHeader">Merci d'accepter les Conditions Generales d'Utilisation suivantes:</header>
                    <textarea id="cguContent" class="full-width"></textarea>
                    <footer><button id="cguButton">J'accepte les Conditions Generales d'Utilisation</button></footer>
                    </div></section>`
                    +templates.footer(["cgu.min.js"])
            };
        else
            return require('./_403.js').exec(req, res);
    }
    return {
        status: 200
        ,body: templates.header("Mimou", ["style.css", "emojione_v2.3.sprites.css"], ['<link href="favicon_err.png" type="image/png" rel="icon" id="linkFavicon" />'])
        +`<aside class="slack-context" id="slackCtx">
              <nav class="slack-context-menu"></nav>
              <div class="slack-context-rooms" id="chatList">
                  <ul class="slack-context-channellist" id="chanList"></ul>
                  <div class="slack-context-imlist"></div>
              </div>
              <div class="slack-context-roominfo hidden"></div>
          </aside>
          <section id="settings" class="maci-setting hidden">
              <header>
                  <div id="settingTitle"></div>
                  <div id="settingDiscardClose"></div>
              </header>
              <div>
                  <aside class="settingNav">
                  </aside>
                  <div class="settingContent">
                  </div>
              </div>
              <footer class="settingFooter">
                  <button id="settingCommit"></button>
              </footer>
          </section>
          <div class="slack-chat-container">
              <div class="slack-chat-title" id="currentRoomTitle"></div>
              <div class="slack-chat-content" id="chatWindow"></div>
              <ul class="slack-chat-whoistyping" id="whoistyping"></ul>
              <div class="slack-chat-control">
                  <div id="replyToContainer" class="replyto-container"></div>
                  <ul id="slashList" class="slack-command-list"></ul>
                  <form id="msgForm" class="msgform">
                      <input type="text" id="msgInput" class="msgform-input" autocomplete="off" />
                      <a id="emojiButton" class="button"/></a>
                      <a id="attachFile" href="#!" class="button"><img src="paperclip.svg" alt="Send file" class="attach-file-icon" /></a>
                      <input type="submit" class="button" value=">" />
                  </form>
              </div>
          </div>
          <div class="hidden file-upload-container" id="fileUploadContainer"><form id="fileUploadForm" enctype="multipart/form-data">
              <input type="file" id="fileUploadInput" />
              <div id="fileUploadError" class="file-upload-error hidden"></div>
              <a id="fileUploadCancel" class="button"/></a>
              <input type="submit" class="button"/>
          </form></div>
          <div class="error" id="neterror"></div>`
        +templates.footer(["emojione_v2.3.sprites.js", "openpgp.min.js", "slack.min.js"])
    };
};

