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 var gInfoTitle = "", gInfo = "", gBatteryListener;
19 $(document).delegate("#main", "pageinit", function() {
20 $("#storage-info").bind("vclick", function() {
21 getSystemProperty("STORAGE", onStorageSuccess);
24 $("#battery-info").bind("vclick", function() {
25 getSystemProperty("BATTERY", onBatterySuccess);
28 $("#cpu-info").bind("vclick", function() {
29 getSystemProperty("CPU", onCpuInfoSuccess);
32 $("#display-info").bind("vclick", function() {
33 getSystemProperty("DISPLAY", onDisplaySuccess);
37 $("#orientation-info").bind("vclick", function() {
38 getSystemProperty("DEVICE_ORIENTATION", onOrientationSuccess);
42 $(window).on('tizenhwkey', function (e) {
43 if (e.originalEvent.keyName === "back") {
44 if ($.mobile.activePage.attr('id') === 'main') {
45 tizen.application.getCurrentApplication().exit();
53 $(document).delegate("#info", "pageinit", function() {
54 $("#info").bind("pagebeforeshow", function() {
55 $("#info-title").html(gInfoTitle);
56 $("#info-list").html(gInfo).trigger("create").listview("refresh");
61 alert("Error: " + e.message);
64 function make2lineListItem(title, value) {
65 return '<li class="ui-li-has-multiline ui-li-text-ellipsis">'
67 + '<span class="ui-li-text-sub">'
72 function make1lineListItem(value) {
73 return '<li>' + value + '</li>';
76 function makeDividerListItem(value) {
77 return '<li data-role="list-divider">' + value + '</li>';
80 function onStorageSuccess(storages) {
81 gInfoTitle = "Storages (" + storages.units.length + ")";
83 for (var i = 0; i < storages.units.length; i++) {
84 gInfo += makeDividerListItem("Storage " + (i + 1))
85 + make2lineListItem("Type", storages.units[i].type)
86 + make2lineListItem("Capacity", Math.floor(storages.units[i].capacity / 1000000) + " MB")
87 + make2lineListItem("Available capacity", Math.floor(storages.units[i].availableCapacity / 1000000) + " MB")
88 + make2lineListItem("Removable", (storages.units[i].isRemoveable == true ? "Yes" : "No"));
91 $.mobile.changePage("#info");
94 function onBatterySuccess(battery) {
95 gInfoTitle = "Battery";
96 gInfo = make2lineListItem("Level", battery.level)
97 + make2lineListItem("Charging", (battery.isCharging == true ? "Yes" : "No"));
99 $.mobile.changePage("#info");
102 function onCpuInfoSuccess(cpu) {
104 gInfo = make2lineListItem("Load", cpu.load);
106 $.mobile.changePage("#info");
109 function onDisplaySuccess(display) {
110 gInfoTitle = "Display";
111 gInfo = makeDividerListItem("Resolution")
112 + make2lineListItem("Width", display.resolutionWidth)
113 + make2lineListItem("Height", display.resolutionHeight)
114 + makeDividerListItem("Dots per inch")
115 + make2lineListItem("Horizontal", display.dotsPerInchWidth)
116 + make2lineListItem("Vertical", display.dotsPerInchHeight)
117 + makeDividerListItem("Physical size")
118 + make2lineListItem("Width", display.physicalWidth)
119 + make2lineListItem("Height", display.physicalHeight)
120 + makeDividerListItem("Brightness")
121 + make1lineListItem(display.brightness);
123 $.mobile.changePage("#info");
126 function onDeviceSuccess(device) {
127 gInfoTitle = "Device";
128 gInfo = make2lineListItem("IMEI", device.imei)
129 + make2lineListItem("Model", device.model)
130 + make2lineListItem("Version", device.version)
131 + make2lineListItem("Vendor", device.vendor);
133 $.mobile.changePage("#info");
136 function onOrientationSuccess(orientation) {
137 gInfoTitle = "Device orientation";
138 gInfo = make2lineListItem("Status", orientation.status);
140 $.mobile.changePage("#info");
143 function getSystemProperty(property, onSuccess) {
145 tizen.systeminfo.getPropertyValue(property, onSuccess, onError);
147 alert("Exception: " + e.message);