-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscript.js
More file actions
79 lines (72 loc) · 3.04 KB
/
Copy pathscript.js
File metadata and controls
79 lines (72 loc) · 3.04 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
function dl(data, fileName) {
(blob = new Blob([data], { type: "octet/stream" })),
(url = window.URL.createObjectURL(blob));
a = document.createElement("a");
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
}
const sliderProps = {
fill: "#0B1EDF",
background: "rgba(255, 255, 255, 0.214)"
};
// Selecting the Range Slider container which will effect the LENGTH property of the password.
const slider = document.querySelector(".range__slider");
// Text which will show the value of the range slider.
const sliderValue = document.querySelector(".length__title");
// Using Event Listener to apply the fill and also change the value of the text.
slider.querySelector("input").addEventListener("input", (event) => {
sliderValue.setAttribute("data-length", event.target.value);
applyFill(event.target);
});
// Selecting the range input and passing it in the applyFill func.
applyFill(slider.querySelector("input"));
// This function is responsible to create the trailing color and setting the fill.
function applyFill(slider) {
const percentage =
(100 * (slider.value - slider.min)) / (slider.max - slider.min);
const bg = `linear-gradient(90deg, ${sliderProps.fill} ${percentage}%, ${
sliderProps.background
} ${percentage + 0.1}%)`;
slider.style.background = bg;
sliderValue.setAttribute("data-length", slider.value);
}
// Checkboxes representing the options that is responsible to create differnt type of password based on user
//const uppercaseEl = document.getElementById("uppercase");
//const lowercaseEl = document.getElementById("lowercase");
//const numberEl = document.getElementById("number");
//const symbolEl = document.getElementById("symbol");
// Button to generate the password
const generateBtn = document.getElementById("generate");
// Button to copy the text
// When Generate is clicked Password id generated.
generateBtn.addEventListener("click", () => {
usb_storage = document.getElementById("usb_storage");
uasp = document.getElementById("uasp");
energy_saving = document.getElementById("energy_saving");
kemu = document.getElementById("4kemu");
hdd_serial = document.getElementById("hdd_serial");
to = document.getElementById("slider").value * 60;
z = atob(document.getElementById("data").innerHTML).split("");
z[0xc4e7] = String.fromCharCode(
(usb_storage.checked << 7) | (uasp.checked << 6) | (kemu.checked << 5) | (z[0xc4e7].charCodeAt(0) & 0x1F)
);
if (hdd_serial.checked) {
z[0xc454]=String.fromCharCode(0);
} else {
z[0xc454]=String.fromCharCode(0x22);
for (x=0xc456;x<0xc466;x++) z[x]=String.fromCharCode(Math.random()*10+48);
}
z[0xc4f2] = String.fromCharCode(0x30 | (energy_saving.checked << 3));
z[0xc4f6] = String.fromCharCode(energy_saving.checked*255 & (to / 256));
z[0xc4f7] = String.fromCharCode(energy_saving.checked*255 & to % 256);
b = new Uint8Array(z.length);
z.map((e, i) => (b[i] = e.charCodeAt(0)));
dl(b, "JMS579_Z_414.bin");
});
document.getElementById("energy_saving").onclick = (e) => {
document.getElementById("timeout").style.visibility = e.srcElement.checked
? ""
: "hidden";
};