Canviat css manual a classe hidden
diff --git a/index.html b/index.html
index 4132f60..652cdec 100644
--- a/index.html
+++ b/index.html
@@ -76,7 +76,7 @@
</section>
- <section id="section-2" class="section" style="display: none;">
+ <section id="section-2" class="section hidden">
<button class="button is-link is-light" onclick="switchSection('section-1')">Torna enrere (Classe)</button>
<div id="letter-container" class="buttons grid">
@@ -95,7 +95,7 @@
</div>
</section>
- <section id="section-3" class="section" style="display: none;">
+ <section id="section-3" class="section hidden">
<button class="button is-link is-light" onclick="switchSection('section-2')">Torna enrere (Lletra)</button>
<div id="number-container" class="buttons grid">
@@ -111,7 +111,7 @@
<button class="button" id="number-10" data-number="10">10</button>
</div>
</section>
- <section id="section-send" class="section" style="display: none;">
+ <section id="section-send" class="section hidden">
<button class="button is-link is-light" onclick="switchSection('section-3')">Torna enrere (Número)</button>
<br/><br/>
<span class="has-text-weight-bold">Assignatura:</span>
diff --git a/js/build_page.js b/js/build_page.js
index 9a533f0..32e0286 100644
--- a/js/build_page.js
+++ b/js/build_page.js
@@ -17,15 +17,15 @@
};
function fillInSummary() {
- var begins = new Date(parseInt(final_JSON.class.begins)*1000);
- var ends = new Date(parseInt(final_JSON.class.ends)*1000);
+ var begins = new Date(parseInt(final_JSON.class.begins)*1000);
+ var ends = new Date(parseInt(final_JSON.class.ends)*1000);
- document.getElementById('subject-final').textContent = final_JSON.class.friendly_name || final_JSON.class.calendar_name;
- document.getElementById('classroom-final').textContent = final_JSON.class.room;
- document.getElementById('date-final').textContent = begins.toLocaleDateString();
- document.getElementById('time-final').textContent = formatDate(begins) + ' - ' + formatDate(ends);
- document.getElementById('letter-final').textContent = final_JSON.letter;
- document.getElementById('number-final').textContent = final_JSON.number;
+ document.getElementById('subject-final').textContent = final_JSON.class.friendly_name || final_JSON.class.calendar_name;
+ document.getElementById('classroom-final').textContent = final_JSON.class.room;
+ document.getElementById('date-final').textContent = begins.toLocaleDateString();
+ document.getElementById('time-final').textContent = formatDate(begins) + ' - ' + formatDate(ends);
+ document.getElementById('letter-final').textContent = final_JSON.letter;
+ document.getElementById('number-final').textContent = final_JSON.number;
}
function clickButton(element) {
@@ -74,102 +74,102 @@
var api_url;
window.addEventListener('load', _ => {
-// Check if user is signed in
-if (localStorage.getItem('devMode') == 'true') {
- var banner = document.getElementById('dev-mode');
- banner.addEventListener('click', _ => {
- localStorage.devMode = 'false';
- location.reload();
- });
- banner.classList.remove('hidden');
- api_url = localStorage.getItem('apiUrl') || 'https://covid-tracability-backend-dev.sandbox.avm99963.com/api/v1/'
-} else {
- api_url = "https://covid-tracability-backend-prod.sandbox.avm99963.com/api/v1/";
-}
-fetch(api_url + "isSignedIn", {
- "mode": "cors",
- "credentials": "include"
-})
- .then(response => response.json())
- .then(data => {
- if (!data.payload.signedIn) {
- console.log("Not signed in!");
- fetch(api_url + "getAuthUrl", {
- "mode": "cors",
- "credentials": "include"
- })
- .then(response => response.json())
- .then(data => {
- // TODO: redirect here
- // location.href = data.payload.url;
- console.warn('Log in here: ', data.payload.url);
- });
- }
- });
+ // Check if user is signed in
+ if (localStorage.getItem('devMode') == 'true') {
+ var banner = document.getElementById('dev-mode');
+ banner.addEventListener('click', _ => {
+ localStorage.devMode = 'false';
+ location.reload();
+ });
+ banner.classList.remove('hidden');
+ api_url = localStorage.getItem('apiUrl') || 'https://covid-tracability-backend-dev.sandbox.avm99963.com/api/v1/'
+ } else {
+ api_url = "https://covid-tracability-backend-prod.sandbox.avm99963.com/api/v1/";
+ }
+ fetch(api_url + "isSignedIn", {
+ "mode": "cors",
+ "credentials": "include"
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (!data.payload.signedIn) {
+ console.log("Not signed in!");
+ fetch(api_url + "getAuthUrl", {
+ "mode": "cors",
+ "credentials": "include"
+ })
+ .then(response => response.json())
+ .then(data => {
+ // TODO: redirect here
+ // location.href = data.payload.url;
+ console.warn('Log in here: ', data.payload.url);
+ });
+ }
+ });
-fetch(api_url + "getCurrentClasses", {
- "mode": "cors",
- "credentials": "include"
-})
- .then(response => response.json())
- .then(data => {
- if (data.payload.classes.length == 0) {
- document.getElementById('no-subjects').classList.remove('hidden');
- } else {
- document.getElementById('fme-maps-container').classList.remove('hidden');
- }
-
- for (var [i, classe] of data.payload.classes.entries()) {
- var hora_inici = formatDate(new Date(parseInt(classe.begins)*1000));
- var hora_final = formatDate(new Date(parseInt(classe.ends)*1000));
-
- var classeDiv = document.createElement('div');
- classeDiv.classList.add('message', 'complex-button');
- classeDiv.id = 'subject-' + classe.subject_id + '-' + classe.room;
- classeDiv.setAttribute('data-class', JSON.stringify(classe));
-
- var header = document.createElement('div');
- header.classList.add('message-header');
- header.textContent = classe.friendly_name || classe.calendar_name;
-
- var body = document.createElement('div');
- body.classList.add('message-body');
-
- var div1 = document.createElement('div');
- var span = document.createElement('span');
- span.textContent = classe.room;
-
- if (i > 0 && data.payload.classes[i-1].calendar_name == classe.calendar_name) {
- div1.classList.add('has-text-danger', 'has-text-weight-bold');
- } else if (i < data.payload.classes.length - 1 && data.payload.classes[i+1].calendar_name == classe.calendar_name) {
- div1.classList.add('has-text-danger', 'has-text-weight-bold');
+ fetch(api_url + "getCurrentClasses", {
+ "mode": "cors",
+ "credentials": "include"
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.payload.classes.length == 0) {
+ document.getElementById('no-subjects').classList.remove('hidden');
+ } else {
+ document.getElementById('fme-maps-container').classList.remove('hidden');
}
- div1.textContent = 'Aula ';
- div1.appendChild(span);
+ for (var [i, classe] of data.payload.classes.entries()) {
+ var hora_inici = formatDate(new Date(parseInt(classe.begins)*1000));
+ var hora_final = formatDate(new Date(parseInt(classe.ends)*1000));
- var div2 = document.createElement('div');
- div2.textContent = hora_inici + ' - ' + hora_final;
+ var classeDiv = document.createElement('div');
+ classeDiv.classList.add('message', 'complex-button');
+ classeDiv.id = 'subject-' + classe.subject_id + '-' + classe.room;
+ classeDiv.setAttribute('data-class', JSON.stringify(classe));
- body.appendChild(div1);
- body.appendChild(div2);
+ var header = document.createElement('div');
+ header.classList.add('message-header');
+ header.textContent = classe.friendly_name || classe.calendar_name;
- classeDiv.appendChild(header);
- classeDiv.appendChild(body);
+ var body = document.createElement('div');
+ body.classList.add('message-body');
- document.getElementById("subject-container").appendChild(classeDiv);
- }
+ var div1 = document.createElement('div');
+ var span = document.createElement('span');
+ span.textContent = classe.room;
- var elements = document.getElementsByClassName("button");
- Array.from(elements).forEach(function(element) {
- element.addEventListener('click', clickButton);
- element.parent = element.parentNode.id;
+ if (i > 0 && data.payload.classes[i-1].calendar_name == classe.calendar_name) {
+ div1.classList.add('has-text-danger', 'has-text-weight-bold');
+ } else if (i < data.payload.classes.length - 1 && data.payload.classes[i+1].calendar_name == classe.calendar_name) {
+ div1.classList.add('has-text-danger', 'has-text-weight-bold');
+ }
+
+ div1.textContent = 'Aula ';
+ div1.appendChild(span);
+
+ var div2 = document.createElement('div');
+ div2.textContent = hora_inici + ' - ' + hora_final;
+
+ body.appendChild(div1);
+ body.appendChild(div2);
+
+ classeDiv.appendChild(header);
+ classeDiv.appendChild(body);
+
+ document.getElementById("subject-container").appendChild(classeDiv);
+ }
+
+ var elements = document.getElementsByClassName("button");
+ Array.from(elements).forEach(function(element) {
+ element.addEventListener('click', clickButton);
+ element.parent = element.parentNode.id;
+ });
+ var elements = document.getElementsByClassName("complex-button");
+ Array.from(elements).forEach(function(element) {
+ element.addEventListener('click', clickButton);
+ element.parent = element.parentNode.id;
+ });
});
- var elements = document.getElementsByClassName("complex-button");
- Array.from(elements).forEach(function(element) {
- element.addEventListener('click', clickButton);
- element.parent = element.parentNode.id;
- });
- });
});
diff --git a/js/page_functionality.js b/js/page_functionality.js
index d19d639..0e7b2ee 100644
--- a/js/page_functionality.js
+++ b/js/page_functionality.js
@@ -1,19 +1,10 @@
var current_section = "section-1";
-function toggleVisibility(id) {
- var x = document.getElementById(id);
- if (x.style.display == "none") {
- x.style.display = "block";
- } else {
- x.style.display = "none";
- }
-}
-
function switchSection(s) {
setTimeout(function(){
- toggleVisibility(current_section);
- toggleVisibility(s);
+ document.getElementById(current_section).classList.add('hidden');
+ document.getElementById(s).classList.remove('hidden');
current_section = s;
}, 75);
}