-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregex english.js
379 lines (280 loc) · 9.23 KB
/
regex english.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
const sleep = (delay) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, delay);
});
}
// Ma gandesc ca astsa trateaza back slashuriile mai diferit
// [21:57, 7/29/2021] Viktorashi: eu scriu acum mai mutle mesaje una dupa alta
// [21:57, 7/29/2021] Viktorashi: casa incerc sa fac un mic programel
// [21:57, 7/29/2021] Viktorashi: cu care poti sa stergi in ceputiriile alea de mesaje de
// pe wapp cand dai copypaste ca sa fie mai usor mai rapid un pic
// let re1 = /ab+c/;
const regexNoNames = /\[\d{2}:\d{2},\s[0-9]{1,2}\/[0-9]{1,2}\/\d{4,10}\]\s.*?:|\[\d{1,2}\/\d{1,2},\s\d{1,2}:\d{1,2}\]\s.*?:/gi;
const regexNames = /\[\d{2}:\d{2},\s[0-9]{1,2}\/[0-9]{1,2}\/\d{4,10}\]\s|\[\d{1,2}\/\d{1,2},\s\d{1,2}:\d{1,2}\]\s/gi;
const form = document.querySelector('#form')
const paragraph = document.querySelector('#message')
const input = form.elements.input
const copyButton = document.querySelector('#copy')
const nameOption = document.querySelector('#select')
const body = document.querySelector('body')
const carousel = $('#carousel').carousel()
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
let player1;
let player2;
let player3;
function onYouTubeIframeAPIReady() {
player1 = new YT.Player('player1', {
height: '390',
width: '300',
videoId: '7PiXpXQiRgA',
playerVars: {
playsinline: 1,
controls: 0,
loop: 1,
enablejsapi: 1,
playlist: `PiXpXQ7iRgA`,
},
events: {
'onReady': onPlayerReady1,
'onStateChange': onPlayerStateChange1
}
});
player2 = new YT.Player('player2', {
height: '390',
width: '300',
videoId: 'Nn4VnKcpwuk',
playerVars: {
playsinline: 1,
controls: 0,
loop: 1,
enablejsapi: 1,
playlist: 'Nn4VnKcpwuk',
},
events: {
'onReady': onPlayerReady2,
'onStateChange': onPlayerStateChange2
}
});
player3 = new YT.Player('player3', {
height: '390',
width: '300',
videoId: 'T_u3GBFOMyQ',
playerVars: {
playsinline: 1,
controls: 0,
loop: 1,
enablejsapi: 1,
playlist: `T_u3GBFOMyQ`,
},
events: {
'onReady': onPlayerReady3,
'onStateChange': onPlayerStateChange3
}
});
const carouselItems = document.querySelectorAll('.carousel-item')
for (let carouselItem of carouselItems) {
carouselItem.children[0].classList.add('d-block');
carouselItem.children[0].classList.add('w-100');
}
}
// 4. The API will call this function when the video player is ready.
async function onPlayerReady1(event) {
event.target.mute()
}
async function onPlayerReady2(event) {
event.target.mute()
// await sleep(7000)
// event.target.playVideo()
}
async function onPlayerReady3(event) {
event.target.mute()
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
async function onPlayerStateChange1(event) {
if (event.data === YT.PlayerState.PLAYING) {
while (true) {
if (Math.round(player1.getCurrentTime()) === Math.round(player1.getDuration())) {
carousel.carousel('next')
break;
}
await sleep(700)
}
}
}
// if (event.target.getCurrentTime() === event.target.getDuration()) {
// players[1].playVideo()
// }
async function onPlayerStateChange2(event) {
if (event.data === YT.PlayerState.PLAYING) {
while (true) {
if (Math.round(player2.getCurrentTime()) === Math.round(player2.getDuration())) {
carousel.carousel('next')
break;
}
await sleep(700)
}
}
}
async function onPlayerStateChange3(event) {
if (event.data === YT.PlayerState.PLAYING) {
while (true) {
if (Math.round(player3.getCurrentTime()) === Math.round(player3.getDuration())) {
carousel.carousel('next')
break;
}
await sleep(700)
}
}
}
// relatedTarget: The DOM element that is being slid into place as the active item.
// slid.bs.carousel This event is fired when the carousel has completed its slide transition.
let count = 1
carousel.on('slide.bs.carousel', (evt) => {
// e.relatedTarget.firstChild.src = src + `&autoplay=1`
if (evt.direction === 'left') {
count < 3 ? count++ : count = 1
} else {
count === 1 ? count = 3 : count--
}
switch (count) {
case 1:
player1.playVideo()
player3.stopVideo()
break;
case 2:
player2.playVideo()
player1.stopVideo()
break;
case 3:
player3.playVideo()
player2.stopVideo()
break;
}
// src = src + `&autoplay=1`
})
carousel.on('slid.bs.carousel', () => {
// e.relatedTarget.firstChild.src = src + `&autoplay=1`
// src = src + `&autoplay=1`
})
let mesaje = []
copyButton.addEventListener('click', e => {
copyText(mesaje)
})
async function removeFormatting(input, regex) {
if (input) {
if (regex.test(input)) {
document.querySelector('#error').classList.add('invisible')
mesaje = input.replaceAll(regex, '')
const clean = mesaje.replaceAll('\n', '<br>')
mesaje = mesaje.replaceAll('\n ', '\n')
mesaje = mesaje.replace(' ', '')
// const clean = mesaje.map(msg => (regex.test(msg) ? '' : msg))
// let touchedInput = input.replaceAll(regex, '');
paragraph.innerHTML = clean
console.log(clean)
console.log(mesaje)
input = ''
return mesaje
} else {
paragraph.value = ''
document.querySelector('#error').innerHTML = ''
document.querySelector('#error').classList.remove('invisible')
document.querySelector('#error').innerHTML = `<h1>"${input}"</h1>
<span> Doesn't contain any whatsapp timestamps, names etc..</span>`
throw (`"${input}"
Doesn't contain any whatsapp timestamps, names etc..`)
}
}
}
nameOption.addEventListener('change', async event => {
// NU DECOMENTA ASTA CA SE BULESTE TOT PRGORAMU
// while (
// document.querySelector('#error').classList[0] != 'invisible' &&
// // !input.value
// ) {
// document.querySelector('#error').classList.add('invisible')
// }
if (mesaje.length !== 0) {
try {
if (nameOption.value === 'noName') {
await removeFormatting(input.value, regexNoNames)
copyText(mesaje)
} else if (nameOption.value === 'name') {
await removeFormatting(input.value, regexNames)
copyText(mesaje)
}
} catch (e) {
console.log(e)
}
}
})
//res = string.replace(regexie, ``)
input.addEventListener('input', async e => {
const input = form.elements.input
// NU DECOMENTA ASTA CA SE BULESTE TOT PRGORAMU
// while (
// document.querySelector('#error').classList[0] != 'invisible' &&
// // !input.value
// ) {
// document.querySelector('#error').classList.add('invisible')
// }
try {
if (nameOption.value === 'noName') {
await removeFormatting(input.value, regexNoNames)
} else if (nameOption.value === 'name') {
await removeFormatting(input.value, regexNames)
}
if (e.inputType === "insertFromPaste") {
copyText(mesaje)
}
} catch (e) {
console.log(e)
}
})
form.addEventListener('submit', e => {
e.preventDefault()
const input = form.elements.input
if (nameOption.value === 'noName') {
removeFormatting(input.value, regexNoNames)
} else if (nameOption.value === 'name') {
removeFormatting(input.value, regexNames)
}
})
function copyText(text) {
let textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
textArea.remove();
alert('Messages have been coppied to clipboard!')
}
// flickerBgColor()
// [8/11, 11:53] Viktorashi: bebe neataa
// [8/11, 11:53] Viktorashi: ce facii
// [8/11, 17:01] Viktorashi: nu intrbea
// [8/11, 17:09] Viktorashi: era buletinu meu ma rog
// if (input.splice(`4`) === 'names') {
// }
const changeBgColor = (color) => {
body.style.backgroundColor = color
}
const flickerBgColor = async() => {
while (true) {
changeBgColor('yellow')
await sleep(1000)
changeBgColor('turquoise')
await sleep(1000)
changeBgColor('orange')
await sleep(1000)
changeBgColor('#df05f381')
await sleep(1000)
}
}