#ifndef ____editview_h__
#define ____editview_h__

#include "HTTPPage.h"
#include "File.h"

namespace http {

   class __editview : public HTTPPage {

      int page(HTTPParameters &p) override {

         char format[256];
         sprintf(format, "/home/barant/jetserver/views/%s.view", p.httpRequest.uriValues["view_name"].str().c_str());
         coreutils::File workspace(format);
         workspace.read();
         // coreutils::ZString requestId(putRequest());

         p.data << "  <div style=\"position: relative;\">"
                   "  <div id=\"window1\" style=\"position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
                   "  <span style=\"font: 20px bebasneue;\">View Editor</span>"
                   "  <div id=\"mainpage\" "
                   "       style=\"width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;\" "
                   "       onmousemove=\"mousemove(event); return true;\" "
                   "       onmouseup=\"mouseup(); return true;\">"
                   "    <canvas id=\"grid\" width=\"600px\" height=\"600px\" style=\"position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;\"></canvas>"
                   "<div id=\"__workspace__\">" << workspace.asString() << "</div>"
                   "  <div id=\"window3\" style=\"position:absolute; top: 235px; left: 610px;"
                   "       border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
                   "  <span style=\"font: 20px bebasneue;\">OPTIONS</span>"
                   "  <div style=\"width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;\" "
                   "       onmousemove=\"mousemove(event); return true;\" "
                   "       onmouseup=\"mouseup(); return true;\">  "
                   "  <div id=\"controls\">"
                   "    <input type=\"checkbox\" name=\"grid\" onchange=\"showGrid = this.checked; drawGrid(); return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Show Grid</span><br>"
                   "    <input type=\"checkbox\" name=\"snaptogrid\" onchange=\"snapToGrid = this.checked; return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Snap To Grid</span><br>"
                   "    <span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Grid Size: </span><input type=\"text\" name=\"gridsize\" id=\"gridsize\" style=\"width: 20px;\" size=\"3\" onchange=\"gridSize = parseInt(this.value); drawGrid(); return true;\"><br>"
                   "  </div>"
                   "  <div id=\"itemparameters\" style=\"font: 12px bebasneue;\"></div>"
                   "  <div id=\"data\" style=\"font: 12px bebasneue;\">"
                   "   <p>NO DATA</p>"
                   "  </div>"
                   "  </div>"
                   "  </div>"
                   "  <div id=\"window2\" style=\"position:absolute; top: 0px; left: 610px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
                   "  <span style=\"font: 20px bebasneue;\">Toolbar</span>"
                   "  <div id=\"toolbar\" "
                   "       style=\"width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;\" "
                   "       onmousemove=\"mousemove(event); return true;\" "
                   "       onmouseup=\"mouseup(); return true;\">"
                   "    <button id=\"button1\" "
                   "       style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
                   "       onmousedown=\"mousedown(this, event); return true;\">Press</button>"
                   "  </div>"
                   "  </div>"
                   "  <div id=\"window3\" style=\"position:absolute; top: 0px; left: 810px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
                   "  <span style=\"font: 20px bebasneue;\">Styles</span>"
                   "  <div id=\"toolbar2\" "
                   "       style=\"width: 100px; height: 150px; border: 1px solid black; position: relative; background: #ffffff;\" "
                   "       onmousemove=\"mousemove(event); return true;\" "
                   "       onmouseup=\"mouseup(); return true;\">"
                   "    <button id=\"button1\" "
                   "       style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
                   "       onmousedown=\"mousedown(this, event); return true;\">Press</button>"
                   "  </div>"
                   "  <div id=\"window4\" style=\"position:absolute; top: 600px; left: 10px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
                   "  <span style=\"font: 20px bebasneue;\">Image Library</span>"
                   "  <div id=\"toolbar3\" "
                   "       style=\"width: 400px; height: 150px; border: 1px solid black; position: relative; background: #ffffff;\" "
                   "       onmousemove=\"mousemove(event); return true;\" "
                   "       onmouseup=\"mouseup(); return true;\">"
                   "    <button id=\"button1\" "
                   "       style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
                   "       onmousedown=\"mousedown(this, event); return true;\">Press</button>"
                   "  </div>"
                   "  </div>"
                   "  </div>"
                   "  <script src=\"/__editview_js\" />";

         p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));

         return 1;
      }

   };

}

#endif
