File size: 6,054 Bytes
ee84cd3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="/static/css/styles.css">
    <link rel="stylesheet" type="text/css" href="/static/css/styles.css" />
    <meta charset="UTF-8" />
    <title>MapMaster Chat</title>
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    />
    <link rel="stylesheet" type="text/css" href="/static/css/styles.css" />
  </head>
  <body>
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <div id="sidebar">
          <h2>Project</h2>
          <a href="/templates/index.html" class="active">MapMaster Chat</a>
<a href="/templates/acc5298da7e6c28972547fee04ae882f6ee7f582566e2f78d23b63253c8a4741.html">Spider-Man</a>
<a href="/templates/4638dc9aab9e7422a3632098471765a445a6e8c61316e5cde4dea4ca7538b969.html">Impresionismo Español</a>
<a href="/templates/bc8c3cc3d2caf61eba4bc498daf9134c68a952ed645fc62d443d111f3f8904ba.html">Arte Abstracto Español</a>
<a href="/templates/9a7f018817c8ff030971229e20b1b07b4d84ad6ef94621bf3382a1da9ffe3a93.html">Daredevil</a>

        </div>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        

    <div class="container">
      <h1 class="mt-5">Chat con MapMaster</h1>
      <form id="chatForm">
        <div class="form-group">
          <label for="message">Mensaje:</label>
          <textarea
            class="form-control"
            id="message"
            name="message"
            required
            rows="5"
          ></textarea>
        </div>
        <button type="submit" class="btn btn-primary">Send</button>
      </form>
      <div class="mt-5" id="response-container">
        <h2>Respuesta</h2>
        <pre id="response"></pre>
      </div>
      <div id="loading">Cargando...</div>
    </div>

    <div id="settings">⚙️</div>
    <div id="settings-menu">
      <ul>
        <li>
          <a href="#" onclick="showDeleteMapDialog()"
            >Eliminar Mapas Mentales</a
          >
        </li>
        <li>
          <a href="#" onclick="regenerateContent()">Regenerar contenido</a>
        </li>
      </ul>
    </div>

    <script>
      document
        .getElementById("chatForm")
        .addEventListener("submit", function (event) {
          event.preventDefault();
          const messageInput = document.getElementById("message");
          const message = messageInput.value;
          const responseContainer = document.getElementById("response");
          const loadingIndicator = document.getElementById("loading");
          const formData = new FormData();
          formData.append("message", message);

          loadingIndicator.style.display = "block";
          responseContainer.textContent = "";

          fetch("/send_message", {
            method: "POST",
            body: formData,
          })
            .then((response) => response.json())
            .then((data) => {
              loadingIndicator.style.display = "none";
              if (data.markdown) {
                responseContainer.textContent = data.markdown;
              } else if (data.status) {
                responseContainer.textContent = data.status;
              }
            })
            .catch((error) => {
              loadingIndicator.style.display = "none";
              console.error("Error:", error);
            });

          messageInput.value = ""; // Clear the input field after sending the message
        });

      document
        .getElementById("settings")
        .addEventListener("click", function () {
          const settingsMenu = document.getElementById("settings-menu");
          if (settingsMenu.style.display === "none") {
            settingsMenu.style.display = "block";
          } else {
            settingsMenu.style.display = "none";
          }
        });

      function showDeleteMapDialog() {
        fetch("/get_maps")
          .then((response) => response.json())
          .then((data) => {
            let mapList = "<ul>";
            data.maps.forEach((map) => {
              mapList += `<li><span>${map.title}</span><button onclick="deleteMap('${map.filename}')">Eliminar</button></li>`;
            });
            mapList += "</ul>";
            document.getElementById("response").innerHTML = mapList;
          });
      }

      function deleteMap(filename) {
        fetch(`/delete_map/${filename}`, { method: "DELETE" })
          .then((response) => response.json())
          .then((data) => {
            if (data.success) {
              alert("Mapa eliminado con éxito");
              location.reload();
            } else {
              alert("Error al eliminar el mapa");
            }
          });
      }

      function regenerateContent() {
        fetch("/regenerate_content", { method: "POST" })
          .then((response) => response.json())
          .then((data) => {
            if (data.success) {
              alert("Contenido regenerado con éxito");
              location.reload();
            } else {
              alert("Error al regenerar el contenido");
            }
          });
      }
    </script>
    <img id="logo" src="/static/assets/logo.png" alt="Logo" />
    <img id="logo" src="/static/assets/logo.png" alt="Logo" />
  <img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
<img id="logo" src="/static/assets/logo.png" alt="Logo">
</body>
</html>