JS Refactoring

This commit is contained in:
Matteo Gheza 2021-06-16 20:45:10 +02:00
parent d47eee83ca
commit 95cb7c8f44
7 changed files with 16 additions and 21 deletions

View File

@ -144,10 +144,10 @@ echo(<<<EOL
<label>{$holidays_selection_question}</label>
<a id="select-all-holiday" class="text-primary">{$holidays_select_all}</a> / <a id="select-none-holiday" class="text-primary">{$holidays_select_none}</a>
<script nonce="{$nonce}">
$('#select-all-holiday').click(function(){
$('#select-all-holiday').on("click",function(){
$('.holiday_check').prop('checked', true);
});
$('#select-none-holiday').click(function(){
$('#select-none-holiday').on("click",function(){
$('.holiday_check').prop('checked', false);
});
</script>

View File

@ -138,15 +138,6 @@ if (installServiceWorker) {
});
}
$(function () {
if ($("#frontend_version") !== undefined) {
$("#frontend_version").append(process.env.GIT_VERSION + " aggiornamento " + new Date(process.env.BUNDLE_DATE).toLocaleString());
}
if(getCookie("JSless")){
location.href="?JSless=0";
}
});
var offline = false;
var loadTableInterval = undefined;
var oldData = "null";
@ -157,9 +148,15 @@ var fillTableLoaded = undefined;
window.addEventListener("securitypolicyviolation", console.error.bind(console));
$(function() {
if(getCookie("JSless")){
location.href="?JSless=0";
}
$("#topNavBar").show();
$("#content").show();
$("#footer").show();
if ($("#frontend_version") !== undefined) {
$("#frontend_version").append(process.env.GIT_VERSION + " aggiornamento " + new Date(process.env.BUNDLE_DATE).toLocaleString());
}
$("#menuButton").on("click", function() {
const topNavBar = document.getElementById("topNavBar");
if (topNavBar.className === "topnav") {
@ -168,6 +165,7 @@ $(function() {
topNavBar.className = "topnav";
}
});
$("#logout-text").on("click", function(){ location.href='{{ urlsoftware }}logout.php'; });
});
export var lastTableLoadConfig = {

View File

@ -249,7 +249,7 @@ export function addrSearch (stringResultsFound= undefined, stringResultsNotFound
$("<p>", { html: stringResultsFound+ ":" }).appendTo("#results");
$(list).appendTo("#results");
$("#results li").click(function(e){
$("#results li").on("click",function(e){
e.preventDefault()
var row = e.target;
console.log(row);

View File

@ -65,9 +65,6 @@
id="logout-text">{{ 'Logout'|t }}</b></a>
<a class="pjax_disable icon" id="menuButton"></a>
</div>
<script nonce="{{ nonce }}">
$("#logout-text").click(function(){ location.href='{{ urlsoftware }}logout.php'; });
</script>
{# /Menu #}
{% endblock %}
{% endif %}

View File

@ -90,7 +90,7 @@
{{ 'Search'|t }}
</button>
<script nonce="{{ nonce }}">
$("#search_button").click(function(){
$("#search_button").on("click",function(){
allertaJS.maps.addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');
});
</script>

View File

@ -74,7 +74,7 @@
{{ 'Search'|t }}
</button>
<script nonce="{{ nonce }}">
$("#search_button").click(function(){
$("#search_button").on("click",function(){
allertaJS.maps.addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');
});
</script>

View File

@ -69,11 +69,11 @@
</tbody>
</table>
<script nonce="{{ nonce }}">
$("#activate-btn").click(function(){
allertaJS.main.activate('{{ user.id }}', '');
$("#activate-btn").on("click",function(){
allertaJS.main.activate('{{ user.id }}', '');
});
$("#deactivate-btn").click(function(){
allertaJS.main.deactivate('{{ user.id }}', '');
$("#deactivate-btn").on("click",function(){
allertaJS.main.deactivate('{{ user.id }}', '');
});
allertaJS.main.loadTable({tablePage: "list", useCustomTableEngine: "default", callback: allertaJS.main.loadListListCallback});
</script>