File size: 4,095 Bytes
e9488eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Advanced Terminal & Image Download</title>
  <style>
    body {
      margin: 0;
      font-family: monospace;
      background: black;
      color: #00ff00;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }

    .container {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }

    .button-container {
      margin-bottom: 20px;
    }

    button {
      background-color: #00ff00;
      border: 1px solid #00ff00;
      padding: 10px 20px;
      margin: 10px;
      color: black;
      font-size: 16px;
      cursor: pointer;
    }

    .image-container {
      display: none;
      justify-content: center;
      align-items: center;
    }

    .terminal {
      display: none;
      width: 80%;
      height: 80%;
      background: black;
      border: 2px solid #00ff00;
      padding: 10px;
      overflow-y: auto;
    }

    .input-line {
      display: flex;
      align-items: center;
    }

    .prompt {
      margin-right: 5px;
    }

    .input {
      border: none;
      background: transparent;
      color: #00ff00;
      outline: none;
      flex: 1;
    }

    .output {
      white-space: pre-wrap;
      margin: 5px 0;
    }

  </style>
</head>
<body>
  <div class="container">
    <div class="button-container">
      <button onclick="showImages()">Show Images</button>
      <button onclick="showTerminal()">Show Terminal</button>
    </div>

    <!-- Image Container -->
    <div class="image-container" id="image-container">
      <h3>Downloaded Image:</h3>
      <img id="downloaded-image" src="" alt="Image will appear here" style="width: 100%; max-width: 600px;">
      <p id="image-size"></p>
      <input type="text" id="image-url" placeholder="Enter image URL">
      <button onclick="downloadImage()">Download Image</button>
    </div>

    <!-- Terminal Container -->
    <div class="terminal" id="terminal">
      <div class="output">Welcome to the Advanced KalY Linux Terminal! Type `help` for a list of commands.</div>
      <div class="input-line">
        <span class="prompt">kaly@linux:~$</span>
        <input type="text" class="input" id="input" autofocus>
      </div>
    </div>
  </div>

  <script>
    function showImages() {
      document.getElementById('image-container').style.display = 'flex';
      document.getElementById('terminal').style.display = 'none';
    }

    function showTerminal() {
      document.getElementById('terminal').style.display = 'block';
      document.getElementById('image-container').style.display = 'none';
    }

    function downloadImage() {
      const imageUrl = document.getElementById('image-url').value;
      if (imageUrl) {
        fetch(`/download_image?url=${encodeURIComponent(imageUrl)}`)
          .then(response => response.json())
          .then(data => {
            if (data.success) {
              document.getElementById('downloaded-image').src = data.image_url;
              document.getElementById('image-size').innerText = `File size: ${data.file_size}`;
            } else {
              alert('Failed to download image.');
            }
          });
      } else {
        alert('Please enter a valid image URL.');
      }
    }

    document.getElementById("input").addEventListener("keydown", function (event) {
      if (event.key === "Enter") {
        let command = event.target.value;
        fetch('/terminal', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({ command: command })
        })
        .then(response => response.json())
        .then(data => {
          let output = document.querySelector(".output");
          output.textContent += '\n' + data.output;
          event.target.value = '';
          window.scrollTo(0, document.body.scrollHeight);
        });
      }
    });
  </script>
</body>
</html>