25 lines
		
	
	
		
			950 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			950 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| = form_with model: @offline, url: "/public/#{@contest.id}/offline" do |form|
 | |
|   .row.mb-3
 | |
|     .col
 | |
|       .form-text.mb-1
 | |
|         = t("puzzles.image_select")
 | |
|       = form.file_field :start_image, accept: "image/*", class: "form-control"
 | |
|       .form-text.error-message style="display: none;" id="image-error-message"
 | |
|         = t("puzzles.form.file_too_big")
 | |
|       javascript:
 | |
|         function setMaxUploadSize() {
 | |
|           const el = document.querySelector('input[type="file"]');
 | |
|           el.onchange = function() {
 | |
|             if(this.files[0].size > 2 * 1024 * 1024) {
 | |
|               document.getElementById('image-error-message').style.display = 'block';
 | |
|               this.value = "";
 | |
|             } else {
 | |
|               document.getElementById('image-error-message').style.display = 'none';
 | |
|             }
 | |
|           };
 | |
|         }
 | |
| 
 | |
|         setMaxUploadSize();
 | |
|   .row.mt-3
 | |
|     .col
 | |
|       = form.submit t("helpers.buttons.add"), class: "btn btn-primary" |