2 * Copyright (c) 2013, Intel Corporation.
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
13 /* replace colons and spaces with dash for jquery ids */
14 return '#' + id.replace(/:| |\//g, '-');
17 function showMsg(title, message) {
18 if (title === 'Error') {
19 console.error(message);
20 if (message.indexOf(ERROR_SETTINGSD_DISCONNECTED) >= 0) {
21 createPopupDialog(false, false, ERROR_SETTINGSD_DISCONNECTED, 'Reconnect?', 'OK', 'Cancel', function() {
22 console.log('Reconnecting to settings daemon...');
30 createPopupDialog(false, false, title, message);
33 function showInputDialog(title, input_message, ok_button_text, cancel_button_text, ok_callback) {
34 createPopupDialog(false, true, title, input_message, ok_button_text, cancel_button_text, ok_callback);
37 function createPopupDialog(dismiss, is_input, title, message, ok_button_text, cancel_button_text, ok_callback) {
38 // inject popup element
39 var $dialog = $('<div/>').popup({
42 }).bind('popupafterclose', function() {
43 // remove element from page
60 text: ok_button_text ? ok_button_text : 'Ok'
63 }).on('click', function() {
64 $dialog.popup('close');
67 /* TODO implement getting input from field */
76 if (cancel_button_text) {
77 /* only create cancel button if requested */
79 text: cancel_button_text,
82 }).on('click', function() {
83 $dialog.popup('close');
87 $dialog.popup('open').trigger('create');
93 function showSpinner(dismiss, message) {
94 $.mobile.loading('show', {
102 function hideSpinner() {
103 $.mobile.loading('hide');