diff --git a/assets/css/index.style.css b/assets/css/index.style.css new file mode 100644 index 00000000..fce88f9d --- /dev/null +++ b/assets/css/index.style.css @@ -0,0 +1,155 @@ +/* +* @Author: prpr +* @Date: 2016-01-21 20:07:47 +* @Last Modified by: prpr +* @Last Modified time: 2016-01-21 21:09:54 +*/ +.home-menu-blur { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: -100; +} +.home-menu-wrp { + height: 100%; + background-color: rgba(255,255,255,0.4); +} +.home-menu-bg { + background-image: url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); + background-position: center 0; + background-size: auto 800px; + position: absolute; + width: 100%; + height: 100%; + z-index: -1; + filter: blur(4px); + -webkit-filter: blur(4px); + -moz-filter: blur(4px); + -o-filter: blur(4px); + -ms-filter: blur(4px); + box-shadow: rgba(0,0,0,0.1) 0 1px 2px; +} + +.container { + background-image: + url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); + /* background-size: cover; */ + background-size: auto 800px; + background-repeat: no-repeat; + background-position: center 0; + width: 100%; + height: 100%; + top: 0; + 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%; + height: 50%; + margin: auto; + position: absolute; + top: 100px; left: 0; bottom: 0; right: 0; + text-align: center; +} +.splash-head { + font-size: 20px; + font-weight: bold; + color: white; + padding: 1em 0.5em; + font-weight: 100; + line-height: 1.5em; + margin: 0.2em 0 0.5em; + font-family: Minecraft; + text-shadow: + 0px 4px 3px rgba(0,0,0,0.4), + 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; +} + +.pure-form { + margin: 10px auto; + width: 40%; +} +.pure-input { + margin: 10px 0; + width: 100%; +} +#keep-label { + float: left; +} +#login-button { + float: right; + margin: .5em 0; +} +#register-button { + margin: .5em 0; + width: 100%; + float: left; +} +#msg { + width: 40%; + margin: 3.5em auto 0; +} + +/* Mobile phone */ +@media (max-width: 48em) { + .splash-head { + font-size: 200%; + } + .splash { + width: 100%; + height: 50%; + } + /*.splash-subhead { + font-size: 200%; + }*/ +} + + +@media (min-width: 48em) { + + .splash { + width: 80%; + height: 50%; + } + + .splash-head { + font-size: 250%; + } + +} + +@media (min-width: 78em) { + .splash-head { + font-size: 300%; + } +} + +@media (min-height: 800px) { + .home-menu-bg, + .container { + background-size: cover; + } +} diff --git a/assets/css/style.css b/assets/css/style.css index f1555252..01f11639 100755 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 07:57:38 * @Last Modified by: prpr -* @Last Modified time: 2016-01-21 19:01:48 +* @Last Modified time: 2016-01-21 20:33:40 */ @font-face { @@ -15,7 +15,7 @@ url('../fonts/minecraft.svg#minecraft') format('svg'); } -body { +html { line-height: 1.7em; color: #fff; font-size: 13px; @@ -24,9 +24,8 @@ body { .home-menu { padding: 0; - /*padding: 0.3em 0.5em 0.3em 0.5em;*/ text-align: center; - /*border: 1px solid transparent;*/ + border-bottom: 1px solid rgba(0, 0, 0, 0.3); box-shadow: rgba(0,0,0,0.1) 0 1px 2px; /* for firefox */ white-space: normal; @@ -60,89 +59,14 @@ body { .pure-button { margin: .5em 1em; } -.home-menu-blur { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: -100; -} -.home-menu-wrp { - height: 100%; - background-color: rgba(255,255,255,0.4); -} -.home-menu-bg { - background-image: url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); - background-position: center 0; - background-size: auto 800px; - position: absolute; - width: 100%; - height: 100%; - z-index: -1; - filter: blur(5px); - -webkit-filter: blur(5px); - -moz-filter: blur(5px); - -o-filter: blur(5px); - -ms-filter: blur(5px); - box-shadow: rgba(0,0,0,0.1) 0 1px 2px; -} .container { - background-image: - url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); - /* background-size: cover; */ - background-size: auto 800px; - background-repeat: no-repeat; - background-position: center 0; width: 100%; height: 100%; top: 0; 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%; - height: 50%; - margin: auto; - position: absolute; - top: 100px; left: 0; bottom: 0; right: 0; - text-align: center; -} -.splash-head { - font-size: 20px; - font-weight: bold; - color: white; - padding: 1em 0.5em; - font-weight: 100; - line-height: 1.5em; - margin: 0.2em 0 0.5em; - font-family: Minecraft; - text-shadow: - 0px 4px 3px rgba(0,0,0,0.4), - 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; -} .footer { color: #fff; @@ -165,25 +89,10 @@ body { .home-menu .pure-menu-selected a { display: none; } - /*.home-menu-bg { - background-size: inherit; - background-position-x: center; - }*/ - .splash-head { - font-size: 200%; - } - .splash { - width: 100%; - height: 50%; - } - /*.splash-subhead { - font-size: 200%; - }*/ } @media (min-width: 48em) { - body { font-size: 16px; } @@ -195,50 +104,7 @@ body { float: right; } - .splash { - width: 80%; - height: 50%; - } - - .splash-head { - font-size: 250%; - } - } @media (min-width: 78em) { - .splash-head { - font-size: 300%; - } -} - -@media (min-height: 800px) { - .home-menu-bg, - .container { - background-size: cover; - } -} -.pure-form { - margin: 10px auto; - width: 40%; -} -.pure-input { - margin: 10px 0; - width: 100%; -} -#keep-label { - float: left; -} -#login-button { - float: right; - margin: .5em 0; -} -#register-button { - margin: .5em 0; - width: 100%; - float: left; -} -#msg { - width: 40%; - margin: 3.5em auto 0; } diff --git a/assets/css/user.style.css b/assets/css/user.style.css new file mode 100644 index 00000000..a78492c3 --- /dev/null +++ b/assets/css/user.style.css @@ -0,0 +1,89 @@ +/* +* @Author: prpr +* @Date: 2016-01-21 19:12:06 +* @Last Modified by: prpr +* @Last Modified time: 2016-01-21 22:09:28 +*/ + +.home-menu-blur { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: -100; +} +.home-menu-wrp { + height: 100%; + background-color: rgba(255,255,255,0.4); +} +.home-menu-bg { + background-image: url("../images/bg_stone.png"); + background-repeat: repeat; + width: 100%; + height: 100%; + z-index: -1; + filter: blur(2px); + -webkit-filter: blur(2px); + -moz-filter: blur(2px); + -o-filter: blur(2px); + -ms-filter: blur(2px); + box-shadow: rgba(0,0,0,0.1) 0 1px 2px; +} + +.container { + background-image: + url("../images/bg_stone.png"); + background-repeat: repeat; +} + +/* Mobile phone */ +@media (max-width: 48em) { + .home-menu .pure-menu-selected a { + display: none; + } + /*.home-menu-bg { + background-size: inherit; + background-position-x: center; + }*/ + .splash-head { + font-size: 200%; + } + .splash { + width: 100%; + height: 50%; + } + /*.splash-subhead { + font-size: 200%; + }*/ +} + +#canvas3d { + margin-top: 8%; + margin-left: 20%; + display: block; +} + +.upload-container { + color: #333; + margin-top: 35%; + margin-right: 30%; + border: #989898 1px solid; + border-radius: 4px; + padding: 40px 40px 40px 40px; + background: rgba(255,255,255,.9); +} +.upload-title { + font-family: Minecraft; +} +button { + margin: 0 !important; +} +span { + padding: .5em .5em; + color: #5e5e5e; + margin-top: 0.1em; +} +.alert { + margin: 20px 0 0; +} diff --git a/assets/js/user.utils.js b/assets/js/user.utils.js index 8f3e6ed9..8f3f4179 100644 --- a/assets/js/user.utils.js +++ b/assets/js/user.utils.js @@ -2,7 +2,137 @@ * @Author: prpr * @Date: 2016-01-21 13:56:40 * @Last Modified by: prpr -* @Last Modified time: 2016-01-21 13:56:42 +* @Last Modified time: 2016-01-21 21:56:09 */ 'use strict'; + +$("body").on("change", "#skininput", function(){ + var files = $("#skininput").prop("files"); + handleFiles(files, "skin"); +}); + +$("body").on("change", "#capeinput", function(){ + var files = $("#capeinput").prop("files"); + handleFiles(files, "cape"); +}); + +function showMsg(type, msg) { + $("#msg").removeClass().addClass("alert").addClass(type).html(msg); +} + +var handleFiles = function (files, type) { + if(files.length > 0) { + var file = files[0]; + if(file.type === 'image/png') { + var fr = new FileReader(); + fr.onload = function (e) { + var img = new Image(); + img.onload = function () { + if (type == "skin") { + MSP.changeSkin(img.src); + } else { + MSP.changeCape(img.src); + } + }; + img.onerror = function () { + alert("Error: Not an image or unknown file format"); + }; + img.src = this.result; + }; + fr.readAsDataURL(file); + } else { + alert("Error: This is not a PNG image!"); + } + } +}; + +var canvas = MSP.get3dSkinCanvas(500, 500); +$("#skinpreview").append($(canvas).prop("id", "canvas3d")); + +$("[title='Movements']").click(function(){ + if (MSP.getStatus("movements")) { + MSP.setStatus("movements", false); + } else { + MSP.setStatus("movements", true); + } +}); + +$("[title='Running']").click(function(){ + if (MSP.getStatus("running")) { + MSP.setStatus("running", false); + } else { + MSP.setStatus("running", true); + } +}); + +$("[title='Rotation']").click(function(){ + if (MSP.getStatus("rotation")) { + MSP.setStatus("rotation", false); + } else { + MSP.setStatus("rotation", true); + } +}); + +$("#logout").click(function(){ + $.ajax({ + type: "POST", + url: "../ajax.php?action=logout", + dataType: "json", + data: {"uname": docCookies.getItem('uname')}, + success: function(json) { + var path = "/" + document.URL.split("/").slice(-3)[0]; + docCookies.removeItem("uname", path); + docCookies.removeItem("token", path); + showMsg('alert-success', json.msg); + window.setTimeout(function(){ + window.location = "./index.php"; + }, 1000); + } + }); +}); + +$("#upload").click(function(){ + var skin_file = $("#skininput").get(0).files[0]; + var cape_file = $("#capeinput").get(0).files[0]; + + var form_data = new FormData(); + if (skin_file) { + form_data.append('skin_file', skin_file); + } + if (cape_file) { + form_data.append('cape_file', cape_file); + } + form_data.append('uname', docCookies.getItem('uname')); + if (skin_file || cape_file) { + $.ajax({ + type: 'POST', + url: '../ajax.php?action=upload', + contentType: false, + dataType: "json", + data: form_data, + processData: false, + beforeSend: function() { + showMsg("alert-info", "Uploading..."); + }, + success: function(json) { + console.log(json); + if (json[0].errno == 0 && json[1].errno == 0) { + showMsg("alert-success", "Successfully uploaded."); + } + if (json[0].errno != 0) { + showMsg("alert-danger", "Error when uploading skin:\n"+json[0].msg); + } + if (json[1].errno != 0) { + showMsg("alert-danger", "Error when uploading cape:\n"+json[1].msg); + } + } + }); + } else { + showMsg("alert-warning", "No input file selected"); + } + +}); + + + diff --git a/includes/utils.class.php b/includes/utils.class.php index 12d1a120..640b3eff 100644 --- a/includes/utils.class.php +++ b/includes/utils.class.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: prpr - * @Last Modified time: 2016-01-17 13:48:15 + * @Last Modified time: 2016-01-21 21:59:47 */ $dir = dirname(dirname(__FILE__)); require "$dir/config.php"; @@ -113,5 +113,12 @@ class utils { } mysql_close(self::$connection); } + + function getValue($key, $array) { + if (array_key_exists($key, $array)) { + return $array[$key]; + } + return false; + } } ?> diff --git a/index.php b/index.php index 337be201..15131e5b 100755 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-17 13:55:20 * @Last Modified by: prpr - * @Last Modified time: 2016-01-21 18:56:34 + * @Last Modified time: 2016-01-21 20:19:15 */ session_start(); function __autoload($classname) { @@ -34,6 +34,7 @@ function getValue($key, $array) { + @@ -49,7 +50,7 @@ function getValue($key, $array) {