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
|
/**
* @module MultimediaPlayerApplication
*/
(function ($) {
"use strict";
/**
* Class which provides methods to fill content of spectrum analyzer for JQuery plugin.
* @class SpectrumAnalyzerObj
* @static
*/
var SpectrumAnalyzerObj = {
/**
* Holds value of spectrum analyzer bar.
* @property bar1 {Integer}
*/
bar1 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar2 {Integer}
*/
bar2 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar3 {Integer}
*/
bar3 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar4 {Integer}
*/
bar4 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar5 {Integer}
*/
bar5 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar6 {Integer}
*/
bar6 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar7 {Integer}
*/
bar7 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar8 {Integer}
*/
bar8 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar9 {Integer}
*/
bar9 : 0,
/**
* Holds value of spectrum analyzer bar.
* @property bar10 {Integer}
*/
bar10 : 0,
/**
* Method provides randomization for spectrum analyzer bars.
* @method spectrumAnalyzerRandomize
*/
spectrumAnalyzerRandomize : function () {
SpectrumAnalyzerObj.bar1 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar2 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar3 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar4 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar5 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar6 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar7 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar8 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar9 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.bar10 = Math.floor((Math.random() * 6) + 1);
SpectrumAnalyzerObj.showSpectrumAnalyzer(this);
},
/**
* Method provides randomization for spectrum analyzer bars.
* @method showSpectrumAnalyzer
* @param thisObj {Object} Object which contains current object of this JQuery plugin.
*/
showSpectrumAnalyzer : function (thisObj) {
var bar1Count, bar2Count, bar3Count, bar4Count, bar5Count, bar6Count, bar7Count, bar8Count, bar9Count, bar10Count, bottom, i;
bar1Count = 2 * SpectrumAnalyzerObj.bar1;
bar2Count = 2 * SpectrumAnalyzerObj.bar2;
bar3Count = 2 * SpectrumAnalyzerObj.bar3;
bar4Count = 2 * SpectrumAnalyzerObj.bar4;
bar5Count = 2 * SpectrumAnalyzerObj.bar5;
bar6Count = 2 * SpectrumAnalyzerObj.bar6;
bar7Count = 2 * SpectrumAnalyzerObj.bar7;
bar8Count = 2 * SpectrumAnalyzerObj.bar8;
bar9Count = 2 * SpectrumAnalyzerObj.bar9;
bar10Count = 2 * SpectrumAnalyzerObj.bar10;
if (bar1Count > 12) {
bar1Count = 12;
}
if (bar2Count > 12) {
bar2Count = 12;
}
if (bar3Count > 12) {
bar3Count = 12;
}
if (bar4Count > 12) {
bar4Count = 12;
}
if (bar5Count > 12) {
bar5Count = 12;
}
if (bar6Count > 12) {
bar6Count = 12;
}
if (bar7Count > 12) {
bar7Count = 12;
}
if (bar8Count > 12) {
bar8Count = 12;
}
if (bar9Count > 12) {
bar9Count = 12;
}
if (bar10Count > 12) {
bar10Count = 12;
}
thisObj.empty();
bottom = 0;
for (i = 0; i < bar1Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar1" class="bar1Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar1" class="bar1Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar2Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar2" class="bar2Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar2" class="bar2Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar3Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar3" class="bar3Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar3" class="bar3Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar4Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar4" class="bar4Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar4" class="bar4Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar5Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar5" class="bar5Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar5" class="bar5Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar6Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar6" class="bar6Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar6" class="bar6Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar7Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar7" class="bar7Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar7" class="bar7Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar8Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar8" class="bar8Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar8" class="bar8Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar9Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar9" class="bar9Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar9" class="bar9Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
bottom = 0;
for (i = 0; i < bar10Count; i++) {
bottom = bottom + 5;
if ((i % 2) === 0) {
thisObj.append('<div id="bar10" class="bar10Class barAnalyzer" style="bottom:' + bottom + 'px;"></div>');
} else {
thisObj.append('<div id="bar10" class="bar10Class barAnalyzer bgColorTheme boxShadow1" style="bottom:' + bottom + 'px;"></div>');
}
}
},
/**
* Method provides clear for spectrum analyzer bars.
* @method clearSpectrumAnalyzer
*/
clearSpectrumAnalyzer : function () {
SpectrumAnalyzerObj.bar1 = 0;
SpectrumAnalyzerObj.bar2 = 0;
SpectrumAnalyzerObj.bar3 = 0;
SpectrumAnalyzerObj.bar4 = 0;
SpectrumAnalyzerObj.bar5 = 0;
SpectrumAnalyzerObj.bar6 = 0;
SpectrumAnalyzerObj.bar7 = 0;
SpectrumAnalyzerObj.bar8 = 0;
SpectrumAnalyzerObj.bar9 = 0;
SpectrumAnalyzerObj.bar10 = 0;
SpectrumAnalyzerObj.showSpectrumAnalyzer(this);
}
};
/**
* Class which provides acces to SpectrumAnalyzerObj methods.
* @class spectrumAnalyzer
* @constructor
* @param method {Object} Identificator (name) of method.
* @return Result of called method.
*/
$.fn.spectrumAnalyzer = function (method) {
// Method calling logic
if (SpectrumAnalyzerObj[method]) {
return SpectrumAnalyzerObj[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return SpectrumAnalyzerObj.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.spectrumAnalyzerAPI');
}
};
}(jQuery));
|