Skip to content

Commit ff395c6

Browse files
committed
fix: added missing globals
1 parent 91f47a3 commit ff395c6

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/client.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import CoCreateSocket from "@cocreate/socket-client"
2-
import CoCreateAction from '@cocreate/action'
3-
import CoCreateRender from '@cocreate/render'
1+
/*globals CustomEvent, config*/
2+
import CoCreateSocket from "@cocreate/socket-client";
3+
import CoCreateAction from '@cocreate/action';
4+
import CoCreateRender from '@cocreate/render';
45

56
let socketApi = new CoCreateSocket('api');
67

78
const CoCreateApi = {
89
modules: { },
910

1011
init: function({name, module}) {
11-
this.register(name, module)
12+
this.register(name, module);
1213
},
1314

1415
register: function(name, m_instance) {
@@ -18,32 +19,32 @@ const CoCreateApi = {
1819

1920
socketApi.listen(name, (data) => {
2021
self.__responseProcess(name, data);
21-
})
22+
});
2223

2324
//. register actions
2425

2526
if (Array.isArray(m_instance['actions'])) {
2627
m_instance['actions'].forEach((action) => {
2728
if (typeof m_instance[`action_${action}`] !== 'function') {
2829
m_instance[`action_${action}`] = function(element) {
29-
self.__commonAction(m_instance.id, action, element)
30-
}
30+
self.__commonAction(m_instance.id, action, element);
31+
};
3132
}
3233
CoCreateAction.init({
3334
action: action,
3435
endEvent: action,
3536
callback: (btn) => {
3637
m_instance[`action_${action}`](btn);
3738
},
38-
})
39-
})
39+
});
40+
});
4041
}
4142
}
4243
},
4344

4445
__responseProcess: function(m_name, data) {
4546
const {type, response} = data;
46-
const m_instance = this.modules[m_name]
47+
const m_instance = this.modules[m_name];
4748

4849
if (type && response && m_instance) {
4950

@@ -57,7 +58,7 @@ const CoCreateApi = {
5758
detail: {
5859
data: response
5960
}
60-
}))
61+
}));
6162
}
6263
},
6364

@@ -73,13 +74,13 @@ const CoCreateApi = {
7374
const self = this;
7475
const elements = container.querySelectorAll(`[${mainAttr}^="${action}."]`);
7576

76-
let data = {}
77+
let data = {};
7778
elements.forEach(element => {
7879
let name = element.getAttribute(mainAttr);
7980
let array_name = element.getAttribute(mainAttr + "_array");
8081
let value = self.__getElValue(element);
8182

82-
if (!name) return
83+
if (!name) return;
8384

8485
if (action) {
8586
let re = new RegExp(`^${action}.`, 'i');
@@ -100,18 +101,18 @@ const CoCreateApi = {
100101
}
101102
});
102103

103-
let keys = Object.keys(data)
104+
let keys = Object.keys(data);
104105
let objectData = {};
105106
keys.forEach((k) => {
106107
if (k.split('.').length > 1) {
107108
let newData = self.__createObject(data[k], k);
108-
delete data[k]
109+
delete data[k];
109110

110111
objectData = self.__mergeObject(objectData, newData);
111112
} else {
112113
objectData[k] = data[k];
113114
}
114-
})
115+
});
115116
return objectData;
116117
},
117118

@@ -121,7 +122,7 @@ const CoCreateApi = {
121122
switch (element.type.toLocaleLowerCase()) {
122123
case 'checkbox':
123124
if (element.checked) {
124-
value = element.value
125+
value = element.value;
125126
}
126127
break;
127128
default:
@@ -142,22 +143,22 @@ const CoCreateApi = {
142143
target = target || {};
143144
for (let key of Object.keys(source)) {
144145
if (source[key] instanceof Object) {
145-
Object.assign(source[key], this.__mergeObject(target[key], source[key]))
146+
Object.assign(source[key], this.__mergeObject(target[key], source[key]));
146147
}
147148
}
148149

149-
Object.assign(target || {}, source)
150-
return target
150+
Object.assign(target || {}, source);
151+
return target;
151152
},
152153

153154
__createObject: function (data, path) {
154155
if (!path) return data;
155156

156-
let keys = path.split('.')
157+
let keys = path.split('.');
157158
let newObject = data;
158159

159160
for (var i = keys.length - 1; i >= 0; i--) {
160-
newObject = {[keys[i]]: newObject}
161+
newObject = {[keys[i]]: newObject};
161162
}
162163
return newObject;
163164
},
@@ -196,7 +197,6 @@ const CoCreateApi = {
196197
{
197198
return {
198199
"apiKey": info.apiKey || config.apiKey,
199-
"securityKey": info.securityKey || config.securityKey,
200200
"organization_id": info.organization_id || config.organization_Id,
201201
}
202202
}
@@ -205,8 +205,6 @@ const CoCreateApi = {
205205
CoCreateApi.createApiSocket(
206206
window.config.host ? window.config.host : 'server.cocreate.app',
207207
window.config.organization_Id
208-
// window.config.apiKey
209-
// window.config.securityKey
210208
);
211209

212210
export default CoCreateApi;

0 commit comments

Comments
 (0)