2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*jslint devel: true*/
18 /*global $, tizen, window*/
20 var gInfoTitle = '', gInfo = '', gBatteryListener;
22 $(document).delegate('#info', 'pageinit', function () {
24 $('#info').bind('pagebeforeshow', function () {
25 $('#info-title').html(gInfoTitle);
26 $('#info-list').html(gInfo).trigger('create').listview('refresh');
32 alert('Error: ' + e.message);
35 function make2lineListItem(title, value) {
37 return '<li class="ui-li-has-multiline ui-li-text-ellipsis">'
39 + '<span class="ui-li-text-sub">'
44 function make1lineListItem(value) {
46 return '<li>' + value + '</li>';
49 function makeDividerListItem(value) {
51 return '<li data-role="list-divider">' + value + '</li>';
54 function onStorageSuccess(storages) {
57 gInfoTitle = 'Storages (' + storages.units.length + ')';
59 for (i = 0; i < storages.units.length; i = i + 1) {
60 gInfo += makeDividerListItem('Storage ' + (i + 1))
61 + make2lineListItem('Type', storages.units[i].type)
62 + make2lineListItem('Capacity',
63 Math.floor(storages.units[i].capacity / 1000000) + ' MB')
64 + make2lineListItem('Available capacity',
65 Math.floor(storages.units[i].availableCapacity / 1000000)
67 + make2lineListItem('Removable',
68 (storages.units[i].isRemoveable === true ? 'Yes' : 'No'));
71 $.mobile.changePage('#info');
74 function onBatterySuccess(battery) {
76 gInfoTitle = 'Battery';
77 gInfo = make2lineListItem('Level', battery.level)
78 + make2lineListItem('Charging',
79 (battery.isCharging === true ? 'Yes' : 'No'));
81 $.mobile.changePage('#info');
84 function onCpuInfoSuccess(cpu) {
87 gInfo = make2lineListItem('Load', cpu.load);
89 $.mobile.changePage('#info');
92 function onDisplaySuccess(display) {
94 gInfoTitle = 'Display';
95 gInfo = makeDividerListItem('Resolution')
96 + make2lineListItem('Width', display.resolutionWidth)
97 + make2lineListItem('Height', display.resolutionHeight)
98 + makeDividerListItem('Dots per inch')
99 + make2lineListItem('Horizontal', display.dotsPerInchWidth)
100 + make2lineListItem('Vertical', display.dotsPerInchHeight)
101 + makeDividerListItem('Physical size')
102 + make2lineListItem('Width', display.physicalWidth)
103 + make2lineListItem('Height', display.physicalHeight)
104 + makeDividerListItem('Brightness')
105 + make1lineListItem(display.brightness);
107 $.mobile.changePage('#info');
110 function onDeviceSuccess(device) {
112 gInfoTitle = 'Device';
113 gInfo = make2lineListItem('IMEI', device.imei)
114 + make2lineListItem('Model', device.model)
115 + make2lineListItem('Version', device.version)
116 + make2lineListItem('Vendor', device.vendor);
118 $.mobile.changePage('#info');
121 function onOrientationSuccess(orientation) {
123 gInfoTitle = 'Device orientation';
124 gInfo = make2lineListItem('Status', orientation.status);
126 $.mobile.changePage('#info');
129 function getSystemProperty(property, onSuccess) {
132 tizen.systeminfo.getPropertyValue(property, onSuccess, onError);
134 alert('Exception: ' + e.message);
138 $(document).delegate('#main', 'pageinit', function () {
140 $('#storage-info').bind('vclick', function () {
141 getSystemProperty('STORAGE', onStorageSuccess);
144 $('#battery-info').bind('vclick', function () {
145 getSystemProperty('BATTERY', onBatterySuccess);
148 $('#cpu-info').bind('vclick', function () {
149 getSystemProperty('CPU', onCpuInfoSuccess);
152 $('#display-info').bind('vclick', function () {
153 getSystemProperty('DISPLAY', onDisplaySuccess);
157 $('#orientation-info').bind('vclick', function () {
158 getSystemProperty('DEVICE_ORIENTATION', onOrientationSuccess);
162 $(window).on('tizenhwkey', function (e) {
163 if (e.originalEvent.keyName === 'back') {
164 if ($.mobile.activePage.attr('id') === 'main') {
165 tizen.application.getCurrentApplication().exit();