Fixes TIVI-2784 - Wifi password is not empty
[profile/ivi/SettingsApp.git] / js / main.js
1 /*
2  * Copyright (c) 2013, Intel Corporation.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 (function() {
11
12     function connected() {
13         console.log('Settings daemon connected');
14     }
15
16     function disconnected(e) {
17         console.log('Settings daemon disconnected...');
18         if (e == null) {
19             showMsg('Error', 'Cannot connect to settings daemon');
20         } else {
21             showMsg('Error', e);
22         }
23     }
24
25     function init() {
26         console.log('Settings started...');
27         $('#quit').on('click', function() {
28             console.log('Settings exiting...');
29             tizen.application.getCurrentApplication().exit();
30         });
31
32         wsAPI.connect('ws://localhost:16000/', 'http-only', connected, disconnected);
33
34         try {
35             /* Settings Panel */
36             $('#main').on('pageshow', function(event, data) {
37                 /* TODO: unsubscribe events if neccessary */
38                 if (data.prevPage.attr('id') === 'page_connman') {
39                     console.log('Connman settings exited');
40                     wsAPI.unsubscribeEvents(connmanEventReceived);
41                 } else if (data.prevPage.attr('id') === 'page_bluetooth') {
42                     console.log('Bluetooth settings exited');
43                     wsAPI.unsubscribeEvents(bluetoothEventReceived);
44                 } else if (data.prevPage.attr('id') === 'page_datetime') {
45                     console.log('Date and Time settings exited');
46                 } else if (data.prevPage.attr('id') === 'page_locale') {
47                     console.log('Locale settings exited');
48                 }
49             });
50
51             /* Different sub panels */
52             connmanPanelInit();
53             bluetoothPanelInit();
54             datetimePanelInit();
55             localePanelInit();
56         } catch (e) {
57             showMsg('Error', 'Javascript Exception Caught: ' + e);
58         }
59     }
60
61     $(document).ready(function() {
62         init();
63     })
64 })();