mirror of
				https://git.openwrt.org/project/luci.git
				synced 2025-10-31 10:49:03 +08:00 
			
		
		
		
	 ae8bbb814f
			
		
	
	ae8bbb814f
	
	
	
		
			
			* HTML Cleanup: Meta tags. * Converted charset to shorthand. * Removed meta tags with `Content-Script-Type` attribute. (Invalid in HTML5 spec.) * HTML Cleanup: CSS tags. * Removed `type` attribute with CSS files from link tags. (HTML5 spec recommends omitting it.) * Removed `type` attribute from style tags. (Deprecated in HTML5 spec.) https://html.spec.whatwg.org/#attr-link-type https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style * HTML Cleanup: Convert from XHTML to HTML5 * Removed XML declaration. * Removed XML namespace. * Changed doctype to HTML5. * HTML Cleanup: CDATA tags. * CDATA sections should not be used within HTML they are considered as comments and not displayed. https://developer.mozilla.org/en-US/docs/Web/API/CDATASection * HTML Cleanup: Script tags. * Removed `language` attribute from script tags. (No longer valid in HTML5) * Removed `type` attribute with JavaScript MIME type from script tags. (HTML5 spec recommends omitting it.) https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type https://mimesniff.spec.whatwg.org/#javascript-mime-type Signed-off-by: Mustafa Can Elmacı <mustafacan@elmaci.net>
		
			
				
	
	
		
			105 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <input type="text" class="cbi-input-text" name="isrc" placeholder="http://host/image.tar" id="isrc" />
 | |
| <input type="text" class="cbi-input-text" name="itag" placeholder="repository:tag" id="itag" />
 | |
| <div style="display: inline-block;">
 | |
| 	<input type="button"" class="btn cbi-button cbi-button-add" id="btnimport" name="import" value="<%:Import%>" />
 | |
| 	<input type="file" id="file_import" style="visibility:hidden; position: absolute;top: 0px; left: 0px;" />
 | |
| </div>
 | |
| 
 | |
| <script>
 | |
| 	let btnImport = document.getElementById('btnimport')
 | |
| 	let valISrc = document.getElementById('isrc')
 | |
| 	let valITag = document.getElementById('itag')
 | |
| 	btnImport.onclick = function (e) {
 | |
| 		if (valISrc.value == "") {
 | |
| 			document.getElementById("file_import").click()
 | |
| 			return
 | |
| 		}
 | |
| 		else {
 | |
| 			let formData = new FormData()
 | |
| 			formData.append('src', valISrc.value)
 | |
| 			formData.append('tag', valITag.value)
 | |
| 			let xhr = new XMLHttpRequest()
 | |
| 			uci_confirm_docker()
 | |
| 			xhr.open("POST", "<%=luci.dispatcher.build_url('admin/docker/images_import')%>", true)
 | |
| 			xhr.onload = function () {
 | |
| 				location.reload()
 | |
| 			}
 | |
| 			xhr.send(formData)
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	let fileimport = document.getElementById('file_import')
 | |
| 	fileimport.onchange = function (e) {
 | |
| 		let fileimport = document.getElementById('file_import')
 | |
| 		if (!fileimport.value) {
 | |
| 			return
 | |
| 		}
 | |
| 		let valITag = document.getElementById('itag')
 | |
| 		let fileName = fileimport.files[0].name
 | |
| 		let formData = new FormData()
 | |
| 		formData.append('upload-filename', fileName)
 | |
| 		formData.append('tag', valITag.value)
 | |
| 		formData.append('upload-archive', fileimport.files[0])
 | |
| 		let xhr = new XMLHttpRequest()
 | |
| 		uci_confirm_docker()
 | |
| 		xhr.open("POST", "<%=luci.dispatcher.build_url('admin/docker/images_import')%>", true)
 | |
| 		xhr.onload = function () {
 | |
| 			fileimport.value = ''
 | |
| 			location.reload()
 | |
| 		}
 | |
| 		xhr.send(formData)
 | |
| 	}
 | |
| 
 | |
| 	let new_tag = function (image_id) {
 | |
| 		let new_tag = prompt("<%:New tag%>\n<%:Image%>" + "ID: " + image_id + "\n<%:Please input new tag%>:", "")
 | |
| 		if (new_tag) {
 | |
| 			(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_tag')%>",
 | |
| 				{
 | |
| 					id: image_id,
 | |
| 					tag: new_tag
 | |
| 				},
 | |
| 				function (r) {
 | |
| 					if (r.status == 201) {
 | |
| 						location.reload()
 | |
| 					}
 | |
| 					else {
 | |
| 						docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
 | |
| 						document.getElementById('docker_apply_overlay').addEventListener(
 | |
| 							"click",
 | |
| 							(e)=>{
 | |
| 								docker_status_message()
 | |
| 							}
 | |
| 						)
 | |
| 					}
 | |
| 				}
 | |
| 			)
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	let un_tag = function (tag) {
 | |
| 		if (tag.match("<none>"))
 | |
| 			return
 | |
| 		if (confirm("<%:Remove tag%>: " + tag + " ?")) {
 | |
| 			(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_untag')%>",
 | |
| 				{
 | |
| 					tag: tag
 | |
| 				},
 | |
| 				function (r) {
 | |
| 					if (r.status == 200) {
 | |
| 						location.reload()
 | |
| 					}
 | |
| 					else {
 | |
| 						docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
 | |
| 						document.getElementById('docker_apply_overlay').addEventListener(
 | |
| 							"click",
 | |
| 							(e)=>{
 | |
| 								docker_status_message()
 | |
| 							}
 | |
| 						)
 | |
| 					}
 | |
| 				}
 | |
| 			)
 | |
| 		}
 | |
| 	}
 | |
| </script>
 |