-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonline-generate-uuid.html
More file actions
87 lines (78 loc) · 2.84 KB
/
Copy pathonline-generate-uuid.html
File metadata and controls
87 lines (78 loc) · 2.84 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
---
title: "Online UUID Üret (Online Generate UUID)"
date: null
layout: calculate
permalink: null
categories: null
tags: null
---
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.js"
integrity="sha256-8L3yX9qPmvWSDIIHB3WGTH4RZusxVA0DDmuAo4LjnOE="
crossorigin="anonymous"></script>
<script>
function generateUUIDv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
</script>
<div class="form-group">
<button id="generate" type="button" class="form-control mt-3 mb-3 btn btn-primary">UUID v4 Üret</button>
<div class="input-group">
<input id="result" type="text" class="form-control text-monospace" data-clipboard-target="#result" placeholder="Sonuç" readonly="readonly" />
<div class="input-group-append">
<button id="copy" type="button" class="form-control btn btn-warning" data-clipboard-target="#result" disabled="disabled"><i class="bi-clipboard2-plus-fill"></i></button>
</div>
</div>
</div>
<script>
function writeUUIDv4() {
let result = generateUUIDv4();
$("#result").val(result);
$("#copy").prop("disabled", false);
}
$(function() {
$("#generate").on("click", function (e) {
writeUUIDv4();
});
$("#result").tooltip({
trigger: "manual",
title: "Kopyalandı...",
placement: "top",
customClass: "tooltip-success"
});
$("#copy").on("click", function (e) {
let result = $("#result").val();
if (result.length === 0) {
console.log("Result is empty and it has not been copied");
return;
}
copyToClipboard(result)
.then(function () {
$("#result").tooltip('show');
setTimeout(function() {
$("#result").tooltip('hide');
}, 1500);
}).catch(function () {
console.error('Copying result to clipboard has failed');
});
});
$("#result").on("click", function (e) {
let result = $("#result").val();
if (result.length === 0) {
console.log("Result is empty and it has not been copied");
return;
}
copyToClipboard(result)
.then(function () {
$("#result").tooltip('show');
setTimeout(function() {
$("#result").tooltip('hide');
}, 1500);
}).catch(function () {
console.error('Copying result to clipboard has failed');
});
});
});
</script>
{% include calculate_menu.html %}