Advertisement
NotRuben

Darkmode with time

Feb 5th, 2019
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.01 KB | None | 0 0
  1. <html>
  2. <head>
  3. <button onclick="darkmode()""dark()">Darkmode</button>
  4. <script>
  5.  
  6. document.getElementById('darkmode()').onclick = changeColor;
  7. var currentColor = "white";
  8. function changeColor() {
  9.         if(currentColor == "white()"){
  10.            document.body.style.color = "black";
  11.            currentColor = "black";
  12.         } else {-
  13.            document.body.style.color = "white";
  14.            currentColor = "white";
  15.         }
  16.     }
  17.    
  18. function darkmode() {
  19.         if (document.body.style.backgroundColor == 'rgb(255, 255, 255)') {
  20.  
  21.                 document.body.style.backgroundColor = '#333';
  22.         }
  23.         else {
  24.                 document.body.style.backgroundColor = 'rgb(255, 255, 255)';
  25.         }
  26.     }
  27.    
  28. document.getElementById('dark()').onclick = changeColor;
  29. var currentColor = "white";
  30. function changeColor() {
  31.         if(currentColor == "white"){
  32.            document.body.style.color = "black";
  33.            currentColor = "black";
  34.         } else {
  35.            document.body.style.color = "white";
  36.            currentColor = "white";
  37.         }
  38.     }
  39.     </script>
  40.    
  41.    
  42. <script>
  43. function startTime() {
  44.   var today = new Date();
  45.   var h = today.getHours();
  46.   var m = today.getMinutes();
  47.   var s = today.getSeconds();
  48.   m = checkTime(m);
  49.   s = checkTime(s);
  50.   document.getElementById('txt').innerHTML =
  51.   h + ":" + m + ":" + s;
  52.   var t = setTimeout(startTime, 500);
  53. }
  54. function checkTime(i) {
  55.   if (i < 10) {i = "0" + i};
  56.  return i;
  57. }
  58. </script>
  59.  
  60. </head>
  61.  
  62. <body onload="startTime()">
  63.  
  64. <div id="txt"></div>
  65.  
  66. </body>
  67.  
  68. <body>
  69. <button id= "dark()">Change color</button>
  70. <script>
  71. document.getElementById('dark()').onclick = changeColor;
  72. var currentColor = "white";
  73. function changeColor() {
  74.         if(currentColor == "white"){
  75.            document.body.style.color = "black";
  76.            currentColor = "black";
  77.         } else {
  78.            document.body.style.color = "white";
  79.            currentColor = "white";
  80.         }
  81.     }
  82. </script>
  83.  
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement