Set username from query string parameter user if present
This commit is contained in:
parent
a69da7cac4
commit
d5e1306e39
19
index.html
19
index.html
|
@ -26,7 +26,7 @@ Latest code should be available at https://github.com/earthiverse
|
|||
<script src="js/three.min.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<style>
|
||||
@import url(http://fonts.googleapis.com/css?family=Lato);
|
||||
@import url(//fonts.googleapis.com/css?family=Lato);
|
||||
|
||||
body {
|
||||
background-image: url('images/bg_stone.png');
|
||||
|
@ -132,6 +132,18 @@ body {
|
|||
Skins downloaded from <a href="https://minotar.net/">Minotar</a>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// I use minotar because it allows CORS requests.
|
||||
var skinDownload = 'https://minotar.net/skin/';
|
||||
|
||||
// set username field from query string if set
|
||||
location.search.substr(1).split("&").forEach(function(item) {
|
||||
var nameVal = item.split("=");
|
||||
if(nameVal[0] == 'user'){
|
||||
document.getElementById('username').value = nameVal[1];
|
||||
return; // bail out
|
||||
}
|
||||
});
|
||||
|
||||
var scene, camera, renderer;
|
||||
var geometry, material, mesh;
|
||||
|
||||
|
@ -193,8 +205,7 @@ body {
|
|||
console.log("Failed loading " + img.src);
|
||||
}
|
||||
|
||||
// I use minotar because it allows CORS requests.
|
||||
img.src = 'https://minotar.net/skin/earthiverse';
|
||||
img.src = skinDownload + document.getElementById('username').value;
|
||||
|
||||
function RenderSkin() {
|
||||
// Head Parts
|
||||
|
@ -1005,7 +1016,7 @@ body {
|
|||
var keyCode = e.keyCode || e.which;
|
||||
if (keyCode == '13'){
|
||||
// Enter pressed, set new image
|
||||
img.src = 'https://minotar.net/skin/' + document.getElementById('username').value;
|
||||
img.src = skinDownload + document.getElementById('username').value;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue