2 * @module DashboardApplication
6 * Class which provides methods to fill content of dashboard's UI.
7 * @class dashBoardControler
11 var dashBoardControler = function() {
17 * Method handles click event on rear left indicator.
18 * @method onRearLDisplayClick
20 dashBoardControler.prototype.onRearLDisplayClick = function() {
22 if (this.RearLDispaly) {
23 $('#rearLButtonText').removeClass("fontColorSelected");
24 $('#rearLButtonText').addClass("fontColorNormal");
25 $('#rearLButtonText').empty();
26 $('#rearLButtonText').append("OFF");
27 this.RearLDispaly = false;
29 $('#rearLButtonText').removeClass("fontColorNormal");
30 $('#rearLButtonText').addClass("fontColorSelected");
31 $('#rearLButtonText').empty();
32 $('#rearLButtonText').append("ON");
33 this.RearLDispaly = true;
38 * Method handles click event on rear right indicator.
39 * @method onRearRDisplayClick
41 dashBoardControler.prototype.onRearRDisplayClick = function() {
43 if (this.RearRDispaly) {
44 $('#rearRButtonText').removeClass("fontColorSelected");
45 $('#rearRButtonText').addClass("fontColorNormal");
46 $('#rearRButtonText').empty();
47 $('#rearRButtonText').append("OFF");
48 this.RearRDispaly = false;
50 $('#rearRButtonText').removeClass("fontColorNormal");
51 $('#rearRButtonText').addClass("fontColorSelected");
52 $('#rearRButtonText').empty();
53 $('#rearRButtonText').append("ON");
54 this.RearRDispaly = true;
59 * Method is setting status of child lock.
60 * @method onChildLockChanged
61 * @param newStatus {Boolean} New status of child lock of the car.
63 dashBoardControler.prototype.onChildLockChanged = function(newStatus) {
65 if (newStatus === false || newStatus === "false") {
66 $('#leftPadlock').removeClass("padlocActive");
67 $('#leftPadlock').addClass("padlocInactive");
68 $('#rightPadlock').removeClass("padlocActive");
69 $('#rightPadlock').addClass("padlocInactive");
70 $('#childLockText').removeClass("fontColorSelected");
71 $('#childLockText').addClass("fontColorNormal");
72 $('#childLockText').empty();
73 $('#childLockText').append("CHILD LOCK DEACTIVATED");
75 $('#leftPadlock').removeClass("padlocInactive");
76 $('#leftPadlock').addClass("padlocActive");
77 $('#rightPadlock').removeClass("padlocInactive");
78 $('#rightPadlock').addClass("padlocActive");
79 $('#childLockText').removeClass("fontColorNormal");
80 $('#childLockText').addClass("fontColorSelected");
81 $('#childLockText').empty();
82 $('#childLockText').append("CHILD LOCK ACTIVATED");
87 * Method is setting status of front lights of the car.
88 * @method onFrontLightsChanged
89 * @param newStatus {Boolean} New status of front lights of car.
91 dashBoardControler.prototype.onFrontLightsChanged = function(newStatus) {
93 if (newStatus === false || newStatus === "false") {
94 $('#frontLightsButton').css("opacity", "0");
95 $("#frontLightsImage").css("opacity", "0");
97 $('#frontLightsButton').css("opacity", "1");
98 $("#frontLightsImage").css("opacity", "1");
103 * Method is setting value of trasmission gear of the car.
104 * @method onGearChanged
105 * @param newStatus {String} New status value for trasmission gear.
107 dashBoardControler.prototype.onGearChanged = function(newStatus) {
109 $("#engineStatus #gearboxStatus").text(newStatus);
113 * Method is setting value of speed of the car.
114 * @method onSpeedChanged
115 * @param newStatus {Number} New value for the speed.
117 dashBoardControler.prototype.onSpeedChanged = function(newStatus) {
119 $("#engineStatus #textIndicator").text(newStatus + " mph");
123 * Method is setting value of odometer of the car.
124 * @method onOdoMeterChanged
125 * @param newStatus {Number} New value for the odoMeter.
127 dashBoardControler.prototype.onOdoMeterChanged = function(newStatus) {
129 $("#engineStatus #statusIndicator").text(newStatus + " mi");
133 * Method is setting status of rear lights of the car.
134 * @method onRearLightsChanged
135 * @param newStatus {Boolean} New status of rear lights of car.
137 dashBoardControler.prototype.onRearLightsChanged = function(newStatus) {
139 if (newStatus === false || newStatus === "false") {
140 $('#rearLightsButton').css("opacity", "0");
141 $("#rearLightsImage").css("opacity", "0");
143 $('#rearLightsButton').css("opacity", "1");
144 $("#rearLightsImage").css("opacity", "1");
148 * Method is setting status of break lights of the car.
149 * @method onBreakLightsChanged
150 * @param newStatus {Boolean} New status of break lights of car.
152 dashBoardControler.prototype.onBreakLightsChanged = function(newStatus) {
154 if (newStatus === false || newStatus === "false") {
155 $("#breakLightsImage").css("opacity", "0");
157 $("#breakLightsImage").css("opacity", "1");
161 * Method is setting status of fan in the car.
162 * @method onFanChanged
163 * @param newStatus {Boolean} New status of fan in the car.
165 dashBoardControler.prototype.onFanChanged = function(newStatus) {
167 if (newStatus === false || newStatus === "false") {
168 $('#fanCircle').css("opacity", "0");
169 $("#fanIcon").css("opacity", "0");
170 $("#fanIcon").css("-webkit-transform", "rotate(0deg)");
171 $("#fanIcon").css("-moz-transform", "rotate(0deg)");
172 $("#fanIcon").css("-ms-transform", "rotate(0deg)");
173 $("#fanIcon").css("-o-transform", "rotate(0deg)");
174 $('#fanStatus').removeClass("fontColorSelected");
175 $('#fanStatus').addClass("fontColorNormal");
177 $('#fanCircle').css("opacity", "1");
178 $("#fanIcon").css("opacity", "1");
179 $("#fanIcon").css("-webkit-transform", "rotate(720deg)");
180 $("#fanIcon").css("-moz-transform", "rotate(720deg)");
181 $("#fanIcon").css("-ms-transform", "rotate(720deg)");
182 $("#fanIcon").css("-o-transform", "rotate(720deg)");
183 $('#fanStatus').removeClass("fontColorNormal");
184 $('#fanStatus').addClass("fontColorSelected");
189 * Method is setting status of exterior brightness .
190 * @method onExteriorBrightnessChanged
191 * @param newStatus {Boolean} New exterior brightness value.
193 dashBoardControler.prototype.onExteriorBrightnessChanged = function(newValue) {
195 var newValueP = (Math.abs(newValue) / 5000) * 100;
196 if (newValueP > 100) {
199 $("#exteriorBrightnessProgressBar").progressBarPlugin('setPosition', newValueP);
203 * Method is setting new value of battery status.
204 * @method onBatteryStatusChanged
205 * @param newValue {Integer} New battery status value.
206 * @param status {bootstrap.carIndicator.status} Current status object.
208 dashBoardControler.prototype.onBatteryStatusChanged = function(newValue, status) {
210 $("#batteryProgressBar").progressBarPlugin('setPosition', newValue);
211 var newBatteryStatus = newValue.toString() + "%";
212 $('#batteryStatus').empty();
213 $('#batteryStatus').append(newBatteryStatus);
214 var newBatteryRange = "~" + Math.round(((newValue / 100) * status.fullBatteryRange)).toString() + " MI";
215 $('#batteryRange').empty();
216 $('#batteryRange').append(newBatteryRange);
220 * Method is setting new value of full battery range.
221 * @method onBatteryRangeChanged
222 * @param newValue {Integer} New full battery range value.
223 * @param status {bootstrap.carIndicator.status} Current status object.
225 dashBoardControler.prototype.onBatteryRangeChanged = function(newValue, status) {
229 $('#batteryStatus').empty();
231 $('#batteryStatus').append(newValue);
232 var newBatteryRange = "~" + Math.round(((status.batteryStatus / 100) * newValue)).toString() + " MI";
233 $('#batteryRange').empty();
234 $('#batteryRange').append(newBatteryRange);
238 * Method is setting new value of outside temperature.
239 * @method onOutsiteTempChanged
240 * @param newValue {Number} New outside temperature status value.
242 dashBoardControler.prototype.onOutsiteTempChanged = function(newValue) {
244 var newOutsiteTemp = newValue + "°C";
245 $("#weatherStatus").empty();
246 $("#weatherStatus").append(newOutsiteTemp);
250 * Method is setting new value of Avg KW.
251 * @method onAvgKWChanged
252 * @param newValue {Number} New Avg KW status value.
254 dashBoardControler.prototype.onAvgKWChanged = function(newValue) {
256 var newAvgKW = newValue + " KW-H / MI";
257 $("#avgConsumptionCaption").empty();
258 $("#avgConsumptionCaption").append(newAvgKW);
262 * Method is setting new value of night mode indicator .
263 * @method onNightModeChanged
264 * @param newValue {Boolean} New value of day/night mode .
266 dashBoardControler.prototype.onNightModeChanged = function(newValue) {
269 $("#dayNight").removeClass("dashboardSunElement");
270 $("#dayNight").addClass("dashboardMoonElement");
272 $("#dayNight").removeClass("dashboardMoonElement");
273 $("#dayNight").addClass("dashboardSunElement");
279 * Method is setting new value of inside temperature.
280 * @method onInsideTempChanged
281 * @param newValue {Number} New inside temperature status value.
283 dashBoardControler.prototype.onInsideTempChanged = function(newValue) {
285 var newInsiteTemp = newValue + "°F";
286 $("#fanStatus").empty();
287 $("#fanStatus").append(newInsiteTemp);
291 * Method is setting new value of weather. Weather is coded to following values:
293 * * 1 - Cloudy weather
294 * * 2 - Sunny weather
295 * * 3 - Stormy weather
297 * @method onWeatherChanged
298 * @param newWeater {Integer} New weather status value.
300 dashBoardControler.prototype.onWeatherChanged = function(newValue) {
302 if (newValue === 1) {
303 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherSun");
304 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherCloudy");
305 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherThunder");
306 $("#dashBoardWeatherIcon").addClass("dashBoardWeatherCloudy");
308 } else if (newValue === 2) {
309 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherSun");
310 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherCloudy");
311 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherThunder");
312 $("#dashBoardWeatherIcon").addClass("dashBoardWeatherSun");
315 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherSun");
316 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherCloudy");
317 $("#dashBoardWeatherIcon").removeClass("dashBoardWeatherThunder");
318 $("#dashBoardWeatherIcon").addClass("dashBoardWeatherThunder");
323 * Method is setting new value of angle of front wheels.
324 * @method onWheelAngleChanged
325 * @param newAngle {Integer} New angle status value for wheels.
327 dashBoardControler.prototype.onWheelAngleChanged = function(newAngle) {
331 newAngle = (-1 * (360 - newAngle));
333 if (newAngle > maxAngle) {
335 } else if (newAngle < (-maxAngle)) {
336 newAngle = -maxAngle;
337 } else if (newAngle === "") {
341 var newDuration = Math.round(Math.abs(newAngle) / 10);
342 if (newDuration === 0) {
346 $("#leftWhell").css("-webkit-transition", newDuration + "s");
347 $("#leftWhell").css("-webkit-transform", "rotate(" + newAngle + "deg)");
348 $("#rightWhell").css("-webkit-transition", newDuration + "s");
349 $("#rightWhell").css("-webkit-transform", "rotate(" + newAngle + "deg)");
351 $("#leftWhell").css("-moz-transition", newDuration + "s");
352 $("#leftWhell").css("-moz-transform", "rotate(" + newAngle + "deg)");
353 $("#rightWhell").css("-moz-transition", newDuration + "s");
354 $("#rightWhell").css("-moz-transform", "rotate(" + newAngle + "deg)");
356 $("#leftWhell").css("-ms-transition", newDuration + "s");
357 $("#leftWhell").css("-ms-transform", "rotate(" + newAngle + "deg)");
358 $("#rightWhell").css("-ms-transition", newDuration + "s");
359 $("#rightWhell").css("-ms-transform", "rotate(" + newAngle + "deg)");
361 $("#leftWhell").css("-o-transition", newDuration + "s");
362 $("#leftWhell").css("-o-transform", "rotate(" + newAngle + "deg)");
363 $("#rightWhell").css("-o-transition", newDuration + "s");
364 $("#rightWhell").css("-o-transform", "rotate(" + newAngle + "deg)");
368 * Method is setting new value of randomizer.
369 * @method onRandomizerChanged
370 * @param newStatus {Boolean} New randomizer status.
372 dashBoardControler.prototype.onRandomizerChanged = function(newStatus) {
374 if (newStatus === false || newStatus === "false") {
375 $('#randomizer').css("opacity", "0");
376 $("#randomizer").css("opacity", "0");
378 $('#randomizer').css("opacity", "1");
379 $("#randomizer").css("opacity", "1");
384 * Method initialize info status on HTML and jQuery plugins.
387 dashBoardControler.prototype.initInfos = function() {
389 $("#weatherCaption").boxCaptionPlugin('init', 'weather');
391 $("#exteriorBrightnessCaption").boxCaptionPlugin('init', 'Exterior Brightness');
393 $("#exteriorBrightnessProgressBar").progressBarPlugin('init', 'progressBar');
394 $("#exteriorBrightnessProgressBar").progressBarPlugin('setPosition', 30);
396 $("#batteryLevelCaption").boxCaptionPlugin('init', 'Battery level');
398 $("#batteryProgressBar").progressBarPlugin('init', 'progressBar');
399 $("#batteryProgressBar").progressBarPlugin('setPosition', 82);
401 $("#avgEConsumption").boxCaptionPlugin('init', 'avg e-consumtion');
402 $("#rearLDisplay").boxCaptionPlugin('init', 'Rear l Display');
403 $("#rearRDisplay").boxCaptionPlugin('init', 'Rear r Display');
405 $('#bottomPanel').bottomPanel('init');
407 $("#leftFrontPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'L FRONT TIRE', 'OK');
408 $("#rightFrontPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'R FRONT TIRE', 'ok');
410 $("#leftRearPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'L Rear TIRE', 'OK');
411 $("#rightRearPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'R Rear TIRE', 'ok');
415 * Method is setting new value of left front tire pressure.
416 * @method onTirePressureLeftFrontChanged
417 * @param newValue {FLoat} new tire pressure status. If is status between 1.8 and 2.2 new status value is string "OK".
419 dashBoardControler.prototype.onTirePressureLeftFrontChanged = function(newValue) {
421 $("#leftFrontPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'L FRONT TIRE', newValue);
424 * Method is setting new value of right front tire pressure.
425 * @method onTirePressureRightFrontChanged
426 * @param newValue {FLoat} new tire pressure status. If is status between 1.8 and 2.2 new status value is string "OK".
428 dashBoardControler.prototype.onTirePressureRightFrontChanged = function(newValue) {
430 $("#rightFrontPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'R FRONT TIRE', newValue);
433 * Method is setting new value of left rear tire pressure.
434 * @method onTirePressureLeftRearChanged
435 * @param newValue {FLoat} new tire pressure status. If is status between 1.8 and 2.2 new status value is string "OK".
437 dashBoardControler.prototype.onTirePressureLeftRearChanged = function(newValue) {
439 $("#leftRearPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'L Rear TIRE', newValue);
442 * Method is setting new value of right rear tire pressure.
443 * @method onTirePressureRightRearChanged
444 * @param newValue {FLoat} new tire pressure status. If is status between 1.8 and 2.2 new status value is string "OK".
446 dashBoardControler.prototype.onTirePressureRightRearChanged = function(newValue) {
448 $("#rightRearPressure").statusBoxPlugin('init', 'PRESSSURE LEVEL', 'R Rear TIRE', newValue);