-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
146 lines (127 loc) · 5.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>TG BOTS PASTE CODE</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.63.1/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.1/cookieconsent.min.css">
<style>
body {
background-color: rgba(255, 144, 163, 1);
}
.footer-info {
font-size: 14px;
color: #f8f9fa;
}
</style>
</head>
<body>
<nav class="navbar navbar-dark bg-dark">
<a class="navbar-brand" href="#">
<span style="color: #f8f9fa;">TG BOTS PASTE SPACE</span>
</a>
</nav>
<div class="container mt-4">
<div class="form-group">
<label for="code">Paste your code here:</label>
<textarea class="form-control" id="code" rows="10"></textarea>
</div>
<div class="btn-group">
<button class="btn btn-primary" id="save">Save</button>
<button class="btn btn-success" id="new">New</button>
</div>
<div id="content" class="mt-4"></div>
</div>
<footer class="bg-dark text-light text-center py-3 mt-4">
<div class="footer-info" id="footer-info"></div>
<div class="footer-info">Copyright © 2023 - <i class="fas fa-cat"></i> <a href="https://github.com/Yumiko-Bots" target="_blank" rel="noopener">santhu</a></div>
</footer>
<!-- Cookie Consent -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.1/cookieconsent.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
theme: "default",
readOnly: false,
autoCloseBrackets: true,
matchBrackets: true,
});
var saveButton = document.getElementById("save");
var newButton = document.getElementById("new");
var footerInfo = document.getElementById("footer-info");
var contentDiv = document.getElementById("content");
saveButton.addEventListener("click", function () {
var fileId = Math.random().toString(36).substring(7);
var codeContent = editor.getValue();
localStorage.setItem(fileId, codeContent);
var link = "https://tg-botsnetwork.github.io/tgbotspaste/?file=" + fileId;
document.getElementById("content").innerHTML = "Share this link: <a href='" + link + "' target='_blank'>" + link + "</a>";
updateFooterInfo();
saveButton.disabled = true; // Disable the save button after saving
});
newButton.addEventListener("click", function () {
editor.setValue("");
document.getElementById("content").innerHTML = "";
saveButton.disabled = false; // Enable the save button when creating a new file
updateFooterInfo();
});
// Check if a shared link is present in the URL
var urlParams = new URLSearchParams(window.location.search);
var fileIdParam = urlParams.get("file");
if (fileIdParam) {
// Display the shared code in read-only mode
var sharedCode = localStorage.getItem(fileIdParam);
if (sharedCode) {
editor.setValue(sharedCode);
editor.setOption("readOnly", "nocursor");
saveButton.style.display = "none";
newButton.style.display = "none";
}
}
// Initial update of footer info
updateFooterInfo();
// Add listener to prevent viewing the page source
document.addEventListener("keydown", function (e) {
if (e.ctrlKey && e.key === "u") {
e.preventDefault();
}
});
// Add listener to prevent right-click context menu
window.addEventListener("contextmenu", function (e) {
e.preventDefault();
});
// Cookie Consent
window.addEventListener("load", function () {
window.cookieconsent.initialise({
"palette": {
"popup": { "background": "#f8f9fa" },
"button": { "background": "#007bff" }
},
"position": "bottom",
"content": {
"message": "This website uses cookies to ensure you get the best experience on our website.",
"dismiss": "Got it!",
"link": "Learn more"
}
});
});
function updateFooterInfo() {
var content = editor.getValue();
var wordCount = content.split(/\s+/).filter(function (word) {
return word.length > 0;
}).length;
var lineCount = editor.lineCount();
var length = content.length;
var lineWrap = editor.getOption("lineWrapping");
var wrapInfo = lineWrap ? "Wrapped" : "Not Wrapped";
var infoText = `Words: ${wordCount} | Lines: ${lineCount} | Length: ${length} | Line Wrap: ${wrapInfo}`;
footerInfo.textContent = infoText;
}
});
</script>
<script src="script.js"></script>
</body>
</html>