-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
122 lines (115 loc) · 3.69 KB
/
Copy pathindex.html
File metadata and controls
122 lines (115 loc) · 3.69 KB
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
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8"/>
<title>Your Code? My Code?</title>
<meta content="Need National Card ID? This is yours ..." name="description"/>
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><![endif]-->
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.1, user-scalable=0" name="viewport"/>
<meta content="summary_large_image" name="twitter:card"/>
<meta content="cover.jpg" name="twitter:image"/>
<style type="text/css">
html{
height: 100%;
}
body{
min-height: 100%;
margin: 0;
background-color: #fafafa;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.text{
color: #3f51b5;
padding-top: 40vh;
display: block;
position: relative;
text-align: center;
margin: 0 auto;
font-family: monospace;
}
#number{
font-size: 5rem;
letter-spacing: 1rem;
word-break: break-all;
-webkit-user-select: all;
-moz-user-select: all;
user-select: all;
}
@media (max-width: 767px) {
.text{
padding-top: 30vh;
}
#number{
font-size: 2rem;
letter-spacing: 0.5rem;
}
}
</style>
</head>
<body>
<section class="text">
<div id="number"></div>
<p>Paste your code everywhere</p>
</section>
<script type="text/javascript">
var number =
[
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
Math.floor(Math.random() * 9) + 1,
];
var lastNumber;
var i = 10;
var p = 0;
number.forEach(function(currentValue, index)
{
if(i != 1)
{
p = p + (i * currentValue);
}
i--;
});
var b = p % 11;
if(b < 2)
{
lastNumber = b;
}
else
{
lastNumber = 11 - b;
}
var x = number.join('');
x = x + '' + lastNumber;
document.getElementById("number").innerHTML = x;
window.addEventListener('load', copyText);
function copyText()
{
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = document.getElementById("number").innerHTML; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
: false; // Mark as false to know no selection existed before
el.select(); // Select the <textarea> content
document.execCommand('copy');
document.body.removeChild(el); // Remove the <textarea> element
if (selected) { // If a selection existed before copying
document.getSelection().removeAllRanges(); // Unselect everything on the HTML document
document.getSelection().addRange(selected); // Restore the original selection
}
}
</script>
</body>
</html>