-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6.js
78 lines (60 loc) · 1.86 KB
/
6.js
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
var container = document.querySelector("#container");
var activeItem = null;
var active = false;
container.addEventListener("mousedown", dragStart, false);
container.addEventListener("mouseup", dragEnd, false);
container.addEventListener("mousemove", drag, false);
function dragStart(e) {
if (e.target !== e.currentTarget) {
active = true;
activeItem = e.target;
if (activeItem !== null) {
if (!activeItem.xOffset) {
activeItem.xOffset = 0;
}
if (!activeItem.yOffset) {
activeItem.yOffset = 0;
}
activeItem.initialX = e.clientX - activeItem.xOffset;
activeItem.initialY = e.clientY - activeItem.yOffset;
}
}
}
function dragEnd(e) {
if (activeItem !== null) {
activeItem.initialX = activeItem.currentX;
activeItem.initialY = activeItem.currentY;
}
active = false;
activeItem = null;
}
function drag(e) {
if (active) {
activeItem.currentX = e.clientX - activeItem.initialX;
activeItem.currentY = e.clientY - activeItem.initialY;
}
activeItem.xOffset = activeItem.currentX;
activeItem.yOffset = activeItem.currentY;
setTranslate(activeItem.currentX, activeItem.currentY, activeItem);
}
function setTranslate(xPos, yPos, el) {
el.style.transform = "translate3d(" + xPos + "px, " + yPos + "px, 0)";
}
function validateNumber() {
var x, text;
x = document.getElementById("numb").value;
if (isNaN(x) || x != 10) {
text = "Input not valid";
location.replace("e4da3b7fbbce2345d7772b0674a318d5");
} else {
text = "Good job!".bold();
document.getElementById("valid").style.visibility = "visible";
}
document.getElementById("demo").innerHTML = text;
}
function changePage() {
location.replace("8f14e45fceea167a5a36dedd4bea2543");
}
document.addEventListener("contextmenu", function (e) {
e.preventDefault();
});