-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_js.py
More file actions
48 lines (40 loc) · 1.51 KB
/
split_js.py
File metadata and controls
48 lines (40 loc) · 1.51 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
import sys, re
sys.stdout.reconfigure(encoding='utf-8')
with open('web/js/all.js', 'r', encoding='utf-8') as f:
js = f.read()
# Find key function/section boundaries
def find_pos(pattern):
m = re.search(pattern, js)
return m.start() if m else -1
# Identify sections
sse_start = find_pos(r'// ===== SSE')
if sse_start == -1:
sse_start = find_pos(r'let _evtSource')
search_start = find_pos(r'// ===== Search')
if search_start == -1:
search_start = find_pos(r'function populateFilters')
region_start = find_pos(r'// ===== Region Popup')
if region_start == -1:
region_start = find_pos(r'function toggleRegionPopup')
trend_start = find_pos(r'// ===== Trend Metrics')
if trend_start == -1:
trend_start = find_pos(r'const TREND_METRICS')
rose_start = find_pos(r'function renderPie')
init_trend_start = find_pos(r'function initTrend')
mock_trend_start = find_pos(r'function mockTrend')
load_events_start = find_pos(r'async function loadEvents')
render_ev_start = find_pos(r'function renderEv')
flt_ev_start = find_pos(r'function fltEv')
mock_events_start = find_pos(r'function mockEvents')
print(f'SSE: {sse_start}')
print(f'Search: {search_start}')
print(f'Region: {region_start}')
print(f'Trend metrics: {trend_start}')
print(f'Rose: {rose_start}')
print(f'initTrend: {init_trend_start}')
print(f'mockTrend: {mock_trend_start}')
print(f'loadEvents: {load_events_start}')
print(f'renderEv: {render_ev_start}')
print(f'fltEv: {flt_ev_start}')
print(f'mockEvents: {mock_events_start}')
print(f'Total JS: {len(js)}')