Skip to content

Commit 21191e8

Browse files
committed
clean up code, start standardizing names, notifications
1 parent 9faadc0 commit 21191e8

6 files changed

Lines changed: 59 additions & 125 deletions

File tree

about/css/index.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ paper-button{
199199
-webkit-transition-duration: 0.5s;
200200
transition-property: border;
201201
transition-duration: 0.5s;
202-
border: 2px solid gray;
202+
border: 2px solid #dbdada;
203203
}
204204
#switch{
205205
margin: 0;
@@ -300,3 +300,7 @@ position: absolute !important;
300300
height: 100%;
301301
background-color: rgba(0,0,0,0.2);
302302
}
303+
304+
#svg2{
305+
box-shadow: rgba(0, 0, 0, 0.48) 5px 4px 5px;
306+
}

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@
9797
<p>Line Numbers</p>
9898
<label class="check-switch" id="side-nums-label">
9999
<input type="checkbox" id="side-nums" checked>
100-
<span onclick="line_number_switch()"></span>
100+
<span onclick="lineNumber()"></span>
101101
</label>
102102
</div>
103103

104104
<div class="select-box">
105105
<p>Line Wrap</p>
106106
<label class="check-switch" id="side-wrap-label">
107107
<input type="checkbox" id="side-wrap" checked>
108-
<span onclick="line_wrap_switch()"></span>
108+
<span onclick="lineWrap()"></span>
109109
</label>
110110
</div>
111111
</div>
@@ -128,8 +128,8 @@
128128
<span id="help_button" class="side-file" onclick='$("#chat-popup").slideToggle()'><i class="md-chat"></i></span>
129129
<span id="open_button" onclick="picker.open()" data-step="2" data-intro='This will open up the file chooser'><i class="md-folder-open"></i></span>
130130
<span id="save_button" class="side-file" onclick="save()" data-step="3" data-intro='You can also save the file you are working on'><i class="md-save"></i></span>
131-
<span id="undo_button" onclick="editor_undo()"><i class="md-undo"></i></span>
132-
<span id="redo_button" onclick="editor_redo()"><i class="md-redo"></i></span>
131+
<span id="undo_button" onclick="editorUndo()"><i class="md-undo"></i></span>
132+
<span id="redo_button" onclick="editorRedo()"><i class="md-redo"></i></span>
133133
</div>
134134

135135
<div id="profile_div"><img id="profile_pic" src="" height="30px" width="30px"></div>

js/editor.js

