diff --git a/index.html b/index.html index d264a27..cdd73af 100644 --- a/index.html +++ b/index.html @@ -201,6 +201,7 @@

aule libere polito

Per qualsiasi problema fai uno screenshot e invialo a @domescala su telegram. Daje

@@ -338,14 +339,14 @@

-

- + + - diff --git a/js/counter.js b/js/counter.js new file mode 100644 index 0000000..8ccca36 --- /dev/null +++ b/js/counter.js @@ -0,0 +1,73 @@ +const COUNTER = { + favorite_add: function(classroom){ + counter_increment("favorite classrooms", "Aula " + classroom) + }, + classroom_opening: function (classroom) { + counter_increment("watch classrooms", "Aula " + classroom) + }, + campus_selected: function (campus) { + counter_increment("campus selected", campus) + }, + filter_selected: function (filter) { + counter_increment("filter selected", filter) + }, + click_buttons: function (button) { + counter_increment("click_buttons", button) + }, + click_links: function (link) { + counter_increment("click_links", link) + }, + main_page: function () { + counter_increment("view", "mainpage") + } +} + + +var counter_increment = function(){} + + + +window.addEventListener("load", function () { + setTimeout(() => { + COUNTER.main_page() + counter_increment = function (action, key){ + var namespace = 'auleliberev2' + var options = { behavior: 'vote' } + + counterApi.increment(key, action, namespace, options, function(err, res){ + console.log(res) + }) + + } + }, 10); +}) + +q("#search_main").addEventListener("mousedown", function () { + + COUNTER.click_buttons("main search") +}) +q("#search_main").addEventListener("input", function () { + + COUNTER.click_buttons("run search") +}) +q("#button_search_class").addEventListener("mousedown", function () { + + COUNTER.click_buttons("bottom search") +}) + +Q(".date_input").forEach(e => { + e.addEventListener("click", function () { + COUNTER.click_buttons("open date") + }) +}) + +q("#campus_input").addEventListener("click", function () { + COUNTER.click_buttons("open campus") +}) + + +Q("a").forEach(e => { + e.addEventListener("mousedown", function () { + COUNTER.click_links(e.innerHTML) + }) +}); \ No newline at end of file diff --git a/js/counterviews.js b/js/counterviews.js deleted file mode 100644 index cf5705b..0000000 --- a/js/counterviews.js +++ /dev/null @@ -1,5 +0,0 @@ -let url = window.location.href - -if(!url.includes("?debug")){ - document.createElement("img").setAttribute("src", "https://counterapi.com/pixel.gif?ns=auleliberev2") -} diff --git a/js/main.js b/js/main.js index fb453bf..91b4ad7 100644 --- a/js/main.js +++ b/js/main.js @@ -358,6 +358,8 @@ function updateDoc_campus(campus, disp){ }); updateDoc_date(disp) setup_search_modal() + + COUNTER.campus_selected(Selected_campus) } function remove_columns(n_fasceorarie) { @@ -452,6 +454,7 @@ function load_localStorage(){ else{ localStorage["favorites"] = "[]" } + } @@ -540,6 +543,8 @@ function open_modal(id_row){ else{ q("#modal_favorite").removeClass("favorite") } + + COUNTER.classroom_opening(Aula_modal) } function exit_modal(){ @@ -576,6 +581,7 @@ FILTERS.forEach(filter => { filtra_aule("reset") } + COUNTER.filter_selected(filter.getAttribute("value").replace("_", "")) }) }); @@ -591,6 +597,8 @@ Q(".row_aule").forEach(ROW => { }) }) +// ---- FAVORITE ADD BUTTON ---- + q("#modal_favorite").addEventListener("click", function(){ q("#modal_favorite").toggleClass("favorite") q('[_id="' + Aula_modal + '"]').toggleClass("favorite") @@ -604,6 +612,8 @@ q("#modal_favorite").addEventListener("click", function(){ } localStorage["favorites"] = JSON.stringify(Favorites) Order_favorites() + + COUNTER.favorite_add(Aula_modal) }) function Order_favorites(){ // i valori di order dipendono se il Filtro è attivo o no e se è nei preferiti o no @@ -710,6 +720,7 @@ function change_date(this_element){ updateDoc_date(disp) } + COUNTER.click_buttons("change date") } function change_campus(this_element) { @@ -814,12 +825,13 @@ q("#button_search_class").addEventListener("click", function(){ // open_modal_search() q("#search_main").focus() q("#button_search_class").removeClass("button_search_appear") + }) q("#search_main").addEventListener("input", function(){ let val = q("#search_main").value.toUpperCase() q("#search_main").value = val; - + // se contiene il carattere nascosto al fondo allora è stato premuto sulla datalist if (val.slice(-1) === '\u2063') { val = val.slice(0, -1); //rimuovi il carattere e lancia il modal