Skip to content

Commit

Permalink
style: added icons to the custom prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsosousah committed Jun 7, 2024
1 parent ae30004 commit 1711cdb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
31 changes: 22 additions & 9 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2185,15 +2185,6 @@ input:-webkit-autofill:active{
margin-top: 0.5rem;
font-size: 0.8rem;
}
/* For landscape (useful for prompt in navigation) */
@media screen and (orientation: landscape) {
#alertBox {
width: 40%;
min-height: 10%;
border-radius: 20px;
background-color: #fff;
}
}
/* #endregion */

/* #region Trip history */
Expand Down Expand Up @@ -3172,4 +3163,26 @@ input:-webkit-autofill:active{
margin-bottom: -12dvh;
}
/* #endregion */

/* #region Custom alert box */
#alertBox {
width: 40%;
min-height: 10%;
}
#alertBox #title {
color: var(--green);
font-weight: bold;
font-size: 1.2rem;
display: block;
margin-top: 1rem;
margin-left: 1.5rem;
margin-bottom: 0.75rem;
}
#alertBox p {
padding: 1.5rem;
margin: 0;
font-size: 0.9rem;
}
/* #endregion */

}
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@
navigator.storage.persist().then(isPersisted => console.log(`Persisted storage granted: ${isPersisted}`));
}

// Import eruda on eruda flag set to true
if (/eruda=true/.test(window.location)) {
document.write("<scr" + 'ipt src="//cdn.jsdelivr.net/npm/eruda"></scr' + "ipt>");
document.write("<scr" + "ipt>eruda.init();</scr" + "ipt>");
//const erudaBtn = document.querySelector(".eruda-entry-btn");
//console.log(erudaBtn);
//erudaBtn?.style.top = "2vh";
}

// Check if the user has set customProxy. if not, use default proxy
const tempCustomProxy = getCookie("customProxy");
if (tempCustomProxy) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/bikes.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ async function rateTrip(tripCode, tripCost) {
if (success) {
ratedTripsList.push(tripCode); // store that this trip was already rated, to not prompt again
payTrip(tripCode, tripCost); // Pay the trip after rating it
alert("Agradecemos o feedback!"); // Thank the user for the feedback
alert("Agradecemos o feedback!", `<i class="bi bi-heart"></i>`); // Thank the user for the feedback
} else {
alert("Não foi possível avaliar a viagem."); // Error
}
Expand All @@ -529,7 +529,7 @@ async function rateTrip(tripCode, tripCost) {
if (success) {
ratedTripsList.push(tripCode); // store that this trip was already rated, to not prompt again
payTrip(tripCode, tripCost); // Pay the trip after rating it
alert("Agradecemos o feedback!"); // Thank the user for the feedback
alert("Agradecemos o feedback!", `<i class="bi bi-heart"></i>`); // Thank the user for the feedback
} else {
alert("Não foi possível avaliar a viagem."); // Error
}
Expand All @@ -541,7 +541,7 @@ async function rateTrip(tripCode, tripCost) {
if (success) {
ratedTripsList.push(tripCode); // store that this trip was already rated, to not prompt again
payTrip(tripCode, tripCost); // Pay the trip after rating it
alert("Agradecemos o feedback!"); // Thank the user for the feedback
alert("Agradecemos o feedback!", `<i class="bi bi-heart"></i>`); // Thank the user for the feedback
} else {
alert("Não foi possível avaliar a viagem.");
}
Expand Down
8 changes: 3 additions & 5 deletions scripts/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ function createCustomAlert(message, title = null) {
const alertObj = mObj.appendChild(document.createElement("div"));
alertObj.id = "alertBox";

if (title) {
const titleObj = alertObj.appendChild(document.createElement("span"));
titleObj.id = "title";
titleObj.innerHTML = title;
}
const titleObj = alertObj.appendChild(document.createElement("span"));
titleObj.id = "title";
titleObj.innerHTML = title ?? "";

const msg = alertObj.appendChild(document.createElement("p"));
msg.innerHTML = message;
Expand Down
5 changes: 4 additions & 1 deletion scripts/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ async function makePostRequest(url, body, accessToken = null) {
alert("Já tem uma viagem a decorrer.");
} else if (responseObject.errors[0].message === "no_bike_found") {
alert("Bicicleta não encontrada.");
} else if (responseObject.errors[0].message === "bike_on_repair") {
} else if (
responseObject.errors[0].message === "bike_on_repair" ||
responseObject.errors[0].message === "bike_in_repair"
) {
alert("Bicicleta a ser reparada.");
} else if (responseObject.errors[0].message !== "Error executing document.") {
// Show general error message for unknown errors
Expand Down
7 changes: 0 additions & 7 deletions scripts/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,6 @@ function showSearchBar() {
function doneTyping() {
searchPlace();
}

// define a custom alert box
if (document.getElementById) {
window.alert = message =>
// set timeout so that if the user clicks on the place where the button is, it doesn't get automatically clicked
setTimeout(() => createCustomAlert(message), 50);
}
}

async function searchPlace() {
Expand Down
4 changes: 2 additions & 2 deletions scripts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async function openUserSettings() {
proxyURL = document.getElementById("proxyUrlInput").value;
createCookie("customProxy", encodeURI(proxyURL), expiryDate);

alert("O proxy foi definido.");
alert("O proxy foi definido.", `<i class="bi bi-info-circle"></i>`);
});

document.getElementById("resetProxyButton").addEventListener("click", () => {
Expand All @@ -330,7 +330,7 @@ async function openUserSettings() {
// Update input
document.getElementById("proxyUrlInput").value = proxyURL;

alert("O proxy foi redefinido.");
alert("O proxy foi redefinido.", `<i class="bi bi-info-circle"></i>`);
});

// Handle value change on distance to station selector
Expand Down

0 comments on commit 1711cdb

Please sign in to comment.