diff --git a/Build.PL b/Build.PL index 6b221c5..a1bb8c3 100755 --- a/Build.PL +++ b/Build.PL @@ -28,6 +28,7 @@ my $build = Module::Build->new( 'List::AllUtils' => 0, 'Lingua::Stem::Snowball' => 0, 'Mojo::Redis' => 0, + 'DBIx::Class' => 0, }, ); $build->create_build_script; diff --git a/js-src/conquer/index.ts b/js-src/conquer/index.ts index 85791e0..e459bca 100644 --- a/js-src/conquer/index.ts +++ b/js-src/conquer/index.ts @@ -14,6 +14,7 @@ export default class Conquer { private disableSetRotationOffset = false private conquerLogin: HTMLDivElement private conquerLoginGoToRegister: HTMLAnchorElement + private conquerRegisterGoToLogin: HTMLAnchorElement private conquerRegister: HTMLDivElement private alpha = 0; private beta = 0; @@ -67,6 +68,13 @@ export default class Conquer { this.conquerRegister.classList.remove('conquer-display-none') } } + async goToLogin(): Promise { + const isLogged = await this.isLogged(); + await this.removeLoginRegisterCombo() + if (!isLogged) { + this.conquerLogin.classList.remove('conquer-display-none') + } + } async removeLoginRegisterCombo(): Promise { this.conquerLogin.classList.add('conquer-display-none') @@ -79,6 +87,14 @@ export default class Conquer { Conquer.fail('conquerRegister is invalid') } this.conquerRegister = conquerRegister + const conquerRegisterGoToLogin = document.querySelector('.conquer-register-go-to-login') + if (conquerRegisterGoToLogin === null || !(conquerRegisterGoToLogin instanceof HTMLAnchorElement)) { + Conquer.fail('Link to go to login from register is invalid.') + } + this.conquerRegisterGoToLogin = conquerRegisterGoToLogin + this.conquerRegisterGoToLogin.addEventListener('click', () => { + this.goToLogin() + }) } async run() { this.fillConquerLogin() @@ -116,30 +132,37 @@ export default class Conquer { maxZoom: 22, }), }); + const proccessLocation = (location: GeolocationPosition) => { + this.currentLatitude = location.coords.latitude + this.currentLongitude = location. coords.longitude + if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) { + this.disableSetRotationOffset = true + this.heading = location.coords.heading + this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading*Math.PI*2)/360 + } + this.setCenterDisplaced(this.currentLatitude, this.currentLongitude) + } this.setCenterDisplaced(37.58237, -5.96766) navigator.geolocation.watchPosition((location) => { - this.setCenterDisplaced(location.coords.latitude, location.coords.longitude); + proccessLocation(location) }, (err) => { + return }, { - enableHighAccuracy: true + enableHighAccuracy: true, + maximumAge: 0 }); window.setInterval(() => { this.disableSetRotationOffset = false - },10000); + }, 10000); window.setTimeout(() => { window.setInterval(() => { navigator.geolocation.getCurrentPosition((location) => { - this.currentLatitude = location.coords.latitude - this.currentLongitude = location. coords.longitude - if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) { - this.disableSetRotationOffset = true - this.heading = location.coords.heading - this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading*Math.PI*2)/360 - } - this.setCenterDisplaced(this.currentLatitude, this.currentLongitude) + proccessLocation(location) }, () => { + return }, { - enableHighAccuracy: true + enableHighAccuracy: true, + maximumAge: 0 }) }, 1000) }, 1000) diff --git a/lib/BurguillosInfo.pm b/lib/BurguillosInfo.pm index 95a4938..a7695ae 100644 --- a/lib/BurguillosInfo.pm +++ b/lib/BurguillosInfo.pm @@ -51,6 +51,7 @@ sub startup ($self) { # $r->get('/:post')->to('Page#post'); $r->get('/stats')->to('Metrics#stats'); $r->get('/conquer')->to('Conquer#index'); + $r->put('/conquer/user')->to('UserConquer#create'); $r->get('/search.json')->to('Search#search'); $r->get('/farmacia-guardia.json')->to('FarmaciaGuardia#current'); $r->get('/<:category>.rss')->to('Page#category_rss'); diff --git a/lib/BurguillosInfo/DB/Migrations.pm b/lib/BurguillosInfo/DB/Migrations.pm index 2e9c5f6..d95c21c 100644 --- a/lib/BurguillosInfo/DB/Migrations.pm +++ b/lib/BurguillosInfo/DB/Migrations.pm @@ -49,18 +49,26 @@ sub MIGRATIONS { id_farmacia TEXT NOT NULL );', 'CREATE INDEX farmacia_guardia_index on farmacia_guardia (date, id_farmacia, uuid);', + 'CREATE TABLE conquer_user ( + uuid UUID NOT NULL PRIMARY KEY, + username TEXT NOT NULL UNIQUE, + encrypted_password TEXT NOT NULL, + last_activity TEXT NOT NULL DEFAULT NOW(), + is_admin boolean NOT NULL DEFAULT false + );', ); } sub _populate_locations ($dbh) { - require BurguillosInfo; - require BurguillosInfo::Tracking; - my $tracking = BurguillosInfo::Tracking->new( BurguillosInfo->new ); - my $page = 0; - while (1) { - last if !_update_request_page( $dbh, $tracking, $page ); - $page += 100; - } + # This subroutine crashes the migrations. + # require BurguillosInfo; + # require BurguillosInfo::Tracking; + # my $tracking = BurguillosInfo::Tracking->new( BurguillosInfo->new ); + # my $page = 0; + # while (1) { + # last if !_update_request_page( $dbh, $tracking, $page ); + # $page += 100; + # } } sub _update_request_page ( $dbh, $tracking, $page ) { diff --git a/lib/BurguillosInfo/Schema.pm b/lib/BurguillosInfo/Schema.pm new file mode 100644 index 0000000..1a772cf --- /dev/null +++ b/lib/BurguillosInfo/Schema.pm @@ -0,0 +1,61 @@ +package BurguillosInfo::Schema; + +use v5.36.0; + +use strict; +use warnings; +use utf8; + +our $VERSION = 1; + +use feature 'signatures'; + +use BurguillosInfo; + +use parent 'DBIx::Class::Schema'; + +__PACKAGE__->load_namespaces(); + +my $schema; + +sub Schema ($class) { + if ( !defined $schema ) { + my $app = BurguillosInfo->new; + my $config = $app->{config}; + my $database_config = $config->{db}; + my $dbname = $database_config->{database}; + my $host = $database_config->{host}; + my $port = $database_config->{port}; + my $user = $database_config->{user}; + my $password = $database_config->{password}; + my $dsn = 'dbi:Pg:'; + + if ( !defined $dbname ) { + die "The key database/dbname must be configured."; + } + $dsn .= "dbname=$dbname"; + if ( defined $host ) { + $dsn .= ";host=$host"; + } + if ( defined $port ) { + $dsn .= ";port=$port"; + } + + # Undef is perfectly fine for username and password. + $schema = $class->connect( + $dsn, $user, + $password, + { + auto_savepoint => 1, + Callbacks => { + connected => sub { + shift->do('set timezone = UTC'); + return; + } + } + } + ); + } + return $schema; +} +1; diff --git a/lib/BurguillosInfo/Schema/Result/ConquerUser.pm b/lib/BurguillosInfo/Schema/Result/ConquerUser.pm new file mode 100644 index 0000000..c32a739 --- /dev/null +++ b/lib/BurguillosInfo/Schema/Result/ConquerUser.pm @@ -0,0 +1,38 @@ +package BurguillosInfo::Schema::Result::ConquerUser; + +use v5.36.0; + +use strict; +use warnings; + +use parent 'DBIx::Class::Core'; + +__PACKAGE__->table('players'); + +__PACKAGE__->add_columns( + uuid => { + data_type => 'uuid', + is_nullable => 0, + }, + username => { + data_type => 'text', + is_nullable => 0, + }, + encrypted_password => { + data_type => 'text', + is_nullable => 0, + }, + last_activity => { + data_type => 'timestamp', + is_nullable => 0, + default_value => \'NOW()', + }, + is_admin => { + data_type => 'boolean', + is_nullable => 0, + default_value => \'0', + } +); +__PACKAGE__->set_primary_key('uuid'); +__PACKAGE__->add_unique_constraint("unique_constraint_username", ['username']); +1; diff --git a/public/css/styles.css b/public/css/styles.css index 375c1ca..5e2f9bd 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -17,12 +17,15 @@ body { top: calc( 50% - 200px - 10px); left: calc( 50% - 150px - 10px); padding: 10px; - justify-content: center; height: 400px; width: 300px; - display: flex; - z-index: 1; - flex-direction: column; } + z-index: 1; } + body div.conquer-login form, body div.conquer-register form { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; } body div.conquer-display-none { display: none; } body div.conquer-container { diff --git a/public/css/styles.scss b/public/css/styles.scss index 1f5b308..69e5d2b 100644 --- a/public/css/styles.scss +++ b/public/css/styles.scss @@ -17,6 +17,13 @@ html { body { div.conquer-login,div.conquer-register { + form { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; + } position: fixed; color: black; font-size: 25px; @@ -25,13 +32,9 @@ body { top: calc( 50% - 200px - 10px ); left: calc( 50% - 150px - 10px ); padding: 10px; - justify-content: center; height: 400px; width: 300px; - display: flex; z-index: 1; - flex-direction: column; - } div.conquer-display-none { display: none; diff --git a/public/js/bundle.js b/public/js/bundle.js index 1cb2f88..c548d70 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -47,7 +47,7 @@ eval(";(function() {\n function Tablesort(el, options) {\n if (!(this instan /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Conquer)\n/* harmony export */ });\n/* harmony import */ var ol_Map__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ol/Map */ \"./node_modules/ol/Map.js\");\n/* harmony import */ var ol_View__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ol/View */ \"./node_modules/ol/View.js\");\n/* harmony import */ var ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ol/proj/Projection.js */ \"./node_modules/ol/proj/Projection.js\");\n/* harmony import */ var ol_layer_Tile__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ol/layer/Tile */ \"./node_modules/ol/layer/Tile.js\");\n/* harmony import */ var ol_source_OSM__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ol/source/OSM */ \"./node_modules/ol/source/OSM.js\");\n/* harmony import */ var ol_proj__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ol/proj */ \"./node_modules/ol/proj.js\");\n\n\n\n\n\n\nclass Conquer {\n static start() {\n const conquerContainer = document.querySelector(\".conquer-container\");\n window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {\n alert(\"Error occured: \" + errorMsg); //or any message\n return false;\n };\n if (conquerContainer !== null) {\n if (!(conquerContainer instanceof HTMLDivElement)) {\n console.error(\".conquer-container is not a div.\");\n return;\n }\n const conquer = new Conquer(conquerContainer);\n conquer.run();\n }\n }\n setCenterDisplaced(lat, lon) {\n const olCoordinates = this.realCoordinatesToOl(lat, lon);\n const size = this.map.getSize();\n if (size === undefined) {\n return;\n }\n this.map.getView().centerOn(olCoordinates, size, [size[0] / 2, size[1] - 60]);\n }\n static fail(error) {\n alert('Error de interfaz');\n throw new Error(error);\n }\n fillConquerLogin() {\n const conquerLogin = document.querySelector('.conquer-login');\n if (conquerLogin === null || !(conquerLogin instanceof HTMLDivElement)) {\n Conquer.fail('conquerLogin is invalid');\n }\n this.conquerLogin = conquerLogin;\n const conquerLoginGoToRegister = document.querySelector('.conquer-login-go-to-register');\n if (conquerLoginGoToRegister === null || !(conquerLoginGoToRegister instanceof HTMLAnchorElement)) {\n Conquer.fail('Link to go to register from login is invalid.');\n }\n this.conquerLoginGoToRegister = conquerLoginGoToRegister;\n this.conquerLoginGoToRegister.addEventListener('click', () => {\n this.goToRegister();\n });\n }\n async goToRegister() {\n const isLogged = await this.isLogged();\n await this.removeLoginRegisterCombo();\n if (!isLogged) {\n this.conquerRegister.classList.remove('conquer-display-none');\n }\n }\n async removeLoginRegisterCombo() {\n this.conquerLogin.classList.add('conquer-display-none');\n this.conquerRegister.classList.add('conquer-display-none');\n }\n fillConquerRegister() {\n const conquerRegister = document.querySelector('.conquer-register');\n if (conquerRegister === null || !(conquerRegister instanceof HTMLDivElement)) {\n Conquer.fail('conquerRegister is invalid');\n }\n this.conquerRegister = conquerRegister;\n }\n async run() {\n this.fillConquerLogin();\n this.fillConquerRegister();\n const isLogged = await this.isLogged();\n if (!isLogged) {\n this.conquerLogin.classList.remove('conquer-display-none');\n }\n const conquerContainer = this.conquerContainer;\n //layer.on('prerender', (evt) => {\n // // return\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D;\n // context.filter = 'grayscale(80%) invert(100%) ';\n // context.globalCompositeOperation = 'source-over';\n // }\n //});\n //layer.on('postrender', (evt) => {\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D;\n // context.filter = 'none';\n // }\n //});\n ol_proj__WEBPACK_IMPORTED_MODULE_0__.useGeographic();\n this.map = new ol_Map__WEBPACK_IMPORTED_MODULE_1__[\"default\"]({\n target: conquerContainer,\n layers: [\n new ol_layer_Tile__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({\n source: new ol_source_OSM__WEBPACK_IMPORTED_MODULE_3__[\"default\"]()\n })\n ],\n view: new ol_View__WEBPACK_IMPORTED_MODULE_4__[\"default\"]({\n zoom: 21,\n maxZoom: 22,\n }),\n });\n this.setCenterDisplaced(37.58237, -5.96766);\n navigator.geolocation.watchPosition((location) => {\n this.setCenterDisplaced(location.coords.latitude, location.coords.longitude);\n }, (err) => {\n }, {\n enableHighAccuracy: true\n });\n window.setInterval(() => {\n this.disableSetRotationOffset = false;\n }, 10000);\n window.setTimeout(() => {\n window.setInterval(() => {\n navigator.geolocation.getCurrentPosition((location) => {\n this.currentLatitude = location.coords.latitude;\n this.currentLongitude = location.coords.longitude;\n if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) {\n this.disableSetRotationOffset = true;\n this.heading = location.coords.heading;\n this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading * Math.PI * 2) / 360;\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n }, () => {\n }, {\n enableHighAccuracy: true\n });\n }, 1000);\n }, 1000);\n if (window.DeviceOrientationEvent) {\n window.addEventListener(\"deviceorientation\", (event) => {\n if (event.alpha !== null && event.beta !== null && event.gamma !== null) {\n this.onRotate(event.alpha, event.beta, event.gamma);\n }\n }, true);\n }\n }\n realCoordinatesToOl(lat, lon) {\n return ol_proj__WEBPACK_IMPORTED_MODULE_0__.transform([lon, lat], new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({ code: \"WGS84\" }), new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({ code: \"EPSG:900913\" }));\n }\n compassHeading(alpha, beta, gamma) {\n const alphaRad = alpha * (Math.PI / 180);\n return alphaRad;\n let betaRad = beta * (Math.PI / 180);\n const gammaRad = gamma * (Math.PI / 180);\n betaRad = 1.5707963268;\n const cA = Math.cos(alphaRad);\n const sA = Math.sin(alphaRad);\n const sB = Math.sin(betaRad);\n const cG = Math.cos(gammaRad);\n const sG = Math.sin(gammaRad);\n const rA = -cA * sG - sA * sB * cG;\n const rB = -sA * sG + cA * sB * cG;\n return Math.atan2(rA, rB);\n }\n logToServer(logValue) {\n const urlLog = new URL('/conquer/log', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n urlLog.searchParams.append('log', logValue);\n fetch(urlLog).then(() => {\n return;\n }).catch((error) => {\n console.error(error);\n });\n }\n onRotate(alpha, beta, gamma) {\n if (this.enabledOnRotate) {\n this.alpha = alpha;\n this.beta = beta;\n this.gamma = gamma;\n this.enabledOnRotate = false;\n this.map.getView().setRotation((this.compassHeading(alpha, beta, gamma) - this.rotationOffset));\n window.setTimeout(() => {\n this.enabledOnRotate = true;\n }, 10);\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n }\n constructor(conquerContainer) {\n this.rotationOffset = 0;\n this.heading = 0;\n this.disableSetRotationOffset = false;\n this.alpha = 0;\n this.beta = 0;\n this.gamma = 0;\n this.enabledOnRotate = true;\n this.conquerContainer = conquerContainer;\n }\n async isLogged() {\n return false;\n // return fetch(\"/conquer/user\")\n // .then(async (res): Promise => {\n // const data = await res.json();\n // if (data === null) {\n // return false;\n // }\n // return true;\n // })\n // .catch((error) => {\n // console.error(error);\n // return false;\n // });\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/index.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Conquer)\n/* harmony export */ });\n/* harmony import */ var ol_Map__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ol/Map */ \"./node_modules/ol/Map.js\");\n/* harmony import */ var ol_View__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ol/View */ \"./node_modules/ol/View.js\");\n/* harmony import */ var ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ol/proj/Projection.js */ \"./node_modules/ol/proj/Projection.js\");\n/* harmony import */ var ol_layer_Tile__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ol/layer/Tile */ \"./node_modules/ol/layer/Tile.js\");\n/* harmony import */ var ol_source_OSM__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ol/source/OSM */ \"./node_modules/ol/source/OSM.js\");\n/* harmony import */ var ol_proj__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ol/proj */ \"./node_modules/ol/proj.js\");\n\n\n\n\n\n\nclass Conquer {\n static start() {\n const conquerContainer = document.querySelector(\".conquer-container\");\n window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {\n alert(\"Error occured: \" + errorMsg); //or any message\n return false;\n };\n if (conquerContainer !== null) {\n if (!(conquerContainer instanceof HTMLDivElement)) {\n console.error(\".conquer-container is not a div.\");\n return;\n }\n const conquer = new Conquer(conquerContainer);\n conquer.run();\n }\n }\n setCenterDisplaced(lat, lon) {\n const olCoordinates = this.realCoordinatesToOl(lat, lon);\n const size = this.map.getSize();\n if (size === undefined) {\n return;\n }\n this.map.getView().centerOn(olCoordinates, size, [size[0] / 2, size[1] - 60]);\n }\n static fail(error) {\n alert('Error de interfaz');\n throw new Error(error);\n }\n fillConquerLogin() {\n const conquerLogin = document.querySelector('.conquer-login');\n if (conquerLogin === null || !(conquerLogin instanceof HTMLDivElement)) {\n Conquer.fail('conquerLogin is invalid');\n }\n this.conquerLogin = conquerLogin;\n const conquerLoginGoToRegister = document.querySelector('.conquer-login-go-to-register');\n if (conquerLoginGoToRegister === null || !(conquerLoginGoToRegister instanceof HTMLAnchorElement)) {\n Conquer.fail('Link to go to register from login is invalid.');\n }\n this.conquerLoginGoToRegister = conquerLoginGoToRegister;\n this.conquerLoginGoToRegister.addEventListener('click', () => {\n this.goToRegister();\n });\n }\n async goToRegister() {\n const isLogged = await this.isLogged();\n await this.removeLoginRegisterCombo();\n if (!isLogged) {\n this.conquerRegister.classList.remove('conquer-display-none');\n }\n }\n async goToLogin() {\n const isLogged = await this.isLogged();\n await this.removeLoginRegisterCombo();\n if (!isLogged) {\n this.conquerLogin.classList.remove('conquer-display-none');\n }\n }\n async removeLoginRegisterCombo() {\n this.conquerLogin.classList.add('conquer-display-none');\n this.conquerRegister.classList.add('conquer-display-none');\n }\n fillConquerRegister() {\n const conquerRegister = document.querySelector('.conquer-register');\n if (conquerRegister === null || !(conquerRegister instanceof HTMLDivElement)) {\n Conquer.fail('conquerRegister is invalid');\n }\n this.conquerRegister = conquerRegister;\n const conquerRegisterGoToLogin = document.querySelector('.conquer-register-go-to-login');\n if (conquerRegisterGoToLogin === null || !(conquerRegisterGoToLogin instanceof HTMLAnchorElement)) {\n Conquer.fail('Link to go to login from register is invalid.');\n }\n this.conquerRegisterGoToLogin = conquerRegisterGoToLogin;\n this.conquerRegisterGoToLogin.addEventListener('click', () => {\n this.goToLogin();\n });\n }\n async run() {\n this.fillConquerLogin();\n this.fillConquerRegister();\n const isLogged = await this.isLogged();\n if (!isLogged) {\n this.conquerLogin.classList.remove('conquer-display-none');\n }\n const conquerContainer = this.conquerContainer;\n //layer.on('prerender', (evt) => {\n // // return\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D;\n // context.filter = 'grayscale(80%) invert(100%) ';\n // context.globalCompositeOperation = 'source-over';\n // }\n //});\n //layer.on('postrender', (evt) => {\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D;\n // context.filter = 'none';\n // }\n //});\n ol_proj__WEBPACK_IMPORTED_MODULE_0__.useGeographic();\n this.map = new ol_Map__WEBPACK_IMPORTED_MODULE_1__[\"default\"]({\n target: conquerContainer,\n layers: [\n new ol_layer_Tile__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({\n source: new ol_source_OSM__WEBPACK_IMPORTED_MODULE_3__[\"default\"]()\n })\n ],\n view: new ol_View__WEBPACK_IMPORTED_MODULE_4__[\"default\"]({\n zoom: 21,\n maxZoom: 22,\n }),\n });\n const proccessLocation = (location) => {\n this.currentLatitude = location.coords.latitude;\n this.currentLongitude = location.coords.longitude;\n if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) {\n this.disableSetRotationOffset = true;\n this.heading = location.coords.heading;\n this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading * Math.PI * 2) / 360;\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n };\n this.setCenterDisplaced(37.58237, -5.96766);\n navigator.geolocation.watchPosition((location) => {\n proccessLocation(location);\n }, (err) => {\n return;\n }, {\n enableHighAccuracy: true,\n maximumAge: 0\n });\n window.setInterval(() => {\n this.disableSetRotationOffset = false;\n }, 10000);\n window.setTimeout(() => {\n window.setInterval(() => {\n navigator.geolocation.getCurrentPosition((location) => {\n proccessLocation(location);\n }, () => {\n return;\n }, {\n enableHighAccuracy: true,\n maximumAge: 0\n });\n }, 1000);\n }, 1000);\n if (window.DeviceOrientationEvent) {\n window.addEventListener(\"deviceorientation\", (event) => {\n if (event.alpha !== null && event.beta !== null && event.gamma !== null) {\n this.onRotate(event.alpha, event.beta, event.gamma);\n }\n }, true);\n }\n }\n realCoordinatesToOl(lat, lon) {\n return ol_proj__WEBPACK_IMPORTED_MODULE_0__.transform([lon, lat], new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({ code: \"WGS84\" }), new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({ code: \"EPSG:900913\" }));\n }\n compassHeading(alpha, beta, gamma) {\n const alphaRad = alpha * (Math.PI / 180);\n return alphaRad;\n let betaRad = beta * (Math.PI / 180);\n const gammaRad = gamma * (Math.PI / 180);\n betaRad = 1.5707963268;\n const cA = Math.cos(alphaRad);\n const sA = Math.sin(alphaRad);\n const sB = Math.sin(betaRad);\n const cG = Math.cos(gammaRad);\n const sG = Math.sin(gammaRad);\n const rA = -cA * sG - sA * sB * cG;\n const rB = -sA * sG + cA * sB * cG;\n return Math.atan2(rA, rB);\n }\n logToServer(logValue) {\n const urlLog = new URL('/conquer/log', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n urlLog.searchParams.append('log', logValue);\n fetch(urlLog).then(() => {\n return;\n }).catch((error) => {\n console.error(error);\n });\n }\n onRotate(alpha, beta, gamma) {\n if (this.enabledOnRotate) {\n this.alpha = alpha;\n this.beta = beta;\n this.gamma = gamma;\n this.enabledOnRotate = false;\n this.map.getView().setRotation((this.compassHeading(alpha, beta, gamma) - this.rotationOffset));\n window.setTimeout(() => {\n this.enabledOnRotate = true;\n }, 10);\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n }\n constructor(conquerContainer) {\n this.rotationOffset = 0;\n this.heading = 0;\n this.disableSetRotationOffset = false;\n this.alpha = 0;\n this.beta = 0;\n this.gamma = 0;\n this.enabledOnRotate = true;\n this.conquerContainer = conquerContainer;\n }\n async isLogged() {\n return false;\n // return fetch(\"/conquer/user\")\n // .then(async (res): Promise => {\n // const data = await res.json();\n // if (data === null) {\n // return false;\n // }\n // return true;\n // })\n // .catch((error) => {\n // console.error(error);\n // return false;\n // });\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/index.ts?"); /***/ }), diff --git a/templates/conquer/index.html.ep b/templates/conquer/index.html.ep index afdca51..405d0e9 100644 --- a/templates/conquer/index.html.ep +++ b/templates/conquer/index.html.ep @@ -9,22 +9,26 @@
- - - - - - - -

¿Ya estás registrado? +

+ + + + + + + +

¿Ya estás registrado? .

+