Added SCRIPT_ROOT parameter. Fixes #52.

Adds a new javascript parameter that holds the webroot of the app. This
allows the the javascript calls to properly identify that they're
running in a subfolder/different webroot and direct their queries there.
This commit is contained in:
Ivan Filippov 2016-07-01 18:45:42 -06:00
parent ff842f66e2
commit ea79c01aff
7 changed files with 13 additions and 11 deletions

View File

@ -97,7 +97,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-flat btn-default pull-left" <button type="button" class="btn btn-flat btn-default pull-left"
data-dismiss="modal">Close</button> data-dismiss="modal">Close</button>
<button type="button" class="btn btn-flat btn-danger" onclick="applyChanges('', '/admin/history');location.reload();">Clear <button type="button" class="btn btn-flat btn-danger" onclick="applyChanges('', $SCRIPT_ROOT + '/admin/history');location.reload();">Clear
History</button> History</button>
</div> </div>
</div> </div>

View File

@ -91,7 +91,7 @@
modal.find('.modal-body p').text(info); modal.find('.modal-body p').text(info);
modal.find('#button_revoke_confirm').click(function() { modal.find('#button_revoke_confirm').click(function() {
var postdata = {'action': 'revoke_user_privielges', 'data': username} var postdata = {'action': 'revoke_user_privielges', 'data': username}
applyChanges(postdata, '/admin/manageuser'); applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser');
modal.modal('hide'); modal.modal('hide');
}) })
modal.modal('show'); modal.modal('show');
@ -104,7 +104,7 @@
modal.find('.modal-body p').text(info); modal.find('.modal-body p').text(info);
modal.find('#button_delete_confirm').click(function() { modal.find('#button_delete_confirm').click(function() {
var postdata = {'action': 'delete_user', 'data': username} var postdata = {'action': 'delete_user', 'data': username}
applyChanges(postdata, '/admin/manageuser', false, true); applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser', false, true);
modal.modal('hide'); modal.modal('hide');
}) })
modal.modal('show'); modal.modal('show');
@ -128,7 +128,7 @@
'is_admin' : is_admin 'is_admin' : is_admin
} }
}; };
applyChanges(postdata, '/admin/manageuser'); applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser');
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -76,14 +76,14 @@
}); });
$(document.body).on('click', '.setting-toggle-button', function() { $(document.body).on('click', '.setting-toggle-button', function() {
var setting = $(this).prop('id'); var setting = $(this).prop('id');
applyChanges('','/admin/setting/' + setting + '/toggle', false, true) applyChanges('', $SCRIPT_ROOT + '/admin/setting/' + setting + '/toggle', false, true)
}); });
$(document.body).on('click', '.setting-save-button', function() { $(document.body).on('click', '.setting-save-button', function() {
var setting = $(this).prop('id'); var setting = $(this).prop('id');
var value = $(this).parents('tr').find('#value')[0].value; var value = $(this).parents('tr').find('#value')[0].value;
var postdata = {'value': value}; var postdata = {'value': value};
applyChanges(postdata, '/admin/setting/' + setting + '/edit', false, true) applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/' + setting + '/edit', false, true)
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -163,7 +163,9 @@
</footer> </footer>
</div> </div>
<!-- ./wrapper --> <!-- ./wrapper -->
<script type="text/javascript">
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
</script>
{% block scripts %} {% block scripts %}
<!-- jQuery 2.2.0 --> <!-- jQuery 2.2.0 -->
<script src="{{ url_for('static', filename='adminlte2/plugins/jQuery/jQuery-2.2.0.min.js') }}"></script> <script src="{{ url_for('static', filename='adminlte2/plugins/jQuery/jQuery-2.2.0.min.js') }}"></script>

View File

@ -240,7 +240,7 @@
}); });
$(document.body).on("click", ".button_dnssec", function() { $(document.body).on("click", ".button_dnssec", function() {
var domain = $(this).prop('id'); var domain = $(this).prop('id');
getdnssec('/domain/' + domain + '/dnssec'); getdnssec($SCRIPT_ROOT + '/domain/' + domain + '/dnssec');
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -204,7 +204,7 @@
modal.find('.modal-body p').text(info); modal.find('.modal-body p').text(info);
modal.find('#button_apply_confirm').click(function() { modal.find('#button_apply_confirm').click(function() {
var data = getTableData(table); var data = getTableData(table);
applyChanges(data, '/domain/' + domain + '/apply', true); applyChanges(data, $SCRIPT_ROOT + '/domain/' + domain + '/apply', true);
modal.modal('hide'); modal.modal('hide');
}) })
modal.modal('show'); modal.modal('show');
@ -253,7 +253,7 @@
//handle update_from_master button //handle update_from_master button
$(document.body).on("click", ".button_update_from_master", function (e) { $(document.body).on("click", ".button_update_from_master", function (e) {
var domain = $(this).prop('id'); var domain = $(this).prop('id');
applyChanges({'domain': domain}, '/domain/' + domain + '/update'); applyChanges({'domain': domain}, $SCRIPT_ROOT + '/domain/' + domain + '/update');
}); });
{% if record_helper_setting %} {% if record_helper_setting %}

View File

@ -165,7 +165,7 @@
'enable_otp' : enable_otp 'enable_otp' : enable_otp
} }
}; };
applyChanges(postdata, '/user/profile'); applyChanges(postdata, $SCRIPT_ROOT + '/user/profile');
location.reload(); location.reload();
}); });
</script> </script>