forked from mkaminsky11/codeyourcloud
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcom.js
More file actions
164 lines (146 loc) · 2.88 KB
/
Copy pathcom.js
File metadata and controls
164 lines (146 loc) · 2.88 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
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event){
if(event.data !== "!_{h:''}"){
var json = JSON.parse(event.data);
if(json.type === "folder"){
justFolder(json.id);
}
else if(json.type === "reload"){
window.location.reload();
}
else if(json.type === "back"){
one_folder_back(json.folder);
}
else if(json.type === "command"){
eval(json.command);
}
else if(json.type === "title"){
title.setText(json.title);
renameFile(current, title.getText());
}
else if(json.type === "save"){
save();
}
else if(json.type === "new"){
insertNewFile(json.folder);
}
else if(json.type === "text"){
try{
text.setText(json.text);
}
catch(e){
}
}
else if(json.type === "permissions"){
getP(json.id);
}
else if(json.type === "add_p"){
insertPermission(json.id, json.email, json.type, json.role);
}
else if(json.type === "remove_p"){
removePermission(json.file, json.id);
}
else if(json.type === "new_chat"){
makeChat(json.message, json.name, json.id, json.photo);
}
else if(json.type === "shared"){
sharedWithMe();
}
else if(json.type === "save_as"){
insert_saveas(json.data, json.title, json.folder);
}
}
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function sendData(data){
parent.postMessage(JSON.stringify(data), "*");
}
function setValue(value){
sendData({
type: "text",
value: value
});
}
function insertUser(the_username, the_color, the_photo, the_sessionId, col){
sendData({
type:"insert_user",
name:the_username,
color:the_color,
photo: the_photo,
session: the_sessionId,
col: col
});
}
function removeUser(the_id){
sendData({
type: "delete_user",
id: the_id
});
}
function setText(value){
text.setText(value);
}
function insertChat(the_message, the_name, is_you, the_photo){
sendData({
type: "insert_chat",
message: the_message,
name: the_name,
you: is_you,
photo: the_photo
});
}
function insert_text(point, text){
sendData({
type: "insert_text",
point: point,
text: text
});
}
function delete_text(back, front){
sendData({
type: "delete_text",
back: back,
front: front
});
}
function sendFolder(folder, id, name){
sendData({
type: "folder",
folder: folder,
id: id
});
}
function perError(){
sendData({
type:"error",
error:"permission"
});
}
function sendTitle(title){
sendData({
type: "title",
title: title
});
}
function sendNew(n){
sendData({
type: "new",
id: n
});
}
function sendP(p){
sendData({
type: "permissions",
p: p
});
}
function parent_error(){
sendData({
type: "parent_error"
});
}