45dff1d5955b3d79890ace2cbb1d4da3392b1ecd
[profile/ivi/sdk/web-sample-build.git] / samples / web / Sample / Tizen / Web App / Modello_Dashboard / project / js / main.js
1 /*global Bootstrap, dashBoardControler */
2
3 /**
4  * DashBoard application show information about vehicle from [tizen.vehicle API](https://raw.github.com/otcshare/automotive-message-broker/master/docs/amb.idl).
5  * Uses mainly {{#crossLink "CarIndicator"}}{{/crossLink}} module from {{#crossLink "Bootstrap/carIndicator:property"}}{{/crossLink}}. Dashboard application uses following
6  * AMB properties to show car data in display only mode:
7  *
8  * * SteeringWheelAngle
9  *   * SteeringWheelAngle
10  * * WheelBrake
11  *   * Engaged
12  * * TirePressure
13  *   * leftFront
14  *   * rightFront
15  *   * leftRear
16  *   * rightRear
17  * * DoorStatus
18  *   * ChildLockStatus
19  * * LightStatus
20  *   * Hazard
21  *   * Head
22  *   * Parking
23  * * BatteryStatus
24  * * FullBatteryRange
25  * * ExteriorTemperature
26  *   * Exterior
27  * * InteriorTemperature
28  *   * Interior
29  * * WheelInformation
30  *   * FrontWheelRadius
31  * * AvgKW
32  *   * AvgKW
33  * * VehicleSpeed
34  * * Odometer
35  * * Transmission
36  *   * ShiftPosition
37  * * ExteriorBrightness
38  * * NightMode
39  *
40  *
41  * Hover and click on elements in images below to navigate to components of Home screen application.
42  *
43  * <img id="Image-Maps_1201312180420487" src="../assets/img/dashboard.png" usemap="#Image-Maps_1201312180420487" border="0" width="649" height="1152" alt="" />
44  *   <map id="_Image-Maps_1201312180420487" name="Image-Maps_1201312180420487">
45  *     <area shape="rect" coords="0,0,573,78" href="../classes/TopBarIcons.html" alt="top bar icons" title="Top bar icons" />
46  *     <area shape="rect" coords="0,77,644,132" href="../classes/Clock.html" alt="clock" title="Clock"    />
47  *     <area shape="rect" coords="0,994,644,1147" href="../classes/BottomPanel.html" alt="bottom panel" title="Bottom panel" />
48  *     <area shape="rect" coords="573,1,644,76" href="../modules/Settings.html" alt="Settings" title="Settings" />
49  *     <area  shape="rect" coords="21,132,90,194" alt="Day/Night mode" title="Day/Night mode" target="_self" href="../classes/dashBoardControler.html#method_onNightModeChanged"     >
50  *     <area  shape="rect" coords="415,128,648,173" alt="Exterior Brightness" title="Exterior Brightness" target="_self" href="../classes/dashBoardControler.html#method_onExteriorBrightnessChanged"     >
51  *     <area  shape="rect" coords="372,173,638,279" alt="Weather" title="Weather" target="_self" href="../classes/dashBoardControler.html#method_onWeatherChanged"     >
52  *     <area  shape="rect" coords="21,196,348,292" alt="Battery Level" title="Battery Level" target="_self" href="../classes/dashBoardControler.html#method_onBatteryStatusChanged"     >
53  *     <area  shape="rect" coords="193,395,451,477" alt="Wheel radius" title="Wheel radius" target="_self" href="../classes/dashBoardControler.html#method_onWheelAngleChanged"     >
54  *     <area  shape="rect" coords="224,320,425,398" alt="Front lights status" title="Front lights status" target="_self" href="../classes/dashBoardControler.html#method_onFrontLightsChanged"     >
55  *     <area  shape="rect" coords="472,509,557,541" alt="Speed" title="Speed" target="_self" href="../classes/dashBoardControler.html#method_onSpeedChanged"     >
56  *     <area  shape="rect" coords="556,509,613,558" alt="Transmission Gear" title="Transmission Gear" target="_self" href="../classes/dashBoardControler.html#method_onGearChanged"     >
57  *     <area  shape="rect" coords="34,564,215,664" alt="Child lock status" title="Child lock status" target="_self" href="../classes/dashBoardControler.html#method_onChildLockChanged"     >
58  *     <area  shape="rect" coords="9,904,212,940" alt="Average KW" title="Average KW" target="_self" href="..//classes/dashBoardControler.html#method_onAvgKWChanged"     >
59  *     <area  shape="rect" coords="11,937,200,962" alt="Battery range" title="Battery range" target="_self" href="../classes/dashBoardControler.html#method_onBatteryRangeChanged"     >
60  *     <area  shape="rect" coords="477,540,556,562" alt="Odometer" title="Odometer" target="_self" href="../classes/dashBoardControler.html#method_onOdoMeterChanged"     >
61  *     <area  shape="rect" coords="204,767,441,805" alt="Rear lights" title="Rear lights" target="_self" href="../classes/dashBoardControler.html#method_onRearLightsChanged"     >
62  *     <area  shape="rect" coords="205,823,442,861" alt="Break lights" title="Break lights" target="_self" href="../classes/dashBoardControler.html#method_onBreakLightsChanged"     >
63  *     <area  shape="rect" coords="27,332,188,410" alt="Left front tire pressure" title="Left front tire pressure" target="_self" href="../classes/dashBoardControler.html#method_onTirePressureLeftFrontChanged"     >
64  *     <area  shape="rect" coords="447,304,608,382" alt="Right front tire pressure" title="Right front tire pressure" target="_self" href="../classes/dashBoardControler.html#method_onTirePressureRightFrontChanged"     >
65  *     <area  shape="rect" coords="18,676,179,754" alt="Left rear tire pressure" title="Left rear tire pressure" target="_self" href="../classes/dashBoardControler.html#method_onTirePressureLeftRearChanged"     >
66  *     <area  shape="rect" coords="458,677,621,752" alt="Right rear tire pressure" title="Right rear tire pressure" target="_self" href="../classes/dashBoardControler.html#method_onTirePressureRightRearChanged"     >
67  *   </map>
68  * @module DashboardApplication
69  * @main DashboardApplication
70  * @class Dashboard
71  */
72
73 /**
74  * Reference to instance of dashBoardIndicator this class manage graphics elements on dasboard
75  * @property dashBoardIndicator {dashBoardIndicator}
76  */
77 var dashBoardIndicator;
78
79 /**
80  * Reference to instance of bootstrap class this class help booting  theme , config and carIndicator
81  * @property bootstrap {Bootstrap}
82  * @private
83  */
84 var bootstrap;
85
86 /**
87  * Method initializes user interface and create events listeners for status indicators.
88  * @method init
89  */
90 var init = function () {
91     "use strict";
92     dashBoardIndicator = new dashBoardControler();
93     bootstrap = new Bootstrap(function (status) {
94         $('#clockElement').ClockPlugin('init', 60);
95         $('#clockElement').ClockPlugin('startTimer');
96
97         $('#bottomPanel').bottomPanel('init', 'withoutBack');
98         $("#topBarIcons").topBarIconsPlugin('init');
99
100         bootstrap.carIndicator.addListener({
101             /* this si for steeringWheel game controler */
102             onSteeringWheelAngleChanged : function(newValue){
103                 dashBoardIndicator.onWheelAngleChanged(newValue,bootstrap.carIndicator.status);
104             },
105             onWheelBrakeChanged : function(newValue){
106                 dashBoardIndicator.onBreakLightsChanged(newValue);
107             },
108             /* end steeringWheel game controler*/
109             onTirePressureLeftFrontChanged : function (newValue){
110                 dashBoardIndicator.onTirePressureLeftFrontChanged(newValue);
111             },
112             onTirePressureRightFrontChanged : function (newValue){
113                 dashBoardIndicator.onTirePressureRightFrontChanged(newValue);
114             },
115             onTirePressureLeftRearChanged : function (newValue){
116                 dashBoardIndicator.onTirePressureLeftRearChanged(newValue);
117             },
118             onTirePressureRightRearChanged : function (newValue){
119                 dashBoardIndicator.onTirePressureRightRearChanged(newValue);
120             },
121             onChildLockChanged : function(newValue){
122                 dashBoardIndicator.onChildLockChanged(newValue);
123             },
124             onFrontLightsChanged : function(newValue){
125                 dashBoardIndicator.onFrontLightsChanged(newValue);
126             },
127             onRearLightsChanged : function(newValue){
128                 dashBoardIndicator.onRearLightsChanged(newValue);
129             },
130             onBatteryStatusChanged : function(newValue) {
131                 dashBoardIndicator.onBatteryStatusChanged(newValue,bootstrap.carIndicator.status);
132             },
133             onFullBatteryRange : function(newValue) {
134                 dashBoardIndicator.onBatteryRangeChanged(newValue,bootstrap.carIndicator.status);
135             },
136             onOutsideTempChanged : function(newValue) {
137                dashBoardIndicator.onOutsiteTempChanged(newValue);
138             },
139             onInsideTempChanged : function(newValue) {
140                 dashBoardIndicator.onInsideTempChanged(newValue);
141             },
142             onWheelAngleChanged : function(newValue){
143                 dashBoardIndicator.onWheelAngleChanged(newValue,bootstrap.carIndicator.status);
144             },
145             onWeatherChanged : function(newValue){
146                 dashBoardIndicator.onWeatherChanged(newValue);
147             },
148             onSpeedChanged : function(newValue) {
149                 dashBoardIndicator.onSpeedChanged(newValue);
150             },
151             onOdoMeterChanged : function(newValue){
152                 dashBoardIndicator.onOdoMeterChanged(newValue);
153             },
154             onGearChanged : function(newValue){
155                 dashBoardIndicator.onGearChanged(newValue);
156             },
157             onRandomizeChanged : function(newValue) {
158                 dashBoardIndicator.onRandomizerChanged(newValue);
159             },
160             onNightModeChanged : function(newValue) {
161                 dashBoardIndicator.onNightModeChanged(newValue);
162             },
163             onExteriorBrightnessChanged : function(newValue) {
164                 dashBoardIndicator.onExteriorBrightnessChanged(newValue);
165             },
166             onAvgKWChanged : function(newValue) {
167                 dashBoardIndicator.onAvgKWChanged(newValue);
168             }
169         });
170     });
171 };
172
173 $(document).ready(init);