Added autoreload
This commit is contained in:
		
							parent
							
								
									cbc61214e2
								
							
						
					
					
						commit
						5a0a567348
					
				
					 3 changed files with 33 additions and 1 deletions
				
			
		|  | @ -9,7 +9,7 @@ theme = dark | ||||||
| 
 | 
 | ||||||
| [i18n] | [i18n] | ||||||
| lang = de | lang = de | ||||||
| more = Mehr Fragen | more = Weiter »»» | ||||||
| title = A oder B | title = A oder B | ||||||
| separator = oder | separator = oder | ||||||
| questions_prefix = Es gibt derzeit | questions_prefix = Es gibt derzeit | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								static/js/autoReload.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								static/js/autoReload.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | ||||||
|  | function autoReload() { | ||||||
|  |     document.querySelectorAll('input[type="radio"]').forEach(function (el) { | ||||||
|  |         el.addEventListener('change', checkForm, { once: true }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     const choices = []; | ||||||
|  | 
 | ||||||
|  |     function checkForm(e) { | ||||||
|  |         item = e.target.id.charAt(1); | ||||||
|  |         if (choices.indexOf(item) === -1) { | ||||||
|  |             choices.push(item); | ||||||
|  |         } | ||||||
|  |         if (choices.length === 5) { | ||||||
|  |             countdown(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     function countdown() { | ||||||
|  |         var timeleft = 3; | ||||||
|  |         var reloadTimer = setInterval(function () { | ||||||
|  |             if (timeleft <= 0) { | ||||||
|  |                 clearInterval(reloadTimer); | ||||||
|  |                 window.location.replace('/') | ||||||
|  |             } else { | ||||||
|  |                 document.getElementById("next").innerHTML = timeleft; | ||||||
|  |             } | ||||||
|  |             timeleft -= 1; | ||||||
|  |         }, 1000); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| <head> | <head> | ||||||
|     <title>{{ title }}</title> |     <title>{{ title }}</title> | ||||||
|     <script type="text/javascript" src="/js/toggle.js?t={{ epoch }}"></script> |     <script type="text/javascript" src="/js/toggle.js?t={{ epoch }}"></script> | ||||||
|  |     <script type="text/javascript" src="/js/autoReload.js?t={{ epoch }}"></script> | ||||||
|     <link rel="stylesheet" type="text/css" href="/css/base.css?t={{ epoch }}"> |     <link rel="stylesheet" type="text/css" href="/css/base.css?t={{ epoch }}"> | ||||||
|     <link rel="stylesheet" type="text/css" href="/css/colors.css?t={{ epoch }}"> |     <link rel="stylesheet" type="text/css" href="/css/colors.css?t={{ epoch }}"> | ||||||
|     <link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='apple-touch-icon.png') }}"> |     <link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='apple-touch-icon.png') }}"> | ||||||
|  | @ -69,6 +70,7 @@ | ||||||
|     </div> |     </div> | ||||||
|     <script type="text/javascript"> |     <script type="text/javascript"> | ||||||
|         initToggle(); |         initToggle(); | ||||||
|  |         autoReload(); | ||||||
|     </script> |     </script> | ||||||
| </body> | </body> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue