forked from vishanurag/Canvas-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1047 lines (906 loc) · 33.6 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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Creative Canvas Tool</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="icon" href="resources/favicon.ico" type="image/ico">
<div class="visitor-counter">
<div>Visitor</div>
<div class="website-counter"></div>
</div>
<style>
#toggleGridButton {
margin-top: 10px;
}
.visitor-counter {
position: fixed;
top: 570px;
left: 10px;
background-color: rgba(255, 255, 255, 0.8);
/* Slightly opaque background for better visibility */
height: 100px;
width: 100px;
color: #333;
/* Darker text for better contrast */
font-weight: 700;
font-size: 18px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-radius: 12px;
/* Softer corners */
backdrop-filter: blur(10px);
/* Increased blur for a modern touch */
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15),
/* Slightly more pronounced shadow */
0 2px 4px rgba(0, 0, 0, 0.1);
z-index: 1000;
transition: all 0.3s ease;
/* Smooth transition for hover effect */
}
.visitor-counter:hover {
transform: scale(1.05);
/* Slightly enlarge on hover */
box-shadow: 0 8px 16px rgba(197, 56, 215, 0.2);
/* Enhance shadow on hover */
}
.visitor-counter div:first-child {
margin-bottom: 5px;
font-size: 14px;
/* Adjusted for clarity */
letter-spacing: 1px;
/* Increased spacing for readability */
}
.website-counter {
font-size: 24px;
font-family: 'Arial', sans-serif;
/* Consistent font family */
}
@media screen and (max-width: 768px) {
.visitor-counter {
height: 100px;
width: 100px;
font-size: 16px;
}
.website-counter {
font-size: 20px;
}
}
@media screen and (max-width: 480px) {
.visitor-counter {
height: 80px;
width: 80px;
font-size: 14px;
}
.website-counter {
font-size: 18px;
}
}
.dark-mode .visitor-counter div {
color: #f0f0f0;
/* Lighter text for dark mode */
}
.dark-mode .visitor-counter .website-counter {
color: #f0f0f0;
/* Lighter color for consistency */
}
.dark-mode .visitor-counter {
background-color: rgba(185, 66, 196, 0.7);
/* Darker background for dark mode */
box-shadow: 0 6px 12px rgba(255, 255, 255, 0.1),
0 2px 4px rgba(255, 255, 255, 0.05);
}
</style>
<script>
// Function to get the count from localStorage or initialize it
function getVisitorCount() {
return localStorage.getItem('visitorCount') || 0;
}
// Function to increment and save the count
function incrementVisitorCount() {
let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);
return count;
}
// Function to display the count
function displayVisitorCount() {
const counterElement = document.querySelector('.website-counter');
const count = incrementVisitorCount();
counterElement.textContent = count;
}
// Call the display function when the page loads
document.addEventListener('DOMContentLoaded', displayVisitorCount);
</script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
display: flex;
overflow-x: hidden;
}
.sidebar {
width: 100px;
background-color: #eca6f4;
color: white;
padding: 17px;
padding-top: 100px;
}
.sidebar button {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 10px;
background-color: #63077f;
border: none;
color: rgb(248, 249, 249);
text-align: left;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
font-size: 15px;
}
.sidebar button:hover {
background-color: #911da1;
}
.canvas{
padding-right: 50px;
padding-left: 10px;
}
.main-content {
flex-grow: 1;
display: flex;
flex-direction: column;
min-height: 100vh;
}
.navbar {
background-color: #f0adfb;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 50px;
}
.navbar h1 {
color: rgb(126, 36, 36);
margin: 0px;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
font-size: 30px;
}
.nav-links {
display: flex;
gap: 20px;
margin: auto;
}
.nav-links a {
color: rgb(255, 255, 255);
text-decoration: none;
padding: 6px 4px;
border-radius: 4px;
transition: background-color 0.3s;
}
.nav-links a:hover {
background-color: #541058;
}
.tools {
display: flex;
gap: 10px;
padding-left: 40px;
padding-bottom: 10px;
background-color: #e76af5;
}
.tool {
background-color: #460346;
border: none;
color: white;
/* padding: 10px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 0px 0px;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}
.tool:hover {
background-color: #87087c;
}
.tool.active {
background-color: #5e044f;
}
#canvas {
border: 1px solid #e049e8;
background-color: white;
cursor: crosshair;
width: 100%;
height: calc(100vh - 280px);
/* Adjusted for footer */
}
.color-picker {
margin: 10px 0;
position: relative;
display: inline-block;
}
.color-picker input[type="color"] {
padding: 0;
width: 50px;
height: 40px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.color-palette {
position: absolute;
top: 100%;
left: 0;
background: white;
padding: 10px;
border-radius: 4px;
box-shadow: 0 2px 10px rgba(187, 60, 178, 0.1);
display: none;
grid-template-columns: repeat(5, 1fr);
gap: 5px;
z-index: 1000;
}
.color-picker:hover .color-palette {
display: grid;
}
.color-swatch {
width: 25px;
height: 25px;
border-radius: 4px;
cursor: pointer;
border: 1px solid #ddd;
}
.footer {
background-color: #fb99f8;
color: rgb(255, 255, 255);
}
.newsletter-section {
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
max-width: 900px;
margin: 0 auto;
}
.newsletter-section input {
padding: 10px;
width: 300px;
border: none;
border-radius: 4px;
}
.newsletter-section button {
background-color: #d426d7;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
.newsletter-section button:hover {
background-color: #a008b7;
}
.text-size-control {
display: flex;
align-items: center;
gap: 10px;
margin: 10px 0;
background-color: #c350da;
padding: 10px;
border-radius: 5px;
color: white;
}
.text-size-control input {
width: 60px;
padding: 5px;
border: none;
border-radius: 4px;
background-color: white;
}
.text-size-control:hover {
background-color: #5d0874;
transition: background-color 0.3s;
}
.credit {
text-align: center;
}
.share {
font-size: 25px;
}
.share i {
transition: transform 0.3s ease, color 0.3s ease;
}
.share i:hover {
cursor: pointer;
color: #5c2872;
}
.profile{
font-size: 2rem;
padding-right: 1rem;
}
</style>
<style>
/* Circle styles */
.circle {
height: 24px;
width: 24px;
border-radius: 50%;
background-color: black;
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 99999999;
transition: transform 0.1s ease-out;
}
</style>
</head>
<body>
<!-- Circles -->
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="sidebar">
<button id="tools-btn">Tools 🔧</button>
<button id="settings-btn">Settings ⚙️</button>
<button id="help-btn">Help ❓</button>
</div>
<div class="main-content">
<nav class="navbar">
<div class="nav-links">
<h1 class="canvas">Canvas Editor</h1>
<a href="index.html">Home</a>
<a href="about-us.html">About Us</a>
<a href="review.html">Review</a>
<a href="testimonial.html">Testimonial</a>
<a href="privacy.html">Privacy</a>
<a href="tutorial.html">Tutorial</a>
<a href="Blog_page.html">Blog</a>
<a href="Faq.html">FAQ</a>
<a href="./Feedback.html">Feedback</a>
<!-- <a href="signup.html">Sign Up</a> -->
<a href="contributors.html">Contributors</a>
</div>
<a href="auth.html" class="profile">
<i class="fas fa-user-circle"></i>
</a>
</nav>
<div class="tools">
<button class="tool active" id="pencil">Pencil</button>
<button class="tool" id="marker">Marker</button>
<button class="tool" id="eraser">Eraser</button>
<button class="tool" id="line">Line</button>
<button class="tool" id="rectangle">Rectangle</button>
<button class="tool" id="circle">Circle</button>
<button class="tool" id="text">Text</button>
<button class="tool" id="textarea">Text Area</button>
<div class="color-picker">
<input type="color" id="colorPicker">
<div class="color-palette">
<div class="color-swatch" style="background: #ff0000"></div>
<div class="color-swatch" style="background: #00ff00"></div>
<div class="color-swatch" style="background: #0000ff"></div>
<div class="color-swatch" style="background: #ffff00"></div>
<div class="color-swatch" style="background: #ff00ff"></div>
<div class="color-swatch" style="background: #00ffff"></div>
<div class="color-swatch" style="background: #000000"></div>
<div class="color-swatch" style="background: #ffffff"></div>
<div class="color-swatch" style="background: #808080"></div>
<div class="color-swatch" style="background: #c0c0c0"></div>
</div>
</div>
<div class="color-picker">
<input type="color" id="bgColorPicker">
<div class="color-palette">
<div class="color-swatch" style="background: #ff0000"></div>
<div class="color-swatch" style="background: #00ff00"></div>
<div class="color-swatch" style="background: #0000ff"></div>
<div class="color-swatch" style="background: #ffff00"></div>
<div class="color-swatch" style="background: #ff00ff"></div>
<div class="color-swatch" style="background: #00ffff"></div>
<div class="color-swatch" style="background: #000000"></div>
<div class="color-swatch" style="background: #ffffff"></div>
<div class="color-swatch" style="background: #808080"></div>
<div class="color-swatch" style="background: #c0c0c0"></div>
</div>
</div>
<input type="range" id="lineWidth" min="1" max="50" value="5">
<div class="text-size-control">
<label for="textSize">Text Size:</label>
<input type="number" id="textSize" min="8" max="72" value="20">
</div>
<button class="tool" id="clear">Clear</button>
<button class="tool" id="toggleGridButton">Toggle Grid</button>
</div>
<canvas id="canvas"></canvas>
<footer class="footer">
<div class="footer-content">
<!-- <div class="footer-image">
<img src="popup.jpg" alt="Newsletter signup" width="100">
</div> -->
<div class="newsletter-section">
<h3>Subscribe to our Newsletter</h3>
<input type="email" id="newsletter-email" placeholder="Enter your email address"><br>
<button onclick="subscribeNewsletter()" class="subscribe">Subscribe</button>
</div>
<div class="credit" style="font-size: 0.6rem;">
<p>
Created by <a href="https://github.com/vishanurag">ANURAG VISHWAKARMA </a> | All rights reserved
© <span id="year"></span>
</p>
<div style="margin: 20px;" class="share">
<i class="fab fa-github" style="margin-right: 10px;"></i>
<i class="fab fa-linkedin" style="margin-right: 10px;"></i>
<i class="fab fa-twitter"></i>
</div>
</div>
</footer>
</div>
<script>
function subscribeNewsletter() {
const email = document.getElementById('newsletter-email').value;
if (email) {
alert('Thank you for subscribing!');
document.getElementById('newsletter-email').value = '';
} else {
alert('Please enter a valid email address');
}
}
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let isDrawing = false;
let currentTool = 'pencil';
let startX, startY;
let showGrid = false;
// Set canvas size
function resizeCanvas() {
canvas.width = window.innerWidth - 200; // Subtracting sidebar width
canvas.height = window.innerHeight - 220; // Adjusted for footer
updateCanvasWithGrid();
}
// Initial resize and add event listener for window resize
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
// Set initial styles
ctx.lineWidth = 5;
ctx.lineCap = 'round';
ctx.strokeStyle = '#000000';
// Tool selection
document.querySelectorAll('.tool').forEach(tool => {
tool.addEventListener('click', () => {
document.querySelector('.tool.active').classList.remove('active');
tool.classList.add('active');
currentTool = tool.id;
});
});
// Color picker and swatches
document.querySelectorAll('.color-swatch').forEach(swatch => {
swatch.addEventListener('click', (e) => {
const color = e.target.style.backgroundColor;
const picker = e.target.closest('.color-picker').querySelector('input[type="color"]');
picker.value = rgbToHex(color);
if (picker.id === 'colorPicker') {
ctx.strokeStyle = color;
ctx.fillStyle = color;
} else {
canvas.style.backgroundColor = color;
}
});
});
// Convert RGB to Hex
function rgbToHex(rgb) {
const rgbArr = rgb.match(/\d+/g);
return '#' + rgbArr.map(x => {
const hex = parseInt(x).toString(16);
return hex.length === 1 ? '0' + hex : hex;
}).join('');
}
// Color picker
document.getElementById('colorPicker').addEventListener('input', (e) => {
ctx.strokeStyle = e.target.value;
ctx.fillStyle = e.target.value;
});
// Background color picker
document.getElementById('bgColorPicker').addEventListener('input', (e) => {
canvas.style.backgroundColor = e.target.value;
});
// Line width
document.getElementById('lineWidth').addEventListener('input', (e) => {
ctx.lineWidth = e.target.value;
});
// Clear canvas
document.getElementById('clear').addEventListener('click', () => {
if (confirm("Are you sure you want to clear the canvas? This action cannot be undone.")) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
else {
console.log("Clear action canceled.");
}
});
// Drawing functions
canvas.addEventListener('mousedown', startDrawing);
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mouseup', stopDrawing);
canvas.addEventListener('mouseout', stopDrawing);
function drawGrid() {
if (!showGrid) return; // Only draw if the grid is enabled
ctx.save();
ctx.strokeStyle = '#c0c0c0';
ctx.lineWidth = 0.5;
const gridSpacing = 20;
for (let x = 0; x < canvas.width; x += gridSpacing) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, canvas.height);
ctx.stroke();
}
for (let y = 0; y < canvas.height; y += gridSpacing) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(canvas.width, y);
ctx.stroke();
}
ctx.restore();
}
// Function to clear and redraw the canvas, including the grid if enabled
function updateCanvasWithGrid() {
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas
drawGrid(); // Draw grid if enabled
// Any other canvas drawing updates should go here if needed
}
// Event listener to toggle the grid on and off
document.getElementById('toggleGridButton').addEventListener('click', () => {
showGrid = !showGrid; // Toggle grid state
updateCanvasWithGrid(); // Redraw canvas with or without grid
});
function startDrawing(e) {
isDrawing = true;
[startX, startY] = [e.offsetX, e.offsetY];
}
function draw(e) {
if (!isDrawing) return;
const x = e.offsetX;
const y = e.offsetY;
switch (currentTool) {
case 'pencil':
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.stroke();
[startX, startY] = [x, y];
break;
case 'marker':
ctx.globalAlpha = 0.5;
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.stroke();
ctx.globalAlpha = 1.0;
[startX, startY] = [x, y];
break;
case 'eraser':
ctx.strokeStyle = canvas.style.backgroundColor || '#FFFFFF';
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.stroke();
ctx.strokeStyle = document.getElementById('colorPicker').value;
[startX, startY] = [x, y];
break;
case 'line':
case 'rectangle':
case 'circle':
// These shapes are drawn on mouseup
break;
case 'text':
case 'textarea':
// Text is added on mouseup
break;
}
}
function stopDrawing(e) {
if (!isDrawing) return;
isDrawing = false;
const x = e.offsetX;
const y = e.offsetY;
const fontSize = document.getElementById('textSize').value;
switch (currentTool) {
case 'line':
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.stroke();
break;
case 'rectangle':
ctx.strokeRect(startX, startY, x - startX, y - startY);
break;
case 'circle':
const radius = Math.sqrt(Math.pow(x - startX, 2) + Math.pow(y - startY, 2));
ctx.beginPath();
ctx.arc(startX, startY, radius, 0, 2 * Math.PI);
ctx.stroke();
break;
case 'text':
const text = prompt('Enter text:');
if (text) {
ctx.font = `${fontSize}px Arial`;
ctx.fillText(text, x, y);
}
break;
case 'textarea':
const textareaContent = prompt('Enter text for textarea:');
if (textareaContent) {
const maxWidth = 200;
const lineHeight = fontSize * 1.2;
const words = textareaContent.split(' ');
let line = '';
let currentY = y;
ctx.font = `${fontSize}px Arial`;
for (let n = 0; n < words.length; n++) {
const testLine = line + words[n] + ' ';
const metrics = ctx.measureText(testLine);
const testWidth = metrics.width;
if (testWidth > maxWidth && n > 0) {
ctx.fillText(line, x, currentY);
line = words[n] + ' ';
currentY += lineHeight;
} else {
line = testLine;
}
}
ctx.fillText(line, x, currentY);
}
break;
}
}
window.embeddedChatbotConfig = {
chatbotId: "X6k1f9B5oxQr2T4-NzVxG",
domain: "www.chatbase.co",
position: "right"
}
</script>
<script src="https://www.chatbase.co/embed.min.js" chatbotId="X6k1f9B5oxQr2T4-NzVxG" domain="www.chatbase.co" defer>
</script>
<!-- script for adding valid email -->
<script>
function subscribeNewsletter() {
const emailInput = document.getElementById('newsletter-email');
const email = emailInput.value;
// Regular expression for basic email validation
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (emailPattern.test(email)) {
alert('Thank you for subscribing!');
// Add your subscription logic here
} else {
alert('Please enter a valid email address.');
emailInput.focus();
}
}
</script>
<div class="gtranslate_wrapper"></div>
<script>window.gtranslateSettings = { "default_language": "en", "detect_browser_language": true, "wrapper_selector": ".gtranslate_wrapper", "switcher_horizontal_position": "right" }</script>
<script src="https://cdn.gtranslate.net/widgets/latest/float.js" defer></script>
<style>
body {
font-family: Arial, sans-serif;
}
/* Popup Styles */
.popup {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
background-color: rgba(0, 0, 0, 0.5);
/* Black background with opacity */
justify-content: center;
/* Center the popup */
align-items: center;
/* Center the popup */
z-index: 1000;
/* Sit on top */
}
.popup-content {
background: linear-gradient(#ffc0fc, rgb(102 51 100)), url(your-image-url.jpg);
padding: 20px;
border-radius: 5px;
max-width: 500px;
max-height: 500px;
min-height: 320px;
text-align: center;
}
/* Set poll options to stack vertically */
#pollOptions {
display: flex;
flex-direction: column;
/* Stack buttons vertically */
align-items: center;
/* Center the buttons */
}
.poll-button {
display: block;
/* Change to block for full-width */
margin: 5px 0;
/* Add vertical margin */
padding: 10px 15px;
border: none;
border-radius: 5px;
background-color: rgb(58 30 86 / 40%);
color: white;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
/* Full width */
}
.poll-button:hover {
background-color: #45a049;
/* Darker green */
}
.poll-button.selected {
background-color: #ad00c9;
/* Blue for selected */
}
/* New Vote Button Styles */
.vote-button {
display: block;
/* Change to block for full-width */
margin: 5px 0;
/* Add vertical margin */
padding: 10px 15px;
border: none;
border-radius: 5px;
background-color: #f44336;
/* Red */
color: white;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
/* Full width */
}
.vote-button:hover {
background-color: #d32f2f;
/* Darker red */
}
/* Result Text Styles */
#result {
margin-top: 10px;
/* Add space above result text */
word-wrap: break-word;
/* Allow long text to wrap within the box */
overflow: hidden;
/* Prevent overflow */
max-height: 50px;
/* Limit height to prevent overflow */
color: rgb(255, 255, 255);
/* Set text color to white */
}
</style>
<div class="popup" id="pollPopup">
<div class="popup-content">
<h2>How likely are you to recommend the Creative Canvas Tool to others?</h2>
<div id="pollOptions">
<button class="poll-button" data-value="Very likely">Very likely – I love it!</button>
<button class="poll-button" data-value="Somewhat likely">Somewhat likely – It’s good but has room for
growth.</button>
<button class="poll-button" data-value="Not likely">Not likely – I prefer other tools.</button>
</div>
<button id="voteButton" class="vote-button" style="margin-top: 10px;">Vote</button>
<p id="result"></p>
</div>
</div>
<script>
// Show the poll popup 10 seconds after the page loads, if not already voted
window.onload = function () {
const hasVoted = sessionStorage.getItem('hasVoted');
setTimeout(function () {
if (!hasVoted) {
document.getElementById('pollPopup').style.display = 'flex';
}
}, 10000); // 10000 milliseconds = 10 seconds
};
const pollButtons = document.querySelectorAll('.poll-button[data-value]');
let selectedValue = '';
pollButtons.forEach(button => {
button.addEventListener('click', function () {
// Remove selected class from all buttons
pollButtons.forEach(btn => btn.classList.remove('selected'));
// Add selected class to the clicked button
button.classList.add('selected');
selectedValue = button.getAttribute('data-value');
});
});
document.getElementById('voteButton').addEventListener('click', function () {
if (selectedValue) {
document.getElementById('result').innerHTML = `You voted for: ${selectedValue}<br>Thank you!`;
// Save voting status in session storage
sessionStorage.setItem('hasVoted', 'true');
// Hide the popup after voting
setTimeout(() => {
document.getElementById('pollPopup').style.display = 'none';
}, 2000);
} else {
alert("Please select an option!");
}
});
function initializePoll() {
console.log("Poll initialized.");
}
initializePoll();
</script>
<script>
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Colors for the circles
const colors = [
"#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d",
"#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d",
"#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060",
"#680060", "#60005f", "#48005f", "#3d005e"
];
// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;