Guest User

Untitled

a guest
Apr 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. var status_sw1 = 0;
  2. var status_sw2 = 0;
  3. var status_sw3 = 0;
  4.  
  5. var time_sw1 = 0;
  6. var time_sw2 = 0;
  7. var time_sw3 = 0;
  8.  
  9. var startBtn1 = document.getElementById("start1");
  10. var startBtn2 = document.getElementById("start2");
  11. var startBtn3 = document.getElementById("start3");
  12.  
  13. var timerLabel1 = document.getElementById("timerLabel1");
  14. var timerLabel2 = document.getElementById("timerLabel2");
  15. var timerLabel3 = document.getElementById("timerLabel3");
  16.  
  17. var moveAllBtn = document.getElementById("moveAllBtn");
  18.  
  19. function moveAll(obj) {
  20.  
  21. if (obj.value == 'START') {
  22. status_sw1 = 1;
  23. status_sw2 = 1;
  24. status_sw3 = 1;
  25. timer1();
  26. timer2();
  27. timer3();
  28. startBtn1.value = "STOP";
  29. startBtn2.value = "STOP";
  30. startBtn3.value = "STOP";
  31. obj.value = "STOP";
  32.  
  33. } else {
  34. status_sw1 = 0;
  35. status_sw2 = 0;
  36. status_sw3 = 0;
  37. startBtn1.value = "START";
  38. startBtn2.value = "START";
  39. startBtn3.value = "START";
  40. obj.value = "START";
  41. }
  42.  
  43. }
  44.  
  45.  
  46. function start_stop(obj) {
  47.  
  48. var stopwatch = obj.id;
  49.  
  50. if (stopwatch == 'start1') {
  51. if (status_sw1 == 0) {
  52. status_sw1 = 1;
  53. timer1();
  54. } else {
  55. status_sw1 = 0;
  56. }
  57. }
  58.  
  59. if (stopwatch == 'start2') {
  60. if (status_sw2 == 0) {
  61. status_sw2 = 1;
  62. timer2();
  63. } else {
  64. status_sw2 = 0;
  65. }
  66. }
  67.  
  68. if (stopwatch == 'start3') {
  69. if (status_sw3 == 0) {
  70. status_sw3 = 1;
  71. timer3();
  72. } else {
  73. status_sw3 = 0;
  74. }
  75. }
  76.  
  77. if (obj.value == "START") {
  78. obj.value = "STOP";
  79.  
  80. } else {
  81. obj.value = "START";
  82. }
  83. }
  84.  
  85.  
  86. function reset(obj) {
  87. var stopwatch = obj.id;
  88.  
  89. if (stopwatch == 'reset1') {
  90. status_sw1 = 0;
  91. time_sw1 = 0;
  92. timerLabel1.innerHTML = "00:00.00";
  93. startBtn1.value = "START";
  94. }
  95.  
  96. if (stopwatch == 'reset2') {
  97. status_sw2 = 0;
  98. time_sw2 = 0;
  99. timerLabel2.innerHTML = "00:00.00";
  100. startBtn2.value = "START";
  101. }
  102.  
  103. if (stopwatch == 'reset3') {
  104. status_sw3 = 0;
  105. time_sw3 = 0;
  106. timerLabel3.innerHTML = "00:00.00";
  107. startBtn3.value = "START";
  108. }
  109.  
  110. }
  111.  
  112.  
  113. function timer1() {
  114. if (status_sw1 == 1) {
  115. setTimeout(function(){
  116. time_sw1++;
  117. timerLabel1.innerHTML = getTime(time_sw1);
  118. timer1();
  119. }, 10);
  120. }
  121. checkAllBtn();
  122. }
  123.  
  124. function timer2() {
  125. if (status_sw2 == 1) {
  126. setTimeout(function(){
  127. time_sw2++;
  128. timerLabel2.innerHTML = getTime(time_sw2);
  129. timer2();
  130. }, 10);
  131. }
  132. checkAllBtn();
  133. }
  134.  
  135. function timer3() {
  136. if (status_sw3 == 1) {
  137. setTimeout(function(){
  138. time_sw3++;
  139. timerLabel3.innerHTML = getTime(time_sw3);
  140. timer3();
  141. }, 10);
  142. }
  143. checkAllBtn();
  144. }
  145.  
  146.  
  147. function checkAllBtn() {
  148.  
  149. if (status_sw1 == 1 || status_sw2 == 1 || status_sw3 == 1) {
  150. moveAllBtn.value = "STOP";
  151. }
  152.  
  153. if (status_sw1 == 0 && status_sw2 == 0 && status_sw3 == 0) {
  154. moveAllBtn.value = "START";
  155. }
  156.  
  157. }
  158.  
  159.  
  160. function getTime(time) {
  161.  
  162. var min = Math.floor(time/100/60);
  163. var sec = Math.floor(time/100);
  164. var mSec = time%100;
  165.  
  166. if (min < 10) {
  167. min = "0" + min;
  168. }
  169. if (sec >= 60) {
  170. sec = sec % 60;
  171. }
  172. if (sec < 10) {
  173. sec = "0" + sec;
  174. }
  175.  
  176. return min + ":" + sec + "." + mSec;
  177.  
  178. }
  179.  
  180. <?
  181. $hostname = "mysql.hostinger.com";
  182. $database = "u556957547_sim";
  183. $username = "u556957547_sim";
  184. $password = "Test1234";
  185.  
  186. $conn = mysqli_connect($hostname, $username, $password,$database );
  187.  
  188. //indien geen verbinding toon je een foutmelding
  189. if (!$conn){
  190. die("Connection error: " . mysqli_connect_errno());
  191. }
  192. else
  193. { echo "succesfully connected to database.<br>"; }
  194. if($_SERVER["REQUEST_METHOD"] == "POST") {
  195. $tijd1=$_POST["timerLabel1"];
  196. $tijd2=$_POST["timerLabel2"];
  197. $tijd3=$_POST["timerLabel3"];
  198. $sql="INSERT INTO Simulatie(id,wachttijd,totaaltijd,dropped)VALUES('$tijd1','$tijd2','$tijd3')";
  199. $result=mysqli_query($conn,$sql);
  200. if ($result)
  201. {
  202. echo "works . $tijd1";
  203. }
  204. else
  205. {
  206. echo"doesn't work ".mysql_error($conn);
  207. }}
  208. mysqli_close($conn);
  209. ?>
Add Comment
Please, Sign In to add comment