Compare commits

..
Author SHA1 Message Date
bence 84cdb84c1b MAPG-123 [WIP] use MutationObserver 2020-06-14 22:05:41 +02:00
11 changed files with 45 additions and 46 deletions

No files matched your search

+3 -8
View File
@@ -17,11 +17,6 @@ button::-moz-focus-inner, input::-moz-focus-inner {
border: 0; border: 0;
} }
::selection {
background-color: #28a745;
color: #ffffff;
}
p, h1, h2, input, textarea, select, button, a { p, h1, h2, input, textarea, select, button, a {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
} }
@@ -251,7 +246,7 @@ div.modal {
border-radius: 3px; border-radius: 3px;
padding: 20px; padding: 20px;
box-sizing: border-box; box-sizing: border-box;
z-index: 6; z-index: 3;
visibility: hidden; visibility: hidden;
} }
@@ -263,7 +258,7 @@ div.modal {
right: 0; right: 0;
background-color: #000000; background-color: #000000;
opacity: 0.5; opacity: 0.5;
z-index: 5; z-index: 2;
visibility: hidden; visibility: hidden;
} }
@@ -329,7 +324,7 @@ div.buttonContainer>button {
left: 50%; left: 50%;
margin-top: -32px; margin-top: -32px;
margin-left: -32px; margin-left: -32px;
z-index: 7; z-index: 5;
visibility: hidden; visibility: hidden;
} }
+24 -17
View File
@@ -336,23 +336,34 @@
}, },
rewriteGoogleLink: function () { rewriteGoogleLink: function () {
if (!Game.googleLink) { if (Game.googleLink) {
var anchors = document.getElementById('panorama').getElementsByTagName('a'); return;
for (var i = 0; i < anchors.length; i++) { }
var a = anchors[i];
if (a.href.indexOf('maps.google.com/maps') !== -1) { var anchors = document.getElementById('panorama').getElementsByTagName('a');
Game.googleLink = a; for (var i = 0; i < anchors.length; i++) {
break; var a = anchors[i];
} if (a.href.indexOf('maps.google.com/maps') !== -1) {
Game.googleLink = a;
break;
} }
} }
setTimeout(function () { if (!Game.googleLink) {
if (Game.googleLink) { return;
Game.googleLink.title = 'Google Maps'; }
Game.googleLink.href = 'https://maps.google.com/maps';
var observer = new MutationObserver(function(mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.attributeName === 'href' && Game.googleLink.href !== 'https://maps.google.com/maps') {
console.log(Game.googleLink.href + ' is changed.')
Game.googleLink.title = 'Google Maps';
Game.googleLink.href = 'https://maps.google.com/maps';
}
} }
}, 1); });
observer.observe(Game.googleLink, { attributes: true });
} }
}; };
@@ -425,10 +436,6 @@
Game.rewriteGoogleLink(); Game.rewriteGoogleLink();
}); });
Game.panorama.addListener('pov_changed', function () {
Game.rewriteGoogleLink();
});
Game.initialize(); Game.initialize();
document.getElementById('showGuessButton').onclick = function () { document.getElementById('showGuessButton').onclick = function () {
+2
View File
@@ -29,6 +29,8 @@
loginFormError.style.display = 'block'; loginFormError.style.display = 'block';
loginFormError.innerHTML = errorText; loginFormError.innerHTML = errorText;
form.elements.email.select();
return; return;
} }
+1 -2
View File
@@ -2,12 +2,11 @@ var MapGuesser = {
httpRequest: function (method, url, callback, data) { httpRequest: function (method, url, callback, data) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.onload = callback; xhr.onload = callback;
xhr.open(method, url, true); xhr.open(method, url, true);
xhr.responseType = 'json';
if (method === 'POST') { if (method === 'POST') {
if (typeof data === 'undefined') { if (typeof data === 'undefined') {
data = new FormData(); data = new FormData();
+3
View File
@@ -37,12 +37,15 @@
profileFormError.style.display = 'block'; profileFormError.style.display = 'block';
profileFormError.innerHTML = errorText; profileFormError.innerHTML = errorText;
form.elements.password_new.select();
return; return;
} }
document.getElementById('profileFormError').style.display = 'none'; document.getElementById('profileFormError').style.display = 'none';
form.reset(); form.reset();
form.elements.save.disabled = true; form.elements.save.disabled = true;
form.elements.password_new.focus();
}, formData); }, formData);
}; };
})(); })();
+3 -3
View File
@@ -14,9 +14,6 @@
if (this.response.error) { if (this.response.error) {
var errorText; var errorText;
switch (this.response.error) { switch (this.response.error) {
case 'email_not_valid':
errorText = 'The given email address is not valid.'
break;
case 'passwords_too_short': case 'passwords_too_short':
errorText = 'The given password is too short. Please choose a password that is at least 6 characters long!' errorText = 'The given password is too short. Please choose a password that is at least 6 characters long!'
break; break;
@@ -35,11 +32,14 @@
signupFormError.style.display = 'block'; signupFormError.style.display = 'block';
signupFormError.innerHTML = errorText; signupFormError.innerHTML = errorText;
form.elements.email.select();
return; return;
} }
document.getElementById('signupFormError').style.display = 'none'; document.getElementById('signupFormError').style.display = 'none';
form.reset(); form.reset();
form.elements.email.focus();
MapGuesser.showModalWithContent('Sign up successful', 'Sign up was successful. Please check your email and click on the activation link to activate your account!'); MapGuesser.showModalWithContent('Sign up successful', 'Sign up was successful. Please check your email and click on the activation link to activate your account!');
}, formData); }, formData);
-5
View File
@@ -43,11 +43,6 @@ class SignupController
return new JsonContent($data); return new JsonContent($data);
} }
if (filter_var($this->request->post('email'), FILTER_VALIDATE_EMAIL) === false) {
$data = ['error' => 'email_not_valid'];
return new JsonContent($data);
}
$select = new Select(\Container::$dbConnection, 'users'); $select = new Select(\Container::$dbConnection, 'users');
$select->columns(User::getFields()); $select->columns(User::getFields());
$select->where('email', '=', $this->request->post('email')); $select->where('email', '=', $this->request->post('email'));
-2
View File
@@ -58,8 +58,6 @@ class UserController implements ISecured
$modify->fill($user->toArray()); $modify->fill($user->toArray());
$modify->save(); $modify->save();
$this->request->session()->set('user', $user);
$data = ['success' => true]; $data = ['success' => true];
return new JsonContent($data); return new JsonContent($data);
} }
+2 -2
View File
@@ -9,8 +9,8 @@ $jsFiles = [
<h2>Login</h2> <h2>Login</h2>
<div class="box"> <div class="box">
<form id="loginForm" action="/login" method="post"> <form id="loginForm" action="/login" method="post">
<input class="big fullWidth" type="email" name="email" placeholder="Email address" required autofocus> <input class="big fullWidth" type="email" name="email" placeholder="Email address" autofocus>
<input class="big fullWidth marginTop" type="password" name="password" placeholder="Password" required minlength="6"> <input class="big fullWidth marginTop" type="password" name="password" placeholder="Password">
<p id="loginFormError" class="formError justify marginTop"></p> <p id="loginFormError" class="formError justify marginTop"></p>
<div class="right marginTop"> <div class="right marginTop">
<button type="submit">Login</button> <button type="submit">Login</button>
+4 -4
View File
@@ -9,12 +9,12 @@ $jsFiles = [
<h2>Profile</h2> <h2>Profile</h2>
<div class="box"> <div class="box">
<form id="profileForm" action="/profile" method="post"> <form id="profileForm" action="/profile" method="post">
<input class="big fullWidth" type="password" name="password" placeholder="Current password" autofocus>
<hr>
<?php /* TODO: disabled for the time being, email modification should be implemented */ ?> <?php /* TODO: disabled for the time being, email modification should be implemented */ ?>
<input class="big fullWidth" type="email" name="email" placeholder="Email address" value="<?= $user['email'] ?>" disabled> <input class="big fullWidth" type="email" name="email" placeholder="Email address" value="<?= $user['email'] ?>" disabled>
<input class="big fullWidth marginTop" type="password" name="password_new" placeholder="New password" minlength="6"> <input class="big fullWidth marginTop" type="password" name="password_new" placeholder="New password" autofocus>
<input class="big fullWidth marginTop" type="password" name="password_new_confirm" placeholder="New password confirmation" minlength="6"> <input class="big fullWidth marginTop" type="password" name="password_new_confirm" placeholder="New password confirmation">
<hr>
<input class="big fullWidth" type="password" name="password" placeholder="Current password">
<p id="profileFormError" class="formError justify marginTop"></p> <p id="profileFormError" class="formError justify marginTop"></p>
<div class="right marginTop"> <div class="right marginTop">
<button type="submit" name="save" disabled>Save</button> <button type="submit" name="save" disabled>Save</button>
+3 -3
View File
@@ -9,9 +9,9 @@ $jsFiles = [
<h2>Sign up</h2> <h2>Sign up</h2>
<div class="box"> <div class="box">
<form id="signupForm" action="/signup" method="post"> <form id="signupForm" action="/signup" method="post">
<input class="big fullWidth" type="email" name="email" placeholder="Email address" required autofocus> <input class="big fullWidth" type="email" name="email" placeholder="Email address" autofocus>
<input class="big fullWidth marginTop" type="password" name="password" placeholder="Password" required minlength="6"> <input class="big fullWidth marginTop" type="password" name="password" placeholder="Password">
<input class="big fullWidth marginTop" type="password" name="password_confirm" placeholder="Password confirmation" required minlength="6"> <input class="big fullWidth marginTop" type="password" name="password_confirm" placeholder="Password confirmation">
<p id="signupFormError" class="formError justify marginTop"></p> <p id="signupFormError" class="formError justify marginTop"></p>
<div class="right marginTop"> <div class="right marginTop">
<button type="submit">Sign up</button> <button type="submit">Sign up</button>