var dnssecKeyList = [] function applyChanges(data, url, showResult, refreshPage) { $.ajax({ type : "POST", url : url, data : JSON.stringify(data),// now data come in this function contentType : "application/json; charset=utf-8", crossDomain : true, dataType : "json", success : function(data, status, jqXHR) { console.log("Applied changes successfully."); console.log(data); if (showResult) { var modal = $("#modal_success"); if (data['msg']) { modal.find('.modal-body p').text(data['msg']); } else { modal.find('.modal-body p').text("Applied changes successfully"); } modal.modal('show'); } if (refreshPage) { location.reload(true); } }, error : function(jqXHR, status) { console.log(jqXHR); var modal = $("#modal_error"); var responseJson = jQuery.parseJSON(jqXHR.responseText); modal.find('.modal-body p').text(responseJson['msg']); modal.modal('show'); } }); } function applyRecordChanges(data, domain) { $.ajax({ type : "POST", url : $SCRIPT_ROOT + '/domain/' + domain + '/apply', data : JSON.stringify(data),// now data come in this function contentType : "application/json; charset=utf-8", crossDomain : true, dataType : "json", success : function(data, status, jqXHR) { // update Apply button value $.getJSON($SCRIPT_ROOT + '/domain/' + domain + '/info', function(data) { $(".button_apply_changes").val(data['serial']); }); console.log("Applied changes successfully.") var modal = $("#modal_success"); modal.find('.modal-body p').text("Applied changes successfully"); modal.modal('show'); }, error : function(jqXHR, status) { console.log(jqXHR); var modal = $("#modal_error"); var responseJson = jQuery.parseJSON(jqXHR.responseText); modal.find('.modal-body p').text(responseJson['msg']); modal.modal('show'); } }); } function getTableData(table) { // reformat - pretty format var records = [] table.rows().every(function() { var r = this.data(); var record = {} record["record_name"] = r[0].trim(); record["record_type"] = r[1].trim(); record["record_status"] = r[2].trim(); record["record_ttl"] = r[3].trim(); record["record_data"] = r[4].trim(); record["record_comment"] = r[5].trim(); records.push(record); }); return records } function saveRow(oTable, nRow) { var status = 'Disabled'; var jqInputs = $(oTable.row(nRow).node()).find("input"); var jqSelect = $(oTable.row(nRow).node()).find("select"); if (jqSelect[1].value == 'false') { status = 'Active'; } oTable.cell(nRow,0).data(jqInputs[0].value); oTable.cell(nRow,1).data(jqSelect[0].value); oTable.cell(nRow,2).data(status); oTable.cell(nRow,3).data(jqSelect[2].value); oTable.cell(nRow,4).data(jqInputs[1].value); oTable.cell(nRow,5).data(jqInputs[2].value); var record = jqInputs[0].value; var button_edit = "" var button_delete = "" oTable.cell(nRow,6).data(button_edit); oTable.cell(nRow,7).data(button_delete); oTable.draw(); } function restoreRow(oTable, nRow) { var aData = oTable.row(nRow).data(); oTable.row(nRow).data(aData); oTable.draw(); } function sec2str(t){ var d = Math.floor(t/86400), h = Math.floor(t/3600) % 24, m = Math.floor(t/60) % 60, s = t % 60; return (d>0?d+' days ':'')+(h>0?h+' hours ':'')+(m>0?m+' minutes ':'')+(s>0?s+' seconds':''); } function editRow(oTable, nRow) { var isDisabled = 'true'; var aData = oTable.row(nRow).data(); var jqTds = oTable.cells(nRow,'').nodes(); var record_types = ""; var ttl_opts = ""; var ttl_not_found = true; for(var i = 0; i < records_allow_edit.length; i++) { var record_type = records_allow_edit[i]; record_types += ""; } for(var i = 0; i < ttl_options.length; i++) { ttl_opts += ""; if (ttl_options[i][0] == aData[3]) { ttl_not_found = false; } } if (ttl_not_found) { ttl_opts += ""; } jqTds[0].innerHTML = ''; jqTds[1].innerHTML = ''; jqTds[2].innerHTML = ''; jqTds[3].innerHTML = ''; jqTds[4].innerHTML = ''; jqTds[5].innerHTML = ''; jqTds[6].innerHTML = ''; jqTds[7].innerHTML = ''; // set current value of dropdown column if (aData[2] == 'Active'){ isDisabled = 'false'; } SelectElement('record_type', aData[1]); SelectElement('record_status', isDisabled); SelectElement('record_ttl', aData[3]); } function SelectElement(elementID, valueToSelect) { var element = document.getElementById(elementID); element.value = valueToSelect; } function enable_dns_sec(url, csrf_token) { $.post(url, {'_csrf_token': csrf_token}, function(data) { var modal = $("#modal_dnssec_info"); if (data['status'] == 'error'){ modal.find('.modal-body p').text(data['msg']); } else { modal.modal('hide'); //location.reload(); window.location.reload(true); } }, 'json') } function getdnssec(url, domain){ $.getJSON(url, function(data) { var dnssec_footer = ''; var modal = $("#modal_dnssec_info"); if (data['status'] == 'error'){ modal.find('.modal-body p').text(data['msg']); } else { var dnssec_msg = ''; var dnssec = data['dnssec']; if (dnssec.length == 0 && parseFloat(PDNS_VERSION) >= 4.1) { dnssec_msg = '