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 $("#main .ui-btn-back").bind("vclick", function() {
21 tizen.application.getCurrentApplication().exit();
24 $("#storage-info").bind("vclick", function() {
25 getSystemProperty("STORAGE", onStorageSuccess);
28 $("#battery-info").bind("vclick", function() {
29 getSystemProperty("BATTERY", onBatterySuccess);
32 $("#cpu-info").bind("vclick", function() {
33 getSystemProperty("CPU", onCpuInfoSuccess);
36 $("#display-info").bind("vclick", function() {
37 getSystemProperty("DISPLAY", onDisplaySuccess);
41 $("#orientation-info").bind("vclick", function() {
42 getSystemProperty("DEVICE_ORIENTATION", onOrientationSuccess);
47 $(document).delegate("#info", "pageinit", function() {
48 $("#info").bind("pagebeforeshow", function() {
49 $("#info-title").html(gInfoTitle);
50 $("#info-list").html(gInfo).trigger("create").listview("refresh");
55 alert("Error: " + e.message);
58 function make2lineListItem(title, value) {
59 return '<li class="ui-li-has-multiline ui-li-text-ellipsis">'
61 + '<span class="ui-li-text-sub">'
66 function make1lineListItem(value) {
67 return '<li>' + value + '</li>';
70 function makeDividerListItem(value) {
71 return '<li data-role="list-divider">' + value + '</li>';
74 function onStorageSuccess(storages) {
75 gInfoTitle = "STORAGES(" + storages.length + ")";
77 for (var i = 0; i < storages.length; i++) {
78 gInfo += makeDividerListItem("Storage " + (i + 1))
79 + make2lineListItem("Type", storages[i].type)
80 + make2lineListItem("Capacity", Math.floor(storages[i].capacity / 1000000) + " MB")
81 + make2lineListItem("Available capacity", Math.floor(storages[i].availableCapacity / 1000000) + " MB")
82 + make2lineListItem("Removable", (storages[i].isRemoveable == true ? "Yes" : "No"));
85 $.mobile.changePage("#info");
88 function onBatterySuccess(battery) {
89 gInfoTitle = "BATTERY";
90 gInfo = make2lineListItem("Level", battery.level)
91 + make2lineListItem("Charging", (battery.isCharging == true ? "Yes" : "No"));
93 $.mobile.changePage("#info");
96 function onCpuInfoSuccess(cpu) {
98 gInfo = make2lineListItem("Load", cpu.load);
100 $.mobile.changePage("#info");
103 function onDisplaySuccess(display) {
104 gInfoTitle = "DISPLAY";
105 gInfo = makeDividerListItem("Resolution")
106 + make2lineListItem("Width", display.resolutionWidth)
107 + make2lineListItem("Height", display.resolutionHeight)
108 + makeDividerListItem("Dots per inch")
109 + make2lineListItem("Horizontal", display.dotsPerInchWidth)
110 + make2lineListItem("Vertical", display.dotsPerInchHeight)
111 + makeDividerListItem("Physical size")
112 + make2lineListItem("Width", display.physicalWidth)
113 + make2lineListItem("Height", display.physicalHeight)
114 + makeDividerListItem("Brightness")
115 + make1lineListItem(display.brightness);
117 $.mobile.changePage("#info");
120 function onDeviceSuccess(device) {
121 gInfoTitle = "DEVICE";
122 gInfo = make2lineListItem("IMEI", device.imei)
123 + make2lineListItem("Model", device.model)
124 + make2lineListItem("Version", device.version)
125 + make2lineListItem("Vendor", device.vendor);
127 $.mobile.changePage("#info");
130 function onOrientationSuccess(orientation) {
131 gInfoTitle = "DEVICE ORIENTATION";
132 gInfo = make2lineListItem("Status", orientation.status);
134 $.mobile.changePage("#info");
137 function getSystemProperty(property, onSuccess) {
139 tizen.systeminfo.getPropertyValue(property, onSuccess, onError);
141 alert("Exception: " + e.message);