Differente menus.
Adding LocationStorage to do make a lot of calls to GitHub. Better DarkMode.
This commit is contained in:
parent
4ee68ed298
commit
fa8a62053f
16
index.html
Normal file
16
index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Locations - Idealista Enhancer</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- TODO: Please integrate a way to add/update/remove locations from a GUI. -->
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
14
locations/AragüésdelPuerto.json
Normal file
14
locations/AragüésdelPuerto.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "Aragüés del Puerto",
|
||||||
|
"altitude": 970,
|
||||||
|
"bus": false,
|
||||||
|
"train": false,
|
||||||
|
"pharmacy": true,
|
||||||
|
"smoke": false,
|
||||||
|
"supermarkets": [{
|
||||||
|
"type": "CUSTOM",
|
||||||
|
"url": "https://goo.gl/maps/8Qukf8FzqMYXkhPt8"
|
||||||
|
}],
|
||||||
|
"pool": false,
|
||||||
|
"gym": false
|
||||||
|
}
|
11
locations/Liédena.json
Normal file
11
locations/Liédena.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "Liédena",
|
||||||
|
"altitude": 432,
|
||||||
|
"bus": true,
|
||||||
|
"train": false,
|
||||||
|
"pharmacy": true,
|
||||||
|
"smoke": true,
|
||||||
|
"supermarkets": [],
|
||||||
|
"pool": true,
|
||||||
|
"gym": true
|
||||||
|
}
|
16
locations/PuentelaReinadeJaca.json
Normal file
16
locations/PuentelaReinadeJaca.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "Puente la Reina de Jaca",
|
||||||
|
"altitude": 707,
|
||||||
|
"bus": true,
|
||||||
|
"train": false,
|
||||||
|
"pharmacy": true,
|
||||||
|
"smoke": false,
|
||||||
|
"supermarkets": [
|
||||||
|
{
|
||||||
|
"type": "CUSTOM",
|
||||||
|
"url": "https://goo.gl/maps/ioeCNKvhrsgn42gu5"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pool": false,
|
||||||
|
"gym": false
|
||||||
|
}
|
20
locations/SanJuandePlan.json
Normal file
20
locations/SanJuandePlan.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "San Juan de Plan",
|
||||||
|
"altitude": 1120,
|
||||||
|
"bus": false,
|
||||||
|
"train": false,
|
||||||
|
"pharmacy": false,
|
||||||
|
"smoke": false,
|
||||||
|
"supermarkets": [
|
||||||
|
{
|
||||||
|
"type": "SUMA",
|
||||||
|
"url": "https://goo.gl/maps/gfyi26FV6iw3QS5E9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SIMPLY",
|
||||||
|
"url": "https://goo.gl/maps/SsQPLC2XzAwWX5gw8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pool": false,
|
||||||
|
"gym": false
|
||||||
|
}
|
@ -60,7 +60,7 @@ export default class ItemHTML {
|
|||||||
html += `<div class='${this.INFORMATION_CONTAINER_CLASS_NAME}'>`;
|
html += `<div class='${this.INFORMATION_CONTAINER_CLASS_NAME}'>`;
|
||||||
html += this._createLocationName(item);
|
html += this._createLocationName(item);
|
||||||
|
|
||||||
if (item.location && item.location.name) {
|
if (item.location && !item.location.errorMessage) {
|
||||||
html += this._createLocationTrain(item);
|
html += this._createLocationTrain(item);
|
||||||
html += this._createLocationBus(item);
|
html += this._createLocationBus(item);
|
||||||
html += this._createLocationGym(item);
|
html += this._createLocationGym(item);
|
||||||
|
43
src/LocationStorage.js
Normal file
43
src/LocationStorage.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import Log from "./Log.js";
|
||||||
|
|
||||||
|
export default class LocationStorage {
|
||||||
|
|
||||||
|
static KEY = 'midefos-idealista-location-storage';
|
||||||
|
|
||||||
|
static get storage() {
|
||||||
|
return window.localStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get data() {
|
||||||
|
if (!this._data) {
|
||||||
|
this._init();
|
||||||
|
}
|
||||||
|
return JSON.parse(this._data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get _data() {
|
||||||
|
return this.storage.getItem(this.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(name) {
|
||||||
|
const locations = this.data;
|
||||||
|
return locations[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
static save(location) {
|
||||||
|
const locations = this.data;
|
||||||
|
locations[location.name] = location;
|
||||||
|
this._save(locations);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _init() {
|
||||||
|
Log.debug(`Init location storage`);
|
||||||
|
this._save({});
|
||||||
|
}
|
||||||
|
|
||||||
|
static _save(data) {
|
||||||
|
const json = JSON.stringify(data);
|
||||||
|
this.storage.setItem(this.key, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,18 +1,29 @@
|
|||||||
import Location from './Location.js';
|
import Location from './Location.js';
|
||||||
|
import LocationStorage from './LocationStorage.js';
|
||||||
import Log from './Log.js';
|
import Log from './Log.js';
|
||||||
|
|
||||||
export default class Locations {
|
export default class Locations {
|
||||||
|
|
||||||
static async get(name) {
|
static async get(name) {
|
||||||
|
const storageLocation = LocationStorage.get(name)
|
||||||
|
if (storageLocation) {
|
||||||
|
return storageLocation;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch(`https://raw.githubusercontent.com/Midefos/idealista-enhancer/main/locations/${name}.json`);
|
const response = await fetch(`https://raw.githubusercontent.com/Midefos/idealista-enhancer/main/locations/${name}.json`);
|
||||||
Log.debug(`Requested location '${name}'`);
|
Log.debug(`Requested location '${name}'`);
|
||||||
|
|
||||||
if (response.status == 404) {
|
if (response.status == 404) {
|
||||||
Log.debug(`Missing information for location: '${name}'`);
|
Log.debug(`Missing information for location: '${name}'`);
|
||||||
return { errorMessage: 'Datos no disponibles...' };
|
const errorLocation = { name: name, errorMessage: 'Datos no disponibles...' };
|
||||||
|
LocationStorage.save(errorLocation);
|
||||||
|
return errorLocation;
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return Location.fromRaw(data);
|
|
||||||
|
const location = Location.fromRaw(data);
|
||||||
|
LocationStorage.save(location);
|
||||||
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
26
src/Menu.js
26
src/Menu.js
@ -6,15 +6,35 @@ import MenuHTML from "./MenuHTML.js";
|
|||||||
|
|
||||||
export default class Menu {
|
export default class Menu {
|
||||||
|
|
||||||
|
static LIST_SELECTOR = '#main-content';
|
||||||
|
|
||||||
|
static OTHER_LOCATIONS_SELECTORS = `#side-content,
|
||||||
|
.home-boxes-container.new-home`;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (this._shouldNotLoad()) return;
|
if (this._shouldNotLoad()) return;
|
||||||
|
|
||||||
const mainContent = document.querySelector('#main-content, #side-content');
|
this._createMenu();
|
||||||
mainContent.innerHTML = MenuHTML.create() + mainContent.innerHTML;
|
|
||||||
|
|
||||||
this._initEvents();
|
this._initEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_createMenu() {
|
||||||
|
const listNode = document.querySelector(Menu.LIST_SELECTOR);
|
||||||
|
if (listNode) {
|
||||||
|
listNode.innerHTML = MenuHTML.create() + listNode.innerHTML;
|
||||||
|
} else {
|
||||||
|
this._createSimpleMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_createSimpleMenu() {
|
||||||
|
const locationNode = document.querySelector(Menu.OTHER_LOCATIONS_SELECTORS);
|
||||||
|
if (locationNode) {
|
||||||
|
locationNode.innerHTML = MenuHTML.createSimple() + locationNode.innerHTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_initEvents() {
|
_initEvents() {
|
||||||
Event.click(MenuHTML.RELOAD_INFORMATION_SELECTOR, () => {
|
Event.click(MenuHTML.RELOAD_INFORMATION_SELECTOR, () => {
|
||||||
Information.create();
|
Information.create();
|
||||||
|
@ -16,9 +16,24 @@ export default class MenuHTML {
|
|||||||
static create() {
|
static create() {
|
||||||
return `
|
return `
|
||||||
<div class='${this.CONTAINER_CLASS_NAME}'>
|
<div class='${this.CONTAINER_CLASS_NAME}'>
|
||||||
<button class='${ButtonClass.IDEALISTA_BUTTON_CLASS} ${ConfigurationHTML.OPEN_CONFIG_CLASS_NAME}' title='Abrir configuración'>⚙ Configuración</button>
|
${this._openConfigButton()}
|
||||||
<button class='${ButtonClass.IDEALISTA_BUTTON_CLASS} ${this.RELOAD_INFORMATION_CLASS_NAME}' title='Refrescar información'>⟳ Refrescar</button>
|
${this._refreshDataButton()}
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static createSimple() {
|
||||||
|
return `
|
||||||
|
<div class='${this.CONTAINER_CLASS_NAME}'>
|
||||||
|
${this._openConfigButton()}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _openConfigButton() {
|
||||||
|
return `<button class='${ButtonClass.IDEALISTA_BUTTON_CLASS} ${ConfigurationHTML.OPEN_CONFIG_CLASS_NAME}' title='Abrir configuración'>⚙ Configuración</button>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _refreshDataButton() {
|
||||||
|
return `<button class='${ButtonClass.IDEALISTA_BUTTON_CLASS} ${this.RELOAD_INFORMATION_CLASS_NAME}' title='Refrescar información'>⟳ Refrescar</button>`
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -131,7 +131,8 @@ export default class Styles {
|
|||||||
.pagination li a,
|
.pagination li a,
|
||||||
.btn.regular,
|
.btn.regular,
|
||||||
.dropdown-wrapper, .dropdown-wrapper .dropdown,
|
.dropdown-wrapper, .dropdown-wrapper .dropdown,
|
||||||
.new-radio-button input:checked + label,
|
.new-radio-button input:checked + label, .new-radio-button label,
|
||||||
|
.new-search-box #campoBus, .result-list, .text-image-component_texts,
|
||||||
.rs-light-adcard_info,
|
.rs-light-adcard_info,
|
||||||
.sticky-bar-detail,
|
.sticky-bar-detail,
|
||||||
.home,
|
.home,
|
||||||
|
Loading…
Reference in New Issue
Block a user