security: Moves inline javascript to files

Signed-off-by: Prachi Srivastava <prachi.chs.2009@gmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Prachi Srivastava 2019-01-21 12:48:04 +05:30 committed by Sunil Mohan Adapa
parent 19e244f152
commit f43e185a8c
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
21 changed files with 479 additions and 306 deletions

View File

@ -81,7 +81,6 @@
{% block page_js %}
{% if is_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
<script type="text/javascript">refresh();</script>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,141 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
var SELFHOST = 'https://carol.selfhost.de/update?username=<User>&' +
'password=<Pass>&myip=<Ip>';
var NOIP = 'http://dynupdate.no-ip.com/nic/update?hostname=' +
'<Domain>&myip=<Ip>';
var FREEDNS = 'https://freedns.afraid.org/dynamic/update.php?' +
'_YOURAPIKEYHERE_';
// Hide all form fields
$('.form-group').hide();
// Show the enable checkbox
$('#id_enabled').closest('.form-group').show();
if ($('#id_enabled').prop('checked')) {
// Show all form fields
show_all();
// Set the selectbox to the last configured value
select_service();
}
$('#id_enabled').change(function() {
if ($('#id_enabled').prop('checked')) {
show_all();
if ($("#id_service_type option:selected").text() == "GnuDIP") {
set_gnudip_mode();
} else {
set_update_url_mode();
}
} else {
$('.form-group').hide();
$('#id_enabled').closest('.form-group').show();
}
});
$('#id_service_type').change(function() {
var service_type = $("#id_service_type option:selected").text();
if (service_type == "GnuDIP") {
set_gnudip_mode();
} else {
set_update_url_mode();
if (service_type == "noip.com") {
$('#id_dynamicdns_update_url').val(NOIP);
$('#id_use_http_basic_auth').prop('checked', true);
} else {
$('#id_use_http_basic_auth').prop('checked', false);
}
if (service_type == "selfhost.bz") {
$('#id_dynamicdns_update_url').val(SELFHOST);
}
if (service_type == "freedns.afraid.org") {
$('#id_dynamicdns_update_url').val(FREEDNS);
}
if (service_type == "other update URL") {
$('#id_dynamicdns_update_url').val('');
}
}
});
$('#id_showpw').change(function() {
// Changing type attribute from password to text is prevented by most
// browsers make a new form field works for me
if ($('#id_showpw').prop('checked')) {
$('#id_dynamicdns_secret').replaceWith(
$('#id_dynamicdns_secret').clone().attr(
'type', 'text'));
} else {
$('#id_dynamicdns_secret').replaceWith(
$('#id_dynamicdns_secret').clone().attr(
'type', 'password'));
}
});
function select_service() {
var update_url = $("#id_dynamicdns_update_url").val();
if ($("#id_dynamicdns_server").val().length == 0) {
set_update_url_mode();
if (update_url == NOIP) {
$("#id_service_type").val("noip");
} else if (update_url == SELFHOST) {
$("#id_service_type").val("selfhost");
} else if (update_url == FREEDNS) {
$("#id_service_type").val("freedns");
} else {
$("#id_service_type").val("other");
}
} else {
$("#id_service_type").val("GnuDIP");
set_gnudip_mode();
}
}
function set_gnudip_mode() {
$('#id_dynamicdns_update_url').closest('.form-group').hide();
$('#id_disable_SSL_cert_check').closest('.form-group').hide();
$('#id_use_http_basic_auth').closest('.form-group').hide();
$('#id_dynamicdns_server').closest('.form-group').show();
}
function set_update_url_mode() {
$('#id_dynamicdns_update_url').closest('.form-group').show();
$('#id_disable_SSL_cert_check').closest('.form-group').show();
$('#id_use_http_basic_auth').closest('.form-group').show();
$('#id_dynamicdns_server').closest('.form-group').hide();
}
function show_all() {
$('#id_enabled').closest('.form-group').show();
$('#id_service_type').closest('.form-group').show();
$('#id_dynamicdns_server').closest('.form-group').show();
$('#id_dynamicdns_update_url').closest('.form-group').show();
$('#id_disable_SSL_cert_check').closest('.form-group').show();
$('#id_use_http_basic_auth').closest('.form-group').show();
$('#id_dynamicdns_domain').closest('.form-group').show();
$('#id_dynamicdns_user').closest('.form-group').show();
$('#id_dynamicdns_secret').closest('.form-group').show();
$('#id_showpw').closest('.form-group').show();
$('#id_dynamicdns_ipurl').closest('.form-group').show();
}
})(jQuery);

View File

@ -20,6 +20,7 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block content %}
@ -43,126 +44,5 @@
{% endblock %}
{% block page_js %}
<script type="text/javascript">
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 or later
(function($) {
var SELFHOST = 'https://carol.selfhost.de/update?username=<User>&' +
'password=<Pass>&myip=<Ip>'
var NOIP = 'http://dynupdate.no-ip.com/nic/update?hostname=' +
'<Domain>&myip=<Ip>'
var FREEDNS = 'https://freedns.afraid.org/dynamic/update.php?' +
'_YOURAPIKEYHERE_'
//hide ALL form fields
$('.form-group').hide();
//show the enable checkbox
$('#id_enabled').closest('.form-group').show();
if ($('#id_enabled').prop('checked')) {
//show all form fields
show_all();
//set the selectbox to the last configured value
select_service();
}
$('#id_enabled').change(function() {
if ($('#id_enabled').prop('checked')) {
show_all();
if ($("#id_service_type option:selected").text() == "GnuDIP") {
set_gnudip_mode()
} else {
set_update_url_mode();
}
} else {
$('.form-group').hide();
$('#id_enabled').closest('.form-group').show();
}
});
$('#id_service_type').change(function() {
var service_type = $("#id_service_type option:selected").text();
if ( service_type == "GnuDIP" ) {
set_gnudip_mode()
} else {
set_update_url_mode();
if ( service_type == "noip.com" ) {
$( '#id_dynamicdns_update_url' ).val( NOIP );
$( '#id_use_http_basic_auth' ).prop( 'checked', true);
} else {
$( '#id_use_http_basic_auth' ).prop( 'checked', false);
}
if ( service_type == "selfhost.bz" ) {
$( '#id_dynamicdns_update_url' ).val(SELFHOST);
}
if ( service_type == "freedns.afraid.org" ) {
$('#id_dynamicdns_update_url').val(FREEDNS);
}
if ( service_type == "other update URL" ) {
$('#id_dynamicdns_update_url').val('');
}
}
});
$('#id_showpw').change(function() {
//changing type attribute from password to text is prevented by
//most browsers make a new form field works for me
if ($('#id_showpw').prop('checked')) {
$('#id_dynamicdns_secret').replaceWith(
$('#id_dynamicdns_secret').clone().attr(
'type', 'text'));
} else {
$('#id_dynamicdns_secret').replaceWith(
$('#id_dynamicdns_secret').clone().attr(
'type', 'password'));
}
});
function select_service() {
var update_url = $("#id_dynamicdns_update_url").val()
if ( $("#id_dynamicdns_server").val().length == 0 ) {
set_update_url_mode()
if ( update_url == NOIP) {
$("#id_service_type").val("noip");
} else if ( update_url == SELFHOST) {
$("#id_service_type").val("selfhost");
} else if ( update_url == FREEDNS) {
$("#id_service_type").val("freedns");
} else {
$("#id_service_type").val("other");
}
} else {
$("#id_service_type").val("GnuDIP");
set_gnudip_mode();
}
}
function set_gnudip_mode() {
$('#id_dynamicdns_update_url').closest('.form-group').hide();
$('#id_disable_SSL_cert_check').closest('.form-group').hide();
$('#id_use_http_basic_auth').closest('.form-group').hide();
$('#id_dynamicdns_server').closest('.form-group').show();
}
function set_update_url_mode() {
$('#id_dynamicdns_update_url').closest('.form-group').show();
$('#id_disable_SSL_cert_check').closest('.form-group').show();
$('#id_use_http_basic_auth').closest('.form-group').show();
$('#id_dynamicdns_server').closest('.form-group').hide();
}
function show_all() {
$('#id_enabled').closest('.form-group').show();
$('#id_service_type').closest('.form-group').show();
$('#id_dynamicdns_server').closest('.form-group').show();
$('#id_dynamicdns_update_url').closest('.form-group').show();
$('#id_disable_SSL_cert_check').closest('.form-group').show();
$('#id_use_http_basic_auth').closest('.form-group').show();
$('#id_dynamicdns_domain').closest('.form-group').show();
$('#id_dynamicdns_user').closest('.form-group').show();
$('#id_dynamicdns_secret').closest('.form-group').show();
$('#id_showpw').closest('.form-group').show();
$('#id_dynamicdns_ipurl').closest('.form-group').show();
}
})(jQuery);
// @license-end
</script>
<script type="text/javascript" src="{% static 'dynamicdns/dynamicdns.js' %}"></script>
{% endblock %}

