MCPcopy Create free account
hub / github.com/adobe/Marinus / add_zone

Function add_zone

web_server/public/javascripts/config.js:225–273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

223}
224
225function add_zone() {
226 var requestId = this.id;
227 var query;
228 var url;
229 document.getElementById('errorMessage').innerHTML = "";
230 if (requestId.includes("IPZone")) {
231 if (document.getElementById("ipZone_add_input").value.length === 0) {
232 document.getElementById('errorMessage').innerHTML = "<b>Error: A zone must be provided</b>";
233 return false;
234 }
235 url = admin_api_map["ip_zones"];
236 query = "zone=" + document.getElementById("ipZone_add_input").value;
237 } else if (requestId.includes("IPv6Zone")) {
238 if (document.getElementById("ipv6Zone_add_input").value.length === 0) {
239 document.getElementById('errorMessage').innerHTML = "<b>Error: A zone must be provided</b>";
240 return false;
241 }
242 url = admin_api_map["ipv6_zones"];
243 query = "zone=" + document.getElementById("ipv6Zone_add_input").value;
244 } else {
245 if (document.getElementById("zone_add_input").value.length === 0) {
246 document.getElementById('errorMessage').innerHTML = "<b>Error: A zone must be provided</b>";
247 return false;
248 }
249 url = admin_api_map["zones"];
250 query = "zone=" + document.getElementById("zone_add_input").value;
251 }
252
253 var xhr = new XMLHttpRequest();
254 xhr.addEventListener("error", errorHandler);
255 xhr.onreadystatechange = function () {
256 if (xhr.readyState === 4 && xhr.status === 201) {
257 try {
258 var myObj = JSON.parse(xhr.responseText);
259 } catch (err) {
260 document.getElementById('errorMessage').innerHTML = "<b>Error: Bad JSON! <pre>" + err.message + "</pre></b>";
261 return;
262 }
263 confirm_zone_update(myObj, requestId);
264 } else if (xhr.status === 500 || xhr.status === 400) {
265 document.getElementById('errorMessage').innerHTML = xhr.responseText;
266 }
267 };
268
269 xhr.open("POST", url);
270 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
271 xhr.send(query);
272 return false;
273}
274
275function display_zone(results) {
276 if (results.length === 0) {

Callers

nothing calls this directly

Calls 1

confirm_zone_updateFunction · 0.85

Tested by

no test coverage detected