webfast 0.1.72 → 0.1.73
Sign up to get free protection for your applications and to get access to all the features.
- package/app/content/js/webfast.js +27 -34
- package/package.json +1 -1
@@ -125,13 +125,34 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
125
125
|
console.log('WebSocket connected');
|
126
126
|
// Start other things (e.g., send initial data)
|
127
127
|
web.fast.que.state = true;
|
128
|
+
|
128
129
|
//alert(web.fast.tools.isMobile);
|
129
|
-
function
|
130
|
+
function arraySend() {
|
130
131
|
try {
|
131
|
-
if (web.fast.
|
132
|
+
if (web.fast.user != undefined || window.Telegram.WebApp.initData == ``) {
|
132
133
|
let arraySend = [];
|
133
|
-
|
134
|
-
|
134
|
+
jQuery(`[webfast-get]`).each(async function(){
|
135
|
+
const type = jQuery(this).attr(`webfast-get`);
|
136
|
+
let id = jQuery(this).attr(`id`);
|
137
|
+
if (id == undefined) {
|
138
|
+
var generateRandomId = async function(length) {
|
139
|
+
var result = '';
|
140
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
141
|
+
var charactersLength = characters.length;
|
142
|
+
for (var i = 0; i < length; i++) {
|
143
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
144
|
+
}
|
145
|
+
return result;
|
146
|
+
};
|
147
|
+
id = await generateRandomId(8); // Generate a random ID of length 8
|
148
|
+
}
|
149
|
+
arraySend.push({
|
150
|
+
id : id,
|
151
|
+
type : type
|
152
|
+
})
|
153
|
+
})
|
154
|
+
console.log(`Send Array`,arraySend);
|
155
|
+
web.fast.tools.on.connect(arraySend);
|
135
156
|
} else {
|
136
157
|
if (countedError < 3) {
|
137
158
|
console.error(`Tried 10 times`);
|
@@ -142,14 +163,13 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
142
163
|
|
143
164
|
}
|
144
165
|
} catch (err) {
|
145
|
-
alert(`err`);
|
146
166
|
setTimeout(function(){
|
147
|
-
|
167
|
+
arraySend();
|
148
168
|
},200);
|
149
169
|
}
|
150
170
|
}
|
151
171
|
// send array
|
152
|
-
|
172
|
+
arraySend();
|
153
173
|
|
154
174
|
};
|
155
175
|
|
@@ -163,7 +183,6 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
163
183
|
// We have user data
|
164
184
|
console.log(`Set User Data`);
|
165
185
|
web.fast.user = json;
|
166
|
-
|
167
186
|
// Now go Through to set all data
|
168
187
|
// Get all webfast client
|
169
188
|
jQuery(`[webfast-client]`).each(function(){
|
@@ -205,32 +224,6 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
205
224
|
|
206
225
|
web.fast.que.state = Date.now();
|
207
226
|
web.fast.receive(`socket`,event.data); // Placeholder for processing response
|
208
|
-
|
209
|
-
let arraySend = [];
|
210
|
-
jQuery(`[webfast-get]`).each(async function(){
|
211
|
-
const type = jQuery(this).attr(`webfast-get`);
|
212
|
-
let id = jQuery(this).attr(`id`);
|
213
|
-
if (id == undefined) {
|
214
|
-
var generateRandomId = async function(length) {
|
215
|
-
var result = '';
|
216
|
-
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
217
|
-
var charactersLength = characters.length;
|
218
|
-
for (var i = 0; i < length; i++) {
|
219
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
220
|
-
}
|
221
|
-
return result;
|
222
|
-
};
|
223
|
-
id = await generateRandomId(8); // Generate a random ID of length 8
|
224
|
-
}
|
225
|
-
arraySend.push({
|
226
|
-
id : id,
|
227
|
-
type : type
|
228
|
-
})
|
229
|
-
})
|
230
|
-
console.log(`Send Array`,arraySend);
|
231
|
-
web.fast.tools.on.connect(arraySend);
|
232
|
-
web.fast.que.state = true;
|
233
|
-
|
234
227
|
} catch (err) {
|
235
228
|
console.error(`Error Receiving`);
|
236
229
|
console.error(event);
|