View File

@ -0,0 +1,27 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
let downloadManualButton = $('a[href="/plinth/help/manual/download/"]');
downloadManualButton.attr("data-turbolinks", "false");
})(jQuery);

View File

@ -96,10 +96,5 @@
{% endblock %}
{% block page_js %}
<script type="text/javascript">
(function($) {
let downloadManualButton = $('a[href="/plinth/help/manual/download/"]');
downloadManualButton.attr("data-turbolinks", "false");
})(jQuery);
</script>
<script type="text/javascript" src="{% static 'help/help.js' %}"></script>
{% endblock %}

View File

@ -0,0 +1,38 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
$('#id_enable_public_registrations').click(function() {
var checkedState = $(this).prop("checked");
if (checkedState) {
$('#id_enable_private_mode').prop('checked', false);
}
});
$('#id_enable_private_mode').click(function() {
var checkedState = $(this).prop("checked");
if (checkedState) {
$('#id_enable_public_registrations').prop('checked', false);
}
});
})(jQuery);

View File

@ -19,23 +19,8 @@
{% endcomment %}
{% load i18n %}
{% load static %}
{% block page_js %}
<script type="text/javascript">
(function($) {
$('#id_enable_public_registrations').click(function () {
var checkedState = $(this).prop("checked");
if (checkedState) {
$('#id_enable_private_mode').prop('checked', false);
}
});
$('#id_enable_private_mode').click(function () {
var checkedState = $(this).prop("checked");
if (checkedState) {
$('#id_enable_public_registrations').prop('checked', false);
}
});
})(jQuery);
</script>
<script type="text/javascript" src="{% static 'mediawiki/mediawiki.js' %}"></script>
{% endblock %}

View File

@ -173,7 +173,6 @@
{% block page_js %}
{% if running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
<script type="text/javascript">refresh();</script>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,97 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
function ip_required(required, ip_version, fields) {
var prefix = '#id_' + ip_version + '_';
for (var i = 0; i < fields.length; i++) {
$(prefix + fields[i]).prop("required", required);
}
}
function ip_readonly(readonly, ip_version, fields) {
var prefix = '#id_' + ip_version + '_';
for (var i = 0; i < fields.length; i++) {
$(prefix + fields[i]).prop("readOnly", readonly);
if (readonly) {
$(prefix + fields[i]).val("");
$(prefix + fields[i]).prop("required", false);
}
}
}
function on_ipv4_method_change() {
if ($("#id_ipv4_method").prop("value") == "manual") {
ip_required(true, 'ipv4', ['address']);
ip_readonly(false, 'ipv4', ['address', 'netmask', 'gateway',
'dns', 'second_dns'
]);
} else if ($("#id_ipv4_method").prop("value") == "shared") {
ip_required(false, 'ipv4', ['address']);
ip_readonly(false, 'ipv4', ['address', 'netmask']);
ip_readonly(true, 'ipv4', ['gateway', 'dns', 'second_dns']);
} else if ($("#id_ipv4_method").prop("value") == "auto") {
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway']);
ip_readonly(false, 'ipv4', ['dns', 'second_dns']);
} else {
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway',
'dns', 'second_dns'
]);
}
}
function on_ipv6_method_change() {
if ($("#id_ipv6_method").prop("value") == "manual") {
ip_required(true, 'ipv6', ['address', 'prefix']);
ip_readonly(false, 'ipv6', ['address', 'prefix', 'gateway',
'dns', 'second_dns'
]);
} else if ($("#id_ipv6_method").prop("value") == "auto" ||
$("#id_ipv6_method").prop("value") == "dhcp") {
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway']);
ip_readonly(false, 'ipv6', ['dns', 'second_dns']);
} else {
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway',
'dns', 'second_dns'
]);
}
}
$("#id_name").focus();
$("#id_ipv4_method").change(on_ipv4_method_change).change();
$("#id_ipv6_method").change(on_ipv6_method_change).change();
$('#id_show_password').change(function() {
// Changing type attribute from password to text is prevented by
// most browsers. Making a new form field works.
new_type = 'password';
if ($('#id_show_password').prop('checked'))
new_type = 'text';
$('#id_password').replaceWith(
$('#id_password').clone().attr('type', new_type));
});
})(jQuery);

