Skip to content

Commit

Permalink
Merge pull request #45 from p1utoze/local
Browse files Browse the repository at this point in the history
update: auto-refresh on page checkin
  • Loading branch information
p1utoze committed May 17, 2024
2 parents 9b7e796 + ed3983a commit ef24ab9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions app/static/js/update_status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Disable F5 and Ctrl+R
window.addEventListener('keydown', function(e) {
if ((e.which || e.keyCode) == 116 || (e.ctrlKey && (e.which === 82))) {
e.preventDefault();
}
});

// Disable context menu (right-click) and refresh
window.addEventListener('contextmenu', function(e) {
e.preventDefault();
}, false);


let startY; // Variable to store the initial touch position
let startX; // Variable to store the initial touch position along the X-axis

// Listen for touchstart event
document.addEventListener('touchstart', function(event) {
// Get the starting X and Y positions of the touch
startX = event.touches[0].clientX;
startY = event.touches[0].clientY;
}, false);

// Listen for touchmove event
document.addEventListener('touchmove', function(event) {
// Calculate the distance the finger has moved along the Y-axis
let currentY = event.touches[0].clientY;
let distanceY = startY - currentY;

// Calculate the distance the finger has moved along the X-axis
let currentX = event.touches[0].clientX;
let distanceX = startX - currentX;

// Check if the user is swiping from the top of the screen
if (distanceY > 0 && Math.abs(distanceX) < Math.abs(distanceY / 2)) {
// Prevent the default behavior (e.g., scroll or refresh)
event.preventDefault();
}
}, false);

// Listen for touchend event
document.addEventListener('touchend', function(event) {
// Reset the starting position
startY = null;
startX = null;
}, false);
1 change: 1 addition & 0 deletions app/templates/update_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="stylesheet" href="../static/css/update_status.css">
<script type="text/javascript" src="../static/js/update_status.js"></script>
</head>
<body>
<div class="header">
Expand Down

0 comments on commit ef24ab9

Please sign in to comment.