-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
120 lines (115 loc) · 4.38 KB
/
index.html
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
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css"/>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="client.js" type="text/javascript"></script>
<script src="ajaxfileupload.js" type="text/javascript"></script>
<script type="text/javascript">
window.onbeforeunload = askConfirm;
function askConfirm() {
return "You really want to leave?";
}
$(document).ready(function(){
//upload file
//$("#uploadFile").change(function () {
// filename = $("#uploadFile").val().split("\\").pop();
// if (filename.length > 0) {
// var result = ajaxFileUpload();
// msg = "http://localhost:8001/files/" + filename;
// send(msg);
// $("#uploadFile").replaceWith("<input type='file' id='uploadFile' />");
// }
//});
});
function upload_file() {
filename = $("#uploadFile").val().split("\\").pop();
if (filename.length > 0) {
var result = ajaxFileUpload();
msg = "http://localhost:8001/files/" + filename;
send(msg);
$("#uploadFile").val('');
}
}
function ajaxFileUpload() {
/*
prepareing ajax file upload
url: the url of script file handling the uploaded files
fileElementId: the file type of input element id and it will be the index of $_FILES Array()
dataType: it support json, xml
secureuri:use secure protocol
success: call back function when the ajax complete
error: callback function when the ajax failed
*/
$.ajaxFileUpload( {
url:'/upload',
secureuri:false,
fileElementId:'uploadFile',
dataType: 'xml',
success: function (data, status) {
if(typeof(data.error) != 'undefined') {
if(data.error != '') {
alert(data.error);
} else {
alert(data.msg);
}
}
},
error: function (data, status, e) {
alert(e);
}
});
return false;
}
</script>
<title>chat</title>
</head>
<body>
<div id="app">
<div id="connect">
<form action="#">
<fieldset>
<table>
<tr>
<td><label for="nick">Name</label></td>
<td><input id="nickInput" class="text" type="text" name="nick" value=""/></td>
</tr>
<tr>
<td><label for="pass">Pass</label></td>
<td><input id="passInput" class="text" type="password" name="pass" value=""/></td>
</tr>
<tr>
<td> </td>
<td><input id="connectButton" class="button" type="submit" name="" value="Join"/></td>
</tr>
</table>
</fieldset>
</form>
</div>
<div id="loading"><p>loading</p></div>
<div id="log">
<table class="message"><tr><td class="date">20:20</td><td valign="top" class="nick">catalystmediastu</td>
<td class="msg-text">bougyman: Thanks, that looks like a good tool too. I'll look into them both a little
more.
</td>
</tr></table>
</div>
<div id="toolbar">
<ul id="status">
<li><a id="usersLink" href="#">0 users</a></li>
<li><a id="filesLink" href="#">0 files</a></li>
<li>uptime: <span id="uptime">?</span></li>
<!-- <li>memory: <span id="rss">?</span>mb RSS</li> -->
</ul>
<div style="float:right;">
<form id="upload" style="margin:0;padding:0 10px;">
<div style="display: block; width: 100px; height: 20px; overflow: hidden;">
<button style="color:#999; width: 110px; height: 30px; position: relative; top: -5px; left: -5px;"><a href="javascript: void(0)"><span style="color:#555">Upload File</span></a></button>
<input type="file" onchange="upload_file();" id="uploadFile" name="upload" style="font-size: 50px; width: 120px; opacity: 0; filter:alpha(opacity: 0); position: relative; top: -40px;; left: -20px" />
</div>
</form>
</div>
<span id="output" style="display:none;"></span>
<input tabindex="1" type="text" id="entry"/>
</div>
</body>
</html>