View File

@ -20,6 +20,7 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block content %}
@ -36,79 +37,6 @@
{% block page_js %}
<script type="text/javascript">
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 or later
(function($) {
function ip_required(required, ip_version, fields) {
var prefix = '#id_' + ip_version + '_';
for (var i = 0; i < fields.length; i++) {
$(prefix + fields[i]).prop("required", required);
}
}
function ip_readonly(readonly, ip_version, fields) {
var prefix = '#id_' + ip_version + '_';
for (var i = 0; i < fields.length; i++) {
$(prefix + fields[i]).prop("readOnly", readonly);
if (readonly) {
$(prefix + fields[i]).val("");
$(prefix + fields[i]).prop("required", false);
}
}
}
function on_ipv4_method_change() {
if ($("#id_ipv4_method").prop("value") == "manual") {
ip_required(true, 'ipv4', ['address']);
ip_readonly(false, 'ipv4', ['address', 'netmask', 'gateway',
'dns', 'second_dns']);
} else if ($("#id_ipv4_method").prop("value") == "shared") {
ip_required(false, 'ipv4', ['address']);
ip_readonly(false, 'ipv4', ['address', 'netmask']);
ip_readonly(true, 'ipv4', ['gateway', 'dns', 'second_dns']);
} else if ($("#id_ipv4_method").prop("value") == "auto") {
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway']);
ip_readonly(false, 'ipv4', ['dns', 'second_dns']);
} else {
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway',
'dns', 'second_dns']);
}
}
function on_ipv6_method_change() {
if ($("#id_ipv6_method").prop("value") == "manual") {
ip_required(true, 'ipv6', ['address', 'prefix']);
ip_readonly(false, 'ipv6', ['address', 'prefix', 'gateway',
'dns', 'second_dns']);
} else if ($("#id_ipv6_method").prop("value") == "auto" ||
$("#id_ipv6_method").prop("value") == "dhcp") {
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway']);
ip_readonly(false, 'ipv6', ['dns', 'second_dns']);
} else {
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway',
'dns', 'second_dns']);
}
}
$("#id_name").focus();
$("#id_ipv4_method").change(on_ipv4_method_change).change();
$("#id_ipv6_method").change(on_ipv6_method_change).change();
$('#id_show_password').change(function() {
// Changing type attribute from password to text is prevented by
// most browsers. Making a new form field works.
new_type = 'password';
if ($('#id_show_password').prop('checked'))
new_type = 'text';
$('#id_password').replaceWith(
$('#id_password').clone().attr('type', new_type));
});
})(jQuery);
// @license-end
</script>
<script type="text/javascript" src="{% static 'networks/networks.js' %}"></script>
{% endblock %}

View File

@ -135,6 +135,5 @@
{% block page_js %}
{% if status.setup_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
<script type="text/javascript">refresh();</script>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,34 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
$('#id_pagekite-enabled').change(function() {
if ($('#id_pagekite-enabled').prop('checked')) {
$('#pagekite-post-enabled-form').show('fast');
} else {
$('#pagekite-post-enabled-form').hide('fast');
}
}).change();
})(jQuery);

View File

@ -20,6 +20,7 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block content %}
@ -45,19 +46,5 @@
{% block page_js %}
<script type="text/javascript">
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 or later
(function($) {
$('#id_pagekite-enabled').change(function() {
if ($('#id_pagekite-enabled').prop('checked')) {
$('#pagekite-post-enabled-form').show('fast');
} else {
$('#pagekite-post-enabled-form').hide('fast');
}
});
})(jQuery);
// @license-end
</script>
<script type="text/javascript" src="{% static 'pagekite/pagekite.js' %}"></script>
{% endblock %}

View File

@ -0,0 +1,32 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
$("#select-all").click(function() {
var checkedState = this.checked;
checkboxes = document.getElementsByName('snapshot_list');
jQuery.each(checkboxes, function(i, checkbox) {
checkbox.checked = checkedState;
});
});
})(jQuery);

View File

@ -20,6 +20,7 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block configuration %}
<form class="form" method="post">
@ -43,7 +44,7 @@
<th>{% trans "Date" %}</th>
<th>{% trans "Description" %}</th>
<th>{% trans "Rollback" %}</th>
<th><input type="checkbox" name="select_all" onclick="toggle(this)"></th>
<th><input type="checkbox" id="select-all"></th>
</thead>
<tbody>
{% for snapshot in snapshots %}
@ -84,14 +85,6 @@
{% endblock %}
{% block page_js %}
<script>
function toggle(source) {
var checkedState = source.checked;
checkboxes = document.getElementsByName('snapshot_list');
jQuery.each(checkboxes, function(i, checkbox) {
checkbox.checked = checkedState;
})
}
</script>
<script type="text/javascript" src="{% static 'snapshot/snapshot.js' %}"></script>
{% endblock %}

View File

@ -0,0 +1,46 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
(function($) {
$('#id_tor-relay_enabled').change(function() {
var bridge = $('#id_tor-bridge_relay_enabled');
var disable = !$('#id_tor-relay_enabled').prop('checked');
bridge.prop('disabled', disable);
if (disable) {
$('#id_tor-bridge_relay_enabled').prop('checked', false);
}
}).change();
$('#id_tor-use_upstream_bridges').change(function() {
if ($('#id_tor-use_upstream_bridges').prop('checked')) {
$('#id_tor-upstream_bridges').parent().parent().show('slow');
$('#id_tor-relay_enabled').prop('checked', false)
.prop('disabled', true);
$('#id_tor-bridge_relay_enabled').prop('checked', false)
.prop('disabled', true);
} else {
$('#id_tor-upstream_bridges').parent().parent().hide('slow');
$('#id_tor-relay_enabled').prop('disabled', false);
}
}).change();
})(jQuery);

View File

@ -143,37 +143,10 @@
{% block page_js %}
<script type="text/javascript">
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 or later
(function($) {
$('#id_tor-relay_enabled').change(function() {
var bridge = $('#id_tor-bridge_relay_enabled');
var disable = ! $('#id_tor-relay_enabled').prop('checked');
bridge.prop('disabled', disable);
if (disable) {
$('#id_tor-bridge_relay_enabled').prop('checked', false);
}
}).change();
$('#id_tor-use_upstream_bridges').change(function() {
if ($('#id_tor-use_upstream_bridges').prop('checked')) {
$('#id_tor-upstream_bridges').parent().parent().show('slow');
$('#id_tor-relay_enabled').prop('checked', false)
.prop('disabled', true);
$('#id_tor-bridge_relay_enabled').prop('checked', false)
.prop('disabled', true);
} else {
$('#id_tor-upstream_bridges').parent().parent().hide('slow');
$('#id_tor-relay_enabled').prop('disabled', false);
}
}).change();
})(jQuery);
// @license-end
</script>
<script type="text/javascript" src="{% static 'tor/tor.js' %}"></script>
{% if config_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
<script type="text/javascript">refresh();</script>
{% endif %}
{% endblock %}

View File

@ -78,16 +78,8 @@
{% endblock %}
{% block page_js %}
<script>
$('.show-details').show();
$('.details').hide();
$('.show-details').click(function() {
$('.details').toggle("slow");
});
</script>
{% if is_busy %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
<script type="text/javascript">refresh();</script>
{% endif %}
{% endblock %}

View File

@ -143,11 +143,10 @@
{% block page_js %}
{% if setup_current_operation or setup_state == 'up-to-date' %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% if setup_state == 'up-to-date' %}
<script type="text/javascript">refresh(0);</script>
<script type="text/javascript" src="{% static 'theme/js/refresh_immediately.js' %}"></script>
{% else %}
<script type="text/javascript">refresh();</script>
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endif %}

View File

@ -1,19 +1,25 @@
/*
This file is part of FreedomBox.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
@ -21,9 +27,8 @@ function sleep(ms) {
// Refresh the page once in n seconds
async function refresh(ms) {
if (typeof ms === 'undefined')
ms = 3000;
await sleep(ms);
await sleep(3000);
window.location.reload();
}
refresh();

View File

@ -0,0 +1,24 @@
/**
* @licstart The following is the entire license notice for the JavaScript
* code in this page.
*
* This file is part of FreedomBox.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice for the JavaScript code
* in this page.
*/
window.location.reload();