-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
148 lines (121 loc) · 5.03 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
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
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Inconsolata" />
<script>
var socket=io();
$(function($){
//Sending
$("#prog").submit(function(e){
e.preventDefault();
var code=$("#code").val(),input = $("#input").val(),lang = $('#lang').val();
var body = {
code : code,
input : input,
lang : lang
};
$.post("/compile", body ,function(compile_msg){
socket.emit('compile_msg',compile_msg);
});
})
});
//Receiving
socket.on('compile_msg',function(msg){
$("#compile_msg").html(msg);
})
socket.on('edited',function(code){
$("#code").val(code);
})
socket.on("projectID",function(name){
window.location.href=name;
})
function send(){
socket.emit('edited',$("#code").val());
}
</script>
<style>
.hidethis{
display: none;
}
#code{
font-family: Courier New ;
font-size: 14px;
font-style: oblique;
font-variant: normal;
font-weight: 400;
line-height: 20px;
width: 100%;
height: 100%;
background-color:#f0f0f0;
resize:none;
}
#msgform { padding: 1px; position: fixed; bottom: 20%; width: 10%; }
</style>
</head>
<body>
<script>
var url=window.location.href;
if(url=="http://localhost:8000/"){
;
}
else{
var name= prompt("Enter your name: ");
socket.emit('user',name);
}
</script>
<div id="main" class="container" style="margin-top:0%;">
<p id="codeId" style="margin-left:30%;margin-top=-1%"></p>
<script>
var url=window.location.pathname.split('/')[1];
$("#codeId").html('Your CodeId: '+'<b>'+ url+'<b>');
</script>
<div class="row" style="width:100%;">
<div class="col-xs-6" style="background-color:green; width:75%;height:65%;float:left">
<form id="prog" name="prog">
<textarea name="code" id="code" oninput="send()" spellcheck="false" autofocus></textarea>
<select id ="lang">
<option name = "cpp">c++</option>
<option name ="python">python</option>
</select>
<input type="submit" name="button" id="button" value="Compile"/>
<input type="checkbox" onclick="$('#input').toggle()">Input <textarea class="hidethis" name="input" id="input" cols="20" rows="3"></textarea>
</form>
</div>
</div>
<div id="chat" style="background-color:green; width:25%;height:75%;float:right;overflow-y:auto;word-wrap:break-word">
<script>
$(function($){
socket.on('chat message',function(message){
$("#messages").append($('<li>').text(message));
});
socket.on('out',function(name){
$("#messages").append($('<li>').text(name+" logged out."));
});
$('#msgform').submit(function(e){
e.preventDefault();
socket.emit('chat message', $('#m').val() );
$('#m').val('');
});
socket.on('names', function(message){
var html = '<b>Connected Users<b><br><br>';
for(i=0; i < message.length; i++){
html+= message[i] + '<br/>'
}
$('#users').html(html);
});
});
</script>
<div id="message_box">
<ul id="messages"></ul>
<form id="msgform">
<input id="m" autocomplete=off autofocus ><input type="submit" id="buttonf">
</form>
</div>
</div>
<div class="row" style="margin-top:30%">
<div class="col-md-12" id="compile_msg" style="border-style:solid; background-color:#09e8d7; width:100%;height:140px;overflow-y:auto ;float:left;word-wrap:break-word;"></div>
</div>
</div>
</body>
</html>