add alert for msg in query string of index.php and fixed some shit

This commit is contained in:
printempw 2016-01-21 19:03:39 +08:00
parent 046b895eac
commit 21e0028ed3
3 changed files with 76 additions and 36 deletions

View File

@ -2,7 +2,7 @@
* @Author: prpr
* @Date: 2016-01-21 07:57:38
* @Last Modified by: prpr
* @Last Modified time: 2016-01-21 18:20:11
* @Last Modified time: 2016-01-21 19:01:48
*/
@font-face {
@ -31,7 +31,6 @@ body {
/* for firefox */
white-space: normal;
}
.home-menu .pure-menu-heading {
color: #5e5e5e;
font-weight: 400;
@ -42,15 +41,16 @@ body {
.pure-menu-heading:hover {
color: #444;
}
.home-menu .pure-menu-selected a {
color: #5e5e5e;
}
.home-menu a {
color: #fff;
font-size: 15px;
}
.pure-menu-selected {
font-weight: bold;
}
.pure-menu-link {
color: #5e5e5e !important;
}
.pure-menu-link:hover,
.pure-menu-link:focus {
background: none;
@ -101,6 +101,20 @@ body {
left: 0;
position: fixed !important;
}
.container .pure-button {
color: white;
padding: 0.8em 2.5em;
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
font-size: 120%;
transition: color 0.25s ease-in-out,
border-color 0.25s ease-in-out,
background-color 0.25s ease-in-out;
}
.container .pure-button:hover {
background-color: rgba(255, 255, 255, 0.2);
}
.splash {
width: 80%;
@ -110,7 +124,6 @@ body {
top: 100px; left: 0; bottom: 0; right: 0;
text-align: center;
}
.splash-head {
font-size: 20px;
font-weight: bold;
@ -125,32 +138,12 @@ body {
0px 8px 13px rgba(0,0,0,0.1),
0px 18px 23px rgba(0,0,0,0.1);
}
.splash-subhead {
letter-spacing: 0.05em;
margin-top: 0.8em;
margin-bottom: 1.5em;
}
.container .pure-button {
color: white;
padding: 0.8em 2.5em;
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
font-size: 120%;
transition: color 0.25s ease-in-out,
border-color 0.25s ease-in-out,
background-color 0.25s ease-in-out;
}
.container .pure-button:hover {
background-color: rgba(255, 255, 255, 0.2);
}
/*.container a.pure-button-primary {
}*/
.footer {
color: #fff;
position: absolute;
@ -159,12 +152,10 @@ body {
text-align: center;
letter-spacing: 0.05em;
}
.footer a {
text-decoration: none;
color: white;
}
.footer a:hover {
color: #1f8dd6;
}

View File

@ -2,7 +2,7 @@
* @Author: prpr
* @Date: 2016-01-21 13:55:44
* @Last Modified by: prpr
* @Last Modified time: 2016-01-21 18:18:37
* @Last Modified time: 2016-01-21 18:47:03
*/
'use strict';
@ -11,6 +11,14 @@ function showMsg(type, msg) {
$("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg);
}
$('#login').click(function(){
$('[data-remodal-id=login-modal]').remodal().open();
})
$('#register').click(function(){
$('[data-remodal-id=register-modal]').remodal().open();
})
// Login Button Click Event
$("body").on("click", "#login-button", function(){
var uname = $("#uname").val();
@ -34,7 +42,7 @@ $("body").on("click", "#login-button", function(){
docCookies.setItem("token", json.token, 604800, '/');
}
showMsg("alert-success", "Logging succeed!");
window.setTimeout("window.location = './user/index.php'", 1000);
window.setTimeout("$('[data-remodal-id=login-modal]').remodal().close(); window.location = './user/index.php'", 1000);
} else {
showMsg("alert-danger", json.msg);
}
@ -59,7 +67,7 @@ $("body").on("click", "#register-button", function(){
success: function(json) {
if (json.errno == 0) {
showMsg("alert-success", json.msg);
window.setTimeout("window.location = './index.php?action=login&msg=Successfully Registered, please log in.'", 1000);
window.setTimeout("$('[data-remodal-id=register-modal]').remodal().close(); window.location = './index.php?action=login&msg=Successfully Registered, please log in.'", 1000);
} else {
showMsg("alert-danger", json.msg);
}

View File

@ -1,3 +1,30 @@
<?php
/**
* @Author: printempw
* @Date: 2016-01-17 13:55:20
* @Last Modified by: prpr
* @Last Modified time: 2016-01-21 18:56:34
*/
session_start();
function __autoload($classname) {
$dir = dirname(__FILE__);
$filename = "$dir/includes/". $classname .".class.php";
include_once($filename);
}
if (getValue('uname', $_COOKIE) && getValue('token', $_COOKIE)) {
$user = new user($_COOKIE['uname']);
if ($_COOKIE['token'] == $user -> getToken()) {
$_SESSION['uname'] = $_COOKIE['uname'];
$_SESSION['token'] = $user -> getToken();
}
}
function getValue($key, $array) {
if (array_key_exists($key, $array)) {
return $array[$key];
}
return false;
}
?>
<!DOCTYPE html>
<html>
<head>
@ -20,7 +47,12 @@
<a href="#" class="pure-menu-link">Home</a>
</li>
<li class="pure-menu-item">
<a id="login" href="#login-modal" class="pure-button pure-button-primary">Sign In</a>
<?php
if ($uname = getValue('uname', $_SESSION)) { ?>
<a href="#" class="pure-menu-link" style="color: #5e5e5e">Welcome, <?php echo $uname; ?></a>
<?php } else { ?>
<a id="login" href="javascript:;" class="pure-button pure-button-primary">Sign In</a>
<?php } ?>
</li>
</ul>
<div class="home-menu-blur">
@ -37,9 +69,12 @@
<p class="splash-subhead">
Just a simple open-source Minecraft skin server
</p>
<?php
if (!getValue('uname', $_SESSION)) { ?>
<p>
<a id="register" href="#register-modal" class="pure-button pure-button-primary">Sign Up</a>
<a id="register" href="javascript:;" class="pure-button pure-button-primary">Sign Up</a>
</p>
<?php } ?>
</div>
</div>
@ -79,6 +114,12 @@
<script src="./libs/cookie.js"></script>
<script src="./libs/remodal/remodal.min.js"></script>
<script src="./assets/js/index.utils.js"></script>
<?php
if ($msg = getValue('msg', $_GET)) { ?>
<div class="remodal" data-remodal-id="msg-modal">
<h3><?php echo $msg; ?></h3>
</div>
<script type="text/javascript">$('[data-remodal-id=msg-modal]').remodal().open();</script>
<?php } ?>
</body>
</html>