2 <script type=
"text/javascript">
6 var vpn_name = div_add.querySelector(
"#instance_name1").value.replace(/[^\x00-\x7F]|[\s!@#$%^&*()\-+=\[\]{};':
"\\|,<>\/?]/g,'');
7 var vpn_template = div_add.querySelector("#instance_template
").value;
8 var form = document.getElementsByName('cbi')[0];
10 if (!vpn_name || !vpn_name.length)
12 return info_message(vpn_output, "<%=pcdata(translate(
"The 'Name' field must not be empty!"))%
>", 2000);
15 document.getElementById("instance_name1
").value = vpn_name;
16 if (document.getElementById("cbi-openvpn-
" + vpn_name) != null)
18 return info_message(vpn_output, "<%=pcdata(translate(
"Instance with that name already exists!"))%
>", 2000);
21 if (!vpn_template || !vpn_template.length)
23 return info_message(vpn_output, "<%=pcdata(translate(
"Please select a valid VPN template!"))%
>", 2000);
34 var vpn_name = div_upload.querySelector("#instance_name2
").value.replace(/[^\x00-\x7F]|[\s!@#$%^&*()\-+=\[\]{};':"\\|,<
>\/?]/g,'');
35 var vpn_file = document.getElementById(
"ovpn_file").value;
36 var form = document.getElementsByName('cbi')[
0];
38 if (!vpn_name || !vpn_name.length)
40 return info_message(vpn_output,
"<%=pcdata(translate("The 'Name' field must not be empty!
"))%>",
2000);
43 document.getElementById(
"instance_name2").value = vpn_name;
44 if (document.getElementById(
"cbi-openvpn-" + vpn_name) != null)
46 return info_message(vpn_output,
"<%=pcdata(translate("Instance with that name already exists!
"))%>",
2000);
49 if (!vpn_file || !vpn_file.length)
51 return info_message(vpn_output,
"<%=pcdata(translate("Please select a valid OVPN config file to upload!
"))%>",
2000);
56 form.enctype = 'multipart/form-data';
57 form.action = '<%=url('admin/services/openvpn/upload')%
>';
62 function info_message(output, msg, timeout)
64 timeout = timeout ||
0;
65 output.innerHTML = '
<em>' + msg + '
</em>';
68 setTimeout(function(){ output.
innerHTML=
""}, timeout);
76 <div class=
"cbi-section-node">
77 <div class=
"table cbi-section-table">
78 <h4><%:Template based configuration%
></h4>
79 <div class=
"tr cbi-section-table-row" id=
"div_add">
81 <input type=
"text" maxlength=
"20" placeholder=
"Instance name" name=
"cbi.cts.<%=self.config%>.<%=self.sectiontype%>.text" id=
"instance_name1" />
84 <select id=
"instance_template" name=
"cbi.cts.<%=self.config%>.<%=self.sectiontype%>.select">
85 <option value=
"" selected=
"selected" disabled=
"disabled"><%:Select template ...%
></option>
86 <%- for k, v in luci.util.kspairs(self.add_select_options) do %
>
87 <option value=
"<%=k%>"><%=luci.util.pcdata(v)%
></option>
92 <input class=
"cbi-button cbi-button-add" type=
"submit" onclick=
"vpn_add(); return false;" value=
"<%:Add%>" title=
"<%:Add template based configuration%>" /><br />
95 <h4><%:OVPN configuration file upload%
></h4>
96 <div class=
"tr cbi-section-table-row" id=
"div_upload">
98 <input type=
"text" maxlength=
"20" placeholder=
"Instance name" name=
"instance_name2" id=
"instance_name2" />
100 <div class=
"td left">
101 <input type=
"file" name=
"ovpn_file" id=
"ovpn_file" accept=
"application/x-openvpn-profile,.ovpn" />
103 <div class=
"td left">
104 <input class=
"cbi-button cbi-button-add" type=
"submit" onclick=
"vpn_upload(); return false;" value=
"<%:Upload%>" title=
"<%:Upload ovpn file%>" />
108 <div class=
"vpn-output">
109 <span id=
"vpn_output"></span>