This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.js
124 lines (109 loc) · 4.94 KB
/
init.js
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
/*
* Copyright (c) Codiad & daeks, distributed
* as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact.
*/
(function (global, $) {
var codiad = global.codiad,
scripts= document.getElementsByTagName('script'),
path = scripts[scripts.length-1].src.split('?')[0],
curpath = path.split('/').slice(0, -1).join('/')+'/';
$.getScript(curpath+'togetherjs-min.js');
$(window)
.load(function() {
codiad.together.init();
});
codiad.together = {
controller: curpath + 'controller.php',
tmp: '',
//////////////////////////////////////////////////////////////////
// Initilization
//////////////////////////////////////////////////////////////////
init: function () {
if(typeof(TogetherJS) != 'undefined') {
/*amplify.subscribe('active.onOpen', function(path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'active.onOpen', path: path});
});
amplify.subscribe('active.onFocus', function(path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'active.onFocus', path: path});
});
amplify.subscribe('active.onSave', function(path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'active.onSave', path: path});
});
amplify.subscribe('active.onRemoveAll', function() {
codiad.together.tmp = 'nopath';
TogetherJS.send({type: "codiad", action: 'active.onRemoveAll', path: 'nopath'});
});
amplify.subscribe('active.onClose', function(path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'active.onClose', path: path});
});
amplify.subscribe('project.onOpen', function(path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'project.onOpen', path: path});
});*/
/*amplify.subscribe('project.onCreate', function(name, path, git_repo, git_branch) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'project.onCreate', path: path});
});
amplify.subscribe('project.onRename', function(name, path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'project.onRename', path: path});
});
amplify.subscribe('project.onDelete', function(name, path) {
codiad.together.tmp = path;
TogetherJS.send({type: "codiad", action: 'project.onDelete', path: path});
});*/
}
},
//////////////////////////////////////////////////////////////////
// Load TogetherJS
//////////////////////////////////////////////////////////////////
load: function () {
var _this = this;
var currentResponse = null;
$.ajax({
url: _this.controller + '?action=username',
async: false,
success: function(data) {
TogetherJSConfig_getUserName = function () {return data;};
TogetherJSConfig_getUserAvatar = function () {return curpath+'avatar.jpg';};
TogetherJSConfig_getUserColor = function () {return '#fff';};
TogetherJSConfig_suppressJoinConfirmation = true;
TogetherJSConfig_suppressInvite = true;
TogetherJSConfig_siteName = "Codiad Together";
TogetherJSConfig_toolName = "Codiad Together";
TogetherJSConfig_findRoom = btoa(window.location.href);
TogetherJS();
}
});
},
//////////////////////////////////////////////////////////////////
// Handle Remote Clicks
//////////////////////////////////////////////////////////////////
handle: function (target) {
if(codiad.together.tmp !== target.path) {
if(target.action == 'active.onOpen') {
codiad.filemanager.openFile(target.path, true);
}
if(target.action == 'active.onClose') {
codiad.active.remove(target.path, false);
}
if(target.action == 'active.onFocus') {
codiad.active.focus(target.path, true, false);
}
if(target.action == 'active.onRemoveAll') {
codiad.active.removeAll(false);
}
if(target.action == 'project.onOpen') {
codiad.project.open(target.path, false);
}
} else {
codiad.together.tmp = '';
}
}
};
})(this, jQuery);