Skip to content

Commit b4e439a

Browse files
committed
code cleanup + es modules + fix 3rd party links
1 parent bd77522 commit b4e439a

File tree

114 files changed

+817
-23939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+817
-23939
lines changed

cli.js

Lines changed: 59 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,107 @@
1-
var waveformData = require('./server/library/waveformData');
1+
import { getLocalWaveData, getRemoteWaveData } from './server/library/waveformData.js'
22

3-
var queryObject = {};
3+
const queryObject = {}
44

55
process.argv.forEach(function (value, index, array) {
6-
7-
var commandParametersLength = array.length - 2;
8-
6+
7+
const commandParametersLength = array.length - 2
8+
99
if (commandParametersLength !== 7) {
10-
11-
var error = 'invalid parameters length, please call the cli with the following parameters: node cli SERVER_PATH TRACK_NAME TRACK_EXTENSION AMOUT_OF_PEAKS LOCAL_OR_REMOTE_SERVICENAME PEAKSLIST_OUTPUT_FORMAT TRACK_FORMAT_DETECTION\n';
12-
13-
process.stderr.write(error + "\n");
14-
15-
process.exit(1);
16-
17-
}
18-
10+
11+
const error = 'invalid parameters length, please call the cli with the following parameters: node cli SERVER_PATH TRACK_NAME TRACK_EXTENSION AMOUT_OF_PEAKS LOCAL_OR_REMOTE_SERVICENAME PEAKSLIST_OUTPUT_FORMAT TRACK_FORMAT_DETECTION\n'
12+
13+
process.stderr.write(error + "\n")
14+
15+
process.exit(1)
16+
17+
}
18+
1919
if (index === 2) {
20-
21-
queryObject.serverDirectory = value;
22-
20+
queryObject.serverDirectory = value
2321
}
24-
22+
2523
if (index === 3) {
26-
27-
queryObject.trackId = value;
28-
24+
queryObject.trackId = value
2925
}
30-
26+
3127
if (index === 4) {
32-
33-
queryObject.trackFormat = value.toLowerCase();
34-
28+
queryObject.trackFormat = value.toLowerCase()
3529
}
36-
30+
3731
if (index === 5) {
38-
39-
queryObject.peaksAmount = parseInt(value);
40-
32+
queryObject.peaksAmount = parseInt(value)
4133
}
42-
34+
4335
if (index === 6) {
44-
45-
queryObject.service = value.toLowerCase();
46-
36+
queryObject.service = value.toLowerCase()
4737
}
48-
38+
4939
if (index === 7) {
50-
51-
queryObject.outputFormat = value.toLowerCase();
52-
40+
queryObject.outputFormat = value.toLowerCase()
5341
}
54-
42+
5543
if (index === 8) {
56-
44+
5745
if (typeof value === 'boolean') {
58-
59-
queryObject.detectFormat = value;
60-
46+
queryObject.detectFormat = value
6147
} else {
62-
63-
var detectFormat = value.toLowerCase();
48+
49+
const detectFormat = value.toLowerCase()
6450

6551
if (detectFormat === 'true') {
66-
67-
queryObject.detectFormat = true;
68-
69-
} else if (detectFormat.substr(0,2) === 'sr') {
70-
71-
var splittedDetectFormat = detectFormat.split('=');
72-
73-
queryObject.detectFormat = parseInt(splittedDetectFormat[1]);
74-
52+
queryObject.detectFormat = true
53+
} else if (detectFormat.substr(0, 2) === 'sr') {
54+
const splittedDetectFormat = detectFormat.split('=')
55+
queryObject.detectFormat = parseInt(splittedDetectFormat[1])
7556
} else {
76-
77-
queryObject.detectFormat = false;
78-
57+
queryObject.detectFormat = false
7958
}
80-
59+
8160
}
82-
8361
}
84-
85-
});
62+
})
8663

87-
var outputResponse = function outputResponseFunction(error, peaks) {
64+
const outputResponse = function outputResponseFunction(error, peaks) {
8865

8966
if (error) {
90-
91-
process.stderr.write(error + "\n");
92-
93-
process.exit(1);
94-
67+
process.stderr.write(error + "\n")
68+
process.exit(1)
9569
} else {
9670

97-
var output = '';
71+
let output = ''
9872

9973
// outputFormat can be json or text
10074
if (queryObject.outputFormat === 'json') {
10175

102-
var outputData = {
76+
const outputData = {
10377
"peaks": peaks
104-
};
105-
106-
output = JSON.stringify(outputData);
107-
78+
}
79+
80+
output = JSON.stringify(outputData)
81+
10882
} else {
109-
110-
var peaksString = '';
111-
var i;
112-
var peaksLength = peaks.length;
83+
84+
const peaksString = ''
85+
let i
86+
const peaksLength = peaks.length
11387

11488
for (i = 0; i < peaksLength; i++) {
89+
peaksString += peaks[i] + ','
90+
}
11591

116-
peaksString += peaks[i] + ',';
92+
output = peaksString.substring(0, peaksString.length - 1)
11793

118-
}
119-
120-
output = peaksString.substring(0, peaksString.length - 1);
121-
12294
}
123-
124-
process.stdout.write(output + "\n");
12595

126-
process.exit(0);
96+
process.stdout.write(output + "\n")
97+
98+
process.exit(0)
12799

128100
}
129-
130-
};
101+
}
131102

132103
if (queryObject.service === 'local') {
133-
134-
// node cli ./downloads 1100511 ogg 200 local json false
135-
// node cli ./downloads 1100511 mp3 200 local json false
136-
waveformData.getLocalWaveData(queryObject, outputResponse);
137-
104+
getLocalWaveData(queryObject, outputResponse)
138105
} else {
139-
140-
// node cli ./downloads 1100511 ogg 200 jamendo json false
141-
// node cli ./downloads 1100511 mp3 200 jamendo json false
142-
waveformData.getRemoteWaveData(queryObject, outputResponse);
143-
106+
getRemoteWaveData(queryObject, outputResponse)
144107
}

client/index.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

client/scripts/library/event.js

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)