cipheron

HTA Clock

Oct 28th, 2024 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Clock Widget</title>
  5. <HTA:APPLICATION
  6. APPLICATIONNAME="Clock Widget"
  7. BORDER = "thick"
  8. INNERBORDER = "no"
  9. CAPTION="no"
  10. SHOWINTASKBAR="yes"
  11. SINGLEINSTANCE="yes"
  12. SYSMENU="no"
  13. WINDOWSTATE="normal"
  14. SCROLL="no"
  15. MAXIMIZEBUTTON="no"
  16. MINIMIZEBUTTON="no"
  17. >
  18. <style>
  19. html, body {
  20. height: 100%; /* Ensure both HTML and body take full height */
  21. margin: 0;
  22. font-family: Arial, sans-serif;
  23. }
  24. #titleBar {
  25. background-color: #FFF;
  26. color: black;
  27. font-size: 14px;
  28. padding: 0px 6px; 8px 6px; /* Adjusted padding */
  29. cursor: move;
  30. user-select: none; /* Prevent text selection */
  31. height: 24px; /* Fixed height for title bar */
  32. }
  33. #titleCaption {
  34. float: left; /* Title floats to the left */
  35. padding: 4px 0px 0px 0px;
  36. }
  37. #closeButton {
  38. background-color: #f44336; /* Red background for close button */
  39. border: none;
  40. color: white;
  41. cursor: pointer;
  42. font-size: 10px; /* Smaller font size */
  43. float: right; /* Button floats to the right */
  44. padding: 4px 6px; 4px 6px; /* Increased padding for button */
  45. margin: 0px 0px 0px 0px;
  46. }
  47. #closeButton:hover {
  48. background-color: #c62828; /* Darker red on hover */
  49. }
  50. #clockContainer {
  51. background-color: black;
  52. color: lime;
  53. text-align: center;
  54. font-size: 24px;
  55. padding: 10px;
  56. height: 100%; /* Set height to 100% */
  57. box-sizing: border-box; /* Include padding in height calculation */
  58. }
  59. </style>
  60. <script language="JScript">
  61. function pad(number) {
  62. return (number < 10 ? "0" : "") + number;
  63. }
  64.  
  65. function updateClock() {
  66. var now = new Date();
  67. var hours = pad(now.getHours());
  68. var minutes = pad(now.getMinutes());
  69. var seconds = pad(now.getSeconds());
  70. document.getElementById("clock").innerText = hours + ":" + minutes + ":" + seconds;
  71. }
  72.  
  73. function startClock() {
  74. updateClock();
  75. setInterval(updateClock, 1000); // Update every second
  76. }
  77.  
  78. function setPosition() {
  79. window.moveTo(screen.width - 200, screen.height - 150); // Position in bottom-right corner
  80. window.resizeTo(180, 100); // Set window size
  81. }
  82.  
  83. // Drag functionality
  84. var offsetX, offsetY;
  85.  
  86. function startDrag(e) {
  87. offsetX = window.event.clientX;
  88. offsetY = window.event.clientY;
  89. document.onmousemove = dragWindow;
  90. document.onmouseup = stopDrag;
  91.  
  92. // Disable text selection during dragging
  93. document.body.style.userSelect = "none";
  94. }
  95.  
  96. function dragWindow(e) {
  97. window.moveBy(window.event.clientX - offsetX, window.event.clientY - offsetY);
  98. }
  99.  
  100. function stopDrag() {
  101. document.onmousemove = null;
  102. document.onmouseup = null;
  103.  
  104. // Re-enable text selection after dragging
  105. document.body.style.userSelect = "";
  106. }
  107.  
  108. // Close the application
  109. function closeApp() {
  110. window.close();
  111. }
  112. </script>
  113. </head>
  114. <body onload="startClock(); setPosition();">
  115. <div id="titleBar" onmousedown="startDrag(event)">
  116. <div id="titleCaption">Clock Widget</div>
  117. <button id="closeButton" onclick="closeApp()">X</button>
  118. </div>
  119. <div id="clockContainer">
  120. <div id="clock">00:00:00</div>
  121. </div>
  122. </body>
  123. </html>
  124.  
Advertisement
Add Comment
Please, Sign In to add comment