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>
		
			
				
	
	
		
			110 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			110 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
 | |
| <script>
 | |
| 	function vpn_add()
 | |
| 	{
 | |
| 		var vpn_name     = div_add.querySelector("#instance_name1").value.replace(/[^\x00-\x7F]|[\s\.!@#$%^&*()\-+=\[\]{};':"\\|,<>\/?]/g,'');
 | |
| 		var vpn_template = div_add.querySelector("#instance_template").value;
 | |
| 		var form         = document.getElementsByName('cbi')[0];
 | |
| 
 | |
| 		if (!vpn_name || !vpn_name.length)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("The 'Name' field must not be empty!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		document.getElementById("instance_name1").value = vpn_name;
 | |
| 		if (document.getElementById("cbi-openvpn-" + vpn_name) != null)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("Instance with that name already exists!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		if (!vpn_template || !vpn_template.length)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("Please select a valid VPN template!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		if (form)
 | |
| 		{
 | |
| 			form.submit();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	function vpn_upload()
 | |
| 	{
 | |
| 		var vpn_name = div_upload.querySelector("#instance_name2").value.replace(/[^\x00-\x7F]|[\s\.!@#$%^&*()\-+=\[\]{};':"\\|,<>\/?]/g,'');
 | |
| 		var vpn_file = document.getElementById("ovpn_file").value;
 | |
| 		var form     = document.getElementsByName('cbi')[0];
 | |
| 
 | |
| 		if (!vpn_name || !vpn_name.length)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("The 'Name' field must not be empty!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		document.getElementById("instance_name2").value = vpn_name;
 | |
| 		if (document.getElementById("cbi-openvpn-" + vpn_name) != null)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("Instance with that name already exists!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		if (!vpn_file || !vpn_file.length)
 | |
| 		{
 | |
| 			return info_message(vpn_output, "<%=pcdata(translate("Please select a valid OVPN config file to upload!"))%>", 2000);
 | |
| 		}
 | |
| 
 | |
| 		if (form)
 | |
| 		{
 | |
| 			form.enctype = 'multipart/form-data';
 | |
| 			form.action  = '<%=url('admin/vpn/openvpn/upload')%>';
 | |
| 			form.submit();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	function info_message(output, msg, timeout)
 | |
| 	{
 | |
| 		timeout = timeout || 0;
 | |
| 		output.innerHTML = '<em>' + msg + '</em>';
 | |
| 		if (timeout > 0)
 | |
| 		{
 | |
| 			setTimeout(function(){ output.innerHTML=""}, timeout);
 | |
| 		}
 | |
| 	}
 | |
| </script>
 | |
| 
 | |
| <%+openvpn/ovpn_css%>
 | |
| 
 | |
| <div class="cbi-section-node">
 | |
| 	<div class="table cbi-section-table">
 | |
| 		<h4><%:Template based configuration%></h4>
 | |
| 		<div class="tr cbi-section-table-row" id="div_add">
 | |
| 			<div class="td left">
 | |
| 				<input type="text" maxlength="20" placeholder="Instance name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.text" id="instance_name1" />
 | |
| 			</div>
 | |
| 			<div class="td left">
 | |
| 				<select id="instance_template" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.select">
 | |
| 					<option value="" selected="selected" disabled="disabled"><%:Select template ...%></option>
 | |
| 					<%- for k, v in luci.util.kspairs(self.add_select_options) do %>
 | |
| 						<option value="<%=k%>"><%=luci.xml.pcdata(v)%></option>
 | |
| 					<% end -%>
 | |
| 				</select>
 | |
| 			</div>
 | |
| 			<div class="td left">
 | |
| 				<input class="btn cbi-button cbi-button-add" type="submit" onclick="vpn_add(); return false;" value="<%:Add%>" title="<%:Add template based configuration%>" /><br />
 | |
| 			</div>
 | |
| 		</div>
 | |
| 		<h4><%:OVPN configuration file upload%></h4>
 | |
| 		<div class="tr cbi-section-table-row" id="div_upload">
 | |
| 			<div class="td left">
 | |
| 				<input type="text" maxlength="20" placeholder="Instance name" name="instance_name2" id="instance_name2" />
 | |
| 			</div>
 | |
| 			<div class="td left">
 | |
| 				<input type="file" name="ovpn_file" id="ovpn_file" accept="application/x-openvpn-profile,.ovpn" />
 | |
| 			</div>
 | |
| 			<div class="td left">
 | |
| 				<input class="btn cbi-button cbi-button-add" type="submit" onclick="vpn_upload(); return false;" value="<%:Upload%>" title="<%:Upload ovpn file%>" />
 | |
| 			</div>
 | |
| 		</div>
 | |
| 	</div>
 | |
| 	<div class="vpn-output">
 | |
| 		<span id="vpn_output"></span>
 | |
| 	</div>
 | |
| </div>
 |