Skip to content

Commit

Permalink
Fix js code as suggestion from LGTM
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoduykhanh committed Aug 31, 2018
1 parent e6f8216 commit 43830e5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 44 deletions.
16 changes: 4 additions & 12 deletions app/static/custom/js/custom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var dnssecKeyList = []

function applyChanges(data, url, showResult, refreshPage) {
var success = false;
$.ajax({
type : "POST",
url : url,
Expand Down Expand Up @@ -36,7 +35,6 @@ function applyChanges(data, url, showResult, refreshPage) {
}

function applyRecordChanges(data, domain) {
var success = false;
$.ajax({
type : "POST",
url : $SCRIPT_ROOT + '/domain/' + domain + '/apply',
Expand Down Expand Up @@ -67,8 +65,6 @@ function applyRecordChanges(data, domain) {
}

function getTableData(table) {
var rData = []

// reformat - pretty format
var records = []
table.rows().every(function() {
Expand All @@ -86,16 +82,14 @@ function getTableData(table) {

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';
} else {
status = 'Disabled';
}


oTable.cell(nRow,0).data(jqInputs[0].value);
oTable.cell(nRow,1).data(jqSelect[0].value);
oTable.cell(nRow,2).data(status);
Expand All @@ -114,12 +108,12 @@ function saveRow(oTable, nRow) {

function restoreRow(oTable, nRow) {
var aData = oTable.row(nRow).data();
var jqTds = $('>td', nRow);
oTable.row(nRow).data(aData);
oTable.draw();
}

function editRow(oTable, nRow) {
var isDisabled = 'true';
var aData = oTable.row(nRow).data();
var jqTds = oTable.cells(nRow,'').nodes();
var record_types = "";
Expand All @@ -139,9 +133,6 @@ function editRow(oTable, nRow) {
if (aData[2] == 'Active'){
isDisabled = 'false';
}
else {
isDisabled = 'true';
}

SelectElement('record_type', aData[1]);
SelectElement('record_status', isDisabled);
Expand Down Expand Up @@ -172,13 +163,14 @@ function enable_dns_sec(url) {
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 {
dnssec_msg = '';
var dnssec_msg = '';
var dnssec = data['dnssec'];

if (dnssec.length == 0 && parseFloat(PDNS_VERSION) >= 4.1) {
Expand Down
60 changes: 30 additions & 30 deletions app/templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ <h1>
<section class="content">
{% with errors = get_flashed_messages(category_filter=["error"]) %} {% if errors %}
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
<h4>
<i class="icon fa fa-ban"></i> Error!
</h4>
<div class="alert-message block-message error">
<a class="close" href="#">x</a>
<ul>
{%- for msg in errors %}
<li>{{ msg }}</li> {% endfor -%}
</ul>
</div>
</div>
</div>
<div class="col-md-12">
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
<h4>
<i class="icon fa fa-ban"></i> Error!
</h4>
<div class="alert-message block-message error">
<a class="close" href="#">x</a>
<ul>
{%- for msg in errors %}
<li>{{ msg }}</li> {% endfor -%}
</ul>
</div>
</div>
</div>
</div>
{% endif %} {% endwith %}
<div class="row">
Expand All @@ -45,11 +45,11 @@ <h4>
<h3 class="box-title">Templates</h3>
</div>
<div class="box-body">
<a href="{{ url_for('create_template') }}">
<button type="button" class="btn btn-flat btn-primary pull-left">
Create Template&nbsp;<i class="fa fa-plus"></i>
</button>
</a>
<a href="{{ url_for('create_template') }}">
<button type="button" class="btn btn-flat btn-primary pull-left">
Create Template&nbsp;<i class="fa fa-plus"></i>
</button>
</a>
</div>
<div class="box-body">
<table id="tbl_template_list" class="table table-bordered table-striped">
Expand All @@ -75,15 +75,15 @@ <h3 class="box-title">Templates</h3>
</td>
<td>
<a href="{{ url_for('edit_template', template=template.name) }}">
<button type="button" class="btn btn-flat btn-warning button_edit" id="">
Edit&nbsp;<i class="fa fa-edit"></i>
</button>
</a>
<a href="{{ url_for('delete_template', template=template.name) }}">
<button type="button" class="btn btn-flat btn-danger button_delete" id="">
Delete&nbsp;<i class="fa fa-trash"></i>
</button>
</a>
<button type="button" class="btn btn-flat btn-warning button_edit" id="btn_edit">
Edit&nbsp;<i class="fa fa-edit"></i>
</button>
</a>
<a href="{{ url_for('delete_template', template=template.name) }}">
<button type="button" class="btn btn-flat btn-danger button_delete" id="btn_delete">
Delete&nbsp;<i class="fa fa-trash"></i>
</button>
</a>
</td>
</tr>
{% endfor %}
Expand Down
3 changes: 1 addition & 2 deletions app/templates/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ <h3 class="box-title">Edit my profile{% if session['authentication_type'] != 'L
// handle checkbox toggling
$('.otp_toggle').on('ifToggled', function(event) {
var enable_otp = $(this).prop('checked');
var username = $(this).prop('id');
postdata = {
var postdata = {
'action' : 'enable_otp',
'data' : {
'enable_otp' : enable_otp
Expand Down

0 comments on commit 43830e5

Please sign in to comment.