Lines changed: 25 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*===
2-
* CODEYOURCLOUD
3-
*
4-
* editor.js built by Michael Kaminsky
5-
* manages the editor + options
6-
*
7-
* contents:
8-
===*/
9-
101
/**
112
* FIND/REPLACE
123
* find and replace for editors
@@ -45,28 +36,25 @@ function setMode(id,mode){
4536
editors[index].editor.setOption("lint",CodeMirror.lint.javascript);
4637
startTern(index);
4738
}
48-
else if(mode === "text/x-coffeescript"){
49-
}
5039
else if(mode === "text/html"){
51-
startHtml(index);
52-
}
53-
else if(mode === "text/x-markdown" || mode === "gfm"){
40+
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
41+
editors[index].editor.on("inputRead", function(cm, change){
42+
if(change.text[0] === "/" || change.text[0] === "<"){
43+
CodeMirror.showHint(editors[index].editor, CodeMirror.hint.html);
44+
}
45+
});
5446
}
5547
else if(mode === "text/css"){
5648
editors[index].editor.setOption("gutters",["CodeMirror-lint-markers"]);
5749
editors[index].editor.setOption("lint",CodeMirror.lint.css);
58-
startCss(index);
50+
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
5951
}
6052
else if(mode === "application/json"){
6153
editors[index].editor.setOption("gutters",["CodeMirror-lint-markers"]);
6254
editors[index].editor.setOption("lint",CodeMirror.lint.json);
6355
}
64-
else if(mode === "text/x-python"){
65-
startPython(index);
66-
}
67-
else if(mode === "text/x-sql"){
68-
startSql(index);
69-
}
56+
else if(mode === "text/x-python"){editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});}
57+
else if(mode === "text/x-sql"){editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});}
7058
editors[index].editor.setOption("mode", mode); //finally, set the mode
7159

7260
adjust(); //adjust the ide
@@ -76,27 +64,23 @@ function extension(fileName){
7664
var ext = "txt";
7765
var hidden = false;
7866

79-
if(fileName.charAt(0) === "."){
80-
hidden = true;
81-
} else {
82-
var array = fileName.split(".");
83-
ext = array[array.length - 1];
67+
if(fileName.charAt(0) === "."){hidden = true;}
68+
else{
69+
ext = fileName.split(".").reverse()[0]
8470
}
8571
return {ext: ext, hidden: hidden}; //hidden like .DS_STORE or .vimrc
8672
}
8773
//get the mode for a given filename
88-
function check_mode(id, fileName){
74+
function checkMode(id, fileName){
8975
var ext_info = extension(fileName);
90-
var hidden = ext_info.hidden;
91-
var ext = ext_info.ext;
9276
var mode_to_use = "text"; //default
93-
if(hidden === false){
77+
if(ext_info.hidden === false){
9478
for(var i = 0; i < modes.length; i++){
9579
var possible_mime = modes[i].mime;
9680
var exts = modes[i].ext;
9781

9882
try{
99-
if(exts.indexOf(ext) !== -1){
83+
if(exts.indexOf(ext_info.ext) !== -1){
10084
mode_to_use = possible_mime;
10185
}
10286
}
@@ -111,21 +95,17 @@ function modeChange(){
11195
}
11296
//populates the mode select
11397
for(var i = 0; i < modes.length; i++){
114-
var name = modes[i].name;
115-
var the_mode = modes[i].mime;
116-
117-
var sel = "<option value='"+the_mode+"'>"+name+"</option>";
118-
$("#mode-select").html($("#mode-select").html() + sel);
98+
$("#mode-select").html($("#mode-select").html() + "<option value='"+modes[i].mime+"'>"+modes[i].name+"</option>");
11999
}
120100

121101

122102
/**
123103
* UNDO/REDO
124104
**/
125-
function editor_undo() {
105+
function editorUndo() {
126106
editor().getDoc().undo();
127107
}
128-
function editor_redo() {
108+
function editorRedo() {
129109
editor().getDoc().redo();
130110
}
131111

@@ -138,23 +118,17 @@ function editor_redo() {
138118
function themeChange(){
139119
setTheme($("#theme-select").val());
140120
}
141-
function setTheme(theme){
142-
143-
//$(".mini").css("background-color",$(".CodeMirror").css("background-color"));
144-
121+
function setTheme(theme){
122+
//$(".mini").css("background-color",$(".CodeMirror").css("background-color"));
145123
localStorage.setItem("theme", theme);
146124
for(var i = 0; i < editors.length; i++){
147125
editors[i].editor.setOption("theme",theme);
148126
}
149127
editor_theme = theme;
150128
}
151129
//populates theme select
152-
for(var j = 0; j < themes.length; j++){
153-
var the_name = themes[j];
154-
var the_theme = the_name.split(" ").join("-").toLowerCase();
155-
156-
var sel = "<option value='"+the_theme+"'>"+the_name+"</option>";
157-
$("#theme-select").html($("#theme-select").html() + sel);
130+
for(var j = 0; j < themes.length; j++){
131+
$("#theme-select").html($("#theme-select").html() + "<option value='"+themes[j].split(" ").join("-").toLowerCase()+"'>"+themes[j]+"</option>");
158132
}
159133

160134
/**
@@ -167,8 +141,7 @@ function fontChange(){
167141

168142
//populates the font select
169143
for(var k = 2; k <= 30; k++){
170-
var sel = "<option value='" + k + "'>" + k + "</option>";
171-
$("#font-select").html($("#font-select").html() + sel);
144+
$("#font-select").html($("#font-select").html() + "<option value='" + k + "'>" + k + "</option>");
172145
}
173146

174147
//sets default settings
@@ -180,7 +153,7 @@ $("#font-select").val("12");
180153
* OPTIONS
181154
* line numbers, line wrap, font size
182155
**/
183-
function line_number_switch() {
156+
function lineNumber() {
184157
if(line_number){
185158
for(var i = 0; i < editors.length; i++){
186159
editors[i].editor.setOption("lineNumbers",false);
@@ -194,7 +167,7 @@ function line_number_switch() {
194167
line_number = true;
195168
}
196169
}
197-
function line_wrap_switch() {
170+
function lineWrap() {
198171
if(editor().getOption("lineWrapping")){
199172
for(var i = 0; i < editors.length; i++){
200173
editors[i].editor.setOption("lineWrapping",false);
@@ -230,28 +203,6 @@ function getHint(){
230203
CodeMirror.showHint(editor(), CodeMirror.hint.sql);
231204
}
232205
}
233-
234-
//HTML
235-
function startHtml(index){
236-
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
237-
editors[index].editor.on("inputRead", function(cm, change){
238-
if(change.text[0] === "/" || change.text[0] === "<"){
239-
CodeMirror.showHint(editors[index].editor, CodeMirror.hint.html);
240-
}
241-
});
242-
}
243-
//CSS
244-
function startCss(index){
245-
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
246-
}
247-
//SQL
248-
function startSql(index){
249-
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
250-
}
251-
//PYTHON
252-
function startPython(index){
253-
editors[index].editor.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
254-
}
255206
//JAVASCRIPT
256207
function getURL(url, c) {
257208
var xhr = new XMLHttpRequest();

js/mobile.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1 @@
1-
document.addEventListener('touchstart', handleTouchStart, false);
2-
document.addEventListener('touchmove', handleTouchMove, false);
3-
4-
var xDown = null;
5-
var yDown = null;
6-
7-
function handleTouchStart(evt) {
8-
xDown = evt.touches[0].clientX;
9-
yDown = evt.touches[0].clientY;
10-
};
11-
12-
function handleTouchMove(evt) {
13-
if ( ! xDown || ! yDown ) {
14-
return;
15-
}
16-
17-
var xUp = evt.touches[0].clientX;
18-
var yUp = evt.touches[0].clientY;
19-
20-
var xDiff = xDown - xUp;
21-
var yDiff = yDown - yUp;
22-
23-
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
24-
if ( xDiff > 0 ) {
25-
/* left swipe */
26-
if(is_mobile && side_open){
27-
close_side();
28-
}
29-
} else {
30-
/* right swipe */
31-
if(is_mobile && !side_open){
32-
open_side();
33-
}
34-
}
35-
} else {
36-
if ( yDiff > 0 ) {
37-
/* up swipe */
38-
} else {
39-
/* down swipe */
40-
}
41-
}
42-
/* reset values */
43-
xDown = null;
44-
yDown = null;
45-
};
1+
//just mobile stuff

js/realtime.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ function get_info(){
131131
function insertUser(name, color, photo, id, fileid){
132132
var new_user = "<img class=\"user-photo\" id=\"img_" + id + "\" src=\""+ photo +"\" height=\"53px\" width=\"53px\" style=\"border:solid 4px "+ color +"\">";
133133
$(".users-container[data-fileid='"+fileid+"']").html( $(".users-container[data-fileid='"+fileid+"']").html() + new_user);
134+
135+
Messenger().post({
136+
message: name + " joined",
137+
type: 'info',
138+
showCloseButton: true
139+
});
134140
}
135141
function removeUser(id, fileid){
136142
try{

js/tabs.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function setIgnore(id, ignore){
6060
function setFileTitle(id, title){
6161
editors[getIndex(id)].title = title;
6262
$(".tab-tab[data-fileid='"+id+"']").find("h4").html(title);
63-
check_mode(id, title);
63+
checkMode(id, title);
6464
var index = getIndex(id);
6565
if(current_file === id){ //if this is the file being show, you should change the title input
6666
$("#title").val(editors[index].title);
@@ -356,6 +356,23 @@ function insert_chat(message, you, photo, name, fileid){
356356
$(".chats-content[data-fileid='"+fileid+"']").html($(".chats-content[data-fileid='"+fileid+"']").html() + push);
357357

358358
$(".chats-content[data-fileid='"+fileid+"']").animate({ scrollTop: $(".chats-content[data-fileid='"+fileid+"']")[0].scrollHeight}, 500);
359+
360+
if(you === false){
361+
if(message.length > 10){
362+
Messenger().post({
363+
message: (name + ':' + message.slice(0, 10) + '...'),
364+
type: 'success',
365+
showCloseButton: true
366+
});
367+
}
368+
else{
369+
Messenger().post({
370+
message: (name + ':' + message),
371+
type: 'success',
372+
showCloseButton: true
373+
});
374+
}
375+
}
359376
}
360377
}
361378
//send a chat message

0 commit comments

Comments
 (0)