This repository was archived by the owner on Mar 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathide.html
More file actions
125 lines (122 loc) · 4.51 KB
/
ide.html
File metadata and controls
125 lines (122 loc) · 4.51 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
<!DOCTYPE html>
<html>
<head>
<title>Cloudev | Edit File</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<style>
html {
padding-top: 50px;
background-color: #282C31;
color: white;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
.faded {
color: #aaaaaa;
}
.hide {
display: none;
}
#editor {
height: 60vh;
width: 90vw;
margin: auto;
font-size: 20px;
text-align: left;
}
button {
margin-top: 10px;
height: 50px;
width: 100px;
font-size: 16px;
border: none;
border-radius: 5px;
outline: none;
background-color: #7187DC;
color: white;
}
button:hover {
background-color: #6076CB;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/mode-javascript.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/theme-textmate.js"></script>
<!-- Firepad -->
<link rel="stylesheet" href="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.css" />
<script src="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.min.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.8/firebase.js"></script>
<script src="http://danml.com/js/download.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyB9ttmojRBWZD7MgGq3uhCCAiokHpQmgdk",
authDomain: "cloudev-6f3f5.firebaseapp.com",
databaseURL: "https://cloudev-6f3f5.firebaseio.com",
projectId: "cloudev-6f3f5",
storageBucket: "cloudev-6f3f5.appspot.com",
messagingSenderId: "545680646927"
};
firebase.initializeApp(config);
//// Get Firebase Database reference.
var firepadRef = firebase.database().ref("users/");
</script>
</head>
<body>
<img src="logo.png" height=100>
<h1 id="FileName">Editing </h1>
<!-- <textarea id="editor" onkeyup="ups(event)"></textarea>-->
<div id="editor"></div>
<script>
var firepad
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
document.getElementById("FileName").innerHTML += window.location.hash.substring(1).split("#")[1].replace("|", ".")
//// Get Firebase Database reference.
var firepadRef = firebase.database().ref("users/" + user.uid + "/" + window.location.hash.substring(1).split("#")[0] + "/" + window.location.hash.substring(1).split("#")[1]);
//// Create ACE
var editor = ace.edit("editor");
editor.setTheme("ace/theme/textmate");
var session = editor.getSession();
session.setUseWrapMode(true);
session.setUseWorker(false);
var language = window.location.hash.substring(1).split("#")[1].split("|")[1];
switch(language){
case "py":
language = "python"
case "js":
language = "javascript"
case "java":
language = "java"
case "rb":
language = "ruby"
case "cpp":
language = "c++"
case "pl":
language = "perl"
case 'txt':
language = "none"
default:
language = "javascript"
}
if(language!="none"){
session.setMode("ace/mode/"+language);
}
//// Create Firepad.
firepad = Firepad.fromACE(firepadRef, editor, {
defaultText: 'CLOUDEV COLLABORATIVE IDE\n\nThis is a real-time collaborative editor. If you share it with somebody, you will see his or her edits almost instantly after he or she edits it.\n\nMore features coming soon! :)\n\nBuilt with ♥ by Riley Kong, Oliver Ni, and Franklin Wang for TinoHacks'
,userId: firebase.auth().currentUser.uid
});
var hashes = window.location.hash.substring(1).split("#");
firebase.database().ref('users/' + firebase.auth().currentUser.uid + '/' + hashes[0] + "/" + hashes[1])
}
});
function dwl() {
download(firepad.getText(), window.location.hash.substring(1).split("#")[1].replace("|", "."), "text/plain")
}
</script>
<!-- <script src="ide.js"></script> -->
<button onclick="dwl()">Download</button>
</body>
</html>