-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·171 lines (151 loc) · 6.33 KB
/
index.html
File metadata and controls
executable file
·171 lines (151 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<link href='http://fonts.googleapis.com/css?family=Gafata|Roboto:700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style>
div{
/*margin-top: 30px;*/
color:white;
font-family: sans-serif;
/*font-size: 20px;*/
text-align: center;
/*margin-left:30px;*/
}
body {
width: 400px;
margin: 100px auto;
background-color: #f5f5f5;
background: url(http://i.imgur.com/j3McPao.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.break{
height: 250px;
}
/****** CODE ******/
.file-upload{display:block;text-align:center;font-family: Helvetica, Arial, sans-serif;font-size: 12px;}
.file-upload .file-select{display:block;border: 2px solid #dce4ec;color: #34495e;cursor:pointer;height:40px;line-height:40px;text-align:left;background:#FFFFFF;overflow:hidden;position:relative;}
.file-upload .file-select .file-select-button{background:#dce4ec;padding:0 10px;display:inline-block;height:40px;line-height:40px;}
.file-upload .file-select .file-select-name{line-height:40px;display:inline-block;padding:0 10px;}
.file-upload .file-select:hover{border-color:#34495e;transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;}
.file-upload .file-select:hover .file-select-button{background:#34495e;color:#FFFFFF;transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;}
.file-upload.active .file-select{border-color:#3fa46a;transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;}
.file-upload.active .file-select .file-select-button{background:#3fa46a;color:#FFFFFF;transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;}
.file-upload .file-select input[type=file]{z-index:100;cursor:pointer;position:absolute;height:100%;width:100%;top:0;left:0;opacity:0;filter:alpha(opacity=0);}
.file-upload .file-select.file-select-disabled{opacity:0.65;}
.file-upload .file-select.file-select-disabled:hover{cursor:default;display:block;border: 2px solid #dce4ec;color: #34495e;cursor:pointer;height:40px;line-height:40px;margin-top:5px;text-align:left;background:#FFFFFF;overflow:hidden;position:relative;}
.file-upload .file-select.file-select-disabled:hover .file-select-button{background:#dce4ec;color:#666666;padding:0 10px;display:inline-block;height:40px;line-height:40px;}
.file-upload .file-select.file-select-disabled:hover .file-select-name{line-height:40px;display:inline-block;padding:0 10px;}
.button {
width: 130px;
height: 40px;
margin: 0 auto;
background-color: #69b1e0;
color: white;
font-weight: 300;
cursor: pointer;
box-shadow: 0px 0px 15px rgba(0,0,0,0.25);
border: none;
}
</style>
</head>
<body>
<!-- <h1>This means you are connected</h1> -->
<div class="break"></div>
<form action="/upload" method="post" enctype="multipart/form-data">
<div class="file-upload">
<div class="file-select">
<div class="file-select-button" id="fileName">Choose File</div>
<div class="file-select-name" id="noFile">Your Song</div>
<input id="chooseFile" type="file" name="upload-file">
</div>
<br>
</div>
<div class="file-upload">
<input class = "button" type="submit" value="Upload">
</div>
</form>
<br>
<article>
<!-- <input id="files" type="file" /> -->
<output id="result" />
</article>
<script>
$('#chooseFile').bind('change', function () {
var filename = $("#chooseFile").val();
if (/^\s*$/.test(filename)) {
$(".file-upload").removeClass('active');
$("#noFile").text("No file chosen...");
}
else {
$(".file-upload").addClass('active');
$("#noFile").text("Song selected. Click Upload.");
}
});
// read text
window.onload = function() {
var filesInput = document.getElementById("files");
var output = document.getElementById("result");
// function httpGet(theUrl)
// {
// if (window.XMLHttpRequest)
// {// code for IE7+, Firefox, Chrome, Opera, Safari
// xmlhttp=new XMLHttpRequest();
// }
// else
// {// code for IE6, IE5
// xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
// }
// xmlhttp.onreadystatechange=function()
// {
// // if (xmlhttp.readyState==4 && xmlhttp.status==200)
// // {
// return xmlhttp.responseText;
// // }
// }
// xmlhttp.open("GET", theUrl, false );
// // xmlhttp.responseType = "blob";
// xmlhttp.send();
// }
// var txt = httpGet('http://ec2-54-152-143-50.compute-1.amazonaws.com:8888/scorelist');
// console.log(txt);
var xhr = new XMLHttpRequest();
xhr.open("GET", "scorelist");
xhr.responseType = "text";//force the HTTP response, response-type header to be blob
var data;
xhr.onload = function()
{
data = xhr.response;//xhr.response is now a blob object
console.log(data)
// console.log(JSON.stringify(data));
// var parsedFile = data.replace( /\n/g, " " ).split( " " );
// var parsedFile = data;
// var fileLength = data.length;
// var display = parsedFile.splice(fileLength-16, 15);
// var displayString= new Array();
// for(var n=0; n < display.length; n++){
// temp = display[n];
// // console.log(temp);
// displayString.push(temp);
//
// if(n == 2||n == 5||n == 8||n == 11||n == 14){
// displayString.push("\n");
// }
// // console.log(displayString);
// }
// console.log(displayString);
var div = document.createElement("div");
// displayString = displayString.join(" ");
div.innerText = data;//displayString
output.insertBefore(div, null);
}
xhr.send();
}
</script>
</body>
</html>