forked from dirk1983/chatgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
319 lines (238 loc) · 9.81 KB
/
index.php
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?php
$type = "NPC.TO";
?>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title><?= $type ?></title>
<link rel="stylesheet" href="css/common.css?v1.1">
<link rel="stylesheet" href="css/wenda.css?v1.1">
<link rel="stylesheet" href="css/hightlight.css">
<style>
#file-input {
display: none;
}
#file-input-btn {
padding: 10px 10px;
background-color: #fff;
color: grey;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
max-width:105px;
width:80px;
}
#key {
margin:2px;
padding: 10px 10px;
background-color: #fff;
color: grey;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
display:block;
width:auto;
}
#preview-container {
position: fixed;
top: 20%;
left: 50%;
transform: translate(-50%,-20%);
z-index: 9999;
}
.dropbtn {
padding: 10px 10px;
background-color: #fff;
color: grey;
font-size: 16px;
font-weight: bold;
border-radius: 4px;
cursor: pointer;
max-width:105px;
width:100px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
z-index: 1;
min-width: 160px;
padding: 12px 16px;
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
border-radius: 4px;
}
.dropdown-content a {
color: black;
padding: 6px 8px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #e1e1e1;
}
.header-logo {
width: 100%;
}
</style>
</head>
<body>
<div class="layout-wrap">
<header class="layout-header">
<div class="dropdown" style="position:relative; display:inline-block;">
<button class="dropbtn">NPC.TO</button>
<div class="dropdown-content">
<div style="display: flex;flex-direction: row;">
<a class="links" id="clean" title="clean text">CLEAN</a>
<a href="/" class="links" id="clickable-link">GPT4</a>
<a href="/35" class="links" id="clickable-link2">GPT3.5</a>
<a href="#" data-value="I want you to act like {Character} from {Series}. I want you to respond and answer like {Character}, without any explanations. You must know everything about {Character}. My first sentence is 'Hello.'">Character</a>
<a href="#" data-value="I want you to be my Linux terminal. I'll input commands, and you'll reply with what the terminal should display. I want you to reply only within a single code block, and not with any other content. Don't provide explanations. Only type commands when I instruct you to do so. When I need to tell you something in English, I will put the text in brackets like this [like this]. My first command is 'pwd'">Linux</a>
<a href="#" data-value="I want you to be my English translator, spell checker, and rhetoric improver. I'll communicate with you in any language, and you'll identify the language, translate it, and respond to me in more elegant and refined English. Please replace my simple vocabulary and sentences with more beautiful and literary expressions while ensuring that the meaning remains unchanged. Please only respond with corrections and improvements, and do not provide explanations. My first sentence is 'How are you?' Please translate it.">Translator</a>
<a href="#" data-value="I want you to play the role of a storyteller. You will come up with an engaging, imaginative, and captivating story that would appeal to the audience. It can be a fairy tale, an educational story, or any other type of story that has the potential to capture people's attention and imagination. Depending on the target audience, you can select a specific theme or subject for the storytelling segment. For instance, if it is for children, you can talk about animals, and if it is for adults, a story based on history might better capture their attention. My first request is, 'I need an interesting story about perseverance.'">Storyteller</a>
<a href="#" data-value=""></a>
<a href="https://github.com/kevacointoolkit/npcto" class="links" id="clickable-link3">GITHUB</a>
</div>
</div>
</div>
<input type="checkbox" id="keep" checked="checked" style="display:none;" checked>
<button id="file-input-btn">PFP</button>
<input type="password" id="key" onload="this.focus();" placeholder="API-KEY">
</header>
<div class="layout-content">
<div class="container">
<article class="article" id="article">
<div class="article-box">
<br>
<center>
<div id="preview-container"></div>
</center>
<br>
<ul id="article-wrapper" style="display: flex; flex-direction: column-reverse;"></ul>
</ul>
<div class="creating-loading" data-flex="main:center dir:top cross:center">
<div class="semi-circle-spin"></div>
</div>
<div id="fixed-block">
<div class="precast-block" id="kw-target-box" data-flex="main:left cross:center">
<div id="target-box" class="box">
<textarea name="kw-target" placeholder="INPUT WORDS, Ctrl+Enter Send" id="kw-target" autofocus rows=1></textarea>
</div>
<div class="right-btn layout-bar">
<p class="btn ai-btn bright-btn" id="ai-btn" data-flex="main:center cross:center"><i class="iconfont icon-wuguan"></i>SEND</p>
</div>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.cookie.min.js"></script>
<script src="js/layer.min.js"></script>
<script src="js/chat.js?v2.8"></script>
<script src="js/highlight.min.js"></script>
<script src="js/showdown.min.js"></script>
<script>
const fileInputBtn = document.querySelector("#file-input-btn");
const previewContainer = document.querySelector("#preview-container");
const kwTarget = document.querySelector("#kw-target");
const xhr1 = new XMLHttpRequest();
const xhr2 = new XMLHttpRequest();
let response = {}; // Declare response object outside the function
let globalnpc = ""; // Declare globalnpc variable outside the function
fileInputBtn.addEventListener("click", function () {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*,video/*";
input.onchange = function (event) {
const file = event.target.files[0];
const fileName = file.name;
if (file.type.startsWith("image")) {
// If the selected file is an image
const reader = new FileReader();
reader.onload = function (event) {
const img = document.createElement("img");
img.src = event.target.result;
img.style.maxHeight = "60vh";
previewContainer.innerHTML = "";
previewContainer.appendChild(img);
};
reader.readAsDataURL(file);
} else if (file.type.startsWith("video")) {
// If the selected file is a video
const video = document.createElement("video");
video.src = URL.createObjectURL(file);
video.controls = true;
video.autoplay = true;
video.loop = true;
video.style.maxHeight = "60vh";
previewContainer.innerHTML = "";
previewContainer.appendChild(video);
}
xhr1.onreadystatechange = function () {
if (xhr1.readyState === 4 && xhr1.status === 200) {
response.fn = xhr1.responseText; // Assign value to fn property of response object
kwTarget.value = response.fn;
// Check if fn response is not empty
if (response.fn.trim() !== "") {
// Trigger click event on ai-btn
const aiBtn = document.querySelector("#ai-btn");
aiBtn.click();
response.fn = ""; // Reset fn response property
}
}
};
xhr2.onreadystatechange = function () {
if (xhr2.readyState === 4 && xhr2.status === 200) {
response.npc = xhr2.responseText; // Assign value to npc property of response object
// Check if npc response is not empty
globalnpc=xhr2.responseText;
}
};
xhr1.open("POST", "keva.php");
xhr1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr1.send("fn=" + fileName);
xhr2.open("POST", "keva.php");
xhr2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr2.send("fn=" + fileName + "&npc=1");
};
input.click();
});
var dropdown = document.querySelector('.dropdown');
var dropdownContent = document.querySelector('.dropdown-content');
var textarea = document.querySelector('#kw-target');
dropdown.addEventListener('click', function() {
dropdownContent.classList.toggle('show');
});
dropdownContent.addEventListener('click', function(event) {
event.preventDefault();
if (event.target.tagName.toLowerCase() === 'a') {
var value = event.target.getAttribute('data-value');
textarea.value = ''; //
textarea.value += value;
dropdownContent.classList.remove('show');
}
});
var links = document.querySelectorAll("[id^='clickable-link']");
for (var i = 0; i < links.length; i++) {
links[i].addEventListener("click", function(event) {
event.stopPropagation();
window.location.href = this.href;
});
}
</script>
</body>
</html>