Adding altitude.

Adding dark mode.
This commit is contained in:
Jorge Bolois Guerrero 2022-10-16 03:11:57 +02:00
parent ca7085bfeb
commit 11584e5a26
16 changed files with 115 additions and 4 deletions

View File

@ -1,5 +1,6 @@
{
"name": "Bielsa",
"altitude": 1034,
"bus": true,
"train": false,
"pharmacy": null,

View File

@ -1,5 +1,6 @@
{
"name": "Biescas",
"altitude": 875,
"bus": true,
"train": false,
"pharmacy": true,

View File

@ -1,5 +1,6 @@
{
"name": "Broto",
"altitude": 905,
"bus": false,
"train": false,
"pharmacy": true,

View File

@ -1,5 +1,6 @@
{
"name": "Castiello de Jaca",
"altitude": 921,
"bus": true,
"train": false,
"pharmacy": false,

View File

@ -1,5 +1,6 @@
{
"name": "Panticosa",
"altitude": 1184,
"bus": true,
"train": false,
"pharmacy": true,

View File

@ -1,5 +1,6 @@
{
"name": "Sabiñanigo",
"altitude": 780,
"bus": true,
"train": true,
"pharmacy": true,

View File

@ -0,0 +1,24 @@
{
"name": "Sallent de Gallego",
"altitude": 1305,
"bus": true,
"train": false,
"pharmacy": true,
"smoke": true,
"supermarkets": [
{
"type": "ALCAMPO",
"url": "https://goo.gl/maps/JQVoBvucXwRMos8u9"
},
{
"type": "CUSTOM",
"url": "https://goo.gl/maps/sPbbdQ6ENUcBgZC18"
},
{
"type": "CUSTOM",
"url": "https://goo.gl/maps/sPbbdQ6ENUcBgZC18"
}
],
"pool": true,
"gym": true
}

View File

@ -1,5 +1,6 @@
{
"name": "Villanúa",
"altitude": 953,
"bus": true,
"train": true,
"pharmacy": true,

View File

@ -1,5 +1,6 @@
{
"name": "Zaragoza",
"altitude": 243,
"bus": true,
"train": true,
"pharmacy": true,

View File

@ -10,7 +10,11 @@ export default class App {
static init() {
Preferences.init();
Styles.add();
Styles.add(Styles.APP_STYLES, 'midefos-idealista-app-styles');
if (Preferences.get('darkMode')) {
Styles.add(Styles.DARK_MODE, 'midefos-idealista-dark-mode');
}
new Menu();
new Configuration();

View File

@ -42,6 +42,7 @@ export default class Configuration {
const container = document.querySelector(ConfigurationHTML.CONTAINER_SELECTOR);
return {
enabled: container.querySelector('#enabled').checked,
darkMode: container.querySelector('#darkMode').checked,
percentages: container.querySelector('#percentages').checked,
percentages_20: container.querySelector('#percentages_20').checked,
percentages_30: container.querySelector('#percentages_30').checked,

View File

@ -30,6 +30,11 @@ export default class ConfigurationHTML {
${CheckboxHTML.create('enabled', Preferences.get('enabled'))}
<span>Habilitado</span>
</label>
<label>
${CheckboxHTML.create('darkMode', Preferences.get('darkMode'))}
<span>Modo oscuro</span>
</label>
</div>
<div class='midefos-idealista-card'>

View File

@ -180,7 +180,12 @@ export default class ItemHTML {
}
static _createLocationName(item) {
return this._createNeutral(item.locationName);
let html = `<div>`
html += this._createNeutral(item.locationName);
if (item.location?.altitude) this._createIndividual('Altitud (m):', item.location.altitude);
html += `</div>`
return html;
}
static _createLocationTrain(item) {

View File

@ -5,6 +5,8 @@ export default class Location {
static fromRaw(raw) {
const location = new Location();
location.name = raw.name;
location.altitude = raw.altitude;
location.train = raw.train;
location.bus = raw.bus;
@ -25,6 +27,7 @@ export default class Location {
}
name;
altitude;
train;
bus;

View File

@ -43,6 +43,7 @@ export default class Preferences {
static _default() {
return {
enabled: true,
darkMode: true,
'max-price': 120_000,
'max-price-per-meter': 1_500,

View File

@ -98,13 +98,73 @@ export default class Styles {
.${ConfigurationHTML.CONTAINER_CLASS_NAME} label {
display: block;
}
/* Ads */
.adv {
display: none;
}
`;
static add(style = null) {
if (!style) style = this.APP_STYLES;
static DARK_MODE = `
div.listing-top,
div.item-info-container,
section.links-block-home,
div.item-toolbar,
.links-block-home div.content,
div.wrapper,
picture.main-image,
.placeholder-multimedia,
section.module-contact,
.side-content .module-contact-gray,
.detail-pagination,
.rs-gallery-hud, .rs-gallery-header,
.rs-gallery-container .image-gallery .image-gallery-content,
.rs-gallery-footer,
.ide-box-detail,
section.ide-box-detail-first-picture,
.${ItemHTML.CONTAINER_CLASS_NAME},
.${MenuHTML.CONTAINER_CLASS_NAME} {
background-color: #060703;
color: white;
}
body,
#wrapper,
.new-listing-filter,
footer {
background-color: #181B0B;
color: white;
}
.description,
.new-listing-filter a,
:root .input-radio > span > span,
:root .input-checkbox > span > span,
.home-boxes-container .draw-search, .home-boxes-container .put-property, .home-boxes-container .solidary-module {
color: white;
}
.save-search-box {
color: black;
}
.description::before {
display: none;
}
`;
static add(style, id = null) {
if (id && document.querySelector(`#${id}`)) return;
const styleNode = document.createElement('style');
styleNode.textContent = style;
if (id) styleNode.id = id;
document.head.appendChild(styleNode);
}
static remove(id) {
const style = document.querySelector(`#${id}`);
if (style) style.remove();
}
}