-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCG.js
44 lines (39 loc) · 1.38 KB
/
LCG.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
function toggleList(id) {
// alert(JSON.stringify($(id).css("display")));
if ($(id).css("display") != "none") {
$(id).fadeOut();
} else {
$(id).fadeIn();
}
}
function dragAndSave(id) {
// mobile devices have trouble to drag.
if (screen.width <= 800) return;
// get positions in localStorage
var positions = JSON.parse(localStorage.positions || "{}");
if (positions[id]) $(id).css(positions[id]);
// save the position of the draggable element into localStorage
$(id).draggable({
scroll: true, // If set to true, container auto-scrolls while dragging.
// Triggered when dragging stops.
stop: function (event, ui) {
let positions = JSON.parse(localStorage.positions || "{}");
positions[id] = ui.position; // { top, left } object.
localStorage.positions = JSON.stringify(positions);
},
});
// reset localStorage
window.onkeydown = function (event) {
if (event.key === "Escape" || event.key === "e") {
if (event.metaKey || event.ctrlKey) {
localStorage.clear();
alert("Local storage has been cleared");
}
} else if (event.key == "b") {
window.location.href = "/cwdc";
} else if (event.key == "B") {
let path = window.location.pathname;
window.location.href = path.split("/", 3).join("/");
}
};
}