-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
468 lines (400 loc) · 23.8 KB
/
index.html
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Defend with AI</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.socket.io/4.7.2/socket.io.min.js"
integrity="sha384-mZLF4UVrpi/QTWPA7BjNPEnkIfRFn4ZEO3Qt/HFklTJBj/gBOV8G3HcKn4NfQblz"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-HE9PB7G54S"></script>
<link href="https://fonts.cdnfonts.com/css/inter" rel="stylesheet">
<link href="https://fonts.cdnfonts.com/css/source-sans-pro" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-HE9PB7G54S');
</script>
<style>
html * {
font-family: Source Sans Pro;
color: black
}
.button.is-primary,
.input.is-primary {
width: 100%;
/* Full width for both button and input */
height: 50px;
/* Equal height for button and input */
padding: 10px 15px;
/* Padding for button and input */
font-size: 1.2rem;
/* Font size for button and input */
box-sizing: border-box;
}
.button.is-primary {
background-color: #0038b8;
border-color: #0038b8;
}
.button.is-primary:hover {
background-color: #0056cc;
/* Slightly lighter shade for hover */
border-color: #0056cc;
}
.input.is-primary:focus,
.input.is-primary.is-focused {
border-color: #0038b8;
box-shadow: 0 0 0.625rem rgba(0, 56, 184, 0.5);
}
/* Adjustments for smaller screens */
@media screen and (max-width: 768px) {
.button.is-primary,
.input.is-primary {
font-size: 1.0rem;
/* Smaller font size on mobile */
height: 40px;
/* Smaller height on mobile */
padding: 8px 10px;
/* Smaller padding on mobile */
}
}
.content {
-webkit-touch-callout: none;
/* iOS Safari */
-webkit-user-select: none;
/* Safari */
-khtml-user-select: none;
/* Konqueror HTML */
-moz-user-select: none;
/* Old versions of Firefox */
-ms-user-select: none;
/* Internet Explorer/Edge */
user-select: none;
/* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
}
</style>
</head>
<body>
<div id="app" class="p-3 flex flex-col items-center container">
<div class="mt-5 text-6xl font-semibold max-sm:text-4xl">
Argument
</div>
<div class="font-light text-[#253540] mt-5 text-2xl text-center max-sm:text-sm">
<div>
Harness the power of AI to defend
<span class="font-bold text-[#1D68C0]">Israel</span>
online
</div>
<div>
with powerful replies
</div>
</div>
<div class="font-[Inter] font-semibold mt-16 text-lg max-sm:text-xs max-sm:mt-6">
Enter an anti-Israel argument below
</div>
<div class="w-full md:max-w-2xl relative sm:mt-5 flex justify-center max-sm:mt-20">
<textarea rows="4" id="txtPrompt" v-model="argument"
class="resize-none absolute z-50 block p-2.5 w-full text-sm text-gray-900 bg-[#FAEEF1] rounded-lg shadow-lg outline-0"></textarea>
<img class="absolute sm:right-0 top-[-110px] w-[200px] z-0 max-sm:top-[-90px]" src="./assets/image-1.png">
</div>
<div class="mt-32">
<button type="button" :disabled="isLoading || isStreaming" @click="socketResponse"
class="text-white bg-gray-800 hover:bg-gray-900 focus:outline-none font-medium text-xl px-6 py-4 mt-5 max-md:text-sm">
<template v-if="!isLoading && !isStreaming">Generate Response</template>
<svg v-if="isLoading || isStreaming" aria-hidden="true" role="status"
class="inline w-4 h-4 me-3 text-white animate-spin" viewBox="0 0 100 101" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="#E5E7EB" />
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentColor" />
</svg>
<template v-if="isLoading || isStreaming">Generating...</template>
</button>
</div>
<!-- <div v-if="isLoading" class="busy-indicator"><img src="https://uploads.superbot.works/site-static/files/shares/supbot.gif"/></div> -->
<!-- <progress v-if="isLoading" class="progress is-large is-info" max="100">60%</progress> -->
<!-- <div v-if="isLoading" class="busy-indicator"><img src="https://mir-s3-cdn-cf.behance.net/project_modules/disp/585d0331234507.564a1d239ac5e.gif"/></div> -->
<!-- <div v-if="isLoading" class="busy-indicator"><img src="supbot.gif"/></div> -->
<br />
<br />
<div v-if='error' class="notification is-warning">
{{error}}
</div>
<div ref='resultDiv' class="container ">
<div v-if="response">
<div v-if="!isLoading" class="flex flex-col items-center">
<!-- anti-israel argument -->
<div
class="w-full relative p-4 flex flex-row bg-[#FBFBFB] border border-gray-100 rounded-md md:flex-row md:max-w-2xl max-md:justify-center max-md:mt-10 max-md:text-center">
<div
class="bg-[#FAEEF1] rounded-lg w-[75px] h-[75px] flex flex-shrink-0 justify-center items-center max-md:hidden">
<img class="object-cover rounded-t-lg h-[50px] items-center"
src="./assets/quarantine-icon.png" alt="anti-israel-icon">
</div>
<div
class="bg-[#FAEEF1] rounded-lg w-[75px] h-[75px] flex flex-shrink-0 justify-center items-center sm:hidden absolute top-[-60px] ">
<img class="object-cover rounded-t-lg h-[50px] items-center"
src="./assets/quarantine-icon.png" alt="anti-israel-icon">
</div>
<div class="justify-between pl-4 pr-4 leading-normal">
<h5 class="font-[Inter] mb-2 text-lg font-semibold tracking-tight text-gray-900">
Anti-Israel Argument</h5>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">{{ _argument }}</p>
</div>
</div>
<!-- pro-israel response -->
<div class="w-full mt-6 p-4 bg-[#EEF5FA] border border-gray-100 rounded-md md:max-w-2xl ">
<div class="flex max-md:flex-col md:max-w-2xl items-center max-md:text-center">
<div
class="bg-white rounded-lg w-[75px] h-[75px] flex flex-shrink-0 justify-center items-center">
<img class="object-cover rounded-t-lg h-[50px] items-center"
src="./assets/magen-david-icon.png" alt="anti-israel-icon">
</div>
<div class="justify-between pl-4 pr-4 leading-normal max-md:mt-4">
<h5 class="font-[Inter] mb-2 text-lg font-semibold tracking-tight text-gray-900">
Pro-Israel Argument</h5>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">{{ message }}</p>
</div>
</div>
<div class="border-t-2 mt-3 mb-3"></div>
<div v-if="response" class="flex justify-between">
<div class="flex w-[165px] justify-between">
<!-- Facebook -->
<a href="https://www.facebook.com/sharer.php?u=https://ai4israel.com/">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M9 8h-3v4h3v12h5v-12h3.642l.358-4h-4v-1.667c0-.955.192-1.333 1.115-1.333h2.885v-5h-3.808c-3.596 0-5.192 1.583-5.192 4.615v3.385z" />
</svg>
</a>
<!-- Whatsapp -->
<a
href="https://api.whatsapp.com/send?text=AI+for+Israel Harness+the+power+of+AI+to+defend+Israel+online+with+powerful%C2%A0replies%21 https://ai4israel.com/">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M.057 24l1.687-6.163c-1.041-1.804-1.588-3.849-1.587-5.946.003-6.556 5.338-11.891 11.893-11.891 3.181.001 6.167 1.24 8.413 3.488 2.245 2.248 3.481 5.236 3.48 8.414-.003 6.557-5.338 11.892-11.893 11.892-1.99-.001-3.951-.5-5.688-1.448l-6.305 1.654zm6.597-3.807c1.676.995 3.276 1.591 5.392 1.592 5.448 0 9.886-4.434 9.889-9.885.002-5.462-4.415-9.89-9.881-9.892-5.452 0-9.887 4.434-9.889 9.884-.001 2.225.651 3.891 1.746 5.634l-.999 3.648 3.742-.981zm11.387-5.464c-.074-.124-.272-.198-.57-.347-.297-.149-1.758-.868-2.031-.967-.272-.099-.47-.149-.669.149-.198.297-.768.967-.941 1.165-.173.198-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.521.151-.172.2-.296.3-.495.099-.198.05-.372-.025-.521-.075-.148-.669-1.611-.916-2.206-.242-.579-.487-.501-.669-.51l-.57-.01c-.198 0-.52.074-.792.372s-1.04 1.016-1.04 2.479 1.065 2.876 1.213 3.074c.149.198 2.095 3.2 5.076 4.487.709.306 1.263.489 1.694.626.712.226 1.36.194 1.872.118.571-.085 1.758-.719 2.006-1.413.248-.695.248-1.29.173-1.414z" />
</svg>
</a>
<!-- Telegran -->
<a href="https://telegram.me/share/url?url=https://ai4israel.com/&text=AI for Israel">
<!-- Telegram -->
<svg class="h-4 w-4" fill="currentColor" viewbox="0 0 24 24" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve" xmlns:serif="http://www.serif.com/"
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
<path id="telegram-1"
d="M18.384,22.779c0.322,0.228 0.737,0.285 1.107,0.145c0.37,-0.141 0.642,-0.457 0.724,-0.84c0.869,-4.084 2.977,-14.421 3.768,-18.136c0.06,-0.28 -0.04,-0.571 -0.26,-0.758c-0.22,-0.187 -0.525,-0.241 -0.797,-0.14c-4.193,1.552 -17.106,6.397 -22.384,8.35c-0.335,0.124 -0.553,0.446 -0.542,0.799c0.012,0.354 0.25,0.661 0.593,0.764c2.367,0.708 5.474,1.693 5.474,1.693c0,0 1.452,4.385 2.209,6.615c0.095,0.28 0.314,0.5 0.603,0.576c0.288,0.075 0.596,-0.004 0.811,-0.207c1.216,-1.148 3.096,-2.923 3.096,-2.923c0,0 3.572,2.619 5.598,4.062Zm-11.01,-8.677l1.679,5.538l0.373,-3.507c0,0 6.487,-5.851 10.185,-9.186c0.108,-0.098 0.123,-0.262 0.033,-0.377c-0.089,-0.115 -0.253,-0.142 -0.376,-0.064c-4.286,2.737 -11.894,7.596 -11.894,7.596Z" />
</svg>
</a>
<!-- Twitter -->
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z" />
</svg>
</a>
<!-- Linkedin -->
<!-- <a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M4.98 3.5c0 1.381-1.11 2.5-2.48 2.5s-2.48-1.119-2.48-2.5c0-1.38 1.11-2.5 2.48-2.5s2.48 1.12 2.48 2.5zm.02 4.5h-5v16h5v-16zm7.982 0h-4.968v16h4.969v-8.399c0-4.67 6.029-5.052 6.029 0v8.399h4.988v-10.131c0-7.88-8.922-7.593-11.018-3.714v-2.155z" />
</svg>
</a> -->
</div>
<div class="hover:cursor-pointer" @click="copyToClipboard">
<div class="flex">
Copy
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" data-slot="icon" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z" />
</svg>
</div>
</div>
</div>
</div>
</div>
<div v-if="response.metadata.link && !isLoading" class="card">
<div class="card-content">
<div class="content">
Use the following link to support your argument:
<br />
<a href="{{ response.metadata.link }}" target="_blank" class="link">{{
response.metadata.link }}</a>
</div>
</div>
</div>
<a v-if="response.metadata.link && !isLoading" href="{{ response.metadata.link }}" target="_blank"
class="link">{{ response.metadata.link }}</a>
</div>
</div>
<div v-if="showCopiedToast"
class="bottom-5 absolute flex items-center w-full max-w-xs p-4 space-x-4 rtl:space-x-reverse text-gray-500 bg-white divide-x rtl:divide-x-reverse divide-gray-200 rounded-lg shadow dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
role="alert">
<div
class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 p-1 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200">
<img src="/assets/magen-david-icon.png" />
</div>
<div class="ps-4 text-sm font-normal">Copied to clipboard!</div>
</div>
</div>
<script>
// development const socket = io('hasbarobot-e4gvrpubja-uc.a.run.app');
const socket = io();
new Vue({
el: '#app',
data: {
argument: '',
response: null,
isLoading: false,
showCopiedToast: false,
isStreaming: false,
error: null,
success: true,
_argument: '',
message: ''
},
// data: {
// _argument: "",
// argument: "",
// error: null,
// isLoading: false,
// isStreaming: false,
// message: "this is a test for the purpose of testing ",
// response: {
// content: "testing ",
// error: null,
// is_last_message: false,
// metadata: {
// answer_id: "1533023167095109299,7",
// link: null,
// link_score: null,
// node_id: "8295268295625768978",
// query: "this is a test\n",
// query_embedding: Array[1536],
// score: 0.968154192,
// text: null,
// type: "canned",
// },
// },
// success: true
// },
computed: {
},
mounted() {
this.setInputValueFromUrl();
// Setting up Socket.IO event listeners
socket.on('connect', () => {
// console.log('Connected to the server.');
});
const input = document.querySelector('#txtPrompt');
input.addEventListener('keyup', (event) => {
if (event.key === 'Enter') {
this.handleEnterPress();
}
});
const noCopyDiv = this.$refs.resultDiv;
// Disable right-click
noCopyDiv.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
// Disable copy using keyboard shortcuts
noCopyDiv.addEventListener('keydown', (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === 'c') {
event.preventDefault();
}
});
// Disable copy event (including using the browser menu)
noCopyDiv.addEventListener('copy', (event) => {
event.preventDefault();
});
socket.on('query_response', (response) => {
this.isLoading = false;
this.isStreaming = true;
if (response.success == false) {
this.success = false;
this.error = response.error;
this.isStreaming = false;
response.is_last_message = true;
}
// console.log('Received response:', response);
if (response.is_last_message) {
this.isStreaming = false;
}
else {
if (response.content != null && response.content != undefined) {
this.message += response.content;
this.response = response;
}
}
});
socket.on('disconnect', () => {
// console.log('Disconnected from the server.');
});
},
methods: {
socketResponse() {
this.error = null;
this._argument = this.argument
socket.emit('send_query', { query: this.argument });
this.argument = ''; // Reset query input
this.message = '';
this.response = false;
this.isLoading = true;
this.isStreaming = true;
gtag("event", "generate_response", {
"event_category": "engagement",
"event_label": "generate_response",
'value': this._argument
});
},
handleEnterPress() {
// Only trigger the button click if it is not disabled
if (!this.isLoading && !this.isStreaming) {
this.socketResponse();
}
},
copyToClipboard() {
const inputElement = document.createElement('input');
inputElement.value = this.message;
document.body.appendChild(inputElement);
inputElement.select();
document.execCommand('copy');
document.body.removeChild(inputElement);
socket.emit('copy_answer', { query: this._argument });
gtag("event", "copy_text_answer", {
"event_category": "engagement",
"event_label": "copy_text_answer",
'value': this._argument
});
this.showCopiedToast = true;
setTimeout(() => {
this.showCopiedToast = false;
}, 2000);
},
setInputValueFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('query')) {
this.argument = urlParams.get('query');
this.socketResponse();
}
}
}
})
// this.response = "This is a static response. Replace with API call.";
</script>
</body>
</html>