From aacd6c3fa1168160f95e585c1202ec9b6d7bb262 Mon Sep 17 00:00:00 2001
From: Editor Lionbridge Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: Code example: var appId = tizen.application.getCurrentApplication().appInfo.id;
- tizen.account.getAccounts(function(accounts) {
- var account = accounts[0];
- if(account) {
- var key = 'nickname';
- var value = 'nickname of anonymous user';
- account.setExtendedData(key, value);
- console.log(account.getExtendedData(key)); // 'nickname of anonymous user'
-
- account.setExtendedData(key, 'nickname updated');
- console.log(account.getExtendedData(key)); // 'nickname updated'
- }
- }, function(e) {
- console.log('Error: ' + e.message);
- }, appId);
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+tizen.account.getAccounts(function(accounts)
+{
+ var account = accounts[0];
+ if (account)
+ {
+ var key = 'nickname';
+ var value = 'nickname of anonymous user';
+ account.setExtendedData(key, value);
+ console.log(account.getExtendedData(key)); /* 'Nickname of anonymous user' */
+
+ account.setExtendedData(key, 'nickname updated');
+ console.log(account.getExtendedData(key)); /* 'Nickname updated' */
+ }
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, appId);
+
var appId = tizen.application.getCurrentApplication().appInfo.id;
- tizen.account.getAccounts(function(accounts) {
- var account = accounts[0];
- if(account) {
- var key = 'accessToken';
- var value = account.getExtendedData(key);
- console.log(account.userName + "'s accessToken is " + value);
- }
- }, function(e) {
- console.log('Error: ' + e.message);
- }, appId);
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+tizen.account.getAccounts(function(accounts)
+{
+ var account = accounts[0];
+ if (account)
+ {
+ var key = 'accessToken';
+ var value = account.getExtendedData(key);
+ console.log(account.userName + "'s accessToken is " + value);
+ }
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, appId);
+
var appId = tizen.application.getCurrentApplication().appInfo.id;
- tizen.account.getAccounts(function(accounts) {
- var account = accounts[0];
- if(account) {
- account.getExtendedData(function(extendedData) {
- for(var i=0; i < extendedData.length; i++) {
- var key = extendedData.key;
- var value = extendedData.value;
- console.log(key + " : " + value);
- }
- }, function(e) {
- console.log("Error : " + e.message);
- });
- }
- }, function(e) {
- console.log('Error: ' + e.message);
- }, appId);
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+tizen.account.getAccounts(function(accounts)
+{
+ var account = accounts[0];
+ if (account)
+ {
+ account.getExtendedData(function(extendedData)
+ {
+ for (var i = 0; i < extendedData.length; i++)
+ {
+ var key = extendedData.key;
+ var value = extendedData.value;
+ console.log(key + ": " + value);
+ }
+ }, function(e)
+ {
+ console.log("Error: " + e.message);
+ });
+ }
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, appId);
+
For more detail
var appId = tizen.application.getCurrentApplication().appInfo.id;
- var provider = tizen.account.getProvider(appId);
- var account = new tizen.Account(provider, {userName: 'admin', iconUri: 'path/to/icon.jpg'});
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+var provider = tizen.account.getProvider(appId);
+var account = new tizen.Account(provider, {userName: 'admin', iconUri: 'path/to/icon.jpg'});
- tizen.account.add(account);
-
+tizen.account.add(account);
+ var appId = tizen.application.getCurrentApplication().appInfo.id;
- tizen.account.getAccounts(function(accounts) {
- var account = accounts[0];
- if(account) {
- tizen.account.remove(account.id);
- }
- }, function(e) {
- console.log('Error: ' + e.message);
- }, appId);
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+tizen.account.getAccounts(function(accounts)
+{
+ var account = accounts[0];
+ if (account)
+ {
+ tizen.account.remove(account.id);
+ }
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, appId);
+
var appId = tizen.application.getCurrentApplication().appInfo.id;
- tizen.account.getAccounts(function(accounts) {
- var account = accounts[0];
- if(account) {
- account.userName = 'abc';
- tizen.account.update(account);
- })
- }, function(e) {
- console.log('Error: ' + e.message);
- }, appId);
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+tizen.account.getAccounts(function(accounts)
+{
+ var account = accounts[0];
+ if (account)
+ {
+ account.userName = 'abc';
+ tizen.account.update(account);
+ }
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, appId);
+
var account = tizen.account.getAccount(1);
-
+
+var account = tizen.account.getAccount(1);
+
tizen.account.getAccounts(function(accounts) {
- // accounts is an array whose members are all registered accounts in this device.
- }, function (e) {
- console.log("Error : " + e.message);
- });
-
-
+
+tizen.account.getAccounts(function(accounts)
+{
+ /* accounts is an array whose members are all registered accounts in this device */
+}, function(e)
+{
+ console.log("Error: " + e.message);
+});
+
var appId = tizen.application.getCurrentApplication().appInfo.id;
- var provider = tizen.account.getProvider(appId);
- if (!provider) {
- console.log('current application is not account provider.');
- }
-
+
+var appId = tizen.application.getCurrentApplication().appInfo.id;
+var provider = tizen.account.getProvider(appId);
+if (!provider)
+{
+ console.log('current application is not account provider.');
+}
+
tizen.account.getProviders(function(providers) {
- // providers is an array whose members are account providers
- // which have contact capability.
- }, function (e) {
- console.log('Error : ' + e.message);
- }, "http://tizen.org/account/capability/contact");
-
+
+tizen.account.getProviders(function(providers)
+{
+ /*
+ providers is an array whose members are account providers
+ which have contact capability
+ */
+}, function(e)
+{
+ console.log('Error: ' + e.message);
+}, "http://tizen.org/account/capability/contact");
+
tizen.account.addAccountListener({
- onadded: function(account) {
- // a callback function which will be called when account is added.
- },
- onremoved: function(accountId) {
- // a callback function which will be called when account is removed.
- },
- onupdated: function(account) {
- // a callback function which will be called when account is updated.
- }
- });
-
+
+tizen.account.addAccountListener(
+{
+ onadded: function(account)
+ {
+ /* Callback function which will be called when account is added */
+ },
+ onremoved: function(accountId)
+ {
+ /* Callback function which will be called when account is removed */
+ },
+ onupdated: function(account)
+ {
+ /* Callback function which will be called when account is updated */
+ }
+});
+
var watchId = tizen.account.addAccountListener({
- onadded: function(account) {
- // a callback function which will be called when account is added.
- },
- onremoved: function(accountId) {
- // a callback function which will be called when account is removed.
- },
- onupdated: function(account) {
- // a callback function which will be called when account is updated.
- }
- });
- tizen.account.removeAccountListener(watchId);
-
+
+var watchId = tizen.account.addAccountListener(
+{
+ onadded: function(account)
+ {
+ /* Callback function which will be called when account is added */
+ },
+ onremoved: function(accountId)
+ {
+ /* Callback function which will be called when account is removed */
+ },
+ onupdated: function(account)
+ {
+ /* Callback function which will be called when account is updated */
+ }
+});
+tizen.account.removeAccountListener(watchId);
+
// Triggers an alarm on a given date/time
- var alarm = new tizen.AlarmAbsolute(new Date(2014, 10, 4, 8, 0));
- var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view");
- tizen.alarm.add(alarm, tizen.application.getCurrentApplication().appInfo.id, appControl);
- console.log("Alarm added with id: " + alarm.id);
-
+
+/* Triggers an alarm on a given date/time */
+var alarm = new tizen.AlarmAbsolute(new Date(2014, 10, 4, 8, 0));
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view");
+tizen.alarm.add(alarm, tizen.application.getCurrentApplication().appInfo.id, appControl);
+console.log("Alarm added with id: " + alarm.id);
+
var alarms = tizen.alarm.getAll();
-
- // Removes the first alarm
- if (alarms.length > 0) {
- try {
- tizen.alarm.remove(alarms[0].id);
- console.log("Successfully removed the first alarm.");
- } catch(error) {
- console.log("Failed to remove the first alarm.");
- }
- }
-
+
+var alarms = tizen.alarm.getAll();
+
+/* Removes the first alarm */
+if (alarms.length > 0)
+{
+ try
+ {
+ tizen.alarm.remove(alarms[0].id);
+ console.log("Successfully removed the first alarm.");
+ }
+ catch (error)
+ {
+ console.log("Failed to remove the first alarm.");
+ }
+}
+
tizen.alarm.removeAll();
- console.log("remove all registered alarms in the storage.");
-
+
+tizen.alarm.removeAll();
+console.log("remove all registered alarms in the storage.");
+
// Sets an alarm
- var date = new Date();
- date.setHours(date.getHours()+1);
- var abs_alarm = new tizen.AlarmAbsolute(date);
+
+/* Sets an alarm */
+var date = new Date();
+date.setHours(date.getHours() + 1);
+var abs_alarm = new tizen.AlarmAbsolute(date);
- // Adds an alarm
- tizen.alarm.add(abs_alarm, tizen.application.getCurrentApplication().appInfo.id);
+/* Adds an alarm */
+tizen.alarm.add(abs_alarm, tizen.application.getCurrentApplication().appInfo.id);
- // Gets an alarm
- var alarm = tizen.alarm.get(abs_alarm.id);
- console.log("The alarm will trigger at " + alarm.getNextScheduledDate());
-
+/* Gets an alarm */
+var alarm = tizen.alarm.get(abs_alarm.id);
+console.log("The alarm will trigger at " + alarm.getNextScheduledDate());
+ var alarms = tizen.alarm.getAll();
- console.log(alarms.length + " alarms present in the storage.");
-
+
+var alarms = tizen.alarm.getAll();
+console.log(alarms.length + " alarms present in the storage.");
+
Code example:
// Gets the current application ID. - var appId = tizen.application.getCurrentApplication().appInfo.id; +Code example:
+/* Gets the current application ID */ +var appId = tizen.application.getCurrentApplication().appInfo.id; - // Sets an alarm in 3 hours from now - var alarm1 = new tizen.AlarmRelative(3 * tizen.alarm.PERIOD_HOUR); - tizen.alarm.add(alarm1, appId); +/* Sets an alarm in 3 hours from now */ +var alarm1 = new tizen.AlarmRelative(3 * tizen.alarm.PERIOD_HOUR); +tizen.alarm.add(alarm1, appId); - // Sets an alarm in one hour, recurring after every 10 minutes - var alarm2 = new tizen.AlarmRelative(tizen.alarm.PERIOD_HOUR, 10 * tizen.alarm.PERIOD_MINUTE); - tizen.alarm.add(alarm2, appId); -+/* Sets an alarm in one hour, recurring after every 10 minutes */ +var alarm2 = new tizen.AlarmRelative(tizen.alarm.PERIOD_HOUR, 10 * tizen.alarm.PERIOD_MINUTE); +tizen.alarm.add(alarm2, appId); +
Code example:
// Gets the current application ID. - var appId = tizen.application.getCurrentApplication().appInfo.id; +Code example:
+/* Gets the current application ID */ +var appId = tizen.application.getCurrentApplication().appInfo.id; - // Sets an alarm in 3 hours from now - var alarm = new tizen.AlarmRelative(3 * tizen.alarm.PERIOD_HOUR); - tizen.alarm.add(alarm, appId); +/* Sets an alarm in 3 hours from now */ +var alarm = new tizen.AlarmRelative(3 * tizen.alarm.PERIOD_HOUR); +tizen.alarm.add(alarm, appId); - var sec = alarm.getRemainingSeconds(); - console.log("remaining time is " + sec); -+var sec = alarm.getRemainingSeconds(); +console.log("remaining time is " + sec); +
Code example:
// Gets the current application ID. - var appId = tizen.application.getCurrentApplication().appInfo.id; +Code example:
+/* Gets the current application ID */ +var appId = tizen.application.getCurrentApplication().appInfo.id; - // Sets an alarm on January 1st 2014 08:00 - var date = new Date(2014, 0, 1, 8, 0); - var alarm1 = new tizen.AlarmAbsolute(date); - tizen.alarm.add(alarm1, appId); +/* Sets an alarm on January 1st 2014 08:00 */ +var date = new Date(2014, 0, 1, 8, 0); +var alarm1 = new tizen.AlarmAbsolute(date); +tizen.alarm.add(alarm1, appId); - // Sets an alarm on January 1st 2014 08:00, repeating every 2 days - var alarm2 = new tizen.AlarmAbsolute(date, 2 * tizen.alarm.PERIOD_DAY); - tizen.alarm.add(alarm2, appId); +/* Sets an alarm on January 1st 2014 08:00, repeating every 2 days */ +var alarm2 = new tizen.AlarmAbsolute(date, 2 * tizen.alarm.PERIOD_DAY); +tizen.alarm.add(alarm2, appId); - // Sets an alarm occurring on every Saturday and Sunday, at 08:00, starting from January 1st 2014 - var alarm3 = new tizen.AlarmAbsolute(date, ["SA", "SU"]); - tizen.alarm.add(alarm3, appId); -+/* Sets an alarm occurring on every Saturday and Sunday, at 08:00, starting from January 1st 2014 */ +var alarm3 = new tizen.AlarmAbsolute(date, ["SA", "SU"]); +tizen.alarm.add(alarm3, appId); +
Code example:
// Gets the current application ID. - var appId = tizen.application.getCurrentApplication().appInfo.id; - - // Sets an alarm on January 1st 2014 08:00 - var date = new Date(2014, 0, 1, 8, 0); - var alarm1 = new tizen.AlarmAbsolute(date); - tizen.alarm.add(alarm1, appId); - - var date = alarm1.getNextScheduledDate(); - console.log("next scheduled time is " + date); -+
Code example:
+/* Gets the current application ID */ +var appId = tizen.application.getCurrentApplication().appInfo.id; + +/* Sets an alarm on January 1st 2014 08:00 */ +var date = new Date(2014, 0, 1, 8, 0); +var alarm1 = new tizen.AlarmAbsolute(date); +tizen.alarm.add(alarm1, appId); + +var date = alarm1.getNextScheduledDate(); +console.log("next scheduled time is " + date); +
Code example:
var app = tizen.application.getCurrentApplication(); - console.log("Current application's app id is " + app.appInfo.id); -+
Code example:
+var app = tizen.application.getCurrentApplication(); +console.log("Current application's app id is " + app.appInfo.id); +
Code example:
function onKillSuccess() { - console.log("Application terminated successfully"); - } - - function onRunningAppsContext(contexts) { - // let's assume that the application "targetApp0.main" has been installed. - var targetId = "targetApp0.main"; - - for (var i = 0; i < contexts.length; i++) { - if (contexts[i].appId == targetId) { - tizen.application.kill(contexts[i].id, onKillSuccess); - } - } - } - - tizen.application.getAppsContext(onRunningAppsContext); -+
Code example:
+function onKillSuccess() +{ + console.log("Application terminated successfully"); +} + +function onRunningAppsContext(contexts) +{ + /* Let's assume that the application "targetApp0.main" has been installed */ + var targetId = "targetApp0.main"; + + for (var i = 0; i < contexts.length; i++) + { + if (contexts[i].appId == targetId) + { + tizen.application.kill(contexts[i].id, onKillSuccess); + } + } +} + +tizen.application.getAppsContext(onRunningAppsContext); +
Code example:
function onsuccess() { - console.log("The application has launched successfully"); - } +Code example:
+function onsuccess() +{ + console.log("The application has launched successfully"); +} - // let's assume that application "targetApp0.main" has been installed - tizen.application.launch("targetApp0.main", onsuccess); -+/* Let's assume that application "targetApp0.main" has been installed */ +tizen.application.launch("targetApp0.main", onsuccess); +
Code example:
var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/pick", - null, - "image/jpeg", - null); - - var appControlReplyCallback = { - // callee sent a reply - onsuccess: function(data) { - for (var i = 0; i < data.length; i++) { - if (data[i].key == "http://tizen.org/appcontrol/data/selected") { - console.log('Selected image is ' + data[i].value[0]); - } - } - }, - // callee returned failure - onfailure: function() { - console.log('The launch application control failed'); - } - } - - tizen.application.launchAppControl( - appControl, - null, - function() {console.log("launch application control succeed"); }, - function(e) {console.log("launch application control failed. reason: " + e.message); }, - appControlReplyCallback ); -+
Code example:
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/pick", + null, "image/jpeg", null); + +var appControlReplyCallback = +{ + /* Callee sent a reply */ + onsuccess: function(data) + { + for (var i = 0; i < data.length; i++) + { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") + console.log('Selected image is ' + data[i].value[0]); + } + }, + /* Callee returned failure */ + onfailure: function() + { + console.log('The launch application control failed'); + } +} + +tizen.application.launchAppControl(appControl, null, + function() {console.log("launch application control succeed");}, + function(e) {console.log("launch application control failed. reason: " + e.message);}, + appControlReplyCallback); +
Code example:
var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/pick", - null, - "image/jpeg", - null); - - function successCB(appInfos, appControl) - { - // appControl is same object with the value passed as first parameter to findAppControl() - var appControlReplyCallback = { - // callee sent a reply - onsuccess: function(data) { - for (var i = 0; i < data.length; i++) { - if (data[i].key == "http://tizen.org/appcontrol/data/selected") { - console.log('Selected image is ' + data[i].value[0]); - } - } - }, - // callee returned failure - onfailure: function() { - console.log('The launch application control failed'); - } - } - - var appId = appInfos[0].id; // select first app's id - - tizen.application.launchAppControl( - appControl, - appId, - function() {console.log("launch application control succeed"); }, - function(e) {console.log("launch application control failed. reason: " + e.message); }, - appControlReplyCallback ); - } - - tizen.application.findAppControl(appControl, successCB); -+
Code example:
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/pick", + null, "image/jpeg", null); + +function successCB(appInfos, appControl) +{ + /* appControl is same object with the value passed as first parameter to findAppControl() */ + var appControlReplyCallback = + { + /* Callee sent a reply */ + onsuccess: function(data) + { + for (var i = 0; i < data.length; i++) + { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") + console.log('Selected image is ' + data[i].value[0]); + } + }, + /* Callee returned failure */ + onfailure: function() + { + console.log('The launch application control failed'); + } + } + + var appId = appInfos[0].id; /* Select first app's id */ + + tizen.application.launchAppControl(appControl, appId, + function() {console.log("launch application control succeed");}, + function(e) {console.log("launch application control failed. reason: " + e.message);}, + appControlReplyCallback); +} + +tizen.application.findAppControl(appControl, successCB); +
Code example:
function onRunningAppsContext(contexts) { - for (var i = 0; i < contexts.length; i++) - console.log("ID : " + contexts[i].id); - } +Code example:
+function onRunningAppsContext(contexts) +{ + for (var i = 0; i < contexts.length; i++) + console.log("ID: " + contexts[i].id); +} - tizen.application.getAppsContext(onRunningAppsContext); -+tizen.application.getAppsContext(onRunningAppsContext); +
Code example:
var appContext = tizen.application.getAppContext(null); - console.log("Application context retrieved for app " + appContext.appId); -+
Code example:
+var appContext = tizen.application.getAppContext(null); +console.log("Application context retrieved for app " + appContext.appId); +
Code example:
function onListInstalledApps(applications) { - for (var i = 0; i < applications.length; i++) - console.log("ID : " + applications[i].id); - } +Code example:
+function onListInstalledApps(applications) +{ + for (var i = 0; i < applications.length; i++) + console.log("ID: " + applications[i].id); +} - tizen.application.getAppsInfo(onListInstalledApps); -+tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
var appInfo = tizen.application.getAppInfo(null); - console.log("Current application name : " + appInfo.name); -+
Code example:
+var appInfo = tizen.application.getAppInfo(null); +console.log("Current application name: " + appInfo.name); +
Code example:
var appCerts = tizen.application.getAppCerts(null); +Code example:
+var appCerts = tizen.application.getAppCerts(null); - for (var i = 0; i < appCerts.length; i++) { - console.log("#" + i + " type:" + appCerts[i].type); - console.log("#" + i + " value:" + appCerts[i].value); - } -+for (var i = 0; i < appCerts.length; i++) +{ + console.log("#" + i + " type:" + appCerts[i].type); + console.log("#" + i + " value:" + appCerts[i].value); +} +
Code example:
var sharedDir = tizen.application.getAppSharedURI(null); - console.log("shared directory : " + sharedDir); -+
Code example:
+var sharedDir = tizen.application.getAppSharedURI(null); +console.log("shared directory: " + sharedDir); +
Code example:
var metaDataArray = tizen.application.getAppMetaData(null); - console.log("size of metadata : " + metaDataArray.length); - -+
Code example:
+var metaDataArray = tizen.application.getAppMetaData(null); +console.log("size of metadata: " + metaDataArray.length); +
Code example:
var appEventCallback = { - oninstalled: function(appInfo) { - console.log('The application ' + appInfo.name + ' is installed'); - }, - onupdated: function(appInfo) { - console.log('The application ' + appInfo.name + ' is updated'); - }, - onuninstalled: function(appid) { - console.log('The application ' + appid + ' is uninstalled'); - } - }; - var watchId = tizen.application.addAppInfoEventListener(appEventCallback); -+
Code example:
+var appEventCallback = +{ + oninstalled: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is installed'); + }, + onupdated: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is updated'); + }, + onuninstalled: function(appid) + { + console.log('The application ' + appid + ' is uninstalled'); + } +}; +var watchId = tizen.application.addAppInfoEventListener(appEventCallback); +
Code example:
var appEventCallback = { - oninstalled: function(appInfo) { - console.log('The application ' + appInfo.name + ' is installed'); - }, - onupdated: function(appInfo) { - console.log('The application ' + appInfo.name + ' is updated'); - }, - onuninstalled: function(appid) { - console.log('The application ' + appid + ' is uninstalled'); - } - }; - var watchId = tizen.application.addAppInfoEventListener(appEventCallback); - tizen.application.removeAppInfoEventListener(watchId); -+
Code example:
+var appEventCallback = +{ + oninstalled: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is installed'); + }, + onupdated: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is updated'); + }, + onuninstalled: function(appid) + { + console.log('The application ' + appid + ' is uninstalled'); + } +}; +var watchId = tizen.application.addAppInfoEventListener(appEventCallback); +tizen.application.removeAppInfoEventListener(watchId); +
Code example:
var app = tizen.application.getCurrentApplication(); +Code example:
+var app = tizen.application.getCurrentApplication(); - app.exit(); -+app.exit(); +
Code example:
var app = tizen.application.getCurrentApplication(); +Code example:
+var app = tizen.application.getCurrentApplication(); - app.hide(); -+app.hide(); +
Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); +Code example:
+var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); - if (reqAppControl) { - console.log("Requester AppID : " + reqAppControl.callerAppId); - } -+if (reqAppControl) +{ + console.log("Requester AppID: " + reqAppControl.callerAppId); +} +
Code example:
var app = tizen.application.getCurrentApplication(); - - // for user events: sender's application ID and event name must be provided by using a dictionary - // Let's assume that at least two applications are installed - function onListInstalledApps(appsInfo) { - var appId = null; - - if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) { - appId = appsInfo[0].id; - } else if (appsInfo.length > 1) { - appId = appsInfo[1].id; - } - - if (appId) { - var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) { - console.log("Data: " + JSON.stringify(data)); - // do something - }); - } - } - tizen.application.getAppsInfo(onListInstalledApps); -+
Code example:
+var app = tizen.application.getCurrentApplication(); + +/* For user events: sender's application ID and event name must be provided by using a dictionary */ +/* Let's assume that at least two applications are installed */ +function onListInstalledApps(appsInfo) +{ + var appId = null; + + if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) + { + appId = appsInfo[0].id; + } + else if (appsInfo.length > 1) + { + appId = appsInfo[1].id; + } + + if (appId) + { + var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) + { + console.log("Data: " + JSON.stringify(data)); + /* Do something */ + }); + } +} +tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
var app = tizen.application.getCurrentApplication(); - - // for user events: sender's application ID and event name must be provided by using a dictionary - // Let's assume that at least two applications are installed - function onListInstalledApps(appsInfo) { - var appId = null; - var watchId = null; - - if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) { - appId = appsInfo[0].id; - } else if (appsInfo.length > 1) { - appId = appsInfo[1].id; - } - - if (appId) { - watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) { - if (watchId) { - app.removeEventListener(watchId); - watchId = null; - } - }); - } - } - tizen.application.getAppsInfo(onListInstalledApps); -+
Code example:
+var app = tizen.application.getCurrentApplication(); + +/* For user events: sender's application ID and event name must be provided by using a dictionary */ +/* Let's assume that at least two applications are installed */ +function onListInstalledApps(appsInfo) +{ + var appId = null; + var watchId = null; + + if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) + { + appId = appsInfo[0].id; + } + else if (appsInfo.length > 1) + { + appId = appsInfo[1].id; + } + + if (appId) + { + watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) + { + if (watchId) + { + app.removeEventListener(watchId); + watchId = null; + } + }); + } +} +tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
var myCustomData = { - foo: 'bar' - }; +Code example:
+var myCustomData = +{ + foo: 'bar' +}; - var app = tizen.application.getCurrentApplication(); +var app = tizen.application.getCurrentApplication(); - app.broadcastEvent({"name": "custom_user_event"}, myCustomData); -+app.broadcastEvent({"name": "custom_user_event"}, myCustomData); +
Code example:
var myTrustedCustomData = { - foo: 'bar' - }; +Code example:
+var myTrustedCustomData = +{ + foo: 'bar' +}; - var app = tizen.application.getCurrentApplication(); +var app = tizen.application.getCurrentApplication(); - app.broadcastTrustedEvent({"name": "custom_user_event"}, myTrustedCustomData); -+app.broadcastTrustedEvent({"name": "custom_user_event"}, myTrustedCustomData); +
Code example:
var appControlData = new tizen.ApplicationControlData("image", [imagedata1]); -+
Code example:
+var appControlData = new tizen.ApplicationControlData("image", [imagedata1]); +
Code example:
var appControl = - new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/view", - null, - "image/jpeg", - null, - [new tizen.ApplicationControlData("images", - [imagedata1, imagedata2])] ); -+
Code example:
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view", + null, "image/jpeg", null, + [new tizen.ApplicationControlData("images", [imagedata1, imagedata2])]); +
Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); - if (reqAppControl) { - console.log("Requester AppID : " + reqAppControl.callerAppId); - - var appControl = reqAppControl.appControl; - if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") { - var data = new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/selected", ["Image1.jpg"]); - reqAppControl.replyResult([data]); - } - } -+
Code example:
+var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); +if (reqAppControl) +{ + console.log("Requester AppID: " + reqAppControl.callerAppId); + + var appControl = reqAppControl.appControl; + if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") + { + var data = new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/selected", ["Image1.jpg"]); + reqAppControl.replyResult([data]); + } +} +
Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); - if (reqAppControl) { - console.log("Requester AppID : " + reqAppControl.callerAppId); - - var appControl = reqAppControl.appControl; - if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") { - reqAppControl.replyFailure(); - } - } -+
Code example:
+var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); +if (reqAppControl) +{ + console.log("Requester AppID: " + reqAppControl.callerAppId); + + var appControl = reqAppControl.appControl; + if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") + { + reqAppControl.replyFailure(); + } +} +
Code example:
function onListInstalledApps(applications) { - for (var i = 0; i < applications.length; i++) - console.log("ID : " + applications[i].id); - } +Code example:
+function onListInstalledApps(applications) +{ + for (var i = 0; i < applications.length; i++) + console.log("ID: " + applications[i].id); +} - tizen.application.getAppsInfo(onListInstalledApps); -+tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/pick", - null, - "image/jpeg", - null); - - // FindAppControlSuccessCallback instance - function successCB(appInfos, appControl) - { - // appControl is same object with the value passed as first parameter to findAppControl() - var appControlReplyCallback = { - // callee sent a reply - onsuccess: function(data) { - for (var i = 0; i < data.length; i++) { - if (data[i].key == "http://tizen.org/appcontrol/data/selected") { - console.log('Selected image is ' + data[i].value[0]); - } - } - }, - // callee returned failure - onfailure: function() { - console.log('The launch application control failed'); - } - } - - var appId = appInfos[0].id; // select first app's id - - tizen.application.launchAppControl( - appControl, - appId, - function() {console.log("launch application control succeed"); }, - function(e) {console.log("launch application control failed. reason: " + e.message); }, - appControlReplyCallback ); - } - - tizen.application.findAppControl(appControl, successCB); -+
Code example:
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/pick", + null, "image/jpeg", null); + +/* FindAppControlSuccessCallback instance */ +function successCB(appInfos, appControl) +{ + /* appControl is same object with the value passed as first parameter to findAppControl() */ + var appControlReplyCallback = + { + /* Callee sent a reply */ + onsuccess: function(data) + { + for (var i = 0; i < data.length; i++) + { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") + console.log('Selected image is ' + data[i].value[0]); + } + }, + /* Callee returned failure */ + onfailure: function() + { + console.log('The launch application control failed'); + } + } + + var appId = appInfos[0].id; /* Select first app's id */ + + tizen.application.launchAppControl(appControl, appId, + function() {console.log("launch application control succeed");}, + function(e) {console.log("launch application control failed. reason: " + e.message);}, + appControlReplyCallback); +} + +tizen.application.findAppControl(appControl, successCB); +
Code example:
var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/pick", - null, - "image/jpeg", - null); - - // ApplicationControlDataArrayReplyCallback instance - var appControlReplyCallback = { - // callee sent a reply - onsuccess: function(data) { - for (var i = 0; i < data.length; i++) { - if (data[i].key == "http://tizen.org/appcontrol/data/selected") { - console.log('Selected image is ' + data[i].value[0]); - } - } - }, - // callee returned failure - onfailure: function() { - console.log('The launch application control failed'); - } - } - - tizen.application.launchAppControl( - appControl, - null, - function() {console.log("launch application control succeed"); }, - function(e) {console.log("launch application control failed. reason: " + e.message); }, - appControlReplyCallback ); -+
Code example:
+var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/pick", + null, "image/jpeg", null); + +/* ApplicationControlDataArrayReplyCallback instance */ +var appControlReplyCallback = +{ + /* Callee sent a reply */ + onsuccess: function(data) + { + for (var i = 0; i < data.length; i++) + { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") + console.log('Selected image is ' + data[i].value[0]); + } + }, + /* Callee returned failure */ + onfailure: function() + { + console.log('The launch application control failed'); + } +} + +tizen.application.launchAppControl(appControl, null, + function() {console.log("launch application control succeed");}, + function(e) {console.log("launch application control failed. reason: " + e.message);}, + appControlReplyCallback); +
Code example:
var appEventCallback = { - oninstalled: function(appInfo) { - console.log('The application ' + appInfo.name + ' is installed'); - }, - onupdated: function(appInfo) { - console.log('The application ' + appInfo.name + ' is updated'); - }, - onuninstalled: function(appid) { - console.log('The application ' + appid + ' is uninstalled'); - } - }; - var watchId = tizen.application.addAppInfoEventListener(appEventCallback); -+
Code example:
+var appEventCallback = +{ + oninstalled: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is installed'); + }, + onupdated: function(appInfo) + { + console.log('The application ' + appInfo.name + ' is updated'); + }, + onuninstalled: function(appid) + { + console.log('The application ' + appid + ' is uninstalled'); + } +}; +var watchId = tizen.application.addAppInfoEventListener(appEventCallback); +
Code example:
var app = tizen.application.getCurrentApplication(); - - // for user events: sender's application ID and event name must be provided by using a dictionary - // Let's assume that at least two applications are installed - function onListInstalledApps(appsInfo) { - var appId = null; - - if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) { - appId = appsInfo[0].id; - } else if (appsInfo.length > 1) { - appId = appsInfo[1].id; - } - - var eventCB = function(event, data) { - console.log("Data: " + JSON.stringify(data)); - // do something - }; - - if (appId) { - var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, eventCB); - } - } - tizen.application.getAppsInfo(onListInstalledApps); -+
Code example:
+var app = tizen.application.getCurrentApplication(); + +/* For user events: sender's application ID and event name must be provided by using a dictionary */ +/* Let's assume that at least two applications are installed */ +function onListInstalledApps(appsInfo) +{ + var appId = null; + + if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) + { + appId = appsInfo[0].id; + } + else if (appsInfo.length > 1) + { + appId = appsInfo[1].id; + } + + var eventCB = function(event, data) + { + console.log("Data: " + JSON.stringify(data)); + /* Do something */ + }; + + if (appId) + { + var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, eventCB); + } +} +tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
function successCallback(archive) { - console.log("Success, can now read from archive " + archive); - } - - function errorCallback(error) { - console.log(error); - } - - tizen.archive.open("downloads/some_archive.zip", "r", successCallback, errorCallback); -+
Code example:
+function successCallback(archive) +{ + console.log("Success, can now read from archive " + archive); +} + +function errorCallback(error) +{ + console.log(error); +} + +tizen.archive.open("downloads/some_archive.zip", "r", successCallback, errorCallback); +
Code example:
function openSuccess(archive) { - operationId = archive.extractAll("downloads/extracted"); - tizen.archive.abort(operationId); - } - - tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); -+
Code example:
+function openSuccess(archive) +{ + operationId = archive.extractAll("downloads/extracted"); + tizen.archive.abort(operationId); +} + +tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); +
Code example:
function errorCallback(error) { - console.log(error); - } - - function successCallback() { - console.log("done"); - } - - function progressCallback(opId, val, name) { - console.log("opId: " + opId + " with progress val: " + val); - } - - function createSuccess(archive) { - archive.add("downloads/file.txt", successCallback, errorCallback, progressCallback); - } - - tizen.archive.open("downloads/new_archive.zip", "w", createSuccess); -+
Code example:
+function errorCallback(error) +{ + console.log(error); +} + +function successCallback() +{ + console.log("done"); +} + +function progressCallback(opId, val, name) +{ + console.log("opId: " + opId + " with progress val: " + val); +} + +function createSuccess(archive) +{ + archive.add("downloads/file.txt", successCallback, errorCallback, progressCallback); +} + +tizen.archive.open("downloads/new_archive.zip", "w", createSuccess); +
Code example:
function errorCallback(error) { - console.log(error); - } - - function successCallback() { - console.log("done"); - } - - function progressCallback(opId, val, name) { - console.log("extracting operation (: " + opId + ") is in progress (" + (val * 100).toFixed(1) + "%)"); - } - - function openSuccess(archive) { - archive.extractAll("music", successCallback, errorCallback, progressCallback); - } - - tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); -+
Code example:
+function errorCallback(error) +{ + console.log(error); +} + +function successCallback() +{ + console.log("done"); +} + +function progressCallback(opId, val, name) +{ + console.log("extracting operation (: " + opId + ") is in progress (" + (val * 100).toFixed(1) + "%)"); +} + +function openSuccess(archive) +{ + archive.extractAll("music", successCallback, errorCallback, progressCallback); +} + +tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); +
Code example:
function errorCallback(error) { - console.log(error); - } - - function getEntriesSuccess(entries) { - console.log("Entries length: " + entries.length); - for (var i=0; i < entries.length; i++) { - console.log(entries[i].name); - } - } - - function openSuccess(archive) { - archive.getEntries(getEntriesSuccess, errorCallback); - } - - tizen.archive.open("downloads/some_archive.zip", "r", openSuccess, errorCallback); -+
Code example:
+function errorCallback(error) +{ + console.log(error); +} + +function getEntriesSuccess(entries) +{ + console.log("Entries length: " + entries.length); + for (var i = 0; i < entries.length; i++) + { + console.log(entries[i].name); + } +} + +function openSuccess(archive) +{ + archive.getEntries(getEntriesSuccess, errorCallback); +} + +tizen.archive.open("downloads/some_archive.zip", "r", openSuccess, errorCallback); +
Code example:
function errorCallback(error) { - console.log(error); - } - - function getEntrySuccess(entry) { - console.log("Entry: " + entry.name + " size: " + entry.size); - } - - function openSuccess(archive) { - archive.getEntryByName("arch/my_file.txt", getEntrySuccess, errorCallback); - } - - tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); -+
Code example:
+function errorCallback(error) +{ + console.log(error); +} + +function getEntrySuccess(entry) +{ + console.log("Entry: " + entry.name + " size: " + entry.size); +} + +function openSuccess(archive) +{ + archive.getEntryByName("arch/my_file.txt", getEntrySuccess, errorCallback); +} + +tizen.archive.open("downloads/some_archive.zip", "r", openSuccess); +
Code example:
function errorCallback(error) { - console.log(error); - } - - function extractSuccessCallback() { - console.log("done"); - } - - function getEntrySuccess(entry) { - entry.extract("downloads/extract", extractSuccessCallback, errorCallback); - } - - function openSuccess(archive) { - archive.getEntryByName("my_file.txt", getEntrySuccess, errorCallback); - } - - tizen.archive.open("downloads/some_archive.zip", "r", openSuccess, errorCallback); -+
Code example:
+function errorCallback(error) +{ + console.log(error); +} + +function extractSuccessCallback() +{ + console.log("done"); +} + +function getEntrySuccess(entry) +{ + entry.extract("downloads/extract", extractSuccessCallback, errorCallback); +} + +function openSuccess(archive) +{ + archive.getEntryByName("my_file.txt", getEntrySuccess, errorCallback); +} + +tizen.archive.open("downloads/some_archive.zip", "r", openSuccess, errorCallback); +
Code example:
console.log("Maximum length of a badge number is " + tizen.badge.maxBadgeCount); -+
Code example:
+console.log("Maximum length of a badge number is " + tizen.badge.maxBadgeCount); +
Code example:
var app = tizen.application.getCurrentApplication(); - var appid = app.appInfo.id; - tizen.badge.setBadgeCount(appid, 3); -+
Code example:
+var app = tizen.application.getCurrentApplication(); +var appid = app.appInfo.id; +tizen.badge.setBadgeCount(appid, 3); +
Code example:
var app = tizen.application.getCurrentApplication(); - var appid = app.appInfo.id; - var count = tizen.badge.getBadgeCount(appid); -+
Code example:
+var app = tizen.application.getCurrentApplication(); +var appid = app.appInfo.id; +var count = tizen.badge.getBadgeCount(appid); +
Code example:
// Let's assume that at least two applications are installed +Code example:
+/* Assume that at least two applications are installed */ - function onListInstalledApps(appsInfo) { - function watcher(appId, count) { - console.log(appId + ' badge number were updated : ' + count); - } +function onListInstalledApps(appsInfo) +{ + function watcher(appId, count) + { + console.log(appId + ' badge number were updated: ' + count); + } - // Registers to be notified when the badge number changes - tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher); - } + /* Registers to be notified when the badge number changes */ + tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher); +} - tizen.application.getAppsInfo(onListInstalledApps); -+tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
// Let's assume that at least two applications are installed +Code example:
+/* Assume that at least two applications are installed */ - function onListInstalledApps(appsInfo) { - function watcher(appId, count) { - console.log(appId + ' badge number were updated : ' + count); - } +function onListInstalledApps(appsInfo) +{ + function watcher(appId, count) + { + console.log(appId + ' badge number were updated: ' + count); + } - // Registers to be notified when the badge number changes - tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher); + /* Registers to be notified when the badge number changes */ + tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher); - // Cancels the watch operation - tizen.badge.removeChangeListener([appsInfo[0].id, [appsInfo[1].id]); - } + /* Cancels the watch operation */ + tizen.badge.removeChangeListener([appsInfo[0].id, [appsInfo[1].id]); +} - tizen.application.getAppsInfo(onListInstalledApps); -+tizen.application.getAppsInfo(onListInstalledApps); +
Code example:
// logs the number of badge changes: - function watcher(appId, count) { - console.log(appId + ' -> badge number updates: ' + count); - } +Code example:
+/* Logs the number of badge changes */ +function watcher(appId, count) +{ + console.log(appId + ' -> badge number updates: ' + count); +} - // gets Application's ID: - var appId = tizen.application.getCurrentApplication().appInfo.id; +/* Gets Application's ID */ +var appId = tizen.application.getCurrentApplication().appInfo.id; - // let's assume that the application "TestSample.main" has been installed. - var targetAppId = "TestSample.main"; +/* Assume that the application "TestSample.main" has been installed */ +var targetAppId = "TestSample.main"; - // registers to be notified when the badge number changes for either - // this or targetAppId application: - tizen.badge.addChangeListener([appId, targetAppId], watcher); -+/* + Registers to be notified when the badge number changes for either + this or targetAppId application +*/ +tizen.badge.addChangeListener([appId, targetAppId], watcher); +
BluetoothLEServiceData(DOMString uuid, DOMString data);
Code example:
// Creates a serviceData. - var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); -+
Code example:
+/* Creates a serviceData */ +var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); ++
Code example:
// Creates a serviceData. - var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); - service.uuid = "f236-41a4"; -+
Code example:
+/* Creates a serviceData */ +var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); +service.uuid = "f236-41a4"; +
Code example:
// Creates a serviceData. - var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); - service.data = "0x1815"; -+
Code example:
+/* Creates a serviceData */ +var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); +service.data = "0x1815"; +
BluetoothLEManufacturerData(DOMString id, DOMString data);
Code example:
// Creates a manufacturerData. - var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); -+
Code example:
+/* Creates a manufacturerData */ +var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); +
Code example:
// Creates a manufacturerData. - var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); - manufacturer.id = "129"; -+
Code example:
+/* Creates a manufacturerData */ +var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); +manufacturer.id = "129"; +
Code example:
// Creates a manufacturerData. - var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); - manufacturer.data = "0x0059" -+
Code example:
+/* Creates a manufacturerData */ +var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); +manufacturer.data = "0x0059" +
Code example:
var advertData = { includeName : false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"], - appearance: 192, includeTxPowerLevel: false } -+
Code example:
+var advertData = +{ + includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"], + appearance: 192, includeTxPowerLevel: false +} +
Code example:
var advertData = { includeName : false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"], - appearance: 192, includeTxPowerLevel: false } - var advertise = new tizen.BluetoothLEAdvertiseData(advertData); -+
Code example:
+var advertData = +{ + includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"], + appearance: 192, includeTxPowerLevel: false +} +var advertise = new tizen.BluetoothLEAdvertiseData(advertData); +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - advertise.includeName = true; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +advertise.includeName = true; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - advertise.uuids = ["180d"]; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +advertise.uuids = ["180d"]; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - advertise.solicitationuuids = ["180f"]; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +advertise.solicitationuuids = ["180f"]; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - advertise.appearance = 192; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +advertise.appearance = 192; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - advertise.includeTxPowerLevel = true; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +advertise.includeTxPowerLevel = true; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); - advertise.serviceData = service; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811"); +advertise.serviceData = service; +
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData(); - var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); - advertise.manufacturerData = manufacture; -+
Code example:
+var advertise = new tizen.BluetoothLEAdvertiseData(); +var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057"); +advertise.manufacturerData = manufacture; +
Code example:
console.log(tizen.bluetooth.deviceMajor); -+
Code example:
+console.log(tizen.bluetooth.deviceMajor); +
Code example:
console.log(tizen.bluetooth.deviceMinor); -+
Code example:
+console.log(tizen.bluetooth.deviceMinor); +
Code example:
console.log(tizen.bluetooth.deviceService); -+
Code example:
+console.log(tizen.bluetooth.deviceService); +
Code example:
try { - var adapter = tizen.bluetooth.getDefaultAdapter() ; - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + var adapter = tizen.bluetooth.getDefaultAdapter(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var adapter = tizen.bluetooth.getLEAdapter(); - } catch (err) { - console.log(err.name +": " + err.message); - } -+
Code example:
+try +{ + var adapter = tizen.bluetooth.getLEAdapter(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
// Access adapter name - var adapter = tizen.bluetooth.getDefaultAdapter(); - console.log ("Bluetooth adapter name: " + adapter.name); -+
Code example:
+/* Access adapter name */ +var adapter = tizen.bluetooth.getDefaultAdapter(); +console.log("Bluetooth adapter name: " + adapter.name); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - console.log("Bluetooth device address: " + adapter.address); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +console.log("Bluetooth device address: " + adapter.address); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - console.log("Bluetooth state: " + (adapter.powered ? "On" : "Off")); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +console.log("Bluetooth state: " + (adapter.powered ? "On" : "Off")); +
Code example:
// Queries the current visible state - var adapter = tizen.bluetooth.getDefaultAdapter(); - console.log ("Bluetooth Visibility: " + (adapter.visible ? "On" : "Off")); -+
Code example:
+/* Queries the current visible state */ +var adapter = tizen.bluetooth.getDefaultAdapter(); +console.log("Bluetooth Visibility: " + (adapter.visible ? "On" : "Off")); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); - - function changeName(newName) { - if (adapter.name != newName) { - // initiate change name - adapter.setName(newName, function() { - console.log("Adapter name changed to " + adapter.name); - }, - function(e) { - console.log("Failed to change name: " + e.message); - }); - } - } - if (bt_always_on === false) { - changeName("myDevice"); - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); + +function changeName(newName) +{ + if (adapter.name != newName) + { + /* Initiate change name */ + adapter.setName(newName, function() + { + console.log("Adapter name changed to " + adapter.name); + }, function(e) + { + console.log("Failed to change name: " + e.message); + }); + } +} +if (bt_always_on === false) +{ + changeName("myDevice"); +} +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function powerOn() { - // If adapter is not powered on - if (!adapter.powered) { - // Initiates power on - adapter.setPowered(true, function() { - console.log("Bluetooth powered on success."); - }, - function(e) { - console.log("Failed to power on Bluetooth: " + e.message); - }); - } - } - - function powerOff() { - // If powered on - if (adapter.powered) { - // Initiates power off - adapter.setPowered(false, function() { - console.log("Bluetooth powered off successfully."); - }, - function(e) { - console.log("Failed to power off Bluetooth: " + e.message); - }); - } - } - - var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); - if (bt_always_on === true) { - console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); - } else { - powerOn(); - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function powerOn() +{ + /* If adapter is not powered on */ + if (!adapter.powered) + { + /* Initiates power on */ + adapter.setPowered(true, function() + { + console.log("Bluetooth powered on success."); + }, function(e) + { + console.log("Failed to power on Bluetooth: " + e.message); + }); + } +} + +function powerOff() +{ + /* If powered on */ + if (adapter.powered) + { + /* Initiates power off */ + adapter.setPowered(false, function() + { + console.log("Bluetooth powered off successfully."); + }, function(e) + { + console.log("Failed to power off Bluetooth: " + e.message); + }); + } +} + +var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); +if (bt_always_on === true) +{ + console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); +} +else +{ + powerOn(); +} +
Code example:
var changeListener = { - onstatechanged: function(powered) { - console.log ("Power state is changed into: " + powered); - }, - onnamechanged: function(name) { - console.log("Name is changed to: " + name); - }, - onvisibilitychanged: function(visible) { - console.log("Visibility is changed into: " + visible); - } - }; - - var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.setChangeListener(changeListener); -+
Code example:
+var changeListener = +{ + onstatechanged: function(powered) + { + console.log("Power state is changed into: " + powered); + }, + onnamechanged: function(name) + { + console.log("Name is changed to: " + name); + }, + onvisibilitychanged: function(visible) + { + console.log("Visibility is changed into: " + visible); + } +}; + +var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.setChangeListener(changeListener); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - var changeListener = { - onstatechanged: function(powered) { - console.log ("Power state is changed into: " + powered); - if (!powered) - adapter.unsetChangeListener(); - }, - onnamechanged: function(name) { - console.log("Name is changed to: " + name); - }, - onvisibilitychanged: function(visible) { - console.log("Visibility is changed into: " + visible); - } - }; - - adapter.setChangeListener(changeListener); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +var changeListener = +{ + onstatechanged: function(powered) + { + console.log("Power state is changed into: " + powered); + if (!powered) + adapter.unsetChangeListener(); + }, + onnamechanged: function(name) + { + console.log("Name is changed to: " + name); + }, + onvisibilitychanged: function(visible) + { + console.log("Visibility is changed into: " + visible); + } +}; + +adapter.setChangeListener(changeListener); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function startDiscovery() { - - var discoverDevicesSuccessCallback = { - onstarted: function() { - console.log ("Device discovery started..."); - }, - ondevicefound: function(device) { - console.log("Found device - name: " + device.name + ", Address: "+ device.address); - }, - ondevicedisappeared: function(address) { - console.log("Device disappeared: " + address); - }, - onfinished: function(devices) { - console.log("Found Devices"); - for (var i = 0; i < devices.length; i++) { - console.log("Name: " + devices[i].name + ", Address: " + devices[i].address); - } - console.log("Total: " + devices.length); - } - }; - - // Starts searching for nearby devices, for about 12 sec. - adapter.discoverDevices(discoverDevicesSuccessCallback, function(e) { - console.log ("Failed to search devices: " + e.message + "(" + e.name + ")"); - }); - } - - function onSetPoweredError(e) { - console.log ("Could not turn on device, reason: " + e.message + "(" + e.name + ")"); - } - - adapter.setPowered(true, startDiscovery, onSetPoweredError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function startDiscovery() +{ + var discoverDevicesSuccessCallback = + { + onstarted: function() + { + console.log("Device discovery started..."); + }, + ondevicefound: function(device) + { + console.log("Found device - name: " + device.name + ", Address: " + device.address); + }, + ondevicedisappeared: function(address) + { + console.log("Device disappeared: " + address); + }, + onfinished: function(devices) + { + console.log("Found Devices"); + for (var i = 0; i < devices.length; i++) + { + console.log("Name: " + devices[i].name + ", Address: " + devices[i].address); + } + console.log("Total: " + devices.length); + } + }; + + /* Starts searching for nearby devices, for about 12 sec */ + adapter.discoverDevices(discoverDevicesSuccessCallback, function(e) + { + console.log("Failed to search devices: " + e.message + "(" + e.name + ")"); + }); +} + +function onSetPoweredError(e) +{ + console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")"); +} + +adapter.setPowered(true, startDiscovery, onSetPoweredError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - // Calls this method whenever user finds one of the device. - function cancelDiscovery() { - adapter.stopDiscovery(function() { - console.log("Stop discovery success."); - }, - function (e) { - console.log("Error while stopDiscovery:" + e.message); - }); - } - - function startDiscovery() { - - var discoverDevicesSuccessCallback = { - onstarted: function() { - console.log ("Device discovery started...") ; - }, - ondevicefound: function(device) { - console.log("Found device - name: " + device.name + ", Address: "+ device.address); - // Shows the device to user to check if this is the device user is looking for. - // For example, add this to list view. - - cancelDiscovery(); - }, - ondevicedisappeared: function(address) { - console.log("Device disappeared: " + address); - // Removes from list, as it is no longer valid. - }, - onfinished: function(devices) { - console.log("Found Devices"); - for (var i = 0; i < devices.length; i++) { - console.log("Name: " + devices[i].name + ", Address: " + devices[i].address); - } - console.log("Total: " + devices.length); - } - }; - - // Starts searching for nearby devices, for about 12 sec. - adapter.discoverDevices(discoverDevicesSuccessCallback, function(e) { - console.log ("Failed to search devices: " + e.message + "(" + e.name + ")"); - }); - } - - function onSetPoweredError(e) { - console.log ("Could not turn on device, reason: " + e.message + "(" + e.name + ")"); - } - - adapter.setPowered(true, startDiscovery, onSetPoweredError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +/* Calls this method whenever user finds one of the device */ +function cancelDiscovery() +{ + adapter.stopDiscovery(function() + { + console.log("Stop discovery success."); + }, function(e) + { + console.log("Error while stopDiscovery:" + e.message); + }); +} + +function startDiscovery() +{ + var discoverDevicesSuccessCallback = + { + onstarted: function() + { + console.log("Device discovery started..."); + }, + ondevicefound: function(device) + { + console.log("Found device - name: " + device.name + ", Address: " + device.address); + /* Shows the device to user to check if this is the device user is looking for */ + /* For example, add this to list view */ + + cancelDiscovery(); + }, + ondevicedisappeared: function(address) + { + console.log("Device disappeared: " + address); + /* Removes from list, as it is no longer valid */ + }, + onfinished: function(devices) + { + console.log("Found Devices"); + for (var i = 0; i < devices.length; i++) + { + console.log("Name: " + devices[i].name + ", Address: " + devices[i].address); + } + console.log("Total: " + devices.length); + } + }; + + /* Starts searching for nearby devices, for about 12 sec */ + adapter.discoverDevices(discoverDevicesSuccessCallback, function(e) + { + console.log("Failed to search devices: " + e.message + "(" + e.name + ")"); + }); +} + +function onSetPoweredError(e) +{ + console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")"); +} + +adapter.setPowered(true, startDiscovery, onSetPoweredError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function onGotDevices(devices) { - console.log("Devices"); - for (var i = 0; i < devices.length; i++) { - console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address); - } - console.log("Total: " + devices.length); - } - - function onError(e) { - console.log ("Error: " + e.message); - } - - function onBluetoothsetPowered() { - adapter.getKnownDevices(onGotDevices, onError); - } - - // Turns on Bluetooth - adapter.setPowered(true, onBluetoothsetPowered); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function onGotDevices(devices) +{ + console.log("Devices"); + for (var i = 0; i < devices.length; i++) + { + console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address); + } + console.log("Total: " + devices.length); +} + +function onError(e) +{ + console.log("Error: " + e.message); +} + +function onBluetoothsetPowered() +{ + adapter.getKnownDevices(onGotDevices, onError); +} + +/* Turns on Bluetooth */ +adapter.setPowered(true, onBluetoothsetPowered); +
Code example:
function gotDeviceInfo(device) { - console.log("Device Name: " + device.name); - console.log("Device Address: " + device.address); - console.log("Device Class: " + device.deviceClass.major); - console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No")); - } - - function onError(e) { - console.log ("Could not get device info:" + e.message); - } - - var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo, onError); -+
Code example:
+function gotDeviceInfo(device) +{ + console.log("Device Name: " + device.name); + console.log("Device Address: " + device.address); + console.log("Device Class: " + device.deviceClass.major); + console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No")); +} + +function onError(e) +{ + console.log("Could not get device info:" + e.message); +} + +var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo, onError); +
Code example:
function onBondingSuccess(device) { - console.log("Device Name:" + device.name); - console.log("Device Address:" + device.address); - console.log("Device Service UUIDs:" + device.uuids.join("\n")); - } - - function onError(e) { - console.log ("Could not create bonding, reason:" + e.message); - } - - var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.createBonding("35:F4:59:D1:7A:03", onBondingSuccess, onError); -+
Code example:
+function onBondingSuccess(device) +{ + console.log("Device Name:" + device.name); + console.log("Device Address:" + device.address); + console.log("Device Service UUIDs:" + device.uuids.join("\n")); +} + +function onError(e) +{ + console.log("Could not create bonding, reason:" + e.message); +} + +var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.createBonding("35:F4:59:D1:7A:03", onBondingSuccess, onError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function gotDevice(device) { - if (device.isBonded) { - // Initiates destroying bonding - adapter.destroyBonding(device.address, function() { - console.log("Succeeded to destroy the bond success with:" + device.address); - }, - function(e) { - console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message); - }); - } - } - - var deviceAddress = "35:F4:59:D1:7A:03"; - adapter.getDevice(deviceAddress, gotDevice, function(e) { - console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function gotDevice(device) +{ + if (device.isBonded) + { + /* Initiates destroying bonding */ + adapter.destroyBonding(device.address, function() + { + console.log("Succeeded to destroy the bond success with:" + device.address); + }, function(e) + { + console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message); + }); + } +} + +var deviceAddress = "35:F4:59:D1:7A:03"; +adapter.getDevice(deviceAddress, gotDevice, function(e) +{ + console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - // Holds currently registered service record - var chatServiceHandler = null; - // Holds currently open socket - var serviceSocket = null; - - function chatServiceSuccessCb(recordHandler) { - console.log("Chat service registration succeeds!"); - chatServiceHandler = recordHandler; - recordHandler.onconnect = function(socket) { - console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); - serviceSocket = socket; - // Messages received from remote device - socket.onmessage = function() { - var data = socket.readData(); - // Handles message code goes here - - }; - - socket.onclose = function() { - console.log('The socket is closed.'); - serviceSocket = null; - }; - }; - }; - - function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - // Error handler - function(e) { - console.log( "Could not register service record, Error: " + e.message); - }); - } - - function unregisterChatService() { - if (chatServiceHandler != null) { - chatServiceHandler.unregister(function() { - console.log("Chat service is unregistered"); - chatServiceHandler = null; - }, function(e) { - console.log("Failed to unregister service: " + e.message); - }); - } - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +/* Holds currently registered service record */ +var chatServiceHandler = null; +/* Holds currently open socket */ +var serviceSocket = null; + +function chatServiceSuccessCb(recordHandler) +{ + console.log("Chat service registration succeeds!"); + chatServiceHandler = recordHandler; + recordHandler.onconnect = function(socket) + { + console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); + serviceSocket = socket; + /* Messages received from remote device */ + socket.onmessage = function() + { + var data = socket.readData(); + /* Handles message code goes here */ + }; + + socket.onclose = function() + { + console.log('The socket is closed.'); + serviceSocket = null; + }; + }; +}; + +function publishChatService() +{ + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); +} + +function unregisterChatService() +{ + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + console.log("Chat service is unregistered"); + chatServiceHandler = null; + }, function(e) + { + console.log("Failed to unregister service: " + e.message); + }); + } +} +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler; - var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health"); - - if (healthCapability) { - healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - } else { - console.log("Bluetooth Health Profile is not supported on this device."); - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler; +var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health"); + +if (healthCapability) +{ + healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +} +else +{ + console.log("Bluetooth Health Profile is not supported on this device."); +} +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("[Found device] address: " + device.address); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("[Found device] address: " + device.address); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - adapter.stopScan(); - } - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + adapter.stopScan(); + } +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - var battery_svc_uuid_16 = "180f"; // the service UUID, 16-bit UUID or 128-bit UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) - var heart_rate_svc_uuid_16 = "180d"; // the service solicitation UUID, 16-bit UUID or 128-bit UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) - var advertiseOptions = { - includeName: true, // Whether the device name should be included - includeTxPowerLevel: true, // Whether the transmission power level should be included - appearance: 192, // The external appearance of device, 192 - Generic Watch - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] - }; - - var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); - var connectable = true; - - adapter.startAdvertise( - advertiseData, - "ADVERTISE", - function onstate(state) { - console.log("Advertiser state: " + state); - }, - function(e) { - console.log("Failed to startAdvertise : " + e.message); - }, - "LOW_LATENCY", - connectable); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g. 180f) */ +var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ +var advertiseOptions = +{ + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] +}; + +var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); +var connectable = true; + +adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) +{ + console.log("Advertiser state: " + state); +}, function(e) +{ + console.log("Failed to startAdvertise: " + e.message); +}, "LOW_LATENCY", connectable); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - var battery_svc_uuid_16 = "180f"; // the service UUID, 16-bit UUID or 128-bit UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) - var heart_rate_svc_uuid_16 = "180d"; // the service solicitation UUID, 16-bit UUID or 128-bit UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) - var advertiseOptions = { - includeName: true, // Whether the device name should be included - includeTxPowerLevel: true, // Whether the transmission power level should be included - appearance: 192, // The external appearance of device, 192 - Generic Watch - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] - }; - - var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); - - adapter.startAdvertise(advertiseData, "ADVERTISE", - function onstate(state) { - console.log("Advertiser state: " + state); - }); - adapter.stopAdvertise(); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g. 180f) */ +var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ +var advertiseOptions = +{ + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] +}; + +var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); + +adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) +{ + console.log("Advertiser state: " + state); +}); +adapter.stopAdvertise(); +
Code example:
function onconnected(device) { - console.log("Connected to device"); - var service = device.getService(device.uuids[0]); - console.log("Service got"); - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("[Found device] address: " + device.address); - device.connect(onconnected.bind(null, device), onerror); - }); - -+
Code example:
+function onconnected(device) +{ + console.log("Connected to device"); + var service = device.getService(device.uuids[0]); + console.log("Service got"); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("[Found device] address: " + device.address); + device.connect(onconnected.bind(null, device), onerror); +}); +
Code example:
var service = device.getService(device.uuids[0]); - console.log("Service UUID " + service.uuid); - -+
Code example:
+var service = device.getService(device.uuids[0]); +console.log("Service UUID " + service.uuid); +
Code example:
var service = device.getService(device.uuids[0]); - for( var i = 0; i service.services.length; ++i) { - console.log("Subservices UUID " + service.services[i].uuid); - } - -+
Code example:
+var service = device.getService(device.uuids[0]); +for (var i = 0; i service.services.length; ++i) +{ + console.log("Subservices UUID " + service.services[i].uuid); +} +
Code example:
var service = device.getService(device.uuids[0]); - for( var i = 0; i service.characteristics.length; ++i) { - console.log("Subservices UUID " + service.characteristics[i].isWritable); - } - -+
Code example:
+var service = device.getService(device.uuids[0]); +for (var i = 0; i service.characteristics.length; ++i) +{ + console.log("Subservices UUID " + service.characteristics[i].isWritable); +} +
Code example:
function onerror(e) { - console.log("Failed to connect to device: " + e.message); - } - - function proccessDevice(device) { - device.connect(onConnected, onerror); - function onConnected() { - var service = device.getService(device.uuids[0]); - if (service.characteristics.length > 0) { - var characteristic = service.characteristics[0]; - characteristic.readValue(function(val) { - console.log("Value read: " + val); - device.disconnect(); - }); - } - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - proccessDevice(device); - } - } - ); -+
Code example:
+function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function proccessDevice(device) +{ + device.connect(onConnected, onerror); + function onConnected() + { + var service = device.getService(device.uuids[0]); + if (service.characteristics.length > 0) + { + var characteristic = service.characteristics[0]; + characteristic.readValue(function(val) + { + console.log("Value read: " + val); + device.disconnect(); + }); + } + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + proccessDevice(device); + } +}); +
Code example:
function onerror(e) { - console.log("Failed to connect to device: " + e.message); - } - - function proccessDevice(device) { - device.connect(onConnected, onerror); - function onConnected() { - var service = device.getService(device.uuids[0]); - if (service.characteristics.length > 0) { - var characteristic = service.characteristics[0]; - var data = new Array(1, 2, 3, 4, 5, 6); - characteristic.writeValue(data, function() { - console.log("Value written"); - device.disconnect(); - }, function(e) { - console.log("Failed to write: " + e.message); - }); - } - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - proccessDevice(device); - } - } - ); -+
Code example:
+function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function proccessDevice(device) +{ + device.connect(onConnected, onerror); + function onConnected() + { + var service = device.getService(device.uuids[0]); + if (service.characteristics.length > 0) + { + var characteristic = service.characteristics[0]; + var data = new Array(1, 2, 3, 4, 5, 6); + characteristic.writeValue(data, function() + { + console.log("Value written"); + device.disconnect(); + }, function(e) + { + console.log("Failed to write: " + e.message); + }); + } + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + proccessDevice(device); + } +}); +
Code example:
function proccessDevice(device) { - - function onConnected() { - var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860"); - if (service.characteristics.length > 0) { - var characteristic = service.characteristics[0]; - var watchID; - - watchID = characteristic.addValueChangeListener(function(value) { - console.log("Characteristic value changed: " + value); - characteristic.removeValueChangeListener(watchID); - device.disconnect(); - }); - } - } - - device.connect(onConnected); - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - adapter.stopScan(); - proccessDevice(device); - } - } - ); -+
Code example:
+function proccessDevice(device) +{ + function onConnected() + { + var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860"); + if (service.characteristics.length > 0) + { + var characteristic = service.characteristics[0]; + var watchID; + + watchID = characteristic.addValueChangeListener(function(value) + { + console.log("Characteristic value changed: " + value); + characteristic.removeValueChangeListener(watchID); + device.disconnect(); + }); + } + } + + device.connect(onConnected); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + adapter.stopScan(); + proccessDevice(device); + } +}); +
Code example:
function onerror(e) { - console.log("Failed to connect to device: " + e.message); - } - - function proccessDevice(device) { - device.connect(onConnected, onerror); - function onConnected() { - var service = device.getService(device.uuids[0]); - if (service.characteristics.length > 0) { - var characteristic = service.characteristics[0]; - var descriptor = characteristic.descriptors[0]; - descriptor.readValue(function(val) { - console.log("Value read: " + val); - device.disconnect(); - }); - } - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - proccessDevice(device); - } - } - ); -+
Code example:
+function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function proccessDevice(device) +{ + device.connect(onConnected, onerror); + function onConnected() + { + var service = device.getService(device.uuids[0]); + if (service.characteristics.length > 0) + { + var characteristic = service.characteristics[0]; + var descriptor = characteristic.descriptors[0]; + descriptor.readValue(function(val) + { + console.log("Value read: " + val); + device.disconnect(); + }); + } + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + proccessDevice(device); + } +}); +
Code example:
function onerror(e) { - console.log("Failed to connect to device: " + e.message); - } - - function proccessDevice(device) { - device.connect(onConnected, onerror); - function onConnected() { - var service = device.getService(device.uuids[0]); - if (service.characteristics.length > 0) { - var characteristic = service.characteristics[0]; - var data = new Array(1, 2, 3, 4, 5, 6); - var descriptor = characteristic.descriptors[0]; - descriptor.writeValue(data, function() { - console.log("Value written"); - device.disconnect(); - }, function(e) { - console.log("Failed to write: " + e.message); - }); - } - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - proccessDevice(device); - } - } - ); -+
Code example:
+function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function proccessDevice(device) +{ + device.connect(onConnected, onerror); + function onConnected() + { + var service = device.getService(device.uuids[0]); + if (service.characteristics.length > 0) + { + var characteristic = service.characteristics[0]; + var data = new Array(1, 2, 3, 4, 5, 6); + var descriptor = characteristic.descriptors[0]; + descriptor.writeValue(data, function() + { + console.log("Value written"); + device.disconnect(); + }, function(e) + { + console.log("Failed to write: " + e.message); + }); + } + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + proccessDevice(device); + } +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Name: " + device.name); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Device Name: " + device.name); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Address: " + device.address); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Device Address: " + device.address); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Major Class: " + device.deviceClass.major); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Device Major Class: " + device.deviceClass.major); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.getDevice("11:22:33:44:55:66", function(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) { - services += uuids[i] + "\n"; - } - console.log ("Services found: " + services); - if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) { - // Connects to service - device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) { - // - // Connected to service, handle socket - // - }, function (e) { - console.log("Could not connect to chat service !!!. Error: " + e.message); - }); - } - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; +adapter.getDevice("11:22:33:44:55:66", function(device) +{ + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Services found: " + services); + if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) + { + /* Connects to service */ + device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) + { + /* Connected to service, handle socket */ + }, function(e) + { + console.log("Could not connect to chat service !!!. Error: " + e.message); + }); + } +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var clientSocket = null; - - // Calls a method that is invoked when user wants to send a message to a remote device. - function sendMessage(msg) { - // Validates socket state, if everything is ok. - if (clientSocket != null && clientSocket.state == "OPEN") { - // Sends the message. - clientSocket.writeData(msg); - } - } - - // Calls a method that is invoked when a socket is open. - function onSocketConnected(socket) { - clientSocket = socket; - console.log("Opening a socket successfully!!!"); - socket.onmessage = function () { - var data = socket.readData(); - var recvmsg = ""; - for (var i = 0; i < data.length; i++) - { - recvmsg += String.fromCharCode(data[i]); - } - console.log("server msg >> " + recvmsg); - }; - - socket.onclose = function() { - console.log("socket disconnected."); - }; - } - - function onDeviceReady(device) { - // Validates device and service uuid - if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) { - // Opens socket - device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) { - console.log ("Error connecting to service. Reason: " + e.message); - }); - } - else { - console.log ("Chat service is not supported by this device"); - } - } - - function onSetPowered() { - // Gets the BluetoothDevice object. - adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) { console.log("Error: " + e.message); }); - } - - adapter.setPowered(true, onSetPowered, function(e) {console.log ("Could not turn on Bluetooth adapter. reason: " + e.message); }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var clientSocket = null; + +/* Calls a method that is invoked when user wants to send a message to a remote device */ +function sendMessage(msg) +{ + /* Validates socket state, if everything is ok */ + if (clientSocket != null && clientSocket.state == "OPEN") + { + /* Sends the message */ + clientSocket.writeData(msg); + } +} + +/* Calls a method that is invoked when a socket is open */ +function onSocketConnected(socket) +{ + clientSocket = socket; + console.log("Opening a socket successfully!!!"); + socket.onmessage = function() + { + var data = socket.readData(); + var recvmsg = ""; + for (var i = 0; i < data.length; i++) + { + recvmsg += String.fromCharCode(data[i]); + } + console.log("server msg >> " + recvmsg); + }; + + socket.onclose = function() + { + console.log("socket disconnected."); + }; +} + +function onDeviceReady(device) +{ + /* Validates device and service uuid */ + if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) + { + /* Opens socket */ + device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) + { + console.log("Error connecting to service. Reason: " + e.message); + }); + } + else + { + console.log("Chat service is not supported by this device"); + } +} + +function onSetPowered() +{ + /* Gets the BluetoothDevice object */ + adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);}); +} + +adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message); }); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("Found device: " + device.address); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("Found device: " + device.address); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("Found device: " + device.name); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("Found device: " + device.name); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("Found device: " + device.txpowerlevel); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("Found device: " + device.txpowerlevel); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("Found device: " + device.appearance); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("Found device: " + device.appearance); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) { - services += uuids[i] + "\n"; - } - console.log ("Service found: " + services); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service found: " + services); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - var uuids = device.solicitationuuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) { - services += uuids[i] + "\n"; - } - console.log ("Service solicitations found: " + services); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + var uuids = device.solicitationuuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service solicitations found: " + services); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - var serviceData = device.serviceData; - var data = ""; - for (var i = 0; i < serviceData.length; i++) { - data += serviceData[i].id + serviceData[i].data + "\n"; - } - console.log ("Service data found: " + data); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + var serviceData = device.serviceData; + var data = ""; + for (var i = 0; i < serviceData.length; i++) + { + data += serviceData[i].id + serviceData[i].data + "\n"; + } + console.log("Service data found: " + data); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - var manufacturerData = device.manufacturerData; - console.log ("Manufacture id: " + manufacturerData.id); - console.log ("Manufacture data: " + manufacturerData.data); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + var manufacturerData = device.manufacturerData; + console.log("Manufacture id: " + manufacturerData.id); + console.log("Manufacture data: " + manufacturerData.data); +}); +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - console.log("Found device: " + device.name); - console.log("RSSI: " + device.rssi); - } - ); -+
Code example:
+var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + console.log("Found device: " + device.name); + console.log("RSSI: " + device.rssi); +}); +
Output example:
Found device: beacon @@ -4092,24 +4265,27 @@ Instead, use http://tizen.org/privilege/bluetooth.
Code example:
function onerror(e) { - console.log("Failed to connect to device: " + e.message); - } - - function onconnected() { - console.log("Connected to device"); - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan( - function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - device.connect(onconnected, onerror); - } - } - ); -+
Code example:
+function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device"); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +}); +
Code example:
function onerror(e) { - console.log("Error occured: " + e.message); - } - - function onDeviceFound(device) { - function ondisconnect() { - console.log("Disconnected"); - } - - function onconnected() { - console.log("Connected to device"); - device.disconnect(ondisconnect, onerror); - } - - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - device.connect(onconnected, onerror); - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan(onDeviceFound, onerror); -+
Code example:
+function onerror(e) +{ + console.log("Error occurred: " + e.message); +} + +function onDeviceFound(device) +{ + function ondisconnect() + { + console.log("Disconnected"); + } + + function onconnected() + { + console.log("Connected to device"); + device.disconnect(ondisconnect, onerror); + } + + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +
Code example:
function onconnected(device) { - console.log("Connected to device"); - var service = device.getService(device.uuids[0]); - console.log("Service got"); - } - - function onerror(e) { - console.log("Error occured: " + e.message); - } - - function onDeviceFound(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - device.connect(onconnected.bind(null, device), onerror); - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan(onDeviceFound, onerror); -+
Code example:
+function onconnected(device) +{ + console.log("Connected to device"); + var service = device.getService(device.uuids[0]); + console.log("Service got"); +} + +function onerror(e) +{ + console.log("Error occurred: " + e.message); +} + +function onDeviceFound(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected.bind(null, device), onerror); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +
Code example:
function onconnected(device) { - console.log("Connected to device"); - var services = device.getServiceAllUuids(); - console.log("Services length " + services.length); - } - - function onerror(e) { - console.log("Error occured: " + e.message); - } - - function onDeviceFound(device) { - if (device.address == "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - device.connect(onconnected.bind(null, device), onerror); - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan(onDeviceFound, onerror); -+
Code example:
+function onconnected(device) +{ + console.log("Connected to device"); + var services = device.getServiceAllUuids(); + console.log("Services length " + services.length); +} + +function onerror(e) +{ + console.log("Error occurred: " + e.message); +} + +function onDeviceFound(device) +{ + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected.bind(null, device), onerror); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +
Code example:
function onerror(e) { - console.log("Error occured: " + e.message); - } - - function onDeviceFound(device) { - var onConnectionStateChange = { - onconnected: function(device) { - console.log("Device " + device.name + " connected"); - }, - ondisconnected: function(device) { - console.log("Device " + device.name + " disconnected"); - } - } - - if (device.address === "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - device.addConnectStateChangeListener(onConnectionStateChange); - device.connect(); - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - adapter.startScan(onDeviceFound, onerror); -+
Code example:
+function onerror(e) +{ + console.log("Error occurred: " + e.message); +} + +function onDeviceFound(device) +{ + var onConnectionStateChange = + { + onconnected: function(device) + { + console.log("Device " + device.name + " connected"); + }, + ondisconnected: function(device) + { + console.log("Device " + device.name + " disconnected"); + } + } + + if (device.address === "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.addConnectStateChangeListener(onConnectionStateChange); + device.connect(); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +
Code example:
function onerror(e) { - console.log("Error occured: " + e.message); - } - - function onDeviceFound(device) { - var onConnectionStateChange = { - onconnected: function(device) { - console.log("Device " + device.name + " connected"); - }, - ondisconnected: function(device) { - console.log("Device " + device.name + " disconnected"); - device.removeConnectStateChangeListener(listenerID); - } - } - - if (device.address === "11:22:33:44:55:66") { - console.log("Found device: " + device.name); - listenerID = device.addConnectStateChangeListener(onConnectionStateChange); - device.connect(); - } - } - - var adapter = tizen.bluetooth.getLEAdapter(); - var listenerID = null; - adapter.startScan(onDeviceFound, onerror); -+
Code example:
+function onerror(e) +{ + console.log("Error occurred: " + e.message); +} + +function onDeviceFound(device) +{ + var onConnectionStateChange = + { + onconnected: function(device) + { + console.log("Device " + device.name + " connected"); + }, + ondisconnected: function(device) + { + console.log("Device " + device.name + " disconnected"); + device.removeConnectStateChangeListener(listenerID); + } + } + + if (device.address === "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + listenerID = device.addConnectStateChangeListener(onConnectionStateChange); + device.connect(); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +var listenerID = null; +adapter.startScan(onDeviceFound, onerror); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function onSocketConnected(socket) { - console.log ("Opened connection to remote device"); - socket.onmessage = function () { - console.log ("Message received: " + socket.readData()); - }; - - socket.onclose = function() { - console.log("Socket closed with " + socket.peer.name); - }; - - // Sends data to peer. - var textmsg = "Test"; - var sendtextmsg = new Array(); - for (var i = 0; i < textmsg.length; i++) - { - sendtextmsg[i] = textmsg.charCodeAt(i); - } - socket.writeData (sendtextmsg); - } - - function onSocketError(e) { - console.log ("Error connecting to service. Reason: " + e.message); - } - - function onDeviceReady(device) { - // Validates device and service uuid. - if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) { - // Opens socket - device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError ); - } - } - function onSetPowered() { - // Gets the BluetoothDevice object. - adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) { console.log("Error: " + e.message); }); - } - - adapter.setPowered(true, onSetPowered, function(e) {console.log ("Could not turn on Bluetooth adapter. reason: " + e.message); }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function onSocketConnected(socket) +{ + console.log("Opened connection to remote device"); + socket.onmessage = function() + { + console.log("Message received: " + socket.readData()); + }; + + socket.onclose = function() + { + console.log("Socket closed with " + socket.peer.name); + }; + + /* Sends data to peer */ + var textmsg = "Test"; + var sendtextmsg = new Array(); + for (var i = 0; i < textmsg.length; i++) + { + sendtextmsg[i] = textmsg.charCodeAt(i); + } + socket.writeData(sendtextmsg); +} + +function onSocketError(e) +{ + console.log("Error connecting to service. Reason: " + e.message); +} + +function onDeviceReady(device) +{ + /* Validates device and service uuid */ + if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) + { + /* Opens socket */ + device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError); + } +} + +function onSetPowered() +{ + /* Gets the BluetoothDevice object */ + adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);}); +} + +adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function onError(e) { - console.log ("Error connecting to service. Reason: " + e.message); - } - - function onSocketConnected(socket) { - console.log ("Opening socket success!!!"); - - socket.onmessage = function() { - // Gets a message from peer, reads it - var data = socket.readData(); - - // - // Code to evaluate message goes here - // - }; - - socket.onclose = function() { - console.log("Socket closed with " + socket.peer.name); - }; - } - - function onDeviceReady(device) { - // Validates device and service uuid - if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) { - // Opens socket - device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError); - } - } - function onSetPowered() { - // Gets the BluetoothDevice object. - adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) { console.log("Error: " + e.message); }); - } - - adapter.setPowered(true, onSetPowered, function(e) {console.log ("Could not turn on Bluetooth adapter. reason: " + e.message); }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function onError(e) +{ + console.log("Error connecting to service. Reason: " + e.message); +} + +function onSocketConnected(socket) +{ + console.log("Opening socket success!!!"); + + socket.onmessage = function() + { + /* Gets a message from peer, reads it */ + var data = socket.readData(); + + /* Code to evaluate message goes here */ + }; + + socket.onclose = function() + { + console.log("Socket closed with " + socket.peer.name); + }; +} + +function onDeviceReady(device) +{ + /* Validates device and service uuid */ + if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) + { + /* Opens socket */ + device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError); + } +} + +function onSetPowered() +{ + /* Gets the BluetoothDevice object */ + adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);}); +} + +adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - - function evaluateDevice(address) { - adapter.getDevice(address, function(device) { - if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) { - // Shows computer icon for this device - console.log("Device is computer"); - } else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) { - // Shows phone icon - console.log("Device is a Phone"); - } - }, function(e) { - console.log("Couldn't get any device with the given address: " + e.message); - }); - } - - evaluateDevice("11:22:33:44:55:66"); - -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); + +function evaluateDevice(address) +{ + adapter.getDevice(address, function(device) + { + if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) + { + /* Shows computer icon for this device */ + console.log("Device is computer"); + } + else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) + { + /* Shows phone icon */ + console.log("Device is a Phone"); + } + }, function(e) + { + console.log("Couldn't get any device with the given address: " + e.message); + }); +} + +evaluateDevice("11:22:33:44:55:66"); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - adapter.getDevice("12:34:56:78:9A:BC", function(device) { - if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) { - console.log("Device supports Positioning service"); - } - }, function(e) { - console.log("Couldn't get device for given address: " + e.message); - }); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +adapter.getDevice("12:34:56:78:9A:BC", function(device) +{ + if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) + { + console.log("Device supports Positioning service"); + } +}, function(e) +{ + console.log("Couldn't get device for given address: " + e.message); +}); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var chatServiceHandler = null; - - function chatServiceSuccessCb(handler) { - console.log("Chat service registration was successful!"); - - chatServiceHandler = handler; - handler.onconnect = function(socket) { - console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); - socket.onmessage = function() { - var data = socket.readData(); - // Handle message code goes here - //.... - }; - - // Expected close - socket.onclose = function() { - console.log('The socket is closed.'); - }; - }; - } - - function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - // Error handler - function(e) { - console.log( "Could not register service record, Error: " + e.message); - }); - } - - function unRegisterChatService() { - if (chatServiceHandler != null) { - chatServiceHandler.unregister(function() { - chatServiceHandler = null; - console.log("Chat service is unregistered."); - }, - function(e) { - console.log ("Error: " + e.message); - }); - } - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var chatServiceHandler = null; + +function chatServiceSuccessCb(handler) +{ + console.log("Chat service registration was successful!"); + + chatServiceHandler = handler; + handler.onconnect = function(socket) + { + console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); + socket.onmessage = function() + { + var data = socket.readData(); + /* Handle message code here */ + }; + + /* Expected close */ + socket.onclose = function() + { + console.log('The socket is closed.'); + }; + }; +} + +function publishChatService() +{ + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); +} + +function unRegisterChatService() +{ + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + chatServiceHandler = null; + console.log("Chat service is unregistered."); + }, function(e) + { + console.log("Error: " + e.message); + }); + } +} +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - } +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); +} - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - var registerHealthApp = null; - - function healthConnectSuccess(channel) { - console.log("Health device is connected"); - var status = "Name of remote device: " + channel.peer.name + - "channel type of device profile: " + channel.channelType + - "health application name: " + channel.appication.name; - console.log(status); - } - - function healthConnectError(e) { - console.log("Failed to connect to source: " + e.message); - }; - - function gotDeviceInfo(device) { - healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); - } - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - registerHealthApp = app; - adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +var registerHealthApp = null; + +function healthConnectSuccess(channel) +{ + console.log("Health device is connected"); + var status = "Name of remote device: " + channel.peer.name + + "channel type of device profile: " + channel.channelType + + "health application name: " + channel.appication.name; + console.log(status); +} + +function healthConnectError(e) +{ + console.log("Failed to connect to source: " + e.message); +}; + +function gotDeviceInfo(device) +{ + healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); +} + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + registerHealthApp = app; + adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - var healthApp = null; - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - healthApp = app; - healthApp.onconnect = function(channel) { - console.log("Connected!!"); - }; - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - function startSink() { - try { - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); - } catch(e) { - console.log("Error: " + e.message); - } - } - - function stopSink() { - try { - if (healthApp != null) { - healthApp.unregister(function() { - healthApp = null; - console.log("Health application is unregistered."); - }, - function(e) { - console.log ("Error: " + e.message); - }); - } - } catch(err) { - console.log("Error: " + err.message); - } - } -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +var healthApp = null; + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + healthApp = app; + healthApp.onconnect = function(channel) + { + console.log("Connected!!"); + }; +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +function startSink() +{ + try + { + healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); + } + catch (e) + { + console.log("Error: " + e.message); + } +} + +function stopSink() +{ + try + { + if (healthApp != null) + { + healthApp.unregister(function() + { + healthApp = null; + console.log("Health application is unregistered."); + }, function(e) + { + console.log("Error: " + e.message); + }); + } + } + catch (err) + { + console.log("Error: " + err.message); + } +} +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) {; - console.log("Health device is connected"); - channel.close(); - } - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.close(); + } +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) { - console.log("Health device is connected"); - channel.sendData(dataToSend); - } - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.sendData(dataToSend); + } +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - - var channelCallback = { - onmessage: function(data) { - console.log("data is received") - }, - onclose: function() { - console.log("channel is closed"); - } - }; - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) {; - console.log("Health device is connected"); - channel.setListener(channelCallback); - } - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + +var channelCallback = +{ + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + } +}; + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.setListener(channelCallback); + } +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - var connectedChannel = null; - - var channelCallback = { - onmessage: function(data) { - console.log("data is received") - }, - onclose: function() { - console.log("channel is closed"); - connectedChannel.unsetListener(); - } - }; - - function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) {; - console.log("Health device is connected"); - connectedChannel = channel; - connectedChannel.setListener(channelCallback); - } - } - - function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); - }; - - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); -+
Code example:
+var adapter = tizen.bluetooth.getDefaultAdapter(); +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +var connectedChannel = null; + +var channelCallback = +{ + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + connectedChannel.unsetListener(); + } +}; + +function healthRegisterSuccess(app) +{ + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + connectedChannel = channel; + connectedChannel.setListener(channelCallback); + } +} + +function healthRegisterError(e) +{ + console.log("Failed to register application: " + e.message); +}; + +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); +
Code example:
try { - // Retrieves bookmarks from the root bookmark folder recursively. - var allBookmarks = tizen.bookmark.get(null, true); - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + /* Retrieves bookmarks from the root bookmark folder recursively */ + var allBookmarks = tizen.bookmark.get(null, true); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - // Adds a bookmark item to root bookmark folder. - tizen.bookmark.add(new tizen.BookmarkItem("tizen", "https://www.tizen.org")); - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + /* Adds a bookmark item to root bookmark folder */ + tizen.bookmark.add(new tizen.BookmarkItem("tizen", "https://www.tizen.org")); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - // Removes all the bookmark folders and items. - tizen.bookmark.remove(); - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + /* Removes all the bookmark folders and items */ + tizen.bookmark.remove(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
BookmarkItem(DOMString title, DOMString url);
Code example:
try { - // Creates a bookmark item. - var tizen = new tizen.BookmarkItem("tizen", "https://www.tizen.org"); - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + /* Creates a bookmark item */ + var tizen = new tizen.BookmarkItem("tizen", "https://www.tizen.org"); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
BookmarkFolder(DOMString title);
Code example:
try { - // creates a bookmark folder - var folder = new tizen.BookmarkFolder("folder"); - } catch (err) { - console.log (err.name +": " + err.message); - } -+
Code example:
+try +{ + /* Creates a bookmark folder */ + var folder = new tizen.BookmarkFolder("folder"); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var calendar; - - function eventFoundCallback(events) { - // The event has been successfully found. - // Changes the summary. - events[0].summary = 'HTML6 Webinar'; - calendar.update(events[0]); - console.log('First event was updated!'); - } - - // Defines the error callback for all the asynchronous calls. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the success callback for retrieving the list of calendars. - function calendarListCallback(calendars) { - if(calendars.length > 0) { - calendar = calendars[0]; - console.log('The calendar id is ' + calendar.id + ' and name ' + calendar.name); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - calendar.add(ev); - - // The event has been successfully added. - // Checks whether the added event can be retrieved from the calendar. - // If the calendar was empty, only the item added through add() should be returned. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); - calendar.find(eventFoundCallback, errorCallback, filter); - } - } - - // Gets a list of available calendars. - tizen.calendar.getCalendars("EVENT", calendarListCallback, errorCallback); -+
Code example:
+var calendar; + +function eventFoundCallback(events) +{ + /* Event has been successfully found */ + /* Changes the summary */ + events[0].summary = 'HTML6 Webinar'; + calendar.update(events[0]); + console.log('First event was updated!'); +} + +/* Defines the error callback for all the asynchronous calls */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the success callback for retrieving the list of calendars */ +function calendarListCallback(calendars) +{ + if (calendars.length > 0) + { + calendar = calendars[0]; + console.log('The calendar id is ' + calendar.id + ' and name ' + calendar.name); + + var ev = new tizen.CalendarEvent( + { + description:'HTML5 Introduction', + summary:'HTML5 Webinar', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' + }); + calendar.add(ev); + + /* Event has been successfully added */ + /* Checks whether the added event can be retrieved from the calendar */ + /* If the calendar was empty, only the item added through add() should be returned */ + var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); + calendar.find(eventFoundCallback, errorCallback, filter); + } +} + +/* Gets a list of available calendars */ +tizen.calendar.getCalendars("EVENT", calendarListCallback, errorCallback); +
Code example:
var unifiedCalendar; - - // Defines the error callback for all the asynchronous calls. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - function eventFoundCallback(events) { - // The event has been successfully found. - // Changes the summary. - events[0].summary = 'HTML6 Webinar'; - unifiedCalendar.update(events[0]); - console.log('First event was updated!'); - } - - // Gets the unified calendar. - unifiedCalendar = tizen.calendar.getUnifiedCalendar("EVENT"); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - - unifiedCalendar.add(ev); - - // The event has been added. - // Checks whether the added event can be retrieved from the calendar. - // If the calendar was empty, only the item added through add() should be returned. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); - unifiedCalendar.find(eventFoundCallback, errorCallback, filter); -+
Code example:
+var unifiedCalendar; + +/* Defines the error callback for all the asynchronous calls */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +function eventFoundCallback(events) +{ + /* Event has been successfully found */ + /* Changes the summary */ + events[0].summary = 'HTML6 Webinar'; + unifiedCalendar.update(events[0]); + console.log('First event was updated!'); +} + +/* Gets the unified calendar */ +unifiedCalendar = tizen.calendar.getUnifiedCalendar("EVENT"); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); + +unifiedCalendar.add(ev); + +/* Event has been added */ +/* Checks whether the added event can be retrieved from the calendar */ +/* If the calendar was empty, only the item added through add() should be returned */ +var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); +unifiedCalendar.find(eventFoundCallback, errorCallback, filter); +
Code example:
var myCalendar; - - // Defines the error callback for all the asynchronous calls. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - function eventFoundCallback(events) { - // The event has been successfully found. - // Changes the summary. - events[0].summary = 'HTML6 Webinar'; - myCalendar.update(events[0]); - console.log('First event was updated!'); - } - - // Gets the default calendar. - myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - - myCalendar.add(ev); - - // The event has been added. - // Checks whether the added event can be retrieved from the calendar. - // If the calendar was empty, only the item added through add() should be returned. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); - myCalendar.find(eventFoundCallback, errorCallback, filter); -+
Code example:
+var myCalendar; + +/* Defines the error callback for all the asynchronous calls */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +function eventFoundCallback(events) +{ + /* Event has been successfully found */ + /* Changes the summary */ + events[0].summary = 'HTML6 Webinar'; + myCalendar.update(events[0]); + console.log('First event was updated!'); +} + +/* Gets the default calendar */ +myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); + +myCalendar.add(ev); + +/* Event has been added */ +/* Checks whether the added event can be retrieved from the calendar */ +/* If the calendar was empty, only the item added through add() should be returned */ +var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); +myCalendar.find(eventFoundCallback, errorCallback, filter); +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var calendar = new tizen.Calendar( - account.id, - 'remote calendar', - 'TASK' - ); - tizen.calendar.addCalendar(calendar); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var calendar = new tizen.Calendar(account.id, + 'remote calendar', 'TASK'); + tizen.calendar.addCalendar(calendar); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var calendar = new tizen.Calendar( - account.id, - 'remote calendar', - 'TASK' - ); - tizen.calendar.addCalendar(calendar); - tizen.calendar.removeCalendar('TASK', calendar.id); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var calendar = new tizen.Calendar(account.id, + 'remote calendar', 'TASK'); + tizen.calendar.addCalendar(calendar); + tizen.calendar.removeCalendar('TASK', calendar.id); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
var calendarId; // calendarId supposed to be initialized - try { - var calendar = tizen.calendar.getCalendar("EVENT", calendarId); - console.log("Successfully retrieved event calendar with id: " + calendarId); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+var calendarId; /* calendarId supposed to be initialized */ +try +{ + var calendar = tizen.calendar.getCalendar("EVENT", calendarId); + console.log("Successfully retrieved event calendar with id: " + calendarId); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var calendar = new tizen.Calendar( - account.id, - 'remote calendar', - 'TASK' - ); - // 'calendar' variable is not available until it is inserted into the database. - tizen.calendar.addCalendar(calendar); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var calendar = new tizen.Calendar(account.id, + 'remote calendar', 'TASK'); + /* 'calendar' variable is not available until it is inserted into the database */ + tizen.calendar.addCalendar(calendar); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
// Gets the default calendar and show its name. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - console.log('The calendar name is ' + calendar.name); -+
Code example:
+/* Gets the default calendar and shows its name */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); +console.log('The calendar name is ' + calendar.name); +
Code example:
var myCalendar; // Calendar supposed to be initialized - var itemId; // Calendar item identifier - try { - var item = myCalendar.get(itemId); - console.log("Successfully retrieved item with id: " + itemId); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+var myCalendar; /* Calendar supposed to be initialized */ +var itemId; /* Calendar item identifier */ +try +{ + var item = myCalendar.get(itemId); + console.log("Successfully retrieved item with id: " + itemId); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
// Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - - calendar.add(ev); - console.log('Event added with uid ' + ev.id.uid); -+
Code example:
+/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); + +calendar.add(ev); +console.log('Event added with uid ' + ev.id.uid); +
Code example:
// Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - function addEventsSuccess(events) { - console.log("Successfully added " + events.length + " events!"); - } - - // Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - - calendar.addBatch([ev], addEventsSuccess, errorCallback); -+
Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +function addEventsSuccess(events) +{ + console.log("Successfully added " + events.length + " events!"); +} + +/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); + +calendar.addBatch([ev], addEventsSuccess, errorCallback); +
Code example:
var myCalendar; - - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the event success callback. - function eventSearchSuccessCallback(events) { - events[0].description = 'New Description'; - // Updates the first existing event. - myCalendar.update(events[0]); - console.log("The first item description was updated!"); - } - - // Gets the default calendar. - myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - // Finds all events in a Calendar. - myCalendar.find(eventSearchSuccessCallback, errorCallback); -+
Code example:
+var myCalendar; + +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the event success callback */ +function eventSearchSuccessCallback(events) +{ + events[0].description = 'New Description'; + /* Updates the first existing event */ + myCalendar.update(events[0]); + console.log("The first item description was updated!"); +} + +/* Gets the default calendar */ +myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +/* Finds all events in a Calendar */ +myCalendar.find(eventSearchSuccessCallback, errorCallback); +
Code example:
var myCalendar; - - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the success callback. - function updateEventsSuccess() { - console.log("Successfully updated !" ); - } - - // Defines the event success callback. - function eventSearchSuccessCallback(events) { - events[0].description = 'New Description 1'; - events[1].description = 'New Description 2'; - // Updates the first two existing events. - myCalendar.updateBatch(events.slice(0,2), updateEventsSuccess, errorCallback); - } - - // Gets the default calendar. - myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - // Finds all events in Calendar. - myCalendar.find(eventSearchSuccessCallback, errorCallback); -+
Code example:
+var myCalendar; + +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the success callback */ +function updateEventsSuccess() +{ + console.log("Successfully updated !"); +} + +/* Defines the event success callback */ +function eventSearchSuccessCallback(events) +{ + events[0].description = 'New Description 1'; + events[1].description = 'New Description 2'; + /* Updates the first two existing events */ + myCalendar.updateBatch(events.slice(0,2), updateEventsSuccess, errorCallback); +} + +/* Gets the default calendar */ +myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +/* Finds all events in Calendar */ +myCalendar.find(eventSearchSuccessCallback, errorCallback); +
Code example:
var myCalendar; - - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the event success callback. - function eventSearchSuccessCallback(events) { - // Deletes the first existing event. - myCalendar.remove(events[0].id); - console.log('The first event was removed'); - } - - // Gets default calendar. - myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - // Finds all events in Calendar. - myCalendar.find(eventSearchSuccessCallback, errorCallback); -+
Code example:
+var myCalendar; + +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the event success callback */ +function eventSearchSuccessCallback(events) +{ + /* Deletes the first existing event */ + myCalendar.remove(events[0].id); + console.log('The first event was removed'); +} + +/* Gets default calendar */ +myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +/* Finds all events in Calendar */ +myCalendar.find(eventSearchSuccessCallback, errorCallback); +
Code example:
var myCalendar; - - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the removeBatch callback. - function removeBatchCallback() { - console.log("Requested events were successfully removed."); - } - - // Defines the event search success callback. - function eventSearchSuccessCallback(events) { - // Deletes the first two existing events. - myCalendar.removeBatch([events[0].id, events[1].id], - removeBatchCallback, - errorCallback); - } - - // Gets the default calendar. - myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - // Retrieves all the events in Calendar. - myCalendar.find(eventSearchSuccessCallback, errorCallback); -+
Code example:
+var myCalendar; + +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the removeBatch callback */ +function removeBatchCallback() +{ + console.log("Requested events were successfully removed."); +} + +/* Defines the event search success callback */ +function eventSearchSuccessCallback(events) +{ + /* Deletes the first two existing events */ + myCalendar.removeBatch([events[0].id, events[1].id], + removeBatchCallback, errorCallback); +} + +/* Gets the default calendar */ +myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +/* Retrieves all the events in Calendar */ +myCalendar.find(eventSearchSuccessCallback, errorCallback); +
Code example:
// Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } +Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} - // Defines the event search success callback. - function eventSearchSuccessCallback(events) { - console.log(events.length + ' results found.'); - } +/* Defines the event search success callback */ +function eventSearchSuccessCallback(events) +{ + console.log(events.length + ' results found.'); +} - // Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); +/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - // Finds all events the calendar that contain in the summary the string Tizen. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'Tizen'); +/* Finds all events the calendar that contain in the summary the string Tizen */ +var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'Tizen'); - // The events returned by the find() query will be sorted by ascending summary. - var sortingMode = new tizen.SortMode('summary', 'ASC'); +/* Events returned by the find() query will be sorted by ascending summary */ +var sortingMode = new tizen.SortMode('summary', 'ASC'); - calendar.find(eventSearchSuccessCallback, errorCallback, filter, sortingMode); -+calendar.find(eventSearchSuccessCallback, errorCallback, filter, sortingMode); +
Code example:
var watcherId = 0; // watcher identifier - var calendar; // This example assumes calendar is initialized - - var watcher = { - onitemsadded: function(items) { - console.log(items.length + ' items were added'); - }, - onitemsupdated: function(items) { - console.log(items.length + ' items were updated'); - }, - onitemsremoved: function(ids) { - console.log(ids.length + ' items were removed'); - } - }; - - // Registers to be notified when the calendar changes. - watcherId = calendar.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var calendar; /* This example assumes calendar is initialized */ + +var watcher = +{ + onitemsadded: function(items) + { + console.log(items.length + ' items were added'); + }, + onitemsupdated: function(items) + { + console.log(items.length + ' items were updated'); + }, + onitemsremoved: function(ids) + { + console.log(ids.length + ' items were removed'); + } +}; + +/* Registers to be notified when the calendar changes */ +watcherId = calendar.addChangeListener(watcher); +
Code example:
var watcherId = 0; // watcher identifier - var calendar; // This example assumes calendar is initialized. - - // Receives calendar changes. - var watcher = { - onitemsadded: function(items) { - console.log(items.length + ' items were added'); - }, - onitemsupdated: function(items) { - console.log(evitemsents.length + ' items were updated'); - }, - onitemsremoved: function(ids) { - console.log(ids.length + ' items were removed'); - } - }; - - // Registers to be notified when the calendar changes. - watcherId = calendar.addChangeListener(watcher); - - // Cancels the watch operation. - calendar.removeChangeListener(watcherId); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var calendar; /* This example assumes calendar is initialized */ + +/* Receives calendar changes */ +var watcher = +{ + onitemsadded: function(items) + { + console.log(items.length + ' items were added'); + }, + onitemsupdated: function(items) + { + console.log(evitemsents.length + ' items were updated'); + }, + onitemsremoved: function(ids) + { + console.log(ids.length + ' items were removed'); + } +}; + +/* Registers to be notified when the calendar changes */ +watcherId = calendar.addChangeListener(watcher); + +/* Cancels the watch operation */ +calendar.removeChangeListener(watcherId); +
Code example:
event.description = 'Tizen Codefest'; -+
Code example:
+event.description = 'Tizen Codefest'; +
Code example:
event.summary = 'Launching the Tizen reference implementation'; -+
Code example:
+event.summary = 'Launching the Tizen reference implementation'; +
Code example:
event.isAllDay = true; // All-Day event -+
Code example:
+event.isAllDay = true; /* All-day event */ +
Code example:
// 2010-04-30 09:00 - event.startDate = new tizen.TZDate(2010, 3, 30, 9, 0); -+
Code example:
+/* 2010-04-30 09:00 */ +event.startDate = new tizen.TZDate(2010, 3, 30, 9, 0); +
Code example:
// 1 hour meeting - event.duration = new tizen.TimeDuration(1, "HOURS"); -+
Code example:
+/* 1 hour meeting */ +event.duration = new tizen.TimeDuration(1, "HOURS"); +
Code example:
event.location = 'Huesca'; -+
Code example:
+event.location = 'Huesca'; +
Code example:
event.geolocation = new tizen.SimpleCoordinates(60.175, 24.934); -+
Code example:
+event.geolocation = new tizen.SimpleCoordinates(60.175, 24.934); +
Code example:
event.organizer = 'Mr. Jones'; -+
Code example:
+event.organizer = 'Mr. Jones'; +
Code example:
event.status = "TENTATIVE"; -+
Code example:
+event.status = "TENTATIVE"; +
Code example:
task.priority = "HIGH"; -+
Code example:
+task.priority = "HIGH"; +
Code example:
ev.startDate = new tizen.TZDate(2011, 2, 11, 8, 0, 0); - // Gives a sound notification 30 minutes before the item's start time. - var alarm = new tizen.CalendarAlarm(new tizen.TimeDuration(30, "MINS"), - "SOUND"); - ev.alarms = [alarm]; -+
Code example:
+ev.startDate = new tizen.TZDate(2011, 2, 11, 8, 0, 0); +/* Gives a sound notification 30 minutes before the item's start time */ +var alarm = new tizen.CalendarAlarm(new tizen.TimeDuration(30, "MINS"), + "SOUND"); +ev.alarms = [alarm]; +
Code example:
event.categories = ['Personal']; -+
Code example:
+event.categories = ['Personal']; +
Code example:
var attendee = new tizen.CalendarAttendee('mailto:bob@domain.com', - {role: "CHAIR", RSVP: true}); - event.attendees = [attendee]; -+
Code example:
+var attendee = new tizen.CalendarAttendee('mailto:bob@domain.com', + {role: "CHAIR", RSVP: true}); +event.attendees = [attendee]; +
Code example:
// Defines the event search success callback. - function eventSearchSuccessCallback(events) { - // Converts the first event to iCalendar 2.0 format (default). - var vevent = events[0].convertToString("ICALENDAR_20"); - console.log('iCalendar 2.0 representation of the event is: ' + vevent); - } - - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Gets the default calendar. - var myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); - - // Finds all events in the first calendar that contain in the summary the string Tizen. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'Tizen'); - myCalendar.find(eventSearchSuccessCallback, errorCallback, filter); -+
Code example:
+/* Defines the event search success callback */ +function eventSearchSuccessCallback(events) +{ + /* Converts the first event to iCalendar 2.0 format (default) */ + var vevent = events[0].convertToString("ICALENDAR_20"); + console.log('iCalendar 2.0 representation of the event is: ' + vevent); +} + +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Gets the default calendar */ +var myCalendar = tizen.calendar.getDefaultCalendar("EVENT"); + +/* Finds all events in the first calendar that contain in the summary the string Tizen */ +var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'Tizen'); +myCalendar.find(eventSearchSuccessCallback, errorCallback, filter); +
Code example:
// Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar(); +Code example:
+/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar(); - var html5seminar = new tizen.CalendarEvent({startDate: new tizen.TZDate(2012, 3, 4), - duration: new tizen.TimeDuration(3, "DAYS"), - summary: "HTML5 Seminar"}); +var html5seminar = new tizen.CalendarEvent({startDate: new tizen.TZDate(2012, 3, 4), + duration: new tizen.TimeDuration(3, "DAYS"), + summary: "HTML5 Seminar"}); - calendar.add(html5seminar); - var tizenseminar = html5seminar.clone(); - tizenseminar.summary = "Tizen Seminar"; - calendar.add(tizenseminar); -+calendar.add(html5seminar); +var tizenseminar = html5seminar.clone(); +tizenseminar.summary = "Tizen Seminar"; +calendar.add(tizenseminar); +
Code example:
var taskCalendar, task; - - try { - var task = new tizen.CalendarTask("BEGIN:VCALENDAR\r\n" + - "VERSION:2.0\r\n" + - "BEGIN:VTODO\r\n" + - "DTSTAMP:TZID=CET:20110902T110000Z\r\n" + - "DTSTART;TZID=CET:20110906T140000Z\r\n" + - "DUE;TZID=CET:20110906T150000Z\r\n" + - "SUMMARY:Discuss the schedule\r\n" + - "DESCRIPTION:Find the feasible schedule\r\n" + - "CATEGORIES:HUMAN RESOURCES\r\n" + - "END:VTODO\r\n" + - "END:VCALENDAR", "ICALENDAR_20"); - - taskCalendar = tizen.calendar.getDefaultCalendar("TASK"); - taskCalendar.add(task); - console.log("Task added with ID " + task.id); - } catch (err) { - console.log("Failed to add VTODO to the calendar, error: " + err.name); - } -+
Code example:
+var taskCalendar, task; + +try +{ + var task = new tizen.CalendarTask("BEGIN:VCALENDAR\r\n" + + "VERSION:2.0\r\n" + + "BEGIN:VTODO\r\n" + + "DTSTAMP:TZID=CET:20110902T110000Z\r\n" + + "DTSTART;TZID=CET:20110906T140000Z\r\n" + + "DUE;TZID=CET:20110906T150000Z\r\n" + + "SUMMARY:Discuss the schedule\r\n" + + "DESCRIPTION:Find the feasible schedule\r\n" + + "CATEGORIES:HUMAN RESOURCES\r\n" + + "END:VTODO\r\n" + + "END:VCALENDAR", "ICALENDAR_20"); + + taskCalendar = tizen.calendar.getDefaultCalendar("TASK"); + taskCalendar.add(task); + console.log("Task added with ID " + task.id); +} +catch (err) +{ + console.log("Failed to add VTODO to the calendar, error: " + err.name); +} +
Code example:
var taskInit = { description: "HTML5 Introduction", - summary: "HTML5 Webinar", - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - dueDate: new tizen.TZDate(2011, 5, 30, 10, 0), - completedDate: new tizen.TZDate(2011, 4, 30, 10, 0), - progress: "0" }; - - var ev = new tizen.CalendarTask(taskInit); -+
Code example:
+var taskInit = +{ + description: "HTML5 Introduction", + summary: "HTML5 Webinar", + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + dueDate: new tizen.TZDate(2011, 5, 30, 10, 0), + completedDate: new tizen.TZDate(2011, 4, 30, 10, 0), + progress: "0" +}; + +var ev = new tizen.CalendarTask(taskInit); +
Code example:
task.dueDate = new tizen.TZDate(2011, 2, 11); -+
Code example:
+task.dueDate = new tizen.TZDate(2011, 2, 11); +
Code example:
task.completedDate = new tizen.TZDate(2011, 2, 11); -+
Code example:
+task.completedDate = new tizen.TZDate(2011, 2, 11); +
Code example:
task.progress = 50; // 50% done -+
Code example:
+task.progress = 50; /* 50% done */ +
Code example:
// Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - - try { - var ev = new tizen.CalendarEvent("BEGIN:VCALENDAR\r\n" + - "BEGIN:VEVENT\r\n" + - "DTSTAMP:19970901T1300Z\r\n" + - "DTSTART:19970903T163000Z\r\n" + - "DTEND:19970903T190000Z\r\n" + - "SUMMARY:Annual Employee Review\r\n" + - "CATEGORIES:BUSINESS,HUMAN RESOURCES\r\n" + - "END:VEVENT\r\n" + - "END:VCALENDAR", "ICALENDAR_20"); - - calendar.add(ev); - console.log('Event added with UID ' + ev.id.uid); - } catch (err) { - console.log("Failed to add VEVENT to the calendar, error: " + err.name); - } -+
Code example:
+/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); + +try +{ + var ev = new tizen.CalendarEvent("BEGIN:VCALENDAR\r\n" + + "BEGIN:VEVENT\r\n" + + "DTSTAMP:19970901T1300Z\r\n" + + "DTSTART:19970903T163000Z\r\n" + + "DTEND:19970903T190000Z\r\n" + + "SUMMARY:Annual Employee Review\r\n" + + "CATEGORIES:BUSINESS,HUMAN RESOURCES\r\n" + + "END:VEVENT\r\n" + + "END:VCALENDAR", "ICALENDAR_20"); + + calendar.add(ev); + console.log('Event added with UID ' + ev.id.uid); +} +catch (err) +{ + console.log("Failed to add VEVENT to the calendar, error: " + err.name); +} +
Code example:
var eventInit = { description: "HTML5 Introduction", - summary: "HTML5 Webinar", - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location: "Huesca" }; +Code example:
+var eventInit = +{ + description: "HTML5 Introduction", + summary: "HTML5 Webinar", + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location: "Huesca" +}; - var ev = new tizen.CalendarEvent(eventInit); -+var ev = new tizen.CalendarEvent(eventInit); +
Code example:
// 2010-04-30 09:00 - event.endDate = new tizen.TZDate(2010, 3, 30, 9, 0); -+
Code example:
+/* 2010-04-30 09:00 */ +event.endDate = new tizen.TZDate(2010, 3, 30, 9, 0); +
Code example:
// Repeats daily for 7 days. - var rule = new tizen.CalendarRecurrenceRule("DAILY", {occurrenceCount: 7}); - event.recurrenceRule = rule; -+
Code example:
+/* Repeats daily for 7 days */ +var rule = new tizen.CalendarRecurrenceRule("DAILY", {occurrenceCount: 7}); +event.recurrenceRule = rule; +
Code example:
// eventId should be set to ID of event obtained with the find function. - var eventId; - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // Defines the event expanding success callback. - function eventExpandingSuccessCallback(events) { - console.log(events.length + ' event instances were returned.'); - } - - var calendar = tizen.calendar.getDefaultCalendar(); - var event = calendar.get(eventId); - - if (event.recurrenceRule != null) { - // This is a recurring event. Expands all the instances during August 2011. - event.expandRecurrence(new tizen.TZDate(2011, 7, 1), - new tizen.TZDate(2011, 7, 31), - eventExpandingSuccessCallback, - errorCallback); - } -+
Code example:
+/* eventId should be set to ID of event obtained with the find function */ +var eventId; +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* Defines the event expanding success callback */ +function eventExpandingSuccessCallback(events) +{ + console.log(events.length + ' event instances were returned.'); +} + +var calendar = tizen.calendar.getDefaultCalendar(); +var event = calendar.get(eventId); + +if (event.recurrenceRule != null) +{ + /* This is a recurring event. Expands all the instances during August 2011 */ + event.expandRecurrence(new tizen.TZDate(2011, 7, 1), new tizen.TZDate(2011, 7, 31), + eventExpandingSuccessCallback, errorCallback); +} +
Code example:
var attendee = new tizen.CalendarAttendee('mailto:bob@domain.com', - {role: "CHAIR", RSVP: true}); - event.attendees = [attendee]; -+
Code example:
+var attendee = new tizen.CalendarAttendee('mailto:bob@domain.com', + {role: "CHAIR", RSVP: true}); +event.attendees = [attendee]; +
Code example:
// Repeats daily for 7 days. - var rule = new tizen.CalendarRecurrenceRule("DAILY", {occurrenceCount:7}); - event.recurrenceRule = rule; -+
Code example:
+/* Repeats daily for 7 days */ +var rule = new tizen.CalendarRecurrenceRule("DAILY", {occurrenceCount:7}); +event.recurrenceRule = rule; +
Code example:
// Creates a sound alarm at the specified time - var alarm1 = new tizen.CalendarAlarm(new tizen.TZDate(2011, 3, 30, 10, 0), "SOUND"); +Code example:
+/* Creates a sound alarm at the specified time */ +var alarm1 = new tizen.CalendarAlarm(new tizen.TZDate(2011, 3, 30, 10, 0), "SOUND"); - // Creates a sound alarm before an event starts - var alarm2 = new tizen.CalendarAlarm(new tizen.TimeDuration(1, "MINS"), "SOUND"); -+/* Creates a sound alarm before an event starts */ +var alarm2 = new tizen.CalendarAlarm(new tizen.TimeDuration(1, "MINS"), "SOUND"); +
Code example:
// eventId should be set to ID of event obtained with the find function. - var eventId; - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // CalendarEventArraySuccessCallback instance - function calendarEventArraySuccessCB(events) { - console.log(events.length + ' event instances were returned.'); - } - - var calendar = tizen.calendar.getDefaultCalendar(); - var event = calendar.get(eventId); - - if (event.recurrenceRule != null) { - // This is a recurring event. Expands all the instances during August 2011. - event.expandRecurrence(new tizen.TZDate(2011, 7, 1), - new tizen.TZDate(2011, 7, 31), - calendarEventArraySuccessCB, - errorCallback); - } -+
Code example:
+/* eventId should be set to ID of event obtained with the find function */ +var eventId; +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* CalendarEventArraySuccessCallback instance */ +function calendarEventArraySuccessCB(events) +{ + console.log(events.length + ' event instances were returned.'); +} + +var calendar = tizen.calendar.getDefaultCalendar(); +var event = calendar.get(eventId); + +if (event.recurrenceRule != null) +{ + /* This is a recurring event. Expands all the instances during August 2011 */ + event.expandRecurrence(new tizen.TZDate(2011, 7, 1), new tizen.TZDate(2011, 7, 31), + calendarEventArraySuccessCB, errorCallback); +} +
Code example:
// Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // CalendarItemArraySuccessCallback instance - function calendarItemArraySuccessCB(events) { - console.log("Successfully added " + events.length + " events!"); - } - - // Gets the default calendar. - var calendar = tizen.calendar.getDefaultCalendar("EVENT"); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - - calendar.addBatch([ev], calendarItemArraySuccessCB, errorCallback); -+
Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* CalendarItemArraySuccessCallback instance */ +function calendarItemArraySuccessCB(events) +{ + console.log("Successfully added " + events.length + " events!"); +} + +/* Gets the default calendar */ +var calendar = tizen.calendar.getDefaultCalendar("EVENT"); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); + +calendar.addBatch([ev], calendarItemArraySuccessCB, errorCallback); +
Code example:
var calendar; - - function eventFoundCallback(events) { - // The event has been successfully found. - // Changes the summary. - events[0].summary = 'HTML6 Webinar'; - calendar.update(events[0]); - console.log('First event was updated!'); - } - - // Defines the error callback for all the asynchronous calls. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } - - // CalendarArraySuccessCallback instance - function calendarArraySuccessCB(calendars) { - if(calendars.length > 0) { - calendar = calendars[0]; - console.log('The calendar id is ' + calendar.id + ' and name ' + calendar.name); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); - calendar.add(ev); - - // The event has been successfully added. - // Checks whether the added event can be retrieved from the calendar. - // If the calendar was empty, only the item added through add() should be returned. - var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); - calendar.find(eventFoundCallback, errorCallback, filter); - } - } - - // Gets a list of available calendars. - tizen.calendar.getCalendars("EVENT", calendarArraySuccessCB, errorCallback); -+
Code example:
+var calendar; + +function eventFoundCallback(events) +{ + /* Event has been successfully found */ + /* Changes the summary */ + events[0].summary = 'HTML6 Webinar'; + calendar.update(events[0]); + console.log('First event was updated!'); +} + +/* Defines the error callback for all the asynchronous calls */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} + +/* CalendarArraySuccessCallback instance */ +function calendarArraySuccessCB(calendars) +{ + if (calendars.length > 0) + { + calendar = calendars[0]; + console.log('The calendar id is ' + calendar.id + ' and name ' + calendar.name); + + var ev = new tizen.CalendarEvent( + { + description:'HTML5 Introduction', + summary:'HTML5 Webinar', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' + }); + calendar.add(ev); + + /* Event has been successfully added */ + /* Checks whether the added event can be retrieved from the calendar */ + /* If the calendar was empty, only the item added through add() should be returned */ + var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); + calendar.find(eventFoundCallback, errorCallback, filter); + } +} + +/* Gets a list of available calendars */ +tizen.calendar.getCalendars("EVENT", calendarArraySuccessCB, errorCallback); +
Code example:
var watcherId = 0; // watcher identifier - var calendar; // This example assumes calendar is initialized - - var watcher = { - onitemsadded: function(items) { - console.log('New item ' + items[0].id + ' added'); - }, - onitemsupdated: function(items) { - // ... - }, - onitemsremoved: function(ids) { - // ... - } - }; - - // Registers to be notified when the calendar changes. - watcherId = calendar.addChangeListener(watcher); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var calendar; /* This example assumes calendar is initialized */ + +var watcher = +{ + onitemsadded: function(items) + { + console.log('New item ' + items[0].id + ' added'); + }, + onitemsupdated: function(items) + { + /* Do something */ + }, + onitemsremoved: function(ids) + { + /* Do something */ + } +}; + +/* Registers to be notified when the calendar changes */ +watcherId = calendar.addChangeListener(watcher); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); +
Code example:
var watcherId = 0; // watcher identifier - var calendar; // This example assumes calendar is initialized - - var watcher = { - onitemsadded: function(items) { - if (calendar.update) { - items[0].location = 'New York'; - calendar.update(items[0]); - } - }, - onitemsupdated: function(items) { - console.log('Item updated'); - }, - onitemsremoved: function(ids) { - // ... - } - }; - - // Registers to be notified when the calendar changes. - watcherId = calendar.addChangeListener(watcher); - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var calendar; /* This example assumes calendar is initialized */ + +var watcher = +{ + onitemsadded: function(items) + { + if (calendar.update) + { + items[0].location = 'New York'; + calendar.update(items[0]); + } + }, + onitemsupdated: function(items) + { + console.log('Item updated'); + }, + onitemsremoved: function(ids) + { + /* Do something */ + } +}; + +/* Registers to be notified when the calendar changes */ +watcherId = calendar.addChangeListener(watcher); +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); +
Code example:
var watcherId = 0; // watcher identifier - var calendar; // This example assumes calendar is initialized - - var watcher = { - onitemsadded: function(items) { - if (calendar.remove) { - calendar.remove(items[0].id); - } - }, - onitemsupdated: function(items) { - // ... - }, - onitemsremoved: function(ids) { - console.log('Item removed'); - } - }; - - // Registers to be notified when the calendar changes. - watcherId = calendar.addChangeListener(watcher); - - var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', - summary:'HTML5 Webinar ', - startDate: new tizen.TZDate(2011, 3, 30, 10, 0), - duration: new tizen.TimeDuration(1, "HOURS"), - location:'Huesca'}); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var calendar; /* This example assumes calendar is initialized */ + +var watcher = +{ + onitemsadded: function(items) + { + if (calendar.remove) + { + calendar.remove(items[0].id); + } + }, + onitemsupdated: function(items) + { + /* Do something */ + }, + onitemsremoved: function(ids) + { + console.log('Item removed'); + } +}; + +/* Registers to be notified when the calendar changes */ +watcherId = calendar.addChangeListener(watcher); + +var ev = new tizen.CalendarEvent( +{ + description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca' +}); +
Code example:
// Defines success callback - function onSuccess(results) { - console.log(results.length + " call history item(s) found!"); - for (var i=0; i<results.length; i++) { - console.log(i + ". " + results[i].toString()); // process the CallHistoryEntry - } - } - - // Defines error callback - function onError(error) { - console.log("Query failed" + error.name); - } - - // Defines filter: list CS calls, most recent first - var filter = new tizen.AttributeFilter("type", "EXACTLY", "TEL"); - - // Defines sort mode: descending on call start time. - var sortMode = new tizen.SortMode("startTime", "DESC"); - - // Makes the query and wires up the callbacks - tizen.callhistory.find(onSuccess, - onError, - filter, - sortMode); - - var numberfilter = new tizen.AttributeFilter( - "remoteParties.remoteParty", - "EXACTLY", - "123456789"); - - // Creates a composite filter for time constraints - var y2009Filter = new tizen.AttributeRangeFilter( - "startTime", - new Date(2009, 0, 1), - new Date(2010, 0, 1)); - - var y2011Filter = new tizen.AttributeRangeFilter( - "startTime", - new Date(2011, 0, 1), - new Date(2012, 0, 1)); - - var datefilter = new tizen.CompositeFilter("UNION", [y2009Filter, y2011Filter]); - - // Creates a filter to find all video calls (including cellular, skype, etc) - // The filter matches any features from the "features" array exactly - var tfilter = new tizen.AttributeFilter("features", "EXACTLY", "VIDEOCALL"); - - // Creates a composite filter - var ifilter = new tizen.CompositeFilter("INTERSECTION", - [numberFilter, dateFilter, tfilter]); - - // Makes the query and wires up the callbacks; reuse sortMode - tizen.callhistory.find(onSuccess, - onError, - ifilter, - sortMode); - -+
Code example:
+/* Defines success callback */ +function onSuccess(results) +{ + console.log(results.length + " call history item(s) found!"); + for (var i = 0; i < results.length; i++) + { + console.log(i + ". " + results[i].toString()); /* Process the CallHistoryEntry */ + } +} + +/* Defines error callback */ +function onError(error) +{ + console.log("Query failed" + error.name); +} + +/* Defines filter: list CS calls, most recent first */ +var filter = new tizen.AttributeFilter("type", "EXACTLY", "TEL"); + +/* Defines sort mode: descending on call start time */ +var sortMode = new tizen.SortMode("startTime", "DESC"); + +/* Makes the query and wires up the callbacks */ +tizen.callhistory.find(onSuccess, onError, filter, sortMode); + +var numberfilter = new tizen.AttributeFilter("remoteParties.remoteParty", + "EXACTLY", "123456789"); + +/* Creates a composite filter for time constraints */ +var y2009Filter = new tizen.AttributeRangeFilter("startTime", new Date(2009, 0, 1), + new Date(2010, 0, 1)); + +var y2011Filter = new tizen.AttributeRangeFilter("startTime", new Date(2011, 0, 1), + new Date(2012, 0, 1)); + +var datefilter = new tizen.CompositeFilter("UNION", [y2009Filter, y2011Filter]); + +/* Creates a filter to find all video calls (including cellular, skype, etc) */ +/* Filter matches any features from the "features" array exactly */ +var tfilter = new tizen.AttributeFilter("features", "EXACTLY", "VIDEOCALL"); + +/* Creates a composite filter */ +var ifilter = new tizen.CompositeFilter("INTERSECTION", + [numberFilter, dateFilter, tfilter]); + +/* Makes the query and wires up the callbacks; reuse sortMode */ +tizen.callhistory.find(onSuccess, onError, ifilter, sortMode); +
Code example:
// Defines success callback - function onSuccess(results) { - if (results.length > 0) - tizen.callhistory.remove(results[0]); - } - - // Defines error callback - function onError(error) { - console.log("Query failed" + error.name); - } - - // Makes the query and wires up the callbacks - tizen.callhistory.find(onSuccess, onError); - -+
Code example:
+/* Defines success callback */ +function onSuccess(results) +{ + if (results.length > 0) + tizen.callhistory.remove(results[0]); +} + +/* Defines error callback */ +function onError(error) +{ + console.log("Query failed" + error.name); +} + +/* Makes the query and wires up the callbacks */ +tizen.callhistory.find(onSuccess, onError); +
Code example:
// Defines success callback - function onSuccess(results) { - tizen.callhistory.removeBatch(results); - } - - // Defines error callback - function onError(error) { - console.log("Query failed" + error.name); - } - - // Makes the query and wires up the callbacks - tizen.callhistory.find(onSuccess, onError); - -+
Code example:
+/* Defines success callback */ +function onSuccess(results) +{ + tizen.callhistory.removeBatch(results); +} + +/* Defines error callback */ +function onError(error) +{ + console.log("Query failed" + error.name); +} + +/* Makes the query and wires up the callbacks */ +tizen.callhistory.find(onSuccess, onError); +
Code example:
var onListenerCB = { - onadded: function(newItems) { - console.log("New Item added"); - for (var i in newItems) { - console.log("Item " + i + " startTime: " + newItems[i].startTime); - } - }, - onchanged: function(changedItems) { - console.log("Items changed"); - for (var i in changedItems) { - console.log("Item " + i + " direction: " + changedItems[i].direction); - } - }, - onremoved: function(removedItems) { - console.log("Items removed"); - for(var i in removedItems) { - console.log("Item " + i + " : " + removedItems[i]); - } - }}; - - try { - // Registers a call history callback - var handle = tizen.callhistory.addChangeListener(onListenerCB); - - // Unregisters a previously registered listener - tizen.callhistory.removeChangeListener(handle); - } catch (error) { - console.log("Exception - code: " + error.name + " message: " + error.message); - } - -+
Code example:
+var onListenerCB = +{ + onadded: function(newItems) + { + console.log("New Item added"); + for (var i in newItems) + { + console.log("Item " + i + " startTime: " + newItems[i].startTime); + } + }, + onchanged: function(changedItems) + { + console.log("Items changed"); + for (var i in changedItems) + { + console.log("Item " + i + " direction: " + changedItems[i].direction); + } + }, + onremoved: function(removedItems) + { + console.log("Items removed"); + for (var i in removedItems) + { + console.log("Item " + i + ": " + removedItems[i]); + } + } +}; + +try +{ + /* Registers a call history callback */ + var handle = tizen.callhistory.addChangeListener(onListenerCB); + + /* Unregisters a previously registered listener */ + tizen.callhistory.removeChangeListener(handle); +} +catch (error) +{ + console.log("Exception - code: " + error.name + " message: " + error.message); +} +
Code example:
var addressbook; - - // Defines the error callback for all the asynchronous calls. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function contactsFoundCB(contacts) { - // The contact is successfully found. - // Tries to change the first name. - contacts[0].name.firstName = 'Jeffrey Ross'; - try { - addressbook.update(contacts[0]); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - console.log('First contact was updated'); - } - - // Defines the success callback for retrieving all the - // Address Books. - function addressBooksCB(addressbooks) { - if(addressbooks.length > 0) { - addressbook = addressbooks[0]; - console.log('The addressbook type is ' + addressbook.type + - ' and name ' + addressbook.name); - - var contact = new tizen.Contact( - {name: new tizen.ContactName({firstName:'Jeffrey', - lastName:'Hyman', - nicknames:['joey ramone']}), - emails:[new tizen.ContactEmailAddress('user@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('123456789')]}); - - addressbook.add(contact); - - // The contact has been successfully added. - // Checks whether the added contact can be retrieved from the address book or not. - // If the address book is empty, only the item added through saveContact - // should be returned. - var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Jeffrey'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } - } - } - - // Gets a list of available address books. - tizen.contact.getAddressBooks(addressBooksCB, errorCB); -+
Code example:
+var addressbook; + +/* Defines the error callback for all the asynchronous calls */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsFoundCB(contacts) +{ + /* Contact is successfully found */ + /* Tries to change the first name */ + contacts[0].name.firstName = 'Jeffrey Ross'; + try + { + addressbook.update(contacts[0]); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } + console.log('First contact was updated'); +} + +/* Defines the success callback for retrieving all the Address Books */ +function addressBooksCB(addressbooks) +{ + if (addressbooks.length > 0) + { + addressbook = addressbooks[0]; + console.log('The addressbook type is ' + addressbook.type + + ' and name ' + addressbook.name); + + var contact = new tizen.Contact( + { + name: new tizen.ContactName( + { + firstName:'Jeffrey', + lastName:'Hyman', + nicknames:['joey ramone'] + }), + emails:[new tizen.ContactEmailAddress('user@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('123456789')] + }); + + addressbook.add(contact); + + /* Contact has been successfully added */ + /* Checks whether the added contact can be retrieved from the address book */ + /* If the address book is empty, only the item added through saveContact should be returned */ + var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Jeffrey'); + try + { + addressbook.find(contactsFoundCB, errorCB, filter); + } + catch (err) + { + console.log('The following error occurred while finding: ' + err.name); + } + } +} + +/* Gets a list of available address books */ +tizen.contact.getAddressBooks(addressBooksCB, errorCB); +
Code example:
var addressbook; - - // Defines the error callback - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - // Tries to change the first name. - contacts[0].name.firstName = 'Jeffrey Ross'; - try { - addressbook.update(contacts[0]); - console.log('First contact was updated'); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - } - - // Gets the unified address book. - addressbook = tizen.contact.getUnifiedAddressBook(); - - // Adds a new contact. - var contact = new tizen.Contact( - {name: new tizen.ContactName({firstName:'Jeffrey', - lastName:'Hyman', - nicknames:['joey ramone']}), - emails:[new tizen.ContactEmailAddress('user@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('123456789')]}); - - try { - addressbook.add(contact); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } - - // The contact has been successfully added. - // Tries to check whether the added contact can be retrieved from the address book - // If the address book is empty, only the item added - // through saveContact should be returned. - var filter = new tizen.AttributeFiilter('name.firstName', 'CONTAINS', 'Jeffrey'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + /* Tries to change the first name */ + contacts[0].name.firstName = 'Jeffrey Ross'; + try + { + addressbook.update(contacts[0]); + console.log('First contact was updated'); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +/* Gets the unified address book */ +addressbook = tizen.contact.getUnifiedAddressBook(); + +/* Adds a new contact */ +var contact = new tizen.Contact( +{ + name: new tizen.ContactName( + { + firstName:'Jeffrey', + lastName:'Hyman', + nicknames:['joey ramone'] + }), + emails:[new tizen.ContactEmailAddress('user@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('123456789')] +}); + +try +{ + addressbook.add(contact); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} + +/* Contact has been successfully added */ +/* Tries to check whether the added contact can be retrieved from the address book */ +/* If the address book is empty, only the item added through saveContact should be returned */ +var filter = new tizen.AttributeFiilter('name.firstName', 'CONTAINS', 'Jeffrey'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - // Tries to change the first name. - contacts[0].name.firstName = 'Jeffrey Ross'; - try { - addressbook.update(contacts[0]); - console.log('First contact was updated'); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - // Adds a new contact. - var contact = new tizen.Contact( - {name: new tizen.ContactName({firstName:'Jeffrey', - lastName:'Hyman', - nicknames:['joey ramone']}), - emails:[new tizen.ContactEmailAddress('user@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('123456789')]}); - - try { - addressbook.add(contact); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } - - // The contact has been successfully added. - // Checks whether the added contact can be retrieved from the address book. - // If the address book is empty, only the item added - // through saveContact should be returned. - var filter = new tizen.AttributeFiilter('name.firstName', 'CONTAINS', 'Jeffrey'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + /* Tries to change the first name */ + contacts[0].name.firstName = 'Jeffrey Ross'; + try + { + addressbook.update(contacts[0]); + console.log('First contact was updated'); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +/* Adds a new contact */ +var contact = new tizen.Contact( +{ + name: new tizen.ContactName( + { + firstName:'Jeffrey', + lastName:'Hyman', + nicknames:['joey ramone'] + }), + emails:[new tizen.ContactEmailAddress('user@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('123456789')] +}); + +try +{ + addressbook.add(contact); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} + +/* Contact has been successfully added */ +/* Checks whether the added contact can be retrieved from the address book */ +/* If the address book is empty, only the item added through saveContact should be returned */ +var filter = new tizen.AttributeFiilter('name.firstName', 'CONTAINS', 'Jeffrey'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var addressbook = new tizen.AddressBook( - account.id, - 'remote addressbook' - ); - tizen.contact.addAddressBook(addressbook); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var addressbook = new tizen.AddressBook(account.id, + 'remote addressbook'); + tizen.contact.addAddressBook(addressbook); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var addressbook = new tizen.AddressBook( - account.id, - 'remote addressbook' - ); - tizen.contact.addAddressBook(addressbook); - tizen.contact.removeAddressBook(addressbook.id); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var addressbook = new tizen.AddressBook(account.id, + 'remote addressbook'); + tizen.contact.addAddressBook(addressbook); + tizen.contact.removeAddressBook(addressbook.id); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
var contactRef; // ContactRef supposed to be initialized - try { - // Retrieves the Contact corresponding to a given ContactRef. - var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); - var contact = addressBook.get(contactRef.contactId); - console.log("Successfully resolved contact with id: " + contactRef.contactId); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+var contactRef; /* ContactRef supposed to be initialized */ +try +{ + /* Retrieves the Contact corresponding to a given ContactRef */ + var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); + var contact = addressBook.get(contactRef.contactId); + console.log("Successfully resolved contact with id: " + contactRef.contactId); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
var contactRef; // ContactRef supposed to be initialized - try { - // Retrieves the Person corresponding to a Contact. - var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); - var contact = addressBook.get(contactRef.contactId); - var person = tizen.contact.get(contact.personId); - console.log("Successfully resolved person with id: " + contact.personId); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+var contactRef; /* ContactRef supposed to be initialized */ +try +{ + /* Retrieves the Person corresponding to a Contact */ + var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); + var contact = addressBook.get(contactRef.contactId); + var person = tizen.contact.get(contact.personId); + console.log("Successfully resolved person with id: " + contact.personId); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
// Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function personsFoundCB(persons) { - // The person has been successfully found. - // Tries to change the isFavorite attribute. - persons[0].isFavorite = true; - try { - tizen.contact.update(persons[0]); - console.log('First person was updated'); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - } - - try { - tizen.contact.find(personsFoundCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function personsFoundCB(persons) +{ + /* Person has been successfully found */ + /* Tries to change the isFavorite attribute */ + persons[0].isFavorite = true; + try + { + tizen.contact.update(persons[0]); + console.log('First person was updated'); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +try +{ + tizen.contact.find(personsFoundCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback for all the asynchronous calls. - function errorCB(err) { - console.log('The following error occurred: ' + err.name); - } - - function personsUpdatedCB() { - console.log('Contacts were updated'); - } - - function personsFoundCB(persons) { - // The person has been successfully found. - for(var i = 0; i < persons.length; i++) { - persons[i].isFavorite = true; - } - try { - tizen.contact.updateBatch(persons, personsUpdatedCB, errorCB); - } catch (err) { - console.log('The following error occurred while updating: ' + err.name); - } - } - - try { - tizen.contact.find(personsFoundCB, errorCB); - } catch (err) { - console.log('The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback for all the asynchronous calls */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function personsUpdatedCB() +{ + console.log('Contacts were updated'); +} + +function personsFoundCB(persons) +{ + /* Person has been successfully found */ + for (var i = 0; i < persons.length; i++) + { + persons[i].isFavorite = true; + } + try + { + tizen.contact.updateBatch(persons, personsUpdatedCB, errorCB); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +try +{ + tizen.contact.find(personsFoundCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback. - function errorCB(err) { - console.log('The following error occurred: ' + err.name); - } - - function personsFoundCB(persons) { - // The person has been successfully found. - if(persons.length > 0) { - try { - tizen.contact.remove(persons[0].id); - console.log('First person was removed'); - } catch (err) { - console.log('The following error occurred while removing: ' + err.name); - } - } else { - console.log( 'No persons.'); - } - } - - try { - tizen.contact.find(personsFoundCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function personsFoundCB(persons) +{ + /* Person has been successfully found */ + if (persons.length > 0) + { + try + { + tizen.contact.remove(persons[0].id); + console.log('First person was removed'); + } + catch (err) + { + console.log('The following error occurred while removing: ' + err.name); + } + } + else + { + console.log('No persons.'); + } +} + +try +{ + tizen.contact.find(personsFoundCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function personsRemovedCB() { - console.log('Contacts were removed'); - } - - function personsFoundCB(persons) { - // The person has been successfully found. - if(persons.length > 2) { - try { - tizen.contact.removeBatch([persons[0].id, persons[1].id], personsRemovedCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while removing: ' + err.name); - } - } else { - console.log( 'Not enough persons.'); - } - } - - try { - tizen.contact.find(personsFoundCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function personsRemovedCB() +{ + console.log('Contacts were removed'); +} + +function personsFoundCB(persons) +{ + /* Person has been successfully found */ + if (persons.length > 2) + { + try + { + tizen.contact.removeBatch([persons[0].id, persons[1].id], personsRemovedCB, errorCB); + } + catch (err) + { + console.log('The following error occurred while removing: ' + err.name); + } + } + else + { + console.log('Not enough persons.'); + } +} + +try +{ + tizen.contact.find(personsFoundCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the person search success callback. - function personsFoundCB(persons) { - console.log(persons.length + ' results found.'); - } - - // Finds all the persons in the contact DB that have the word Ramone in their display name. - var filter = new tizen.AttributeFilter('displayName', 'CONTAINS', 'Ramone'); - - // The persons returned by the find() query will be sorted in the ascending order of their display name. - var sortingMode = new tizen.SortMode('displayName', 'ASC'); - try { - tizen.contact.find(personsFoundCB, errorCB, - filter, sortingMode); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the person search success callback */ +function personsFoundCB(persons) +{ + console.log(persons.length + ' results found.'); +} + +/* Finds all the persons in the contact DB that have the word Ramone in their display name */ +var filter = new tizen.AttributeFilter('displayName', 'CONTAINS', 'Ramone'); + +/* Persons returned by the find() query will be sorted in the ascending order of their display name */ +var sortingMode = new tizen.SortMode('displayName', 'ASC'); +try +{ + tizen.contact.find(personsFoundCB, errorCB, filter, sortingMode); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the person search success callback. - function personsFoundCB(persons) { - console.log(persons.length + ' results found.'); - } - - // Finds all the persons in the contact DB that have exactly five OUTGOING_CALL - var filter = new tizen.AttributeFilter('OUTGOING_CALL', 'EXACTLY', 5); - // Finds all the persons in the contact DB that have OUTGOING_CALL in range <0, 5> - //var filter = new tizen.AttributeRangeFilter('OUTGOING_CALL', 0, 5); - try { - // Finds three most used contacts from contacts found with filter - tizen.contact.findByUsageCount(filter, personsFoundCB, errorCB, 'DESC', 3, 0); - // Finds three least used contacts from contacts found with filter - //tizen.contact.findByUsageCount(filter, personsFoundCB, errorCB, 'ASC', 3, 0); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the person search success callback */ +function personsFoundCB(persons) +{ + console.log(persons.length + ' results found.'); +} + +/* Finds all the persons in the contact DB that have exactly five OUTGOING_CALL */ +var filter = new tizen.AttributeFilter('OUTGOING_CALL', 'EXACTLY', 5); +/* Finds all the persons in the contact DB that have OUTGOING_CALL in range <0, 5> */ +/* var filter = new tizen.AttributeRangeFilter('OUTGOING_CALL', 0, 5); */ +try +{ + /* Finds three most used contacts from contacts found with filter */ + tizen.contact.findByUsageCount(filter, personsFoundCB, errorCB, 'DESC', 3, 0); + /* Finds three least used contacts from contacts found with filter */ + /* tizen.contact.findByUsageCount(filter, personsFoundCB, errorCB, 'ASC', 3, 0); */ +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Output example:
3 results found. @@ -1867,23 +1981,28 @@ contain an invalid value.
Code example:
var watcherId = 0; // watcher identifier - - var watcher = { - onpersonsadded: function(persons) { - console.log(persons.length + ' persons were added'); - }, - onpersonsupdated: function(persons) { - console.log(persons.length + ' persons were updated'); - }, - onpersonsremoved: function(ids) { - console.log(ids.length + ' persons were deleted'); - } - }; - - // Registers to be notified when the person changes. - watcherId = tizen.contact.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ + +var watcher = +{ + onpersonsadded: function(persons) + { + console.log(persons.length + ' persons were added'); + }, + onpersonsupdated: function(persons) + { + console.log(persons.length + ' persons were updated'); + }, + onpersonsremoved: function(ids) + { + console.log(ids.length + ' persons were deleted'); + } +}; + +/* Registers to be notified when the person changes */ +watcherId = tizen.contact.addChangeListener(watcher); +
Code example:
var watcherId = 0; // watcher identifier - - // Receives person changes. - var watcher = { - onpersonsadded: function(persons) { - console.log(persons.length + ' persons were added'); - }, - onpersonsupdated: function(persons) { - console.log(persons.length + ' persons were updated'); - }, - onpersonsremoved: function(ids) { - console.log(ids.length + ' persons were removed'); - } - }; - - // Cancels the watch operation. - function cancelWatch() { - tizen.contact.removeChangeListener(watcherId); - } - - // Registers to be notified of person changes. - watcherId = tizen.contact.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ + +/* Receives person changes */ +var watcher = +{ + onpersonsadded: function(persons) + { + console.log(persons.length + ' persons were added'); + }, + onpersonsupdated: function(persons) + { + console.log(persons.length + ' persons were updated'); + }, + onpersonsremoved: function(ids) + { + console.log(ids.length + ' persons were removed'); + } +}; + +/* Cancels the watch operation */ +function cancelWatch() +{ + tizen.contact.removeChangeListener(watcherId); +} + +/* Registers to be notified of person changes */ +watcherId = tizen.contact.addChangeListener(watcher); +
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; - tizen.account.getAccounts(function(accounts) { - var account = accounts[0]; - if(account) { - var addressbook = new tizen.AddressBook( - account.id, - 'remote addressbook' - ); - - // 'addressbook' variable is not available until it is inserted into database. - tizen.contact.addAddressBook(addressbook); - } - }, function(e) { - console.log('Error: ' + e.message); - }, appId); -+
Code example:
+var appId = tizen.application.getCurrentApplication().appInfo.id; +tizen.account.getAccounts(function(accounts) +{ + var account = accounts[0]; + if (account) + { + var addressbook = new tizen.AddressBook(account.id, + 'remote addressbook'); + + /* 'addressbook' variable is not available until it is inserted into database */ + tizen.contact.addAddressBook(addressbook); + } +}, function(e) +{ + console.log('Error: ' + e.message); +}, appId); +
Code example:
var contactRef; // ContactRef supposed to be initialized - try { - // Retrieves the Contact corresponding to a given ContactRef. - var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); - var contact = addressBook.get(contactRef.contactId); - console.log("Successfully resolved contact with id: " + contactRef.contactId); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+var contactRef; /* ContactRef supposed to be initialized */ +try +{ + /* Retrieves the Contact corresponding to a given ContactRef */ + var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); + var contact = addressBook.get(contactRef.contactId); + console.log("Successfully resolved contact with id: " + contactRef.contactId); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
var addressbook; - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - try { - var contact = new tizen.Contact({name: new tizen.ContactName({firstName:'Jeffrey', - lastName:'Hyman', - nicknames:['joey ramone']}), - emails:[new tizen.ContactEmailAddress('user@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('123456789')]}); - addressbook.add(contact); - console.log('Contact added with id ' + contact.id); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +try +{ + var contact = new tizen.Contact( + { + name: new tizen.ContactName( + { + firstName:'Jeffrey', + lastName:'Hyman', + nicknames:['joey ramone'] + }), + emails:[new tizen.ContactEmailAddress('user@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('123456789')] + }); + addressbook.add(contact); + console.log('Contact added with id ' + contact.id); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the add contact success callback - function contactsAddedCB(contacts) { - console.log( contacts.length + ' contact(s) were successfully added to an Address Book' ); - }; - - // Gets the default address book - addressbook = tizen.contact.getDefaultAddressBook(); - - var c1 = new tizen.Contact({name: new tizen.ContactName({firstName:'Jeffrey', - lastName:'Hyman', - nicknames:['joey ramone']}), - emails:[new tizen.ContactEmailAddress('user1@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('123456789')]}); - - var c2 = new tizen.Contact({name: new tizen.ContactName({firstName:'Elton', - lastName:'John', - nicknames:['El']}), - emails:[new tizen.ContactEmailAddress('user2@domain.com')], - phoneNumbers:[new tizen.ContactPhoneNumber('987654321')]}); - - try { - addressbook.addBatch([c1, c2], contactsAddedCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the add contact success callback */ +function contactsAddedCB(contacts) +{ + console.log(contacts.length + ' contact(s) were successfully added to an Address Book'); +}; + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +var c1 = new tizen.Contact( +{ + name: new tizen.ContactName( + { + firstName:'Jeffrey', + lastName:'Hyman', + nicknames:['joey ramone'] + }), + emails:[new tizen.ContactEmailAddress('user1@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('123456789')] +}); + +var c2 = new tizen.Contact( +{ + name: new tizen.ContactName( + { + firstName:'Elton', + lastName:'John', + nicknames:['El'] + }), + emails:[new tizen.ContactEmailAddress('user2@domain.com')], + phoneNumbers:[new tizen.ContactPhoneNumber('987654321')] +}); + +try +{ + addressbook.addBatch([c1, c2], contactsAddedCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - // Tries to change the first name. - contacts[0].name.firstName = 'Christopher'; - try { - addressbook.update(contacts[0]); - console.log('First contact was updated'); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + /* Tries to change the first name */ + contacts[0].name.firstName = 'Christopher'; + try + { + addressbook.update(contacts[0]); + console.log('First contact was updated'); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback for all the asynchronous calls. - function errorCB(err) { - console.log('The following error occurred: ' + err.name); - } - - function contactsUpdatedCB() { - console.log('Contacts were updated'); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - for(var i = 0; i < contacts.length; i++) { - contacts[i].name.firstName = 'Christopher'; - } - try { - addressbook.updateBatch(contacts, contactsUpdatedCB, errorCB); - } catch (err) { - console.log('The following error occurred while updating: ' + err.name); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log('The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback for all the asynchronous calls */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsUpdatedCB() +{ + console.log('Contacts were updated'); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + for (var i = 0; i < contacts.length; i++) + { + contacts[i].name.firstName = 'Christopher'; + } + try + { + addressbook.updateBatch(contacts, contactsUpdatedCB, errorCB); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback. - function errorCB(err) { - console.log('The following error occurred: ' + err.name); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - if(contacts.length > 0) { - try { - addressbook.remove(contacts[0].id); - console.log('First contact was removed'); - } catch (err) { - console.log('The following error occurred while removing: ' + err.name); - } - } else { - console.log( 'No contacts.'); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + if (contacts.length > 0) + { + try + { + addressbook.remove(contacts[0].id); + console.log('First contact was removed'); + } + catch (err) + { + console.log('The following error occurred while removing: ' + err.name); + } + } + else + { + console.log('No contacts.'); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function contactsRemovedCB() { - console.log('Contacts were removed'); - } - - function contactsFoundCB(contacts) { - // The contact has been successfully found. - if(contacts.length > 2) { - try { - addressbook.removeBatch([contacts[0].id, contacts[1].id], contactsRemovedCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while removing: ' + err.name); - } - } else { - console.log( 'Not enough contacts.'); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function contactsRemovedCB() +{ + console.log('Contacts were removed'); +} + +function contactsFoundCB(contacts) +{ + /* Contact has been successfully found */ + if (contacts.length > 2) + { + try + { + addressbook.removeBatch([contacts[0].id, contacts[1].id], contactsRemovedCB, errorCB); + } + catch (err) + { + console.log('The following error occurred while removing: ' + err.name); + } + } + else + { + console.log('Not enough contacts.'); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +var filter = new tizen.AttributeFilter('name.firstName', 'CONTAINS', 'Chris'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the contact search success callback. - function contactsFoundCB(contacts) { - console.log(contacts.length + ' results found.'); - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - // Finds all contacts in the address book that have "Ramone" in the nick name. - var filter = new tizen.AttributeFilter('name.nicknames', 'CONTAINS', 'Ramone'); - - // The contacts returned by the find() query will be sorted by - // ascending last name. - var sortingMode = new tizen.SortMode('name.lastName', 'ASC'); - try { - addressbook.find(contactsFoundCB, errorCB, - filter, sortingModes); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the contact search success callback */ +function contactsFoundCB(contacts) +{ + console.log(contacts.length + ' results found.'); +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +/* Finds all contacts in the address book that have "Ramone" in the nick name */ +var filter = new tizen.AttributeFilter('name.nicknames', 'CONTAINS', 'Ramone'); + +/* Contacts returned by the find() query will be sorted by ascending last name */ +var sortingMode = new tizen.SortMode('name.lastName', 'ASC'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter, sortingModes); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var watcherId = 0; // watcher identifier - var addressbook; // This example assumes addressbook is initialized - - var watcher = { - oncontactsadded: function(contacts) { - console.log(contacts.length + ' contacts were added'); - }, - oncontactsupdated: function(contacts) { - console.log(contacts.length + ' contacts were updated'); - }, - oncontactsremoved: function(ids) { - console.log(ids.length + ' contacts were deleted'); - } - }; - - // Registers to be notified when the address book changes. - watcherId = addressbook.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var addressbook; /* This example assumes addressbook is initialized */ + +var watcher = +{ + oncontactsadded: function(contacts) + { + console.log(contacts.length + ' contacts were added'); + }, + oncontactsupdated: function(contacts) + { + console.log(contacts.length + ' contacts were updated'); + }, + oncontactsremoved: function(ids) + { + console.log(ids.length + ' contacts were deleted'); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = addressbook.addChangeListener(watcher); +
Code example:
var watcherId = 0; // watcher identifier - var addressbook; // This example assumes addressbook is initialized - - // Receives address book changes. - var watcher = { - oncontactsadded: function(contacts) { - console.log(contacts.length + ' contacts were added'); - }, - oncontactsupdated: function(contacts) { - console.log(contacts.length + ' contacts were updated'); - }, - oncontactsremoved: function(ids) { - console.log(ids.length + ' contacts were removed'); - } - }; - - // Cancels the watch operation. - function cancelWatch() { - addressbook.removeChangeListener(watcherId); - } - - // Registers to be notified when the address book changes. - watcherId = addressbook.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var addressbook; /* This example assumes addressbook is initialized */ + +/* Receives address book changes */ +var watcher = +{ + oncontactsadded: function(contacts) + { + console.log(contacts.length + ' contacts were added'); + }, + oncontactsupdated: function(contacts) + { + console.log(contacts.length + ' contacts were updated'); + }, + oncontactsremoved: function(ids) + { + console.log(ids.length + ' contacts were removed'); + } +}; + +/* Cancels the watch operation */ +function cancelWatch() +{ + addressbook.removeChangeListener(watcherId); +} + +/* Registers to be notified when the address book changes */ +watcherId = addressbook.addChangeListener(watcher); +
Code example:
try { - // Retrieves the Person corresponding to a Contact. - var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); - var contact = addressBook.get(contactRef.contactId); - var group = addressBook.getGroup(contact.groupIds[0].id); - console.log("Successfully resolved group with id: " + contact.groupIds[0].id); - } catch(err) { - console.log("Error: " + err.name); - } -+
Code example:
+try +{ + /* Retrieves the Person corresponding to a Contact */ + var addressBook = tizen.contact.getAddressBook(contactRef.addressBookId); + var contact = addressBook.get(contactRef.contactId); + var group = addressBook.getGroup(contact.groupIds[0].id); + console.log("Successfully resolved group with id: " + contact.groupIds[0].id); +} +catch (err) +{ + console.log("Error: " + err.name); +} +
Code example:
var addressbook; - - // Gets the address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - try { - var group = new tizen.ContactGroup('Company'); - addressbook.addGroup(group); - console.log('Group added with id ' + group.id); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Gets the address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +try +{ + var group = new tizen.ContactGroup('Company'); + addressbook.addGroup(group); + console.log('Group added with id ' + group.id); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +
Code example:
var addressbook; - - // Gets the address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - try { - groups = addressbook.getGroups(); - groups[0].name = 'Friends'; - addressbook.updateGroup(groups[0]); - console.log('First group was updated'); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Gets the address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +try +{ + groups = addressbook.getGroups(); + groups[0].name = 'Friends'; + addressbook.updateGroup(groups[0]); + console.log('First group was updated'); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +
Code example:
var addressbook; - - // Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - try { - groups = addressbook.getGroups(); - addressbook.removeGroup(groups[0].id); - console.log('First group was removed'); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +try +{ + groups = addressbook.getGroups(); + addressbook.removeGroup(groups[0].id); + console.log('First group was removed'); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
var addressbook; - - // Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - try { - groups = addressbook.getGroups(); - console.log('Number of groups is ' + groups.length); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+
Code example:
+var addressbook; + +/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +try +{ + groups = addressbook.getGroups(); + console.log('Number of groups is ' + groups.length); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Defines the error callback for all the asynchronous calls. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function personsFoundCB(persons) { - // The persons have been successfully found. - try { - persons[0].link(persons[1].id); - console.log('Second person was merged to the first person.'); - } catch (err) { - console.log( 'The following error occurred while updating: ' + err.name); - } - } - - try { - tizen.contact.find(personsFoundCB, errorCB); - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+
Code example:
+/* Defines the error callback for all the asynchronous calls */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function personsFoundCB(persons) +{ + /* Persons have been successfully found */ + try + { + persons[0].link(persons[1].id); + console.log('Second person was merged to the first person.'); + } + catch (err) + { + console.log('The following error occurred while updating: ' + err.name); + } +} + +try +{ + tizen.contact.find(personsFoundCB, errorCB); +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +
Code example:
var myPersonId = '1'; //ID of modified - - var addressbook; // Default addressbook - var person; // Existing person obtained from addressbook - var newPerson; // New person, which will be created during unlink - - // Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the contact search success callback. - function contactsFoundCB(contacts) { - if (contacts.length > 1) { - try { - // Unlinks the first contact. - newPerson = person.unlink(contacts[0].id); - } catch (err) { - console.log( 'The following error occurred while unlink: ' + err.name); - } - } else { - console.log( 'Not enough contacts '); - } - } - - try { - // Gets the person. - person = tizen.contact.get(myPersonId); - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - // Finds all the contacts in the default address book with personId - // as exactly myPersonId. - var filter = new tizen.AttributeFilter('personId', 'EXACTLY', myPersonId); - - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while processing: ' + err.name); - } -+
Code example:
+var myPersonId = '1'; /* ID of modified */ + +var addressbook; /* Default addressbook */ +var person; /* Existing person obtained from addressbook */ +var newPerson; /* New person, which will be created during unlink */ + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the contact search success callback */ +function contactsFoundCB(contacts) +{ + if (contacts.length > 1) + { + try + { + /* Unlinks the first contact */ + newPerson = person.unlink(contacts[0].id); + } + catch (err) + { + console.log('The following error occurred while unlink: ' + err.name); + } + } + else + { + console.log('Not enough contacts '); + } +} + +try +{ + /* Gets the person */ + person = tizen.contact.get(myPersonId); + + /* Gets the default address book */ + addressbook = tizen.contact.getDefaultAddressBook(); + + /* Finds all the contacts in the default address book with personId as exactly myPersonId */ + var filter = new tizen.AttributeFilter('personId', 'EXACTLY', myPersonId); + + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while processing: ' + err.name); +} +
Code example:
var myPersonId = '1'; // ID of person - var person = tizen.contact.get(myPersonId); +Code example:
+var myPersonId = '1'; /* ID of person */ +var person = tizen.contact.get(myPersonId); - var outCalls = person.getUsageCount(OUTGOING_CALL); - var allUsages = person.getUsageCount(); +var outCalls = person.getUsageCount(OUTGOING_CALL); +var allUsages = person.getUsageCount(); - console.log('Number of outgoing calls: ' + outCalls); - console.log('Number of all usages: ' + allUsages); -+console.log('Number of outgoing calls: ' + outCalls); +console.log('Number of all usages: ' + allUsages); +
Output example:
Number of outgoing calls: 12 @@ -3966,12 +4226,13 @@ is not compatible with the expected type for that parameter.
Code example:
var myPersonId = '1'; // ID of person - var person = tizen.contact.get(myPersonId); - console.log('Usage count before reset: ' + person.getUsageCount()); - person.resetUsageCount(); - console.log('Usage count after reset: ' + person.getUsageCount()); -+
Code example:
+var myPersonId = '1'; /* ID of person */ +var person = tizen.contact.get(myPersonId); +console.log('Usage count before reset: ' + person.getUsageCount()); +person.resetUsageCount(); +console.log('Usage count after reset: ' + person.getUsageCount()); +
Output example:
Usage count before reset: 2 @@ -4077,72 +4338,91 @@ This dictionary is used to input parameters when contacts are created. 1.0-Code example:
// Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - var contact = null; - - try { - contact = new tizen.Contact( - "BEGIN:VCARD\n"+ - "VERSION:3.0\n"+ - "N:Gump;Forrest\n"+ - "FN:Forrest Gump\n"+ - "ORG:Bubba Gump Shrimp Co.\n"+ - "TITLE:Shrimp Man\n"+ - "TEL;WORK:(111) 555-1212\n"+ - "TEL;HOME:(404) 555-1212\n"+ - "EMAIL;WORK;PREF:forrestgump@example.com\n"+ - "END:VCARD"); - } catch (err) { - console.log( 'The following error occurred while converting: ' + err.name); - } - - try { - if (contact) { - addressbook.add(contact); - console.log('Contact was added with ID ' + contact.id); - } - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+Code example:
+/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +var contact = null; + +try +{ + contact = new tizen.Contact("BEGIN:VCARD\n"+ + "VERSION:3.0\n"+ + "N:Gump;Forrest\n"+ + "FN:Forrest Gump\n"+ + "ORG:Bubba Gump Shrimp Co.\n"+ + "TITLE:Shrimp Man\n"+ + "TEL;WORK:(111) 555-1212\n"+ + "TEL;HOME:(404) 555-1212\n"+ + "EMAIL;WORK;PREF:forrestgump@example.com\n"+ + "END:VCARD"); +} +catch (err) +{ + console.log('The following error occurred while converting: ' + err.name); +} + +try +{ + if (contact) + { + addressbook.add(contact); + console.log('Contact was added with ID ' + contact.id); + } +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +-Code example:
// Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - var contact = null; - - var name = new tizen.ContactName({ - firstName: "Forrest", - lastName: "Gump" - }); - var addresses = [ new tizen.ContactAddress({ - city: "New York", - streetAddress: "46th St.", - isDefault: true }) ]; - var phoneNumbers = [ new tizen.ContactPhoneNumber("(111) 555-1212"), - new tizen.ContactPhoneNumber("(111) 555-1213") ]; - - try { - contact = new tizen.Contact({ - name: name, - addresses: addresses, - phoneNumbers: phoneNumbers - }); - } catch (err) { - console.log( 'The following error occurred while creating contact: ' + err.name); - } - - try { - if (contact) { - addressbook.add(contact); - console.log('Contact was added with ID ' + contact.id); - } - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } -+Code example:
+/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); +var contact = null; + +var name = new tizen.ContactName( +{ + firstName: "Forrest", + lastName: "Gump" +}); +var addresses = [new tizen.ContactAddress( +{ + city: "New York", + streetAddress: "46th St.", + isDefault: true +})]; +var phoneNumbers = [new tizen.ContactPhoneNumber("(111) 555-1212"), + new tizen.ContactPhoneNumber("(111) 555-1213")]; + +try +{ + contact = new tizen.Contact( + { + name: name, + addresses: addresses, + phoneNumbers: phoneNumbers + }); +} +catch (err) +{ + console.log('The following error occurred while creating contact: ' + err.name); +} + +try +{ + if (contact) + { + addressbook.add(contact); + console.log('Contact was added with ID ' + contact.id); + } +} +catch (err) +{ + console.log('The following error occurred while adding: ' + err.name); +} +Constructors
@@ -4232,10 +4512,12 @@ By default, this attribute is set to false. 1.0-Code example:
if (contact.isFavorite) { - // ... - } -+Code example:
+if (contact.isFavorite) +{ + /* Do something */ +} +@@ -4262,13 +4544,17 @@ By default, this attribute is set to an empty array. 1.0 -Code example:
var contactInit = {}; - var contactAddr = new tizen.ContactAddress({streetAddress:'Gran Via, 32', - postalCode:'50013', - city:'Zaragoza', - country:'ES'}); - contactInit.addresses = [contactAddr]; -+Code example:
+var contactInit = {}; +var contactAddr = new tizen.ContactAddress( +{ + streetAddress:'Gran Via, 32', + postalCode:'50013', + city:'Zaragoza', + country:'ES' +}); +contactInit.addresses = [contactAddr]; +@@ -4290,11 +4576,13 @@ By default, this attribute is set to null. 1.0 -Code example:
var contactInit = {}; - tizen.filesystem.resolve('images/mypicture.jpg', function(imageFile) { - contactInit.photoURI = imageFile.toURI(); - }); -+Code example:
+var contactInit = {}; +tizen.filesystem.resolve('images/mypicture.jpg', function(imageFile) +{ + contactInit.photoURI = imageFile.toURI(); +}); +@@ -4312,10 +4600,11 @@ By default, this attribute is set to an empty array. 1.0 -Code example:
var contactInit = {}; - var phoneNumber = new tizen.ContactPhoneNumber('123456789'); - contactInit.phoneNumbers = [phoneNumber]; -+Code example:
+var contactInit = {}; +var phoneNumber = new tizen.ContactPhoneNumber('123456789'); +contactInit.phoneNumbers = [phoneNumber]; +@@ -4333,10 +4622,11 @@ By default, this attribute is set to an empty array. 1.0 -Code example:
var contactInit = {}; - var email = new tizen.ContactEmailAddress('deedee@ramones.com'); - contactInit.emails = [email]; -+Code example:
+var contactInit = {}; +var email = new tizen.ContactEmailAddress('deedee@ramones.com'); +contactInit.emails = [email]; +@@ -4354,10 +4644,11 @@ By default, this attribute is set to an empty array. 2.3 -Code example:
var contactInit = {}; - var messenger = new tizen.ContactInstantMessenger('user@example.com'); - contactInit.messengers = [messenger]; -+Code example:
+var contactInit = {}; +var messenger = new tizen.ContactInstantMessenger('user@example.com'); +contactInit.messengers = [messenger]; +@@ -4378,11 +4669,12 @@ By default, this attribute is set to an empty array. 2.3 -Code example:
var contactInit = {}; - // Contact is brother of 'Anna'. - var relationship = new tizen.ContactRelationship('Anna', "BROTHER"); - contactInit.relationships = [relationship]; -+Code example:
+var contactInit = {}; +/* Contact is brother of 'Anna' */ +var relationship = new tizen.ContactRelationship('Anna', "BROTHER"); +contactInit.relationships = [relationship]; +@@ -4400,10 +4692,11 @@ By default, this attribute is set to an empty array. 3.0 -Code example:
var contactInit = {}; - var extension = new tizen.ContactExtension({ data1: 20, data2: 'Place of birth: Elbląg' }); - contactInit.extensions = [extension]; -+Code example:
+var contactInit = {}; +var extension = new tizen.ContactExtension({data1: 20, data2: 'Place of birth: Elbląg'}); +contactInit.extensions = [extension]; +@@ -4423,9 +4716,10 @@ By default, this attribute is set to null. 1.0 -Code example:
var contactInit = {}; - contactInit.birthday = new Date(1996, 4, 15); -+Code example:
+var contactInit = {}; +contactInit.birthday = new Date(1996, 4, 15); +@@ -4446,10 +4740,11 @@ By default, this attribute is set to an empty array. 1.0 -Code example:
var contactInit = {}; - var marriage_anniv = new tizen.ContactAnniversary(new Date(1976, 11, 2), 'Marriage'); - contactInit.anniversaries = [marriage_anniv]; -+Code example:
+var contactInit = {}; +var marriage_anniv = new tizen.ContactAnniversary(new Date(1976, 11, 2), 'Marriage'); +contactInit.anniversaries = [marriage_anniv]; +@@ -4638,35 +4933,44 @@ is not compatible with the expected type for that parameter. -Code example:
var addressbook; - - // Defines the error callback. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the contact find success callback. - function contactsFoundCB(contacts) { - try { - // Converts the first contact to vCard 3.0 format. - var vcard = contacts[0].convertToString("VCARD_30"); - console.log('textual representation of the contact is: ' + vcard); - } catch (err) { - console.log( 'The following error occurred while converting: ' + err.name); - } - } - - // Gets the default address book. - addressbook = tizen.contact.getDefaultAddressBook(); - - // Finds all contacts in the address book whose first name contains the string 'Chris'. - var filter = new tizen.AttributeFilter('firstName', 'CONTAINS', 'Chris'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (err) { - console.log( 'The following error occurred while finding: ' + err.name); - } -+Code example:
+var addressbook; + +/* Defines the error callback */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the contact find success callback */ +function contactsFoundCB(contacts) +{ + try + { + /* Converts the first contact to vCard 3.0 format */ + var vcard = contacts[0].convertToString("VCARD_30"); + console.log('textual representation of the contact is: ' + vcard); + } + catch (err) + { + console.log('The following error occurred while converting: ' + err.name); + } +} + +/* Gets the default address book */ +addressbook = tizen.contact.getDefaultAddressBook(); + +/* Finds all contacts in the address book whose first name contains the string 'Chris' */ +var filter = new tizen.AttributeFilter('firstName', 'CONTAINS', 'Chris'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (err) +{ + console.log('The following error occurred while finding: ' + err.name); +} +
Code example:
// Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); - - var bob = new tizen.Contact(); - bob.name = new tizen.ContactName({firstName:'Bob', - lastName:'Smith'}); - addressbook.add(bob); - var alice = bob.clone(); - contact.name.firstName = "Alice"; // Bob's wife - addressbook.add(alice); -+
Code example:
+/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +var bob = new tizen.Contact(); +bob.name = new tizen.ContactName({firstName:'Bob', lastName:'Smith'}); +addressbook.add(bob); +var alice = bob.clone(); +contact.name.firstName = "Alice"; /* Bob's wife */ +addressbook.add(alice); +
ContactRef(AddressBookId addressBookId, ContactId contactId);
Code example:
// Gets the default address book. - var addressbook = tizen.contact.getDefaultAddressBook(); +Code example:
+/* Gets the default address book */ +var addressbook = tizen.contact.getDefaultAddressBook(); - // Creates a new contact: - var eve = new tizen.Contact(); - eve.name = new tizen.ContactName({firstName:'Eve', lastName:'Green'}); - addressbook.add(eve); +/* Creates a new contact */ +var eve = new tizen.Contact(); +eve.name = new tizen.ContactName({firstName:'Eve', lastName:'Green'}); +addressbook.add(eve); - // Creates a reference to this contact: - var refToEve = new tizen.ContactRef(addressbook.id, eve.id); -+/* Creates a reference to this contact */ +var refToEve = new tizen.ContactRef(addressbook.id, eve.id); +
ContactName(optional ContactNameInit? nameInitDict);
Code example:
var myContactName = new tizen.ContactName( - {prefix : "Mr.", firstName : "John", lastName : "Doe"}); -+
Code example:
+var myContactName = new tizen.ContactName( +{ + prefix: "Mr.", firstName: "John", lastName: "Doe" +}); +
Code example:
contact.name.prefix = "Dr."; -+
Code example:
+contact.name.prefix = "Dr."; +
Code example:
contact.name.suffix = "Jr."; -+
Code example:
+contact.name.suffix = "Jr."; +
Code example:
contact.name.firstName = 'Douglas'; -+
Code example:
+contact.name.firstName = 'Douglas'; +
Code example:
contact.name.middleName = 'Glenn'; -+
Code example:
+contact.name.middleName = 'Glenn'; +
Code example:
contact.name.lastName = 'Colvin'; -+
Code example:
+contact.name.lastName = 'Colvin'; +
Code example:
contact.name.nickNames = ['Dee Dee']; -+
Code example:
+contact.name.nickNames = ['Dee Dee']; +
Code example:
var organization = new tizen.ContactOrganization({name: "Nice Company", role: "SW Engineer"}); -+
Code example:
+var organization = new tizen.ContactOrganization({name: "Nice Company", role: "SW Engineer"}); +
Code example:
var contactInit = {} - var blog = new tizen.ContactWebSite('http://www.domain.com', 'BLOG'); - contactInit.urls = [blog]; -+
Code example:
+var contactInit = {} +var blog = new tizen.ContactWebSite('http://www.domain.com', 'BLOG'); +contactInit.urls = [blog]; +
Code example:
var contactInit = {} - var marriage_anniv = new tizen.ContactAnniversary(new Date(1976, 11, 2), 'Marriage'); - contactInit.anniversaries = [marriage_anniv]; -+
Code example:
+var contactInit = {} +var marriage_anniv = new tizen.ContactAnniversary(new Date(1976, 11, 2), 'Marriage'); +contactInit.anniversaries = [marriage_anniv]; +
Code example:
var contactInit = {}; - var contactAddress = new tizen.ContactAddress({streetAddress:'Gran Via, 32', - postalCode:'50013', city:'Zaragoza', - country:'ES', types:['WORK']}); - contactInit.contactAddress = [contactAddress]; -+
Code example:
+var contactInit = {}; +var contactAddress = new tizen.ContactAddress( +{ + streetAddress:'Gran Via, 32', + postalCode:'50013', city:'Zaragoza', + country:'ES', types:['WORK'] +}); +contactInit.contactAddress = [contactAddress]; +
Code example:
var contactInit = {}; - var phoneNumber = new tizen.ContactPhoneNumber('123456789', ['WORK','VOICE'], true); - contactInit.phoneNumbers = [phoneNumber]; -+
Code example:
+var contactInit = {}; +var phoneNumber = new tizen.ContactPhoneNumber('123456789', ['WORK','VOICE'], true); +contactInit.phoneNumbers = [phoneNumber]; +
Code example:
var contactInit = {}; - var email = new tizen.ContactEmailAddress('user@domain.com', ['WORK']); - contactInit.emails = [email]; -+
Code example:
+var contactInit = {}; +var email = new tizen.ContactEmailAddress('user@domain.com', ['WORK']); +contactInit.emails = [email]; +
Code example:
var contactInit = {}; - var messenger = new tizen.ContactInstantMessenger('user@domain.com', 'GOOGLE'); - contactInit.messengers = [messenger]; -+
Code example:
+var contactInit = {}; +var messenger = new tizen.ContactInstantMessenger('user@domain.com', 'GOOGLE'); +contactInit.messengers = [messenger]; +
Code example:
var addressbook = null; - var group = null; - var ringtones = null; - - // Defines the error callback for all the asynchronous calls. - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - // Defines the success callback for retrieving all the - // Address Books. - function addressBooksCB(addressbooks) { - addressbook = addressbooks[0]; - try { - group = new tizen.ContactGroup('Family', ringtones.resolve('ring.mp3').toURI()); - } catch (err) { - console.log( 'The following error occurred while converting: ' + err.name); - } - - try { - if (group) { - addressbook.addGroup(group); - console.log('Group was added with ID ' + group.id); - } - } catch (err) { - console.log( 'The following error occurred while adding: ' + err.name); - } - } - - tizen.filesystem.resolve("ringtones", function(dir) { - ringtones = dir; - tizen.contact.getAddressBooks(addressBooksCB, errorCB); - }); - -+
Code example:
+var addressbook = null; +var group = null; +var ringtones = null; + +/* Defines the error callback for all the asynchronous calls */ +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +/* Defines the success callback for retrieving all the Address Books */ +function addressBooksCB(addressbooks) +{ + addressbook = addressbooks[0]; + try + { + group = new tizen.ContactGroup('Family', ringtones.resolve('ring.mp3').toURI()); + } + catch (err) + { + console.log('The following error occurred while converting: ' + err.name); + } + + try + { + if (group) + { + addressbook.addGroup(group); + console.log('Group was added with ID ' + group.id); + } + } + catch (err) + { + console.log('The following error occurred while adding: ' + err.name); + } +} + +tizen.filesystem.resolve("ringtones", function(dir) +{ + ringtones = dir; + tizen.contact.getAddressBooks(addressBooksCB, errorCB); +}); +
Code example:
var contactInit = {}; - // Contact is brother of 'Anna' - var relationship = new tizen.ContactRelationship('Anna', 'BROTHER'); - contactInit.relationships = [relationship]; -+
Code example:
+var contactInit = {}; +/* Contact is brother of 'Anna' */ +var relationship = new tizen.ContactRelationship('Anna', 'BROTHER'); +contactInit.relationships = [relationship]; +
Code example:
var name = new tizen.ContactName({ firstName: 'Anna' }); +Code example:
+var name = new tizen.ContactName({firstName: 'Anna'}); - var contact_extension1 = new tizen.ContactExtension({ data1: 20, data2: 'Place of birth: Elbląg' }); - var contact_extension2 = new tizen.ContactExtension({ data3: 'Favourite color: green' }); - var contact1 = new tizen.Contact({ - name: name, - extensions: [ contact_extension1, contact_extension2 ] - }); +var contact_extension1 = new tizen.ContactExtension({data1: 20, data2: 'Place of birth: Elbląg'}); +var contact_extension2 = new tizen.ContactExtension({data3: 'Favourite color: green'}); +var contact1 = new tizen.Contact( +{ + name: name, + extensions: [contact_extension1, contact_extension2] +}); - console.log(contact1.extensions[1].data3); // It shows: 'Favourite color: green' -+console.log(contact1.extensions[1].data3); /* It shows: 'Favourite color: green' */ +
Code example:
function onerror(err) { - console.log("The following error occurred " + err.name); - } - - function onsuccess(persons) { - var p; - - // log each found person's name to the console: - for (p = 0; p < persons.length; p += 1) { - console.log("Name: " + persons[p].displayName); - } - } - - try { - tizen.contact.find(onsuccess, onerror); - } catch (err) { - console.log("The following error occurred while finding: " + err.name); - } -+
Code example:
+function onerror(err) +{ + console.log("The following error occurred " + err.name); +} + +function onsuccess(persons) +{ + var p; + + /* Log each found person's name to the console */ + for (p = 0; p < persons.length; p += 1) + { + console.log("Name: " + persons[p].displayName); + } +} + +try +{ + tizen.contact.find(onsuccess, onerror); +} +catch (err) +{ + console.log("The following error occurred while finding: " + err.name); +} +
Code example:
function errorCB(err) { - console.log("An error occurred: " + err.name); - } - - // A callback invoked on successful retrieval of all the Address Books. - function addressBooksCB(addressBooks) { - console.log(addressBooks.length + " address books available."); - } - - // Gets a list of available address books. - tizen.contact.getAddressBooks(addressBooksCB, errorCB); -+
Code example:
+function errorCB(err) +{ + console.log("An error occurred: " + err.name); +} + +/* Callback invoked on successful retrieval of all the Address Books */ +function addressBooksCB(addressBooks) +{ + console.log(addressBooks.length + " address books available."); +} + +/* Gets a list of available address books */ +tizen.contact.getAddressBooks(addressBooksCB, errorCB); +
Code example:
var watcherId = 0; // watcher identifier - var addressbook = tizen.contact.getDefaultAddressBook(); - - var watcher = { - oncontactsadded: function(contacts) { - console.log(contacts.length + " contacts were added"); - }, - oncontactsupdated: function(contacts) { - console.log(contacts.length + " contacts were updated"); - }, - oncontactsremoved: function(ids) { - console.log(ids.length + " contacts were removed"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = addressbook.addChangeListener(watcher); - - // Adds a new contact to invoke an oncontactsadded call: - try { - var contact = new tizen.Contact({name : new tizen.ContactName({ - firstName : 'John', lastName : 'Doe', - nicknames : ['Johnny']}), - emails : [new tizen.ContactEmailAddress('john@doe.com')], - phoneNumbers : [new tizen.ContactPhoneNumber('789456123')]}); - addressbook.add(contact); - } catch (err) { - console.log('An error occurred while adding a contact: ' + err.name + ", " + err.message); - } -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +var watcher = +{ + oncontactsadded: function(contacts) + { + console.log(contacts.length + " contacts were added"); + }, + oncontactsupdated: function(contacts) + { + console.log(contacts.length + " contacts were updated"); + }, + oncontactsremoved: function(ids) + { + console.log(ids.length + " contacts were removed"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = addressbook.addChangeListener(watcher); + +/* Adds a new contact to invoke an oncontactsadded call */ +try +{ + var contact = new tizen.Contact( + { + name: new tizen.ContactName( + { + firstName: 'John', + lastName: 'Doe', + nicknames: ['Johnny'] + }), + emails: [new tizen.ContactEmailAddress('john@doe.com')], + phoneNumbers: [new tizen.ContactPhoneNumber('789456123')]}); + addressbook.add(contact); +} +catch (err) +{ + console.log('An error occurred while adding a contact: ' + err.name + ", " + err.message); +} +
Code example:
var watcherId = 0; // watcher identifier - var addressbook = tizen.contact.getDefaultAddressBook(); - - var watcher = { - oncontactsadded: function(contacts) { - console.log(contacts.length + " contacts were added"); - }, - oncontactsupdated: function(contacts) { - console.log(contacts.length + " contacts were updated"); - }, - oncontactsremoved: function(ids) { - console.log(ids.length + " contacts were removed"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = addressbook.addChangeListener(watcher); - - // Updates a contact to invoke an oncontactsupdated call: - function errorCB(error) { - console.log(error.name + ": " + error.message); - } - - function contactsFoundCB(contacts) { - contacts[0].name.firstName = 'Stanley'; - try { - addressbook.update(contacts[0]); - console.log('Successfully updated.'); - } catch (error) { - console.log(error.name + ": " + error.message); - } - } - - var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe'); - try { - addressbook.find(contactsFoundCB, errorCB, filter); - } catch (error) { - console.log(error.name + ": " + error.message); - } -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +var watcher = +{ + oncontactsadded: function(contacts) + { + console.log(contacts.length + " contacts were added"); + }, + oncontactsupdated: function(contacts) + { + console.log(contacts.length + " contacts were updated"); + }, + oncontactsremoved: function(ids) + { + console.log(ids.length + " contacts were removed"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = addressbook.addChangeListener(watcher); + +/* Updates a contact to invoke an oncontactsupdated call */ +function errorCB(error) +{ + console.log(error.name + ": " + error.message); +} + +function contactsFoundCB(contacts) +{ + contacts[0].name.firstName = 'Stanley'; + try + { + addressbook.update(contacts[0]); + console.log('Successfully updated.'); + } + catch (error) + { + console.log(error.name + ": " + error.message); + } +} + +var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe'); +try +{ + addressbook.find(contactsFoundCB, errorCB, filter); +} +catch (error) +{ + console.log(error.name + ": " + error.message); +} +
Code example:
var watcherId = 0; // watcher identifier - var addressbook = tizen.contact.getDefaultAddressBook(); - - var watcher = { - oncontactsadded: function(contacts) { - console.log(contacts.length + " contacts were added"); - }, - oncontactsupdated: function(contacts) { - console.log(contacts.length + " contacts were updated"); - }, - oncontactsremoved: function(ids) { - console.log(ids.length + " contacts were removed"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = addressbook.addChangeListener(watcher); - - // Removes a first contact whose name is 'Doe' - // to invoke oncontactsremoved call: - function onErrorCB(err) { - console.log('An error occurred: ' + err.name); - } - - function onContactsFoundCB(contacts) { - if(contacts.length > 0) { - try { - addressbook.remove(contacts[0].id); - console.log('First contact has been removed.'); - } catch (err) { - console.log('An error occurred while removing: ' + err.name); - } - } else { - console.log('No contacts to delete.'); - } - } - - var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe'); - try { - addressbook.find(onContactsFoundCB, onErrorCB, filter); - } catch (err) { - console.log('An error occured while finding: ' + err.name); - } -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var addressbook = tizen.contact.getDefaultAddressBook(); + +var watcher = +{ + oncontactsadded: function(contacts) + { + console.log(contacts.length + " contacts were added"); + }, + oncontactsupdated: function(contacts) + { + console.log(contacts.length + " contacts were updated"); + }, + oncontactsremoved: function(ids) + { + console.log(ids.length + " contacts were removed"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = addressbook.addChangeListener(watcher); + +/* Removes a first contact whose name is 'Doe' to invoke oncontactsremoved call */ +function onErrorCB(err) +{ + console.log('An error occurred: ' + err.name); +} + +function onContactsFoundCB(contacts) +{ + if (contacts.length > 0) + { + try + { + addressbook.remove(contacts[0].id); + console.log('First contact has been removed.'); + } + catch (err) + { + console.log('An error occurred while removing: ' + err.name); + } + } + else + { + console.log('No contacts to delete.'); + } +} + +var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe'); +try +{ + addressbook.find(onContactsFoundCB, onErrorCB, filter); +} +catch (err) +{ + console.log('An error occurred while finding: ' + err.name); +} +
Code example:
var watcherId = 0; // watcher identifier - - var watcher = { - onpersonsadded: function(persons) { - console.log(persons.length + " persons were added"); - }, - onpersonsupdated: function(persons) { - console.log(persons.length + " persons were updated"); - }, - onpersonsremoved: function(ids) { - console.log(ids.length + " persons were deleted"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = tizen.contact.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ + +var watcher = +{ + onpersonsadded: function(persons) + { + console.log(persons.length + " persons were added"); + }, + onpersonsupdated: function(persons) + { + console.log(persons.length + " persons were updated"); + }, + onpersonsremoved: function(ids) + { + console.log(ids.length + " persons were deleted"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = tizen.contact.addChangeListener(watcher); +
Code example:
var watcherId = 0; // watcher identifier - - var watcher = { - onpersonsadded: function(persons) { - console.log(persons.length + " persons were added"); - }, - onpersonsupdated: function(persons) { - console.log(persons.length + " persons were updated"); - }, - onpersonsremoved: function(ids) { - console.log(ids.length + " persons were deleted"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = tizen.contact.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ + +var watcher = +{ + onpersonsadded: function(persons) + { + console.log(persons.length + " persons were added"); + }, + onpersonsupdated: function(persons) + { + console.log(persons.length + " persons were updated"); + }, + onpersonsremoved: function(ids) + { + console.log(ids.length + " persons were deleted"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = tizen.contact.addChangeListener(watcher); +
Code example:
var watcherId = 0; // watcher identifier - - var watcher = { - onpersonsadded: function(persons) { - console.log(persons.length + " persons were added"); - }, - onpersonsupdated: function(persons) { - console.log(persons.length + " persons were updated"); - }, - onpersonsremoved: function(ids) { - console.log(ids.length + " persons were deleted"); - } - }; - - // Registers to be notified when the address book changes. - watcherId = tizen.contact.addChangeListener(watcher); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ + +var watcher = +{ + onpersonsadded: function(persons) + { + console.log(persons.length + " persons were added"); + }, + onpersonsupdated: function(persons) + { + console.log(persons.length + " persons were updated"); + }, + onpersonsremoved: function(ids) + { + console.log(ids.length + " persons were deleted"); + } +}; + +/* Registers to be notified when the address book changes */ +watcherId = tizen.contact.addChangeListener(watcher); +
Code example:
// Assume the content is a Content object as a result of find method. - // Check the description is editable, and then set a description. - if (content.editableAttributes.indexOf("description") >= 0) { - content.description = "Sample content"; - } - tizen.content.update(content); -+
Code example:
+/* Assume the content is a Content object as a result of find method */ +/* Check the description is editable, and then set a description */ +if (content.editableAttributes.indexOf("description") >= 0) +{ + content.description = "Sample content"; +} +tizen.content.update(content); +
Code example:
// The following example increases rating of an content by 1 - - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function successCB() { - console.log('Attributes set successfully'); - } - - // Assume the content is a Content object as a result of find method. - // Check the rating is editable, and then increase by 1. - if (content.editableAttributes.indexOf("rating") >= 0) { - content.rating++; - } - tizen.content.updateBatch([content], successCB, errorCB); -+
Code example:
+/* Following example increases rating of a content by 1 */ + +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function successCB() +{ + console.log('Attributes set successfully'); +} + +/* Assume the content is a Content object as a result of find method */ +/* Check the rating is editable, and then increase by 1 */ +if (content.editableAttributes.indexOf("rating") >= 0) +{ + content.rating++; +} +tizen.content.updateBatch([content], successCB, errorCB); +
Code example:
// The following example retrieves content directories in the storage. +Code example:
+/* Following example retrieves content directories in the storage */ - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} - function printDirectory(directory, index, directories) { - console.log('directoryURI: ' + directory.directoryURI + ' Title: ' + directory.title); - } - function getDirectoriesCB(directories) { - directories.forEach(printDirectory); - } +function printDirectory(directory, index, directories) +{ + console.log('directoryURI: ' + directory.directoryURI + ' Title: ' + directory.title); +} - tizen.content.getDirectories(getDirectoriesCB, errorCB); -+function getDirectoriesCB(directories) +{ + directories.forEach(printDirectory); +} + +tizen.content.getDirectories(getDirectoriesCB, errorCB); +
Code example:
// The following example retrieves all songs from the album "The Joshua Tree", by artist "U2", ordered by the name. - var count = 100; - var offset = 0; - var sortMode = new tizen.SortMode("name", "ASC"); - var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2"); - var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree"); - var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]); - - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } - - function printContent(content, index, contents) { - console.log('Name: ' + content.name + ' Title: ' + content.title + 'URL: ' + content.contentURI + 'MIME: ' + content.mimeType); - } - - function findCB(contents) { - console.log('The Joshua Tree by U2:'); - contents.forEach(printContent); - // Increase the offset as much as the count and then find content again. - if (contents.length === count) { - offset += count; - tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset); - } - } - - tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset); - -+
Code example:
+/* Following example retrieves all songs from the album "The Joshua Tree", by artist "U2", ordered by the name */ +var count = 100; +var offset = 0; +var sortMode = new tizen.SortMode("name", "ASC"); +var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2"); +var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree"); +var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]); + +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function printContent(content, index, contents) +{ + console.log('Name: ' + content.name + ' Title: ' + content.title + + 'URL: ' + content.contentURI + 'MIME: ' + content.mimeType); +} + +function findCB(contents) +{ + console.log('The Joshua Tree by U2:'); + contents.forEach(printContent); + /* Increase the offset as much as the count and then find content again */ + if (contents.length === count) + { + offset += count; + tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset); + } +} + +tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset); +
Code example:
// The following example scan 'tizen.jpg' in media directory - - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } +Code example:
+/* Following example scans 'tizen.jpg' in media directory */ - function successCB(path) { - console.log('scanning is completed'); - } +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} - tizen.filesystem.resolve("images/tizen.jpg", function(imageFile) { - tizen.content.scanFile(imageFile.toURI(), successCB, errorCB); - }); +function successCB(path) +{ + console.log('scanning is completed'); +} -+tizen.filesystem.resolve("images/tizen.jpg", function(imageFile) +{ + tizen.content.scanFile(imageFile.toURI(), successCB, errorCB); +}); +
Code example:
// The following example scans 'images' directory - - function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } +Code example:
+/* Following example scans 'images' directory */ - function successCB(path) { - console.log('scanning is completed'); - } +function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} - tizen.filesystem.resolve("images", function(directory) { - tizen.content.scanDirectory(directory.toURI(), true, successCB, errorCB); - }); +function successCB(path) +{ + console.log('scanning is completed'); +} -+tizen.filesystem.resolve("images", function(directory) +{ + tizen.content.scanDirectory(directory.toURI(), true, successCB, errorCB); +}); +
Code example:
tizen.content.cancelScanDirectory(directory.toURI()); - -+
Code example:
+tizen.content.cancelScanDirectory(directory.toURI()); +
Code example:
var listener = { - oncontentadded: function(content) { - console.log(content.contentURI + ' content is added'); - }, - oncontentupdated: function(content) { - console.log(content.contentURI + ' content is updated'); - }, - oncontentremoved: function(id) { - console.log(id + ' is removed'); - }, - oncontentdiradded: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is added'); - }, - oncontentdirupdated: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is updated'); - }, - oncontentdirremoved: function(id) { - console.log(id + ' directory is removed'); - } - }; - - // Adds the listener - var listenerId = tizen.content.addChangeListener(listener); - - console.log('Listener ID: ' + listenerId); -+
Code example:
+var listener = +{ + oncontentadded: function(content) + { + console.log(content.contentURI + ' content is added'); + }, + oncontentupdated: function(content) + { + console.log(content.contentURI + ' content is updated'); + }, + oncontentremoved: function(id) + { + console.log(id + ' is removed'); + }, + oncontentdiradded: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is added'); + }, + oncontentdirupdated: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is updated'); + }, + oncontentdirremoved: function(id) + { + console.log(id + ' directory is removed'); + } +}; + +/* Adds the listener */ +var listenerId = tizen.content.addChangeListener(listener); + +console.log('Listener ID: ' + listenerId); +
Output example:
Listener ID: 1 @@ -1069,34 +1099,42 @@ contain an invalid value (e.g. given contentDirURI is an empty string).
Code example:
var listener = { - oncontentadded: function(content) { - console.log(content.contentURI + ' content is added'); - }, - oncontentupdated: function(content) { - console.log(content.contentURI + ' content is updated'); - }, - oncontentremoved: function(id) { - console.log(id + ' is removed'); - }, - oncontentdiradded: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is added'); - }, - oncontentdirupdated: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is updated'); - }, - oncontentdirremoved: function(id) { - console.log(id + ' directory is removed'); - } - }; - - var listenerId = tizen.content.addChangeListener(listener); - - // Do some job here and when the listener is not needed anymore remove it - - // Removes the listener - tizen.content.removeChangeListener(listenerId); -+
Code example:
+var listener = +{ + oncontentadded: function(content) + { + console.log(content.contentURI + ' content is added'); + }, + oncontentupdated: function(content) + { + console.log(content.contentURI + ' content is updated'); + }, + oncontentremoved: function(id) + { + console.log(id + ' is removed'); + }, + oncontentdiradded: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is added'); + }, + oncontentdirupdated: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is updated'); + }, + oncontentdirremoved: function(id) + { + console.log(id + ' directory is removed'); + } +}; + +var listenerId = tizen.content.addChangeListener(listener); + +/* Do some job here and when the listener is not needed anymore remove it */ + +/* Removes the listener */ +tizen.content.removeChangeListener(listenerId); +
Code example:
var listener= { - oncontentadded: function(content) { - console.log(content.contentURI + ' content is added'); - }, - oncontentupdated: function(content) { - console.log(content.contentURI + ' content is updated'); - }, - oncontentremoved: function(id) { - console.log(id + ' is removed'); - }, - oncontentdiradded: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is added'); - }, - oncontentdirupdated: function(contentDir) { - console.log(contentDir.directoryURI + ' content directory is updated'); - }, - oncontentdirremoved: function(id) { - console.log(id + ' directory is removed'); - } - }; - - // Registers to be notified when the content changes - tizen.content.setChangeListener(listener); - -+
Code example:
+var listener = +{ + oncontentadded: function(content) + { + console.log(content.contentURI + ' content is added'); + }, + oncontentupdated: function(content) + { + console.log(content.contentURI + ' content is updated'); + }, + oncontentremoved: function(id) + { + console.log(id + ' is removed'); + }, + oncontentdiradded: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is added'); + }, + oncontentdirupdated: function(contentDir) + { + console.log(contentDir.directoryURI + ' content directory is updated'); + }, + oncontentdirremoved: function(id) + { + console.log(id + ' directory is removed'); + } +}; + +/* Registers to be notified when the content changes */ +tizen.content.setChangeListener(listener); +
Code example:
tizen.content.unsetChangeListener(); - -+
Code example:
+tizen.content.unsetChangeListener(); +
Code example:
var gPlaylists; - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - var cur, i; - gPlaylists = playlists; - for(i = 0; i < gPlaylists.length; ++i) { - cur = gPlaylists[i]; - console.log("[" + i + "] name:" + cur.name + " num tracks:" + - cur.numberOfTracks); - } - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); -+
Code example:
+var gPlaylists; + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + var cur, i; + gPlaylists = playlists; + for (i = 0; i < gPlaylists.length; ++i) + { + cur = gPlaylists[i]; + console.log("[" + i + "] name:" + cur.name + " num tracks:" + + cur.numberOfTracks); + } +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
var gPlaylists; - var gPlaylist; - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err.message); - } - - function getPlaylistsSuccess(playlists) { - var cur, i; - gPlaylists = playlists; - for(i = 0; i < gPlaylists.length; ++i) { - cur = gPlaylists[i]; - console.log("[" + i + "] name:" + cur.name + " num tracks:" + - cur.numberOfTracks); - } - } - - function findSuccess(contents) { - if (contents.length > 0) { - gPlaylist.add(contents[0]); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); - } - - function findFail(err) { - console.log("find FAIL: " + err.message); - } - - function createSuccess(playlist) { - console.log("create SUCCESS"); - - gPlaylist = playlist; - tizen.content.find(findSuccess, findFail, null, - new tizen.AttributeFilter("type", "EXACTLY", "AUDIO")); - } - - function createFail(err) { - console.log("create FAIL: " + err.message); - } - - tizen.content.createPlaylist("My new playlist", createSuccess, createFail); - -+
Code example:
+var gPlaylists; +var gPlaylist; + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err.message); +} + +function getPlaylistsSuccess(playlists) +{ + var cur, i; + gPlaylists = playlists; + for (i = 0; i < gPlaylists.length; ++i) + { + cur = gPlaylists[i]; + console.log("[" + i + "] name:" + cur.name + " num tracks:" + + cur.numberOfTracks); + } +} + +function findSuccess(contents) +{ + if (contents.length > 0) + { + gPlaylist.add(contents[0]); + } + + tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +} + +function findFail(err) +{ + console.log("find FAIL: " + err.message); +} + +function createSuccess(playlist) +{ + console.log("create SUCCESS"); + + gPlaylist = playlist; + tizen.content.find(findSuccess, findFail, null, + new tizen.AttributeFilter("type", "EXACTLY", "AUDIO")); +} + +function createFail(err) +{ + console.log("create FAIL: " + err.message); +} + +tizen.content.createPlaylist("My new playlist", createSuccess, createFail); +
Code example:
var gPlaylists; - - function removePlaylistSuccess() { - console.log("removePlaylist SUCCESS"); - } - - function removePlaylistFail(err) { - console.log("removePlaylist FAIL: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - var cur, i; - gPlaylists = playlists; - for(i = 0; i < gPlaylists.length; ++i) { - cur = gPlaylists[i]; - console.log("[" + i + "] name:" + cur.name + " num tracks:" + - cur.numberOfTracks); - } - - if(gPlaylists.length < 1) { - console.log("Please add at least 1 playlist"); - return; - } - - console.log("will remove playlist at index [0] name:" - + gPlaylists[0].name); - - tizen.content.removePlaylist(gPlaylists[0].id, removePlaylistSuccess, - removePlaylistFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); - -+
Code example:
+var gPlaylists; + +function removePlaylistSuccess() +{ + console.log("removePlaylist SUCCESS"); +} + +function removePlaylistFail(err) +{ + console.log("removePlaylist FAIL: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + var cur, i; + gPlaylists = playlists; + for (i = 0; i < gPlaylists.length; ++i) + { + cur = gPlaylists[i]; + console.log("[" + i + "] name:" + cur.name + " num tracks:" + + cur.numberOfTracks); + } + + if (gPlaylists.length < 1) + { + console.log("Please add at least 1 playlist"); + + return; + } + + console.log("will remove playlist at index [0] name:" + + gPlaylists[0].name); + + tizen.content.removePlaylist(gPlaylists[0].id, removePlaylistSuccess, + removePlaylistFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
function createCB(path) { - console.log("The thumbnail path is " + path); - } - - function findCB(contents) { - if (contents.length > 0) { - tizen.content.createThumbnail(contents[0], createCB); - } - } - - tizen.content.find(findCB); -+
Code example:
+function createCB(path) +{ + console.log("The thumbnail path is " + path); +} + +function findCB(contents) +{ + if (contents.length > 0) + { + tizen.content.createThumbnail(contents[0], createCB); + } +} + +tizen.content.find(findCB); +
Output example:
The thumbnail path is /home/owner/share/media/.thumb/phone/.jpg-bed1d5f494830f7a52e1217f1e924aff.jpg @@ -2820,59 +2888,71 @@ UnknownError: In case of any error
Code example:
var gPlaylists, gItems, gCurPlaylist; - - function get2Fail(err) { - console.log("get items (after remove) failed: " + err); - } - - function get2Success(items) { - console.log("Playlist items:"); - for(var i = 0; i < items.length ; ++i) { - console.log("[" + i + "]: name:" + items[i].content.name); - } - } - - function getSuccess(items) { - gItems = items; - - if(gItems.length < 1) { - console.log("Please add at least 1 tracks to playlist!"); - return; - } - - console.log("Original playlist:"); - for(var i = 0; i < gItems.length ; ++i) { - console.log("[" + i + "]: name:" + gItems[i].content.name); - } - - console.log("Will remove item at index [0] name:" + gItems[0].content.name); - gCurPlaylist.remove(gItems[0]); - gCurPlaylist.get(get2Success, get2Fail); - } - - function getFail(err) { - console.log("get items failed: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - gPlaylists = playlists; - if(gPlaylists.length === 0) { - console.log("Please create at least 1 playlist!"); - return; - } - - gCurPlaylist = gPlaylists[0]; - gCurPlaylist.get(getSuccess, getFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); - -+
Code example:
+var gPlaylists, gItems, gCurPlaylist; + +function get2Fail(err) +{ + console.log("get items (after remove) failed: " + err); +} + +function get2Success(items) +{ + console.log("Playlist items:"); + for (var i = 0; i < items.length; ++i) + { + console.log("[" + i + "]: name:" + items[i].content.name); + } +} + +function getSuccess(items) +{ + gItems = items; + + if (gItems.length < 1) + { + console.log("Please add at least 1 tracks to playlist!"); + + return; + } + + console.log("Original playlist:"); + for (var i = 0; i < gItems.length; ++i) + { + console.log("[" + i + "]: name:" + gItems[i].content.name); + } + + console.log("Will remove item at index [0] name:" + gItems[0].content.name); + gCurPlaylist.remove(gItems[0]); + gCurPlaylist.get(get2Success, get2Fail); +} + +function getFail(err) +{ + console.log("get items failed: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + gPlaylists = playlists; + if (gPlaylists.length === 0) + { + console.log("Please create at least 1 playlist!"); + + return; + } + + gCurPlaylist = gPlaylists[0]; + gCurPlaylist.get(getSuccess, getFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
var gPlaylists, gItems, gCurPlaylist; - - function get2Fail(err) { - console.log("get items (after remove batch) failed: " + err); - } - - function get2Success(items) { - console.log("Playlist after remove batch:"); - for(var i = 0; i < items.length ; ++i) { - console.log("[" + i + "]: name:" + items[i].content.name); - } - } - - function removeBatchSuccess() { - console.log("removeBatch success"); - gCurPlaylist.get(get2Success, get2Fail); - } - - function removeBatchFail(err) { - console.log("removeBatch failed: " + err); - } - - function getSuccess(items) { - gItems = items; - - if(gItems.length < 4) { - console.log("Please add at least 4 tracks to playlist!"); - return; - } - - console.log("Original playlist:"); - for(var i = 0; i < gItems.length ; ++i) { - console.log("[" + i + "]: name:" + gItems[i].content.name); - } - - console.log("Will remove items at index [0](name:" + gItems[0].content.name - + ") and at index [2](name:" + gItems[2].content.name + ")"); - gCurPlaylist.removeBatch([gItems[2], gItems[0]], - removeBatchSuccess, removeBatchFail); - } - - function getFail(err) { - console.log("get items failed: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - gPlaylists = playlists; - if(gPlaylists.length === 0) { - console.log("Please create at least 1 playlist!"); - return; - } - - gCurPlaylist = gPlaylists[0]; - gCurPlaylist.get(getSuccess, getFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); - -+
Code example:
+var gPlaylists, gItems, gCurPlaylist; + +function get2Fail(err) +{ + console.log("get items (after remove batch) failed: " + err); +} + +function get2Success(items) +{ + console.log("Playlist after remove batch:"); + for (var i = 0; i < items.length; ++i) + { + console.log("[" + i + "]: name:" + items[i].content.name); + } +} + +function removeBatchSuccess() +{ + console.log("removeBatch success"); + gCurPlaylist.get(get2Success, get2Fail); +} + +function removeBatchFail(err) +{ + console.log("removeBatch failed: " + err); +} + +function getSuccess(items) +{ + gItems = items; + + if (gItems.length < 4) + { + console.log("Please add at least 4 tracks to playlist!"); + + return; + } + + console.log("Original playlist:"); + for (var i = 0; i < gItems.length; ++i) + { + console.log("[" + i + "]: name:" + gItems[i].content.name); + } + + console.log("Will remove items at index [0](name:" + gItems[0].content.name + + ") and at index [2](name:" + gItems[2].content.name + ")"); + gCurPlaylist.removeBatch([gItems[2], gItems[0]], removeBatchSuccess, removeBatchFail); +} + +function getFail(err) +{ + console.log("get items failed: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + gPlaylists = playlists; + if (gPlaylists.length === 0) + { + console.log("Please create at least 1 playlist!"); + + return; + } + + gCurPlaylist = gPlaylists[0]; + gCurPlaylist.get(getSuccess, getFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
var gPlaylists, gItems, gCurPlaylist; - - function getSuccess(items) { - gItems = items; - console.log("Playlist items:"); - for(var i = 0; i < items.length ; ++i) { - console.log("[" + i + "]: name:" + items[i].name); - } - } - - function getFail(err) { - console.log("get items failed: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - gPlaylists = playlists; - if(gPlaylists.length === 0) { - console.log("Please create at least 1 playlist!"); - return; - } - - gCurPlaylist = gPlaylists[0]; - // To retrieves all playlist items of 'gCurPlaylist' playlist. - gCurPlaylist.get(getSuccess, getFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); -+
Code example:
+var gPlaylists, gItems, gCurPlaylist; + +function getSuccess(items) +{ + gItems = items; + console.log("Playlist items:"); + for (var i = 0; i < items.length; ++i) + { + console.log("[" + i + "]: name:" + items[i].name); + } +} + +function getFail(err) +{ + console.log("get items failed: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + gPlaylists = playlists; + if (gPlaylists.length === 0) + { + console.log("Please create at least 1 playlist!"); + + return; + } + + gCurPlaylist = gPlaylists[0]; + /* To retrieve all playlist items of 'gCurPlaylist' playlist */ + gCurPlaylist.get(getSuccess, getFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
var gPlaylists, gItems, gCurPlaylist, gExpectedOrder; - - function get2Fail(err) { - console.log("get items (after set order) failed: " + err); - } - - function get2Success(items) { - console.log("Playlist order after setOrder:"); - for(var i = 0; i < items.length ; ++i) { - console.log("[" + i + "]: name:" + items[i].content.name); - } - } - - function setOrderSuccess() { - console.log("set items order SUCCESS"); - gCurPlaylist.get(get2Success, get2Fail); - } - - function setOrderFail(err) { - console.log("set items order failed: " + err); - } - - function getSuccess(items) { - gItems = items; - - if(gItems.length < 2) { - console.log("Please add at least 2 tracks to playlist!"); - return; - } - - console.log("Original order:"); - for(var i = 0; i < gItems.length ; ++i) { - console.log("[" + i + "]: name:" + gItems[i].content.name); - } - - gExpectedOrder = gItems.slice(0); - gExpectedOrder.reverse(); - - console.log("New order:"); - for(var i = 0; i < gExpectedOrder.length ; ++i) { - console.log("[" + i + "]: name:" + gExpectedOrder[i].content.name); - } - - gCurPlaylist.setOrder(gExpectedOrder, setOrderSuccess, setOrderFail); - } - - function getFail(err) { - console.log("get items failed: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - gPlaylists = playlists; - if(gPlaylists.length === 0) { - console.log("Please create at least 1 playlist!"); - return; - } - - gCurPlaylist = gPlaylists[0]; - gCurPlaylist.get(getSuccess, getFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); - -+
Code example:
+var gPlaylists, gItems, gCurPlaylist, gExpectedOrder; + +function get2Fail(err) +{ + console.log("get items (after set order) failed: " + err); +} + +function get2Success(items) +{ + console.log("Playlist order after setOrder:"); + for (var i = 0; i < items.length; ++i) + { + console.log("[" + i + "]: name:" + items[i].content.name); + } +} + +function setOrderSuccess() +{ + console.log("set items order SUCCESS"); + gCurPlaylist.get(get2Success, get2Fail); +} + +function setOrderFail(err) +{ + console.log("set items order failed: " + err); +} + +function getSuccess(items) +{ + gItems = items; + + if (gItems.length < 2) + { + console.log("Please add at least 2 tracks to playlist!"); + + return; + } + + console.log("Original order:"); + for (var i = 0; i < gItems.length; ++i) + { + console.log("[" + i + "]: name:" + gItems[i].content.name); + } + + gExpectedOrder = gItems.slice(0); + gExpectedOrder.reverse(); + + console.log("New order:"); + for (var i = 0; i < gExpectedOrder.length; ++i) + { + console.log("[" + i + "]: name:" + gExpectedOrder[i].content.name); + } + + gCurPlaylist.setOrder(gExpectedOrder, setOrderSuccess, setOrderFail); +} + +function getFail(err) +{ + console.log("get items failed: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + gPlaylists = playlists; + if (gPlaylists.length === 0) + { + console.log("Please create at least 1 playlist!"); + + return; + } + + gCurPlaylist = gPlaylists[0]; + gCurPlaylist.get(getSuccess, getFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
var gPlaylists, gItems, gCurPlaylist; - - function get2Fail(err) { - console.log("get items (after move item) failed: " + err); - } - - function get2Success(items) { - console.log("Playlist order after move:"); - for(var i = 0; i < items.length ; ++i) { - console.log("[" + i + "]: name:" + items[i].content.name); - } - } - - function moveSuccess() { - console.log("move item SUCCESS"); - gCurPlaylist.get(get2Success, get2Fail); - } - - function moveFail(err) { - console.log("move item failed: " + err); - } - - function getSuccess(items) { - gItems = items; - - if(gItems.length < 2) { - console.log("Please add at least 2 tracks to playlist!"); - return; - } - - console.log("Original order:"); - for(var i = 0; i < gItems.length ; ++i) { - console.log("[" + i + "]: name:" + gItems[i].content.name); - } - - console.log("Will move item at index [1] (name: " + - gItems[1].content.name + ") up by one place (to [0])"); - - gCurPlaylist.move(gItems[1], -1, moveSuccess, moveFail); - gItems.unshift(gItems.splice(1, 1)[0]); - } - - function getFail(err) { - console.log("get items failed: " + err); - } - - function getPlaylistsFail(err) { - console.log("getPlaylists failed: " + err); - } - - function getPlaylistsSuccess(playlists) { - gPlaylists = playlists; - if(gPlaylists.length === 0) { - console.log("Please create at least 1 playlist!"); - return; - } - - gCurPlaylist = gPlaylists[0]; - gCurPlaylist.get(getSuccess, getFail); - } - - tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); -+
Code example:
+var gPlaylists, gItems, gCurPlaylist; + +function get2Fail(err) +{ + console.log("get items (after move item) failed: " + err); +} + +function get2Success(items) +{ + console.log("Playlist order after move:"); + for (var i = 0; i < items.length; ++i) + { + console.log("[" + i + "]: name:" + items[i].content.name); + } +} + +function moveSuccess() +{ + console.log("move item SUCCESS"); + gCurPlaylist.get(get2Success, get2Fail); +} + +function moveFail(err) +{ + console.log("move item failed: " + err); +} + +function getSuccess(items) +{ + gItems = items; + + if (gItems.length < 2) + { + console.log("Please add at least 2 tracks to playlist!"); + + return; + } + + console.log("Original order:"); + for (var i = 0; i < gItems.length; ++i) + { + console.log("[" + i + "]: name:" + gItems[i].content.name); + } + + console.log("Will move item at index [1] (name: " + + gItems[1].content.name + ") up by one place (to [0])"); + + gCurPlaylist.move(gItems[1], -1, moveSuccess, moveFail); + gItems.unshift(gItems.splice(1, 1)[0]); +} + +function getFail(err) +{ + console.log("get items failed: " + err); +} + +function getPlaylistsFail(err) +{ + console.log("getPlaylists failed: " + err); +} + +function getPlaylistsSuccess(playlists) +{ + gPlaylists = playlists; + if (gPlaylists.length === 0) + { + console.log("Please create at least 1 playlist!"); + + return; + } + + gCurPlaylist = gPlaylists[0]; + gCurPlaylist.get(getSuccess, getFail); +} + +tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail); +
Code example:
console.log('A is for Alice.'); -+
Code example:
console.log('A is for Alice.');
Output example:
A is for Alice. @@ -153,8 +152,7 @@ The text will be logged as an error message.
Code example:
console.error('B is for Bob.'); -+
Code example:
console.error('B is for Bob.');
Output example:
B is for Bob. @@ -185,8 +183,7 @@ The text will be logged as a warning message.
Code example:
console.warn('C is for Christopher.'); -+
Code example:
console.warn('C is for Christopher.');
Output example:
C is for Christopher. @@ -217,8 +214,7 @@ The text will be logged as an info message.
Code example:
console.info('D is for Dorothy.'); -+
Code example:
console.info('D is for Dorothy.');
Output example:
D is for Dorothy. @@ -249,8 +245,7 @@ The text will be logged as a debug message.
Code example:
console.debug('E is for Eve.'); -+
Code example:
console.debug('E is for Eve.');
Output example:
E is for Eve. @@ -285,11 +280,12 @@ the message is written to the console.
Code example:
var felix = 'Felix'; +Code example:
+var felix = 'Felix'; - // This assertion checks whether the first letter in name 'Felix' is 'A': - console.assert(felix.charAt(0) === 'A', felix + ' does not start with A.'); -+/* This assertion checks whether the first letter in name 'Felix' is 'A' */ +console.assert(felix.charAt(0) === 'A', felix + ' does not start with A.'); +
Output example:
Felix does not start with A. @@ -321,9 +317,10 @@ Object view is forced.
Code example:
var john = {name: "John", surname: "Doe"}; - console.dir(john.name); -+
Code example:
+var john = {name: "John", surname: "Doe"}; +console.dir(john.name); +
Output example:
John @@ -354,9 +351,10 @@ if possible or the JavaScript Object if it is not.
Code example:
var john = {name: "John", surname: "Doe"}; - console.dirxml(john.surname); -+
Code example:
+var john = {name: "John", surname: "Doe"}; +console.dirxml(john.surname); +
Output example:
Doe @@ -388,13 +386,15 @@ is displayed in the console. Timer values are accurate to the sub-millisecond.
Code example:
console.time("Big array initialization"); - var array = new Array(1000000); - for (var i = array.length - 1; i >= 0; i -= 1) { - array[i] = new Object(); - }; - console.timeEnd("Big array initialization"); -+
Code example:
+console.time("Big array initialization"); +var array = new Array(1000000); +for (var i = array.length - 1; i >= 0; i -= 1) +{ + array[i] = new Object(); +}; +console.timeEnd("Big array initialization"); +
Output example:
Big array initialization: 461.989ms @@ -424,13 +424,15 @@ is displayed in the console. Timer values are accurate to the sub-millisecond.
Code example:
console.time("Big array initialization"); - var array = new Array(1000000); - for (var i = array.length - 1; i >= 0; i -= 1) { - array[i] = new Object(); - }; - console.timeEnd("Big array initialization"); -+
Code example:
+console.time("Big array initialization"); +var array = new Array(1000000); +for (var i = array.length - 1; i >= 0; i -= 1) +{ + array[i] = new Object(); +}; +console.timeEnd("Big array initialization"); +
Output example:
Big array initialization: 461.989ms diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/cordova.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/cordova.html index 50365fd..b596947 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/cordova.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/cordova.html @@ -3,7 +3,7 @@ -Cordova API +Cordova API diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device-motion.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device-motion.html index 4326230..cd18e3c 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device-motion.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device-motion.html @@ -3,7 +3,7 @@ -DeviceMotion API +DeviceMotion API Output example:
Acceleration X: 0.00 @@ -197,22 +200,25 @@ Timestamp: 1456480118000-Code example:
function onSuccess(acceleration) { - console.log('Acceleration X: ' + acceleration.x + '\n' + - 'Acceleration Y: ' + acceleration.y + '\n' + - 'Acceleration Z: ' + acceleration.z + '\n' + - 'Timestamp: ' + acceleration.timestamp); - console.log('Please wait 3 seconds for the next measurement...'); - }; +Code example:
+function onSuccess(acceleration) +{ + console.log('Acceleration X: ' + acceleration.x + '\n' + + 'Acceleration Y: ' + acceleration.y + '\n' + + 'Acceleration Z: ' + acceleration.z + '\n' + + 'Timestamp: ' + acceleration.timestamp); + console.log('Please wait 3 seconds for the next measurement...'); +}; - function onError() { - console.log('onError!'); - }; +function onError() +{ + console.log('onError!'); +}; - var options = { frequency: 3000 }; // Update every 3 seconds +var options = {frequency: 3000}; /* Update every 3 seconds */ - var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); -+var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); +Output example:
Acceleration X: 0.00 @@ -259,26 +265,30 @@ Please wait 3 seconds for the next measurement...-Code example:
var counter = 0, watchID; +Code example:
+var counter = 0, watchID; - function onSuccess(acceleration) { - console.log('Acceleration X: ' + acceleration.x + '\n' + - 'Acceleration Y: ' + acceleration.y + '\n' + - 'Acceleration Z: ' + acceleration.z + '\n' + - 'Timestamp: ' + acceleration.timestamp); - if(3 == ++counter) { - navigator.accelerometer.clearWatch(watchID); - } - }; +function onSuccess(acceleration) +{ + console.log('Acceleration X: ' + acceleration.x + '\n' + + 'Acceleration Y: ' + acceleration.y + '\n' + + 'Acceleration Z: ' + acceleration.z + '\n' + + 'Timestamp: ' + acceleration.timestamp); + if (3 == ++counter) + { + navigator.accelerometer.clearWatch(watchID); + } +}; - function onError() { - console.log('onError!'); - }; +function onError() +{ + console.log('onError!'); +}; - var options = { frequency: 30 }; // Update every 0.03 seconds +var options = {frequency: 30}; /* Update every 0.03 seconds */ - watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); -+watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); +Output example:
Acceleration X: 0.00 diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device.html index 974550e..80e68c9 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/device.html @@ -3,7 +3,7 @@ -Device API +Device API @@ -94,12 +94,14 @@ Original documentation: -Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - console.log('Device Cordova: ' + device.cordova); - } -+function onDeviceReady() +{ + console.log('Device Cordova: ' + device.cordova); +} +Output example:
Device Cordova: 5.1.1 @@ -112,12 +114,14 @@ Original documentation: -Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - console.log('Device Model: ' + device.model); - } -+function onDeviceReady() +{ + console.log('Device Model: ' + device.model); +} +Output example:
Device Model: tm1 @@ -130,12 +134,14 @@ Original documentation: -Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - console.log('Device Platform: ' + device.platform); - } -+function onDeviceReady() +{ + console.log('Device Platform: ' + device.platform); +} +Output example:
Device Platform: Tizen @@ -148,12 +154,14 @@ Original documentation: -Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - console.log('Device UUID: ' + device.uuid); - } -+function onDeviceReady() +{ + console.log('Device UUID: ' + device.uuid); +} +Output example:
Device UUID: 2LR1b3MXfEUSFvH04m4e1EXYvQA= @@ -166,12 +174,14 @@ Original documentation: -Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - console.log('Device Version: ' + device.version); - } -+function onDeviceReady() +{ + console.log('Device Version: ' + device.version); +} +Output example:
Device Version: 3.0 diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/dialogs.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/dialogs.html index 10d12b0..1143a2c 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/dialogs.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/dialogs.html @@ -3,7 +3,7 @@ -Dialogs API +Dialogs API @@ -140,13 +140,15 @@ The navigator.notification object allows access to the Dialogs API.-Code example:
var alertDismissed = function() { - console.log('Alert was dismissed'); - } +Code example:
+var alertDismissed = function() +{ + console.log('Alert was dismissed'); +} - navigator.notification.alert('Please click OK button', alertDismissed, - 'OK click alert', 'OK'); -+navigator.notification.alert('Please click OK button', alertDismissed, + 'OK click alert', 'OK'); +Output example:
Alert was dismissed @@ -189,13 +191,15 @@ Callback provides index of button pressed (1,2,3 etc.) or 0, if dialog was dismi-Code example:
var confirmCallback = function(buttonIndex) { - console.log('Selected option was ' + buttonIndex); - } +Code example:
+var confirmCallback = function(buttonIndex) +{ + console.log('Selected option was ' + buttonIndex); +} - navigator.notification.confirm('Choose one option', confirmCallback, - 'Options', ['Option1', 'Option2']); -+navigator.notification.confirm('Choose one option', confirmCallback, + 'Options', ['Option1', 'Option2']); +Output example:
Selected option was 1 @@ -242,16 +246,15 @@ Callback provides PromptData object, which holds all data provided by u-Code example:
var promptCallback = function(results) { - console.log('Hello ' + results.input1 + ', you selected option ' + results.buttonIndex); - } +Code example:
+var promptCallback = function(results) +{ + console.log('Hello ' + results.input1 + ', you selected option ' + results.buttonIndex); +} - navigator.notification.prompt('Please enter your name', - promptCallback, - 'Registration Box', - ['Ok', 'Exit'], - 'e.g. Jane Doe'); -+navigator.notification.prompt('Please enter your name', promptCallback, + 'Registration Box', ['Ok', 'Exit'], 'e.g. Jane Doe'); +Output example:
Hello Jane Doe, you selected option 1 @@ -281,10 +284,11 @@ Callback provides PromptData object, which holds all data provided by u-Code example:
var times = 2; - console.log('Device would beep ' + times + ' times'); - navigator.notification.beep(times); -+Code example:
+var times = 2; +console.log('Device would beep ' + times + ' times'); +navigator.notification.beep(times); +Output example:
Device would beep 2 times diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/events.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/events.html index c12cb82..acd3d1d 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/events.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/events.html @@ -3,7 +3,7 @@ -Events API +Events API @@ -211,12 +211,14 @@ The deviceready event behaves somewhat differently from others. Any event handle Original documentation: Cordova deviceredy event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - // Now safe to use device APIs - } -+Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + /* Now safe to use device APIs */ +} +@@ -243,16 +245,19 @@ Applications typically should use document.addEventListener() to attach an event Original documentation: Cordova pause event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('pause', onPause, false); - } - - function onPause() { - // Handle the pause event - } -+Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('pause', onPause, false); +} + +function onPause() +{ + /* Handle the pause event */ +} +@@ -279,16 +284,19 @@ Applications typically should use document.addEventListener() to attach an event Original documentation: Cordova resume event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('resume', onResume, false); - } - - function onResume() { - // Handle the resume event - } -+Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('resume', onResume, false); +} + +function onResume() +{ + /* Handle the resume event */ +} +@@ -313,16 +321,19 @@ It is no longer necessary to call any other method to override the back-button b Original documentation: Cordova backbutton event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('backbutton', onBackKeyDown, false); - } - - function onBackKeyDown() { - // Handle the back button - } -+Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('backbutton', onBackKeyDown, false); +} + +function onBackKeyDown() +{ + /* Handle the back button */ +} +@@ -349,16 +360,19 @@ Applications typically should use document.addEventListener() to attach an event Original documentation: Cordova menubutton event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('menubutton', onMenuKeyDown, false); - } - - function onMenuKeyDown() { - // Handle the back button - } -+Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('menubutton', onMenuKeyDown, false); +} + +function onMenuKeyDown() +{ + /* Handle the back button */ +} +
Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('searchbutton', onSearchKeyDown, false); - } - - function onSearchKeyDown() { - // Handle the search button - } -+
Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('searchbutton', onSearchKeyDown, false); +} + +function onSearchKeyDown() +{ + /* Handle the search button */ +} +
Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('startcallbutton', onStartCallKeyDown, false); - } - - function onStartCallKeyDown() { - // Handle the start call button - } -+
Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('startcallbutton', onStartCallKeyDown, false); +} + +function onStartCallKeyDown() +{ + /* Handle the start call button */ +} +
Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('endcallbutton', onEndCallKeyDown, false); - } - - function onEndCallKeyDown() { - // Handle the end call button - } -+
Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('endcallbutton', onEndCallKeyDown, false); +} + +function onEndCallKeyDown() +{ + /* Handle the end call button */ +} +
Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('volumedownbutton', onVolumeDownKeyDown, false); - } - - function onVolumeDownKeyDown() { - // Handle the volume down button - } -+
Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('volumedownbutton', onVolumeDownKeyDown, false); +} + +function onVolumeDownKeyDown() +{ + /* Handle the volume down button */ +} +
Code example:
document.addEventListener('deviceready', onDeviceReady, false); - - function onDeviceReady() { - document.addEventListener('volumeupbutton', onVolumeUpKeyDown, false); - } - - function onVolumeUpKeyDown() { - // Handle the volume up button - } -+
Code example:
+document.addEventListener('deviceready', onDeviceReady, false); + +function onDeviceReady() +{ + document.addEventListener('volumeupbutton', onVolumeUpKeyDown, false); +} + +function onVolumeUpKeyDown() +{ + /* Handle the volume up button */ +} +
Code example:
var eventInit = { - loaded: 128, - total: 1024 - }; - var event = new ProgressEvent('submit', eventInit); -+
Code example:
+var eventInit = +{ + loaded: 128, + total: 1024 +}; +var event = new ProgressEvent('submit', eventInit); +
Code example:
console.log("The directory where the application is installed " + cordova.file.applicationDirectory); -+
Code example:
console.log("The directory where the application is installed " + cordova.file.applicationDirectory);
Output example:
The directory where the application is installed file:///opt/usr/apps/WfigBlWDyf/res/wgt/ @@ -519,8 +520,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Root directory of the application's sandbox " + cordova.file.applicationStorageDirectory); -+Code example:
console.log("Root directory of the application's sandbox " + cordova.file.applicationStorageDirectory);Output example:
Root directory of the application's sandbox file:///opt/usr/apps/WfigBlWDyf/ @@ -537,8 +537,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Data directory " + cordova.file.dataDirectory); -+Code example:
console.log("Data directory " + cordova.file.dataDirectory);Output example:
Data directory file:///opt/usr/apps/WfigBlWDyf/data/ @@ -555,8 +554,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Cache directory " + cordova.file.cacheDirectory); -+Code example:
console.log("Cache directory " + cordova.file.cacheDirectory);Output example:
Cache directory file:///opt/usr/apps/WfigBlWDyf/tmp/ @@ -573,8 +571,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Space on external storage " + cordova.file.externalApplicationStorageDirectory); -+Code example:
console.log("Space on external storage " + cordova.file.externalApplicationStorageDirectory);Output example:
Space on external storage null @@ -591,8 +588,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Data files on external storage " + cordova.file.externalDataDirectory); -+Code example:
console.log("Data files on external storage " + cordova.file.externalDataDirectory);Output example:
Data files on external storage null @@ -609,8 +605,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Cache on external storage " + cordova.file.externalCacheDirectory); -+Code example:
console.log("Cache on external storage " + cordova.file.externalCacheDirectory);Output example:
Cache on external storage null @@ -627,8 +622,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Root on external storage " + cordova.file.externalRootDirectory); -+Code example:
console.log("Root on external storage " + cordova.file.externalRootDirectory);Output example:
Root on external storage file:///usr/storage/sdcard/ @@ -645,8 +639,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Temp directory " + cordova.file.tempDirectory); -+Code example:
console.log("Temp directory " + cordova.file.tempDirectory);Output example:
Temp directory null @@ -663,8 +656,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Synced data directory " + cordova.file.syncedDataDirectory); -+Code example:
console.log("Synced data directory " + cordova.file.syncedDataDirectory);Output example:
Synced data directory null @@ -681,8 +673,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Documents directory " + cordova.file.documentsDirectory); -+Code example:
console.log("Documents directory " + cordova.file.documentsDirectory);Output example:
Documents directory null @@ -699,8 +690,7 @@ This manager interface exposes the Filesystem base API constants. 3.0-Code example:
console.log("Files globally available to all applications " + cordova.file.sharedDirectory); -+Code example:
console.log("Files globally available to all applications " + cordova.file.sharedDirectory);Output example:
Files globally available to all applications file:///opt/usr/media/ @@ -743,10 +733,12 @@ The specifics of naming filesystems is unspecified, but a name must be unique ac 3.0-Code example:
requestFileSystem(TEMPORARY, 100, function (fileSystem) { - console.log('Name of the filesystem: '+fileSystem.name); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fileSystem) +{ + console.log('Name of the filesystem: ' + fileSystem.name); +}); +Output example:
Name of the filesystem: temporary @@ -1007,17 +999,19 @@ The specifics of naming filesystems is unspecified, but a name must be unique ac-Code example:
successCallback = function(fs) { - console.log('File system name ' + fs.name); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - requestFileSystem(TEMPORARY, 1024*1024, successCallback, errorCallback); - -+Code example:
+successCallback = function(fs) +{ + console.log('File system name ' + fs.name); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +requestFileSystem(TEMPORARY, 1024 * 1024, successCallback, errorCallback); +Output example:
File system name temporary @@ -1070,18 +1064,20 @@ The specifics of naming filesystems is unspecified, but a name must be unique ac-Code example:
successCallback = function(entry) { - console.log('Entry name ' + entry.name); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - var uri = 'file:///home/owner/content/Documents/example.txt'; - resolveLocalFileSystemURL(uri, successCallback, errorCallback); - -+Code example:
+successCallback = function(entry) +{ + console.log('Entry name ' + entry.name); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +var uri = 'file:///home/owner/content/Documents/example.txt'; +resolveLocalFileSystemURL(uri, successCallback, errorCallback); +Output example:
Entry name example.txt @@ -1224,12 +1220,15 @@ The specifics of naming filesystems is unspecified, but a name must be unique ac-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getMetadata(function (metadata) { - console.log("Last modification time: " + metadata.modificationTime);// get metadata successfully - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getMetadata(function(metadata) + { + console.log("Last modification time: " + metadata.modificationTime); /* Get metadata successfully */ + }); +}); +Output example:
Last modification time: Fri Jan 02 2015 03:58:08 GMT+0900 (KST) @@ -1311,16 +1310,21 @@ A move of a directory on top of an existing empty directory must attempt to dele-Code example:
successCallback = function(entry){console.log('Full path to the moved file: '+entry.fullPath)}; - requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getDirectory('testDirectory', {create:true}, function(direntry) { - fs.root.getFile("aa.txt", {create:true}, function(fileentry) { - console.log('Full path before move: '+fileentry.fullPath); - fileentry.moveTo(direntry,'newname.txt',successCallback); - }); - }); - }); -+Code example:
+successCallback = function(entry) {console.log('Full path to the moved file: ' + entry.fullPath)}; + +requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getDirectory('testDirectory', {create:true}, function(direntry) + { + fs.root.getFile("aa.txt", {create:true}, function(fileentry) + { + console.log('Full path before move: ' + fileentry.fullPath); + fileentry.moveTo(direntry, 'newname.txt', successCallback); + }); + }); +}); +Output example:
Full path before move: /aa.txt @@ -1404,18 +1408,20 @@ Directory copies are always recursive--that is, they copy all contents of the di-Code example:
successCallback = function(entry){console.log('Full path to the copied file: '+entry.fullPath);}; - requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getDirectory('testDirectory', {create:true}, - function(direntry) { - fs.root.getFile("test.txt", {create:true}, - function(fileentry) { - fileentry.copyTo(direntry,'newname.txt',successCallback); - } - ); - }); - }); -+Code example:
+successCallback = function(entry) {console.log('Full path to the copied file: ' + entry.fullPath);}; + +requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getDirectory('testDirectory', {create:true}, function(direntry) + { + fs.root.getFile("test.txt", {create:true}, function(fileentry) + { + fileentry.copyTo(direntry, 'newname.txt', successCallback); + }); + }); +}); +Output example:
Full path to the copied file: /testDirectory/newname.txt @@ -1464,12 +1470,15 @@ Directory copies are always recursive--that is, they copy all contents of the di-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getParent(function (entry) { - console.log("success"); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getParent(function(entry) + { + console.log("success"); + }); +}); +Output example:
success @@ -1522,14 +1531,18 @@ Directory copies are always recursive--that is, they copy all contents of the di-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getFile('test.txt', {create: true}, function(fileEntry) { - fileEntry.remove(function () { - console.log("success"); - }); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getFile('test.txt', {create: true}, function(fileEntry) + { + fileEntry.remove(function() + { + console.log("success"); + }); + }); +}); +Output example:
success @@ -1554,14 +1567,16 @@ Directory copies are always recursive--that is, they copy all contents of the di URL that can be used to identify this entry.-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getDirectory('testDirectory', {create:true}, - function(entry) { - var url = entry.toURL(); - console.log('URL: '+url); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getDirectory('testDirectory', {create:true}, function(entry) + { + var url = entry.toURL(); + console.log('URL: ' + url); + }); +}); +Output example:
URL: file:///home/owner/apps_rw/WfigBlWDyf/tmp/testDirectory/ @@ -1620,12 +1635,15 @@ Directory copies are always recursive--that is, they copy all contents of the di DirectoryReader-Code example:
requestFileSystem(TEMPORARY, 100, function (entry) { - entry.root.getDirectory("MyDocument", {create:true}, function(dirEntry) { - var directoryReader = dirEntry.createReader(); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(entry) +{ + entry.root.getDirectory("MyDocument", {create:true}, function(dirEntry) + { + var directoryReader = dirEntry.createReader(); + }); +}); +@@ -1696,12 +1714,15 @@ Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry c -Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getDirectory("ert",{create:true},function(dir){ - console.log('Created dir: '+dir.name); - }) - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getDirectory("ert", {create:true}, function(dir) + { + console.log('Created dir: ' + dir.name); + }) +}); +Output example:
Created dir: ert @@ -1776,12 +1797,15 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getFile("qa.txt",{create:true},function(file){ - console.log('Created file: '+file.name); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getFile("qa.txt", {create:true}, function(file) + { + console.log('Created file: ' + file.name); + }); +}); +Output example:
Created file: qa.txt @@ -1834,15 +1858,18 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getDirectory("testDirectory", {create:true}, - function(directoryEntry) { - directoryEntry.removeRecursively(function() { - console.log("success"); - }); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getDirectory("testDirectory", {create:true}, function(directoryEntry) + { + directoryEntry.removeRecursively(function() + { + console.log("success"); + }); + }); +}); +Output example:
success @@ -1906,13 +1933,16 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - var a = fs.root.createReader(); - a.readEntries(function successCallback(entries) { - console.log("success"); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + var a = fs.root.createReader(); + a.readEntries(function successCallback(entries) + { + console.log("success"); + }); +}); +Output example:
success @@ -1976,20 +2006,26 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getFile("logFile.txt", {create: true}, function (f) { - f.createWriter(function(fileWriter) { - fileWriter.write(new Blob(['hello'])); - fileWriter.onerror = function(e) { - console.log('Write file failed:' + e); - }; - fileWriter.onwriteend = function () { - console.log("success"); - }; - }); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getFile("logFile.txt", {create: true}, function(f) + { + f.createWriter(function(fileWriter) + { + fileWriter.write(new Blob(['hello'])); + fileWriter.onerror = function(e) + { + console.log('Write file failed:' + e); + }; + fileWriter.onwriteend = function() + { + console.log("success"); + }; + }); + }); +}); +Output example:
success @@ -2031,14 +2067,18 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi-Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { - fs.root.getFile("abcdz.txt", {create: true}, function (f) { - f.file(function (file) { - console.log("success"); - }); - }); - }); -+Code example:
+requestFileSystem(TEMPORARY, 100, function(fs) +{ + fs.root.getFile("abcdz.txt", {create: true}, function(f) + { + f.file(function(file) + { + console.log("success"); + }); + }); +}); +Output example:
success @@ -2090,12 +2130,14 @@ Otherwise, if no other error occurs, getFile must return a FileEntry correspondi 3.0-Code example:
var deviceReady, fileReader; - deviceReady = function() { - fileReader = new FileReader(); - }; - document.addEventListener('deviceready', deviceReady, true); -+Code example:
+var deviceReady, fileReader; +deviceReady = function() +{ + fileReader = new FileReader(); +}; +document.addEventListener('deviceready', deviceReady, true); +Constructors
@@ -2236,17 +2278,20 @@ Returns a Blob's data as a DOMString, or byte[], or null, depending on the read 3.0-Code example:
var blob = new Blob(['abc']); - var fileReader = new FileReader(); - fileReader.onload = function(){ - console.log('Loaded'); - }; - fileReader.onabort = function(){ - console.log('aborted'); - }; - fileReader.readAsDataURL(blob); - fileReader.abort(); -+Code example:
+var blob = new Blob(['abc']); +var fileReader = new FileReader(); +fileReader.onload = function() +{ + console.log('Loaded'); +}; +fileReader.onabort = function() +{ + console.log('aborted'); +}; +fileReader.readAsDataURL(blob); +fileReader.abort(); +Output example:
aborted @@ -2295,13 +2340,15 @@ Returns a Blob's data as a DOMString, or byte[], or null, depending on the read-Code example:
var blob = new Blob(['abc']); - var fileReader = new FileReader(); - fileReader.onload = function(){ - console.log('Loaded, result = '+fileReader.result); - }; - fileReader.readAsDataURL(blob); -+Code example:
+var blob = new Blob(['abc']); +var fileReader = new FileReader(); +fileReader.onload = function() +{ + console.log('Loaded, result = ' + fileReader.result); +}; +fileReader.readAsDataURL(blob); +Output example:
Loaded, result = data:;base64,YWJj @@ -2354,13 +2401,15 @@ Returns a Blob's data as a DOMString, or byte[], or null, depending on the read-Code example:
var blob = new Blob(['abc']); - var fileReader = new FileReader(); - fileReader.onload = function(){ - console.log('Loaded, result = '+fileReader.result); - }; - fileReader.readAsText(blob); -+Code example:
+var blob = new Blob(['abc']); +var fileReader = new FileReader(); +fileReader.onload = function() +{ + console.log('Loaded, result = ' + fileReader.result); +}; +fileReader.readAsText(blob); +Output example:
Loaded, result = abc @@ -2409,13 +2458,15 @@ Returns a Blob's data as a DOMString, or byte[], or null, depending on the read-Code example:
var blob = new Blob(['abc']); - var fileReader = new FileReader(); - fileReader.onload = function(){ - console.log('Loaded, result = '+fileReader.result); - }; - fileReader.readAsBinaryString(blob); -+Code example:
+var blob = new Blob(['abc']); +var fileReader = new FileReader(); +fileReader.onload = function() +{ + console.log('Loaded, result = ' + fileReader.result); +}; +fileReader.readAsBinaryString(blob); +Output example:
Loaded, result = abc @@ -2464,14 +2515,16 @@ Returns a Blob's data as a DOMString, or byte[], or null, depending on the read-Code example:
var blob = new Blob(['abc']); - var fileReader = new FileReader(); - fileReader.onload = function(){ - resultValue = fileReader.result; - console.log("Result: "+resultValue.toString()+'+
'+'ByteLength: '+resultValue.byteLength); - }; - fileReader.readAsArrayBuffer(blob); -Code example:
+var blob = new Blob(['abc']); +var fileReader = new FileReader(); +fileReader.onload = function() +{ + resultValue = fileReader.result; + console.log("Result: " + resultValue.toString() + '<br>' + 'ByteLength: ' + resultValue.byteLength); +}; +fileReader.readAsArrayBuffer(blob); +Output example:
Result: [object ArrayBuffer] @@ -2660,24 +2713,29 @@ ByteLength: 3-Code example:
successCallback = function(writer) { - writer.onwrite = function(evt) { - console.log('write success'); - }; - writer.onabort = function(e){ - console.log('abort'); - }; - writer.write('some sample text'); - writer.abort(); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - // entry is FileEntry object retrieved by getFile() function of DirectoryEntry interface. - entry.createWriter(successCallback, errorCallback); -+Code example:
+successCallback = function(writer) +{ + writer.onwrite = function(evt) + { + console.log('write success'); + }; + writer.onabort = function(e) + { + console.log('abort'); + }; + writer.write('some sample text'); + writer.abort(); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +/* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface */ +entry.createWriter(successCallback, errorCallback); +Output example:
abort @@ -2719,18 +2777,21 @@ If the offset is a negative number the position of the file pointer is rewound.-Code example:
successCallback = function(writer) { - // fast forwards file pointer to the end of file. - writer.seek(writer.length); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - // entry is FileEntry object retrieved by getFile() function of DirectoryEntry interface. - entry.createWriter(successCallback, errorCallback); -+Code example:
+successCallback = function(writer) +{ + /* Fast forwards file pointer to the end of file */ + writer.seek(writer.length); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +/* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface */ +entry.createWriter(successCallback, errorCallback); +@@ -2771,21 +2832,25 @@ If the offset is a negative number the position of the file pointer is rewound. -Code example:
successCallback = function(writer) { - writer.onwrite = function(evt) { - console.log('truncate success'); - }; - - writer.truncate(10); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - // entry is FileEntry object retrieved by getFile() function of DirectoryEntry interface. - entry.createWriter(successCallback, errorCallback); -+Code example:
+successCallback = function(writer) +{ + writer.onwrite = function(evt) + { + console.log('truncate success'); + }; + + writer.truncate(10); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +/* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface */ +entry.createWriter(successCallback, errorCallback); +Output example:
truncate success @@ -2834,21 +2899,25 @@ If the offset is a negative number the position of the file pointer is rewound.-Code example:
successCallback = function(writer) { - writer.onwrite = function(evt) { - console.log('write success'); - }; - - writer.write('some sample text'); - }; - - errorCallback = function(err) { - console.log(err.code); - }; - - // entry is FileEntry object retrieved by getFile() function of DirectoryEntry interface. - entry.createWriter(successCallback, errorCallback); -+Code example:
+successCallback = function(writer) +{ + writer.onwrite = function(evt) + { + console.log('write success'); + }; + + writer.write('some sample text'); +}; + +errorCallback = function(err) +{ + console.log(err.code); +}; + +/* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface */ +entry.createWriter(successCallback, errorCallback); +Output example:
write success diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/filetransfer.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/filetransfer.html index c6f25f7..2591b06 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/filetransfer.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/filetransfer.html @@ -3,7 +3,7 @@ -FileTransfer API +FileTransfer API @@ -169,34 +169,37 @@ The key / value type of download options values. Currently only supports header 3.0@@ -519,32 +524,36 @@ Sent = 1024 3.0-Code example:
var fileURL; // We assume the variable fileURL contains a valid URL to a text file on the device. - - var win = function (r) { - console.log('Code = ' + r.responseCode); - console.log('Response = ' + r.response); - console.log('Sent = ' + r.bytesSent); - } - - var fail = function (error) { - alert('An error has occurred: Code = ' + error.code); - console.log('upload error source ' + error.source); - console.log('upload error target ' + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = 'file'; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = 'text/plain'; - - var params = {}; - params.value1 = 'test'; - params.value2 = 'param'; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail, options); -+Code example:
+var fileURL; /* Assume the variable fileURL contains a valid URL to a text file on the device */ + +var win = function(r) +{ + console.log('Code = ' + r.responseCode); + console.log('Response = ' + r.response); + console.log('Sent = ' + r.bytesSent); +} + +var fail = function(error) +{ + alert('An error has occurred: Code = ' + error.code); + console.log('upload error source ' + error.source); + console.log('upload error target ' + error.target); +} + +var options = new FileUploadOptions(); +options.fileKey = 'file'; +options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); +options.mimeType = 'text/plain'; + +var params = {}; +params.value1 = 'test'; +params.value2 = 'param'; + +options.params = params; + +var ft = new FileTransfer(); +ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail, options); +@@ -502,9 +506,10 @@ Sent = 1024Output example:
Code = 200 @@ -209,9 +212,10 @@ Sent = 1024
FileUploadOptions(DOMString fileKey, DOMString fileName, DOMString mimeType, FileUploadParams params, HeaderFields headers, DOMString httpMethod);-Code example:
// Creates a FileUploadOptions object. - var options = new FileUploadOptions('file', 'doc.txt', 'text/plain', null, null, 'POST'); -+Code example:
+/* Creates a FileUploadOptions object */ +var options = new FileUploadOptions('file', 'doc.txt', 'text/plain', null, null, 'POST'); +
FileTransfer();-Code example:
// Creates a FileTransfer object. - var file_transfer = new FileTransfer(); -+Code example:
+/* Creates a FileTransfer object */ +var file_transfer = new FileTransfer(); +-Code example:
var fileURL; // should be a valid url eg. cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log('Success. File uploaded.'); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert('An error has occurred: Code = ' + error.code); - console.log('upload error source ' + error.source); - console.log('upload error target ' + error.target); - }; - - var ft = new FileTransfer(); - - ft.onprogress = function(event) { - console.log('uploaded: ' + event.loaded); - }; - - ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); -+Code example:
+var fileURL; /* Must be a valid url, such as cdvfile://localhost/persistent/path/to/file.txt */ + +var win = function(r) +{ + console.log('Success. File uploaded.'); +} + +var fail = function(error) +{ + /* error.code == FileTransferError.ABORT_ERR */ + alert('An error has occurred: Code = ' + error.code); + console.log('upload error source ' + error.source); + console.log('upload error target ' + error.target); +}; + +var ft = new FileTransfer(); + +ft.onprogress = function(event) +{ + console.log('uploaded: ' + event.loaded); +}; + +ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); +@@ -607,23 +616,26 @@ Success. File uploaded.Output example:
uploaded: 512 uploaded: 1024 -Success. File uploaded. +Success. File uploaded.-Code example:
var fileURL; // should be a valid url eg. cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log('Code = ' + r.responseCode); - console.log('Response = ' + r.response); - console.log('Sent = ' + r.bytesSent); - } - - var fail = function (error) { - alert('An error has occurred: Code = ' + error.code); - console.log('upload error source ' + error.source); - console.log('upload error target ' + error.target); - } - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); -+Code example:
+var fileURL; /* Must be a valid url, such as cdvfile://localhost/persistent/path/to/file.txt */ + +var win = function(r) +{ + console.log('Code = ' + r.responseCode); + console.log('Response = ' + r.response); + console.log('Sent = ' + r.bytesSent); +} + +var fail = function(error) +{ + alert('An error has occurred: Code = ' + error.code); + console.log('upload error source ' + error.source); + console.log('upload error target ' + error.target); +} + +var ft = new FileTransfer(); +ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); +Output example:
Code = 200 @@ -687,30 +699,28 @@ Sent = 1024-Code example:
var fileURL; // should be a valid url eg. cdvfile://localhost/persistent/path/to/file.txt - - var fileTransfer = new FileTransfer(); - var uri = encodeURI('http://some.server.com/download.php'); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log('download complete: ' + entry.toURL()); - }, - function(error) { - console.log('download error source ' + error.source); - console.log('download error target ' + error.target); - console.log('upload error code' + error.code); - }, - false, - { - headers: { - 'Authorization': 'Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==' - } - } - ); -+Code example:
+var fileURL; /* Must be a valid url, such as cdvfile://localhost/persistent/path/to/file.txt */ + +var fileTransfer = new FileTransfer(); +var uri = encodeURI('http://some.server.com/download.php'); + +fileTransfer.download(uri, fileURL, function(entry) +{ + console.log('download complete: ' + entry.toURL()); +}, function(error) +{ + console.log('download error source ' + error.source); + console.log('download error target ' + error.target); + console.log('upload error code' + error.code); +}, false, +{ + headers: + { + 'Authorization': 'Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==' + } +}); +Output example:
download complete: file:///home/owner/apps_rw/Gk6hf8hjk/tmp/file.txt @@ -739,26 +749,29 @@ Sent = 1024 http://tizen.org/privilege/internet-Code example:
var fileURL; // should be a valid url eg. cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log('Should not be called.'); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert('An error has occurred: Code = ' + error.code); - console.log('upload error source ' + error.source); - console.log('upload error target ' + error.target); - }; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); - ft.abort(); -+Code example:
+var fileURL; /* Must be a valid url, such as cdvfile://localhost/persistent/path/to/file.txt */ + +var win = function(r) +{ + console.log('Should not be called.'); +} + +var fail = function(error) +{ + /* error.code == FileTransferError.ABORT_ERR */ + alert('An error has occurred: Code = ' + error.code); + console.log('upload error source ' + error.source); + console.log('upload error target ' + error.target); +}; + +var ft = new FileTransfer(); +ft.upload(fileURL, encodeURI('http://some.server.com/upload.php'), win, fail); +ft.abort(); +-Output example:
An error has occured: Code = 4 +Output example:
An error has occurred: Code = 4 upload error source file:///home/owner/apps_rw/Gk6hf8hjk/tmp/file.txt upload error target http://some.server.com/file.txtdiff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html index b54d264..d1dce58 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html @@ -3,7 +3,7 @@ -Globalization API +Globalization API @@ -263,15 +263,20 @@ during this method's execution.-Code example:
// When the browser is set to the en-US language, - // this should output the text - // similar to the results that follow. - - navigator.globalization.getPreferredLanguage( - function (language) { console.log('Language: ' + language.value); }, - function () { console.log('Error getting language.'); } - ); -+Code example:
+/* + When the browser is set to the en-US language, + this outputs the text + similar to the results that follow +*/ +navigator.globalization.getPreferredLanguage(function(language) +{ + console.log('Language: ' + language.value); +}, function() +{ + console.log('Error getting language.'); +}); +Output example:
Language: en-US @@ -323,15 +328,20 @@ occuring while getting a locale name.-Code example:
// When the browser is set to the en-US language, - // this should output the text - // similar to the results that follow. - - navigator.globalization.getLocaleName( - function (locale) { console.log('Locale: ' + locale.value); }, - function () { console.log('Error getting locale.'); } - ); -+Code example:
+/* + When the browser is set to the en-US language, + this outputs the text + similar to the results that follow +*/ +navigator.globalization.getLocaleName(function(locale) +{ + console.log('Locale: ' + locale.value); +}, function() +{ + console.log('Error getting locale.'); +}); +Output example:
Locale: en-US @@ -387,17 +397,20 @@ passed as a parameter to the successCallback.-Code example:
// When the browser is set to the en-US language, - // this should output text similar to the results that follow. - // This example uses the default conversion options. - - navigator.globalization.dateToString( - new Date(), - function (date) { console.log('Date: ' + date.value); }, - function () { console.log('Error getting dateString.'); }, - { formatLength: 'short', selector: 'date and time' } - ); -+Code example:
+/* + When the browser is set to the en-US language, + this outputs the text similar to the results that follow + This example uses the default conversion options +*/ +navigator.globalization.dateToString(new Date(), function(date) +{ + console.log('Date: ' + date.value); +}, function() +{ + console.log('Error getting dateString.'); +}, {formatLength: 'short', selector: 'date and time'}); +Output example:
Date: 9/25/2012 4:21PM @@ -450,24 +463,25 @@ for example 'USD'.-Code example:
// When the browser is set to the en-US locale and the selected - // currency is United States Dollars, this example outputs - // text similar to the results that follow. - - navigator.globalization.getCurrencyPattern( - 'USD', - function (pattern) { - console.log('pattern: ' + pattern.pattern); - console.log('code: ' + pattern.code); - console.log('fraction: ' + pattern.fraction); - console.log('rounding: ' + pattern.rounding); - console.log('decimal: ' + pattern.decimal); - console.log('grouping: ' + pattern.grouping); - }, - function () { console.log('Error getting pattern.'); } - ); - -+Code example:
+/* + When the browser is set to the en-US language, + and the selected currency is United States Dollars, + this outputs the text similar to the results that follow +*/ +navigator.globalization.getCurrencyPattern('USD', function(pattern) +{ + console.log('pattern: ' + pattern.pattern); + console.log('code: ' + pattern.code); + console.log('fraction: ' + pattern.fraction); + console.log('rounding: ' + pattern.rounding); + console.log('decimal: ' + pattern.decimal); + console.log('grouping: ' + pattern.grouping); +}, function() +{ + console.log('Error getting pattern.'); +}); +Output example:
pattern: $#,##0.##;($#,##0.##) @@ -527,20 +541,23 @@ The default value is {type: 'wide', item: 'months'}-Code example:
// When the browser is set to the en_US locale, - // this example logs the names of months, as per locale settings, - // with text similar to the results that follow. - - navigator.globalization.getDateNames( - function (names) { - for (var i = 0; i < names.value.length; i++) { - console.log('month: ' + names.value[i]); - } - }, - function () { console.log('Error getting names.'); }, - { type: 'wide', item: 'months' } - ); -+Code example:
+/* + When the browser is set to the en-US language, + this example logs the names of months, as per locale settings + with text similar to the results that follow +*/ +navigator.globalization.getDateNames(function(names) +{ + for (var i = 0; i < names.value.length; i++) + { + console.log('month: ' + names.value[i]); + } +}, function() +{ + console.log('Error getting names.'); +}, {type: 'wide', item: 'months'}); +Output example:
month: January @@ -604,20 +621,25 @@ The default value is {formatLength: 'short', selector: 'date and time'}-Code example:
// This example displays the locale date pattern. - // When the browser is set to the en_US locale, - // the text displayed is similar to the results that follow. - - function checkDatePattern () { - navigator.globalization.getDatePattern( - function (date) { console.log('Date pattern: ' + date.pattern); }, - function () { console.log('Error getting pattern'); }, - { formatLength: 'short', selector: 'date and time' } - ); - } - - checkDatePattern(); -+Code example:
+/* + This example displays the locale date pattern + When the browser is set to the en-US locale, + this outputs the text similar to the results that follow +*/ +function checkDatePattern() +{ + navigator.globalization.getDatePattern(function(date) + { + console.log('Date pattern: ' + date.pattern); + }, function() + { + console.log('Error getting pattern'); + }, {formatLength: 'short', selector: 'date and time'}); +} + +checkDatePattern(); +Output example:
Date pattern: M/d/yyyy h:mm a @@ -667,14 +689,19 @@ the first day of a week.-Code example:
// When the browser is set to the en_US locale, - // this outputs the text similar to "day: 1". - - navigator.globalization.getFirstDayOfWeek( - function (day) { console.log('day: ' + day.value); }, - function () { console.log('Error getting first day of week.'); } - ); -+Code example:
+/* + When the browser is set to the en_US locale, + this outputs the text similar to "day: 1" +*/ +navigator.globalization.getFirstDayOfWeek(function(day) +{ + console.log('day: ' + day.value); +}, function() +{ + console.log('Error getting first day of week.'); +}); +Output example:
day: 1 @@ -729,26 +756,26 @@ the pattern will be returned.-Code example:
// When the browser is set to the en_US locale, - // this example outputs the text - // similar to the results that follow. - - navigator.globalization.getNumberPattern( - function (pattern) { - console.log('pattern: ' + pattern.pattern); - console.log('symbol: ' + pattern.symbol); - console.log('fraction: ' + pattern.fraction); - console.log('rounding: ' + pattern.rounding); - console.log('positive: ' + pattern.positive); - console.log('negative: ' + pattern.negative); - console.log('decimal: ' + pattern.decimal); - console.log('grouping: ' + pattern.grouping); - }, - function() { console.log('An error occurred.'); }, - { type: 'decimal' } - ); - -+Code example:
+/* + When the browser is set to the en_US locale, + this outputs the text similar to the results that follow +*/ +navigator.globalization.getNumberPattern(function(pattern) +{ + console.log('pattern: ' + pattern.pattern); + console.log('symbol: ' + pattern.symbol); + console.log('fraction: ' + pattern.fraction); + console.log('rounding: ' + pattern.rounding); + console.log('positive: ' + pattern.positive); + console.log('negative: ' + pattern.negative); + console.log('decimal: ' + pattern.decimal); + console.log('grouping: ' + pattern.grouping); +}, function() +{ + console.log('An error occurred.'); +}, {type: 'decimal'}); +Output example:
pattern: #,##0.### @@ -811,16 +838,19 @@ errors occuring during this method's execution.-Code example:
// During the summer, and if the browser - // is set to a DST-enabled timezone, - // this should log text similar to "dst: true": - - navigator.globalization.isDayLightSavingsTime( - new Date(), - function (date) { console.log('dst: ' + date.dst); }, - function () { console.log('Error getting the DST state.'); } - ); -+Code example:
+/* + During the summer, and if the browser is set to a DST-enabled timezone, + this logs text similar to "dst: true" +*/ +navigator.globalization.isDayLightSavingsTime(new Date(), function(date) +{ + console.log('dst: ' + date.dst); +}, function() +{ + console.log('Error getting the DST state.'); +}); +Output example:
dst: true @@ -884,37 +914,43 @@ The default value of this parameter is {type: 'decimal'}.-Code example:
// When the browser is set to the en_US locale, - // this code displays the results that follow. - - navigator.globalization.numberToString( - 3.1415926, - function (number) { console.log('decimal number: ' + number.value); }, - function () { console.log('Error getting number.'); }, - { type: 'decimal' } - ); - - navigator.globalization.numberToString( - 1000003, - function (number) { console.log('big decimal number: ' + number.value); }, - function () { console.log('Error getting number.'); }, - { type: 'decimal' } - ); - - navigator.globalization.numberToString( - 0.3183099, - function (number) { console.log('percentile: ' + number.value); }, - function () { console.log('Error getting number.'); }, - { type: 'percent' } - ); - - navigator.globalization.numberToString( - 1099.95, - function (number) { console.log('currency: ' + number.value); }, - function () { console.log('Error getting number'); }, - { type: 'currency' } - ); -+Code example:
+/* + When the browser is set to the en_US locale, + this code displays the results that follow +*/ +navigator.globalization.numberToString(3.1415926, function(number) +{ + console.log('decimal number: ' + number.value); +}, function() +{ + console.log('Error getting number.'); +}, {type: 'decimal'}); + +navigator.globalization.numberToString(1000003, function(number) +{ + console.log('big decimal number: ' + number.value); +}, function() +{ + console.log('Error getting number.'); +}, {type: 'decimal'}); + +navigator.globalization.numberToString(0.3183099, function(number) +{ + console.log('percentile: ' + number.value); +}, function() +{ + console.log('Error getting number.'); +}, {type: 'percent'}); + +navigator.globalization.numberToString(1099.95, function(number) +{ + console.log('currency: ' + number.value); +}, function() +{ + console.log('Error getting number'); +}, {type: 'currency'}); +Output example:
decimal number: 3.142 @@ -973,22 +1009,23 @@ The default value is {formatLength: 'short', selector: 'date and time'}-Code example:
// when the browser is set to the en_US locale, - // this example outputs text similar to the results that follow. - // Note that the month integer is one less than the string, - // as the month integer represents an array index. - - navigator.globalization.stringToDate( - '9/25/2012', - function (date) { - console.log('month: ' + date.month + - ', day: ' + date.day + - ', year: ' + date.year) - }, - function () { console.log('Error getting date.'); }, - { selector: 'date' } - ); -+Code example:
+/* + When the browser is set to the en_US locale, + this example outputs text similar to the results that follow + Note that the month integer is one less than the string, + as the month integer represents an array index +*/ +navigator.globalization.stringToDate('9/25/2012', function(date) +{ + console.log('month: ' + date.month + + ', day: ' + date.day + + ', year: ' + date.year) +}, function() +{ + console.log('Error getting date.'); +}, {selector: 'date'}); +Output example:
month: 8, day: 25, year: 2012 @@ -1047,16 +1084,19 @@ The default value is {type: 'decimal'}-Code example:
// When the browser is set to the en_US locale, - // this should display the text similar to the results that follow. - - navigator.globalization.stringToNumber( - '1234.56', - function (number) { console.log('number: ' + number.value); }, - function () { console.log('Error getting number.'); }, - { type: 'decimal' } - ); -+Code example:
+/* + When the browser is set to the en_US locale, + this displays the text similar to the results that follow +*/ +navigator.globalization.stringToNumber('1234.56', function(number) +{ + console.log('number: ' + number.value); +}, function() +{ + console.log('Error getting number.'); +}, {type: 'decimal'}); +Output example:
number: 1234.56 diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/media.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/media.html index b54cbca..5aa9d31 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/media.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/media.html @@ -3,7 +3,7 @@ -Media API +Media API @@ -125,8 +125,8 @@ Original documentation: -Code example:
var myMedia = new Media(src, successCallback, errorCallback, statusCallback); -+Code example:
+var myMedia = new Media(src, successCallback, errorCallback, statusCallback);Output example:
Audio file has been played back. @@ -290,20 +294,23 @@ Current position is 2.000 3.0-Code example:
successCallback = function() { - console.log('Audio file has been played back.); - } - - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } - - var src = 'file:///home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); - - var duration = myMedia.getDuration(); - console.log('Audio duration is ' + duration); -+Code example:
+successCallback = function() +{ + console.log('Audio file has been played back.'); +} + +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} + +var src = 'file:///home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); + +var duration = myMedia.getDuration(); +console.log('Audio duration is ' + duration); +Output example:
Audio duration is 281.035 @@ -324,31 +331,36 @@ Current position is 2.000 3.0-Code example:
successCallback = function() { - console.log('Audio file has been played back.'); - } - - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } - - statusCallback = function(status) { - if (status == Media.MEDIA_PAUSED) { - console.log('Audio file has been paused'); - } - } - - var src = 'file:///home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback, statusCallback); - - myMedia.play(); - - //Pause after 2 seconds - setTimeout(function() { - myMedia.pause(); - }, 2000); - -+Code example:
+successCallback = function() +{ + console.log('Audio file has been played back.'); +} + +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} + +statusCallback = function(status) +{ + if (status == Media.MEDIA_PAUSED) + { + console.log('Audio file has been paused'); + } +} + +var src = 'file:///home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback, statusCallback); + +myMedia.play(); + +/* Pause after 2 seconds */ +setTimeout(function() +{ + myMedia.pause(); +}, 2000); +Output example:
Audio file has been paused. @@ -369,19 +381,22 @@ Current position is 2.000 3.0-Code example:
successCallback = function() { - console.log('Audio file has been played back.'); - } +Code example:
+successCallback = function() +{ + console.log('Audio file has been played back.'); +} - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} - var src = 'file:///home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); +var src = 'file:///home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); - myMedia.play(); -+myMedia.play(); +Output example:
Audio file has been played back. @@ -403,21 +418,24 @@ Applications should call the release function for any Media resource that is no 3.0-Code example:
successCallback = function() { - console.log('Audio file has been stopped or released.'); - } - - errorCallback = function(err) { - console.log('An error occurred: ' + err.message); - } - - var src = 'file://home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); - - myMedia.play(); - myMedia.stop(); - myMedia.release(); -+Code example:
+successCallback = function() +{ + console.log('Audio file has been stopped or released.'); +} + +errorCallback = function(err) +{ + console.log('An error occurred: ' + err.message); +} + +var src = 'file://home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); + +myMedia.play(); +myMedia.stop(); +myMedia.release(); +Output example:
Audio file has been stopped or released. @@ -448,24 +466,28 @@ Audio file has been stopped or released.-Code example:
successCallback = function() { - console.log('Audio file has been played back.'); - } - - errorCallback = function(err) { - console.log('An error occurred: ' + err.message); - } - - var src = 'file://home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); - - myMedia.play(); - - //SeekTo to 10 seconds after 5 seconds - setTimeout(function() { - myMedia.seekTo(10000); - console.log('Playback position has been set to 10 seconds.'); - }, 5000); +Code example:
+successCallback = function() +{ + console.log('Audio file has been played back.'); +} + +errorCallback = function(err) +{ + console.log('An error occurred: ' + err.message); +} + +var src = 'file://home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); + +myMedia.play(); + +/* SeekTo to 10 seconds after 5 seconds */ +setTimeout(function() +{ + myMedia.seekTo(10000); + console.log('Playback position has been set to 10 seconds.'); +}, 5000);@@ -505,31 +527,36 @@ Audio file has been played back.-Code example:
successCallback = function() { - console.log('Audio file has been played back.'); - } - - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } - - var src = 'file://home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); - - myMedia.play(); - - // Mute volume after 2 seconds - setTimeout(function() { - myMedia.setVolume(0.0); - console.log('Playback volume has been muted.'); - }, 2000); - - // Set volume to 1.0 after 5 seconds - setTimeout(function() { - myMedia.setVolume(1.0); - console.log('Playback volume has been set to 1.0.'); - }, 5000); -+Code example:
+successCallback = function() +{ + console.log('Audio file has been played back.'); +} + +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} + +var src = 'file://home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); + +myMedia.play(); + +/* Mute volume after 2 seconds */ +setTimeout(function() +{ + myMedia.setVolume(0.0); + console.log('Playback volume has been muted.'); +}, 2000); + +/* Set volume to 1.0 after 5 seconds */ +setTimeout(function() +{ + myMedia.setVolume(1.0); + console.log('Playback volume has been set to 1.0.'); +}, 5000); +Output example:
Playback volume has been muted. @@ -560,19 +587,22 @@ Audio file has been played back. http://tizen.org/privilege/mediacapture-Code example:
successCallback = function() { - console.log('Started recording an audio file.'); - } +Code example:
+successCallback = function() +{ + console.log('Started recording an audio file.'); +} - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} - var src = 'recordAudio.mp3'; - var myRecMedia = new Media(src, successCallback, errorCallback); +var src = 'recordAudio.mp3'; +var myRecMedia = new Media(src, successCallback, errorCallback); - myRecMedia.startRecord(); -+myRecMedia.startRecord(); +Output example:
Started recording an audio file. @@ -601,25 +631,29 @@ Audio file has been played back. http://tizen.org/privilege/mediacapture-Code example:
successCallback = function() { - console.log('Started recording an audio file.'); - } - - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } - - var src = 'recordAudio.mp3'; - var myRecMedia = new Media(src, successCallback, errorCallback); - - myRecMedia.startRecord(); - - // Stop recording after 10 seconds - setTimeout(function() { - myRecMedia.stopRecord(); - console.log('Stopped recording an audio file.'); - }, 10000); -+Code example:
+successCallback = function() +{ + console.log('Started recording an audio file.'); +} + +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} + +var src = 'recordAudio.mp3'; +var myRecMedia = new Media(src, successCallback, errorCallback); + +myRecMedia.startRecord(); + +/* Stop recording after 10 seconds */ +setTimeout(function() +{ + myRecMedia.stopRecord(); + console.log('Stopped recording an audio file.'); +}, 10000); +Output example:
Started recording an audio file. @@ -641,24 +675,28 @@ Stopped recording an audio file. 3.0-Code example:
successCallback = function() { - console.log('Audio file has been stopped.'); - } - - errorCallback = function(err) { - console.log('Error occurred ' + err.message); - } - - var src = 'file://home/app/content/Documents/play.mp3'; - var myMedia = new Media(src, successCallback, errorCallback); - - myMedia.play(); - - // Stop after 10 seconds - setTimeout(function() { - myMedia.stop(); - }, 10000); -+Code example:
+successCallback = function() +{ + console.log('Audio file has been stopped.'); +} + +errorCallback = function(err) +{ + console.log('Error occurred ' + err.message); +} + +var src = 'file://home/app/content/Documents/play.mp3'; +var myMedia = new Media(src, successCallback, errorCallback); + +myMedia.play(); + +/* Stop after 10 seconds */ +setTimeout(function() +{ + myMedia.stop(); +}, 10000); +Output example:
Audio playback has been stopped. diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/networkInformation.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/networkInformation.html index 81a6afb..1d0fc4a 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/networkInformation.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/networkInformation.html @@ -3,7 +3,7 @@ -NetworkInformation API +NetworkInformation API @@ -112,23 +112,25 @@ The navigator.connection object allows access to the NetworkInformation http://tizen.org/privilege/telephony-Code example:
function checkConnection() { - var networkState = navigator.connection.type; +Code example:
+function checkConnection() +{ + var networkState = navigator.connection.type; - var states = {}; - states[Connection.UNKNOWN] = 'Unknown connection'; - states[Connection.ETHERNET] = 'Ethernet connection'; - states[Connection.WIFI] = 'WiFi connection'; - states[Connection.CELL_2G] = 'Cell 2G connection'; - states[Connection.CELL_3G] = 'Cell 3G connection'; - states[Connection.CELL_4G] = 'Cell 4G connection'; - states[Connection.CELL] = 'Cell generic connection'; - states[Connection.NONE] = 'No network connection'; - alert('Connection type: ' + states[networkState]); - } + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + alert('Connection type: ' + states[networkState]); +} - checkConnection(); -+checkConnection(); +Output example:
Connection type: Cell 3G connection @@ -165,8 +167,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.UNKNOWN); -+Code example:
console.log(Connection.UNKNOWN);Output example:
unknown @@ -183,8 +184,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.ETHERNET); -+Code example:
console.log(Connection.ETHERNET);Output example:
ethernet @@ -201,8 +201,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.WIFI); -+Code example:
console.log(Connection.WIFI);Output example:
wifi @@ -219,8 +218,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.CELL_2G); -+Code example:
console.log(Connection.CELL_2G);Output example:
2g @@ -237,8 +235,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.CELL_3G); -+Code example:
console.log(Connection.CELL_3G);diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html index 33575ec..81b4a6d 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html @@ -227,25 +227,34 @@ DataControl API.Output example:
3g @@ -255,8 +252,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.CELL_4G); -+Code example:
console.log(Connection.CELL_4G);Output example:
4g @@ -273,8 +269,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.CELL); -+Code example:
console.log(Connection.CELL);Output example:
cellular @@ -291,8 +286,7 @@ The navigator.connection object allows access to the NetworkInformation 3.0-Code example:
console.log(Connection.NONE); -+Code example:
console.log(Connection.NONE);Output example:
none @@ -326,16 +320,19 @@ Applications typically should use document.addEventListener() to attach an event Original documentation: Cordova online event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - document.addEventListener('online', onOnline, false); - } +function onDeviceReady() +{ + document.addEventListener('online', onOnline, false); +} - function onOnline() { - // Handle the online event - } -+function onOnline() +{ + /* Handle the online event */ +} +@@ -362,16 +359,19 @@ Applications typically should use document.addEventListener() to attach an event Original documentation: Cordova offline event-Code example:
document.addEventListener('deviceready', onDeviceReady, false); +Code example:
+document.addEventListener('deviceready', onDeviceReady, false); - function onDeviceReady() { - document.addEventListener('offline', onOffline, false); - } +function onDeviceReady() +{ + document.addEventListener('offline', onOffline, false); +} - function onOffline() { - // Handle the offline event - } -+function onOffline() +{ + /* Handle the offline event */ +} +-@@ -394,29 +403,34 @@ The string consists of one or more components, separated by a slash('/').Code example:
//The data provider, a native application, should be pre-installed and launched. - //The same provider ID should be defined for the use of this API between a native application(provider) and a web application(consumer). - //In this example, the DictionaryDataControlProvider native sample application is used as a data control provider. +Code example:
+/* + The data provider, a native application, should be pre-installed and launched + The same provider ID should be defined for the use of this API between a native application(provider) and a web application(consumer) + In this example, the DictionaryDataControlProvider native sample application is used as a data control provider +*/ - //Gets SQL type DataControlConsumerObject - try { - var globalSQLConsumer = tizen.datacontrol.getDataControlConsumer( - "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "SQL"); - } catch (err) { - console.log (err.name +": " + err.message); - } - // Gets MAP type DataControlConsumerObject - try { - globalMappedConsumer = tizen.datacontrol.getDataControlConsumer( - "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "MAP"); - } catch (err) { - console.log (err.name +": " + err.message); - } -+/* Gets SQL type DataControlConsumerObject */ +try +{ + var globalSQLConsumer = tizen.datacontrol.getDataControlConsumer( + "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "SQL"); +} +catch (err) +{ + console.log(err.name +": " + err.message); +} +/* Gets MAP type DataControlConsumerObject */ +try +{ + globalMappedConsumer = tizen.datacontrol.getDataControlConsumer( + "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "MAP"); +} +catch (err) +{ + console.log(err.name +": " + err.message); +} +-Code example:
function successcb(id, insertRowId) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id, insertRowId) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - var rowData = { - columns : ["WORD", "WORD_DESC"] , - values : ["'tizen1'", "'tizen2'"] - }; - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalSQLConsumer.insert(globalReqId, rowData, successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + var rowData = + { + columns: ["WORD", "WORD_DESC"] , + values: ["'tizen1'", "'tizen2'"] + }; + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalSQLConsumer.insert(globalReqId, rowData, successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -484,29 +498,34 @@ The string consists of one or more components, separated by a slash('/'). -Code example:
function successcb(id) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - var rowData = { - columns : ["WORD", "WORD_DESC"] , - values : ["'tizen1'", "'Web apps platform!'"] - }; - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalSQLConsumer.update(globalReqId, rowData, "WORD='tizen1'", successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + var rowData = + { + columns: ["WORD", "WORD_DESC"] , + values: ["'tizen1'", "'Web apps platform!'"] + }; + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalSQLConsumer.update(globalReqId, rowData, "WORD='tizen1'", successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -570,25 +589,29 @@ The string consists of one or more components, separated by a slash('/'). -Code example:
function successcb(id) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalSQLConsumer.remove(globalReqId, "WORD='tizen1'", successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalSQLConsumer.remove(globalReqId, "WORD='tizen1'", successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -671,46 +694,48 @@ The sorting order of the selected rows.
It is an SQL ORDER BY cla-@@ -811,25 +836,29 @@ The sorting order of the selected rows.Code example:
function getValueSuccessCB(result, id) - { - console.log("getValueSuccessCB result.length: " + result.length); - var length = result.length; - for (var i = 0; i < length; i++) - { - var rowData = "| "; - var j = 0; - for (j = 0; j < result[i].columns.length; j++) - { - rowData += "column: " + result[i].columns[j] + ", value: " + result[i].values[j] + " | "; - } - console.log(rowData); - } - } +Code example:
+function getValueSuccessCB(result, id) +{ + console.log("getValueSuccessCB result.length: " + result.length); + var length = result.length; + for (var i = 0; i < length; i++) + { + var rowData = "| "; + var j = 0; + for (j = 0; j < result[i].columns.length; j++) + { + rowData += "column: " + result[i].columns[j] + ", value: " + result[i].values[j] + " | "; + } + console.log(rowData); + } +} +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } - - try { - // globalSQLConsumer and globalReqId should be defined before. - // Increases globalReqId for uniqueness - var columns = ["WORD", "WORD_DESC" ]; - var whereClause = "1"; - console.log("----- Calling for ascending order -----"); - globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb, - null, null, "WORD_DESC ASC"); - setTimeout( function() { - console.log("----- Calling descending order -----"); - globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb, - null, null, "WORD_DESC DESC"); - }, 1000); - } - catch (err) { - console.log (err.name +": " + err.message); - } - -+try +{ + /* globalSQLConsumer and globalReqId should be defined before */ + /* Increases globalReqId for uniqueness */ + var columns = ["WORD", "WORD_DESC"]; + var whereClause = "1"; + console.log("----- Calling for ascending order -----"); + globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb, + null, null, "WORD_DESC ASC"); + setTimeout(function() + { + console.log("----- Calling descending order -----"); + globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb, + null, null, "WORD_DESC DESC"); + }, 1000); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
It is an SQL ORDER BY cla-Code example:
function successcb(id) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalMappedConsumer.addValue(globalReqId, "tizen", "Foo", successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalMappedConsumer.addValue(globalReqId, "tizen", "Foo", successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -900,25 +929,29 @@ The sorting order of the selected rows.
It is an SQL ORDER BY cla-Code example:
function successcb(id) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalMappedConsumer.removeValue(globalReqId, "tizen", "Foo", successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalMappedConsumer.removeValue(globalReqId, "tizen", "Foo", successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -985,25 +1018,29 @@ The sorting order of the selected rows.
It is an SQL ORDER BY cla-Code example:
function getValueSuccessCB(result, id) - { - console.log(result.length + ":" + result[0]); - } +Code example:
+function getValueSuccessCB(result, id) +{ + console.log(result.length + ":" + result[0]); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalMappedConsumer.getValue(globalReqId, "tizen", getValueSuccessCB, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalMappedConsumer.getValue(globalReqId, "tizen", getValueSuccessCB, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +@@ -1078,25 +1115,29 @@ The sorting order of the selected rows.
It is an SQL ORDER BY cla-diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/datasync.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/datasync.html index 76870f4..f01cdfd 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/datasync.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/datasync.html @@ -782,18 +782,19 @@ The profile ID is provided when the profile is successfully added.Code example:
function successcb(id) - { - console.log("ok : reqid " + id); - } +Code example:
+function successcb(id) +{ + console.log("ok: reqid " + id); +} - function errorcb(id, error) - { - console.log("error id : " + id + ", error msg : " + error.message); - } +function errorcb(id, error) +{ + console.log("error id: " + id + ", error msg: " + error.message); +} - try { - // Defines globalReqId before - // Increases globalReqId for uniqueness - globalReqId++; - globalMappedConsumer.updateValue(globalReqId, "tizen", "Foo", "Bar", successcb, errorcb); - } catch (err) { - console.log (err.name +": " + err.message); - } -+try +{ + /* Defines globalReqId before */ + /* Increases globalReqId for uniqueness */ + globalReqId++; + globalMappedConsumer.updateValue(globalReqId, "tizen", "Foo", "Bar", successcb, errorcb); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +-Code example:
// Creates a sync info - var syncInfo = new tizen.SyncInfo("http://example.com/sync", "myId", "myPassword", "MANUAL", "TWO_WAY"); - - // Syncs both contacts and events - var contactInfo = new tizen.SyncServiceInfo(true, "CONTACT", "serverContact"); - var eventInfo = new tizen.SyncServiceInfo(true, "EVENT", "serverEvent"); - var serviceInfo = [contactInfo, eventInfo]; - - // Adds a profile to sync - var profile = new tizen.SyncProfileInfo("MyProfile", syncInfo, serviceInfo); - tizen.datasync.add(profile); -+Code example:
+/* Creates a sync info */ +var syncInfo = new tizen.SyncInfo("http://example.com/sync", "myId", "myPassword", "MANUAL", "TWO_WAY"); + +/* Syncs both contacts and events */ +var contactInfo = new tizen.SyncServiceInfo(true, "CONTACT", "serverContact"); +var eventInfo = new tizen.SyncServiceInfo(true, "EVENT", "serverEvent"); +var serviceInfo = [contactInfo, eventInfo]; + +/* Adds a profile to sync */ +var profile = new tizen.SyncProfileInfo("MyProfile", syncInfo, serviceInfo); +tizen.datasync.add(profile); +@@ -845,13 +846,14 @@ The profile ID is provided when the profile is successfully added. -Code example:
// Retrieves and updates a profile - var profile = tizen.datasync.get(profileId); +Code example:
+/* Retrieves and updates a profile */ +var profile = tizen.datasync.get(profileId); - profile.profileName = "newProfileName"; +profile.profileName = "newProfileName"; - tizen.datasync.update(profile); -+tizen.datasync.update(profile); +@@ -903,9 +905,10 @@ The profile ID is provided when the profile is successfully added. -Code example:
// Removes a profile - tizen.datasync.remove(profileId); -+Code example:
+/* Removes a profile */ +tizen.datasync.remove(profileId); +@@ -947,9 +950,10 @@ Normally the platform sets a limitation on the number of supported profiles. It -Code example:
// Gets the maximum number of supported profiles on the platform - var numMaxProfiles = tizen.datasync.getMaxProfilesNum(); -+Code example:
+/* Gets the maximum number of supported profiles on the platform */ +var numMaxProfiles = tizen.datasync.getMaxProfilesNum(); +@@ -990,9 +994,10 @@ Normally the platform sets a limitation on the number of supported profiles. It -Code example:
// Gets the present number of profiles on the device - var numProfiles = tizen.datasync.getProfilesNum(); -+Code example:
+/* Gets the present number of profiles on the device */ +var numProfiles = tizen.datasync.getProfilesNum(); +@@ -1053,9 +1058,10 @@ The attempt to retrieve SyncProfileInfo doesn't get any confidential in -Code example:
// Gets the profile information with the given ID - var profile = tizen.datasync.get(profileId); -+Code example:
+/* Gets the profile information with the given ID */ +var profile = tizen.datasync.get(profileId); +@@ -1101,9 +1107,10 @@ An attempt to retrieve SyncProfileInfo doesn't get any confidential inf -Code example:
// Gets all the profile information - var profiles = tizen.datasync.getAll(); -+Code example:
+/* Gets all the profile information */ +var profiles = tizen.datasync.getAll(); +@@ -1167,19 +1174,23 @@ If the sync mode is set to MANUAL, the synchronization does not start a -Code example:
var profileId; //profileId obtained from SyncProfileInfo - var syncCallback = { - onprogress: function(profileId, serviceType, isFromServer, totalPerType, syncedPerType) { - console.log('Total: ' + totalPerType + ', synced: ' + syncedPerType + ' for the sync type: ' + serviceType); - }, - onfailed: function(profileId, error) { - console.log('Failed with id: ' + profileId + ', error name: ' + error.name); - } - }; - - // Starts the sync operation with the corresponding callbacks - tizen.datasync.startSync(profileId, syncCallback); -+Code example:
+var profileId; /* profileId obtained from SyncProfileInfo */ +var syncCallback = +{ + onprogress: function(profileId, serviceType, isFromServer, totalPerType, syncedPerType) + { + console.log('Total: ' + totalPerType + ', synced: ' + syncedPerType + ' for the sync type: ' + serviceType); + }, + onfailed: function(profileId, error) + { + console.log('Failed with id: ' + profileId + ', error name: ' + error.name); + } +}; + +/* Starts the sync operation with the corresponding callbacks */ +tizen.datasync.startSync(profileId, syncCallback); +@@ -1231,10 +1242,11 @@ If the sync mode is set to MANUAL, the synchronization does not start a -Code example:
var profileId; //profileId obtained from SyncProfileInfo - // Stops the ongoing sync operation - tizen.datasync.stopSync(profileId); -+Code example:
+var profileId; /* profileId obtained from SyncProfileInfo */ +/* Stops the ongoing sync operation */ +tizen.datasync.stopSync(profileId); +@@ -1290,10 +1302,11 @@ If the sync mode is set to MANUAL, the synchronization does not start a -diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/download.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/download.html index 70b8bc2..bd156e4 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/download.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/download.html @@ -279,11 +279,12 @@ The default value is an empty object. 2.1Code example:
var profileId; //profileId obtained from SyncProfileInfo - // Gets the sync statistics information with the given ID - var statistics = tizen.datasync.getLastSyncStatistics(profileId); -+Code example:
+var profileId; /* profileId obtained from SyncProfileInfo */ +/* Gets the sync statistics information with the given ID */ +var statistics = tizen.datasync.getLastSyncStatistics(profileId); +-@@ -384,47 +385,59 @@ If the network is not available for downloading, the return value is -1 since TiCode example:
var req = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt"); - req.httpHeader["Pragma"] = "no-cache"; - req.httpHeader["Cookie"] = "version=1; Skin=new"; - req.httpHeader["X-Agent"] = "Tizen Sample App"; -+Code example:
+var req = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt"); +req.httpHeader["Pragma"] = "no-cache"; +req.httpHeader["Cookie"] = "version=1; Skin=new"; +req.httpHeader["X-Agent"] = "Tizen Sample App"; +-Code example:
// Check if Download API is supported not on a device. - var download_api_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/download"); - if (download_api_capability === false) { - console.log("Download API is not supported on this device."); - return; - } +Code example:
+/* Check whether Download API is supported on a device */ +var download_api_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/download"); +if (download_api_capability === false) +{ + console.log("Download API is not supported on this device."); - var listener = { - onprogress: function(id, receivedSize, totalSize) { - console.log('Received with id: ' + id + ', ' + receivedSize + '/' + totalSize); - }, - onpaused: function(id) { - console.log('Paused with id: ' + id); - }, - oncanceled: function(id) { - console.log('Canceled with id: ' + id); - }, - oncompleted: function(id, path) { - console.log('Completed with id: ' + id + ', path: ' + path); - }, - onfailed: function(id, error) { - console.log('Failed with id: ' + id + ', error name: ' + error.name); - } - }; + return; +} - // Starts downloading the file from the Web with the corresponding callbacks. - var downloadRequest = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt", "documents"); - var downloadId = tizen.download.start(downloadRequest, listener); +var listener = +{ + onprogress: function(id, receivedSize, totalSize) + { + console.log('Received with id: ' + id + ', ' + receivedSize + '/' + totalSize); + }, + onpaused: function(id) + { + console.log('Paused with id: ' + id); + }, + oncanceled: function(id) + { + console.log('Canceled with id: ' + id); + }, + oncompleted: function(id, path) + { + console.log('Completed with id: ' + id + ', path: ' + path); + }, + onfailed: function(id, error) + { + console.log('Failed with id: ' + id + ', error name: ' + error.name); + } +}; - // If you want to download a large file through Wi-Fi, - var wifi_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.wifi"); - var wifiDownloadRequest = new tizen.DownloadRequest("http://download.tizen.org/tools/archive/14.02.2/Ubuntu_12.04/qemu_1.6.0rc3.orig.tar.gz", "downloads", null, "WIFI"); +/* Starts downloading the file from the Web with the corresponding callbacks */ +var downloadRequest = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt", "documents"); +var downloadId = tizen.download.start(downloadRequest, listener); - if (wifi_capability === true) { - var downlodId_wifi = tizen.download.start(wifiDownloadRequest, listener); - } else { - // If you call tizen.download.start(), NotSupportedError will be thrown. - console.log("This device doesn't support Download API through Wi-Fi."); - } +/* If you want to download a large file through Wi-Fi */ +var wifi_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.wifi"); +var wifiDownloadRequest = new tizen.DownloadRequest( + "http://download.tizen.org/tools/archive/14.02.2/Ubuntu_12.04/qemu_1.6.0rc3.orig.tar.gz", "downloads", null, "WIFI"); -+if (wifi_capability === true) +{ + var downlodId_wifi = tizen.download.start(wifiDownloadRequest, listener); +} +else +{ + /* If you call tizen.download.start(), NotSupportedError will be thrown */ + console.log("This device doesn't support Download API through Wi-Fi."); +} +@@ -468,9 +481,10 @@ If the network is not available for downloading, the return value is -1 since Ti -Code example:
// Cancels the ongoing download operation with the specified ID. - tizen.download.cancel(downloadId); -+Code example:
+/* Cancels the ongoing download operation with the specified ID */ +tizen.download.cancel(downloadId); +@@ -515,9 +529,10 @@ The paused download operation can be resumed later by the resume() meth -Code example:
// Pauses the ongoing download operation with the specified ID. - tizen.download.pause(downloadId); -+Code example:
+/* Pauses the ongoing download operation with the specified ID */ +tizen.download.pause(downloadId); +@@ -561,9 +576,10 @@ The paused download operation can be resumed later by the resume() meth -Code example:
// Resumes the paused download operation with the specified ID. - tizen.download.resume(downloadId); -+Code example:
+/* Resumes the paused download operation with the specified ID */ +tizen.download.resume(downloadId); +@@ -611,9 +627,10 @@ The paused download operation can be resumed later by the resume() meth -Code example:
// Gets the state of the download operation with the given ID. - var state = tizen.download.getState(downloadId); -+Code example:
+/* Gets the state of the download operation with the given ID */ +var state = tizen.download.getState(downloadId); +@@ -664,9 +681,10 @@ parameters contain an invalid value. -Code example:
// Gets the download request information with the given ID. - var downloadRequest = tizen.download.getDownloadRequest(downloadId); -+Code example:
+/* Gets the download request information with the given ID */ +var downloadRequest = tizen.download.getDownloadRequest(downloadId); +@@ -721,9 +739,10 @@ parameters contain an invalid value. -Code example:
// Get the MIME type of the download operation with the given ID. - var MIMEtype = tizen.download.getMIMEType(downloadId); -+Code example:
+/* Get the MIME type of the download operation with the given ID */ +var MIMEtype = tizen.download.getMIMEType(downloadId); +@@ -775,31 +794,38 @@ parameters contain an invalid value. -diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/exif.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/exif.html index 0ad7642..ec9cc0a 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/exif.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/exif.html @@ -250,27 +250,33 @@ UnknownError: In any other error caseCode example:
var listener = { - onprogress: function(id, receivedSize, totalSize) { - console.log('Received with id: ' + id + ', ' + receivedSize + '/' + totalSize); - }, - onpaused: function(id) { - console.log('Paused with id: ' + id); - }, - oncanceled: function(id) { - console.log('Canceled with id: ' + id); - }, - oncompleted: function(id, fileName) { - console.log('Completed with id: ' + id + ', file name: ' + fileName); - }, - onfailed: function(id, error) { - console.log('Failed with id: ' + id + ', error name: ' + error.name); - } - }; +Code example:
+var listener = +{ + onprogress: function(id, receivedSize, totalSize) + { + console.log('Received with id: ' + id + ', ' + receivedSize + '/' + totalSize); + }, + onpaused: function(id) + { + console.log('Paused with id: ' + id); + }, + oncanceled: function(id) + { + console.log('Canceled with id: ' + id); + }, + oncompleted: function(id, fileName) + { + console.log('Completed with id: ' + id + ', file name: ' + fileName); + }, + onfailed: function(id, error) + { + console.log('Failed with id: ' + id + ', error name: ' + error.name); + } +}; - // Start downloading the html file on the web with the corresponding callbacks. - var downloadRequest = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt", "documents"); - downloadId = tizen.download.start(downloadRequest); +/* Start downloading the html file on the web with the corresponding callbacks */ +var downloadRequest = new tizen.DownloadRequest("http://download.tizen.org/tools/README.txt", "documents"); +downloadId = tizen.download.start(downloadRequest); - // Add the listener. - tizen.download.setListener(downloadId, listener); -+/* Add the listener */ +tizen.download.setListener(downloadId, listener); +-Code example:
//Preconditions: please provide images/tizen.jpg file with present Exif data - - // Defines success callback - function onSuccess(exifInfo) { - console.log("success to get Exif information object"); - } - - // Defines error callback - function onError(error) { - console.log("error occurred: " + error.name); - } - - function resolveSuccess(file) { - tizen.exif.getExifInfo(file.toURI(), onSuccess, onError); - } - - function resolveFail(error) { - console.log("error occurred: " + error.name); - } - tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); -+Code example:
+/* Preconditions: provide images/tizen.jpg file with present Exif data */ + +/* Defines success callback */ +function onSuccess(exifInfo) +{ + console.log("success to get Exif information object"); +} + +/* Defines error callback */ +function onError(error) +{ + console.log("error occurred: " + error.name); +} + +function resolveSuccess(file) +{ + tizen.exif.getExifInfo(file.toURI(), onSuccess, onError); +} + +function resolveFail(error) +{ + console.log("error occurred: " + error.name); +} + +tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); +
Code example:
//Preconditions: please provide images/tizen.jpg file with present Exif data - - // Defines success callback - function onSaveSuccess() { - console.log("success to save Exif information"); - } - - // Defines error callback - function onSaveError(error) { - console.log("error occur" + error.name); - } - - // Defines success callback - function onSuccess(exifInfo) { - console.log("success to get Exif information object"); - exifInfo.orientation = "ROTATE_90"; - tizen.exif.saveExifInfo(exifInfo, onSaveSuccess, onSaveError); - } - - // Defines error callback - function onError(error) { - console.log("error occur" + error.name); - } - - function resolveSuccess(file) { - tizen.exif.getExifInfo(file.toURI(), onSuccess, onError); - } - - function resolveFail(error) { - console.log("error occurred: " + error.name); - } - - tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); - -+
Code example:
+/* Preconditions: provide images/tizen.jpg file with present Exif data */ + +/* Defines success callback */ +function onSaveSuccess() +{ + console.log("success to save Exif information"); +} + +/* Defines error callback */ +function onSaveError(error) +{ + console.log("error occur" + error.name); +} + +/* Defines success callback */ +function onSuccess(exifInfo) +{ + console.log("success to get Exif information object"); + exifInfo.orientation = "ROTATE_90"; + tizen.exif.saveExifInfo(exifInfo, onSaveSuccess, onSaveError); +} + +/* Defines error callback */ +function onError(error) +{ + console.log("error occur" + error.name); +} + +function resolveSuccess(file) +{ + tizen.exif.getExifInfo(file.toURI(), onSuccess, onError); +} + +function resolveFail(error) +{ + console.log("error occurred: " + error.name); +} + +tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); +
Code example:
//Preconditions: please provide images/tizen.jpg file with present Exif data - - // Defines success callback - function onSuccess(thumbData) { - console.log("got thumbnail data of JPEG file"); - if (thumbData) { - var img = new Image(); - img.src = thumbData; - document.body.appendChild(img); - } - } - - // Defines error callback - function onError(error) { - console.log("error occur" + error.name); - } - - function resolveSuccess(file) { - tizen.exif.getThumbnail(file.toURI(), onSuccess, onError); - } - - function resolveFail(error) { - console.log("error occurred: " + error.name); - } - - tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); -+
Code example:
+/* Preconditions: provide images/tizen.jpg file with present Exif data */ + +/* Defines success callback */ +function onSuccess(thumbData) +{ + console.log("got thumbnail data of JPEG file"); + if (thumbData) + { + var img = new Image(); + img.src = thumbData; + document.body.appendChild(img); + } +} + +/* Defines error callback */ +function onError(error) +{ + console.log("error occur" + error.name); +} + +function resolveSuccess(file) +{ + tizen.exif.getThumbnail(file.toURI(), onSuccess, onError); +} + +function resolveFail(error) +{ + console.log("error occurred: " + error.name); +} + +tizen.filesystem.resolve("images/tizen.jpg", resolveSuccess, resolveFail); +
Code example:
try { - tizen.feedback.play("CHARGERCONN", "TYPE_SOUND"); - } catch (err) { - console.log (err.name +': ' + err.message); - } -+
Code example:
+try +{ + tizen.feedback.play("CHARGERCONN", "TYPE_SOUND"); +} +catch (err) +{ + console.log(err.name + ': ' + err.message); +} +
Code example:
try { - tizen.feedback.play("BT_CONNECTED", "TYPE_VIBRATION"); - tizen.feedback.stop(); - } catch (err) { - console.log (err.name +': ' + err.message); - } -+
Code example:
+try +{ + tizen.feedback.play("BT_CONNECTED", "TYPE_VIBRATION"); + tizen.feedback.stop(); +} +catch (err) +{ + console.log(err.name + ': ' + err.message); +} +
Code example:
var pattern = "BT_CONNECTED", type = "TYPE_SOUND"; - var isPatternSupported = tizen.feedback.isPatternSupported(pattern, type); - var isSupported = ""; - if(!isPatternSupported) { - isSupported = " not"; - } - console.log("pattern " + pattern + " is" + isSupported + " supported"); -+
Code example:
+var pattern = "BT_CONNECTED", type = "TYPE_SOUND"; +var isPatternSupported = tizen.feedback.isPatternSupported(pattern, type); +var isSupported = ""; +if (!isPatternSupported) +{ + isSupported = " not"; +} +console.log("pattern " + pattern + " is" + isSupported + " supported"); +
Output example:
pattern BT_CONNECTED is supported diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/filesystem.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/filesystem.html index cc19a3a..eb2608f 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/filesystem.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/filesystem.html @@ -357,41 +357,44 @@ as determining root and default locations, resolving a given location into a fil
Code example:
var documentsDir; - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - console.log("File Name is " + files[i].name); // displays file name - } - - var testFile = documentsDir.createFile("test.txt"); - - if (testFile != null) { - testFile.openStream( - "w", - function(fs) { - fs.write("HelloWorld"); - fs.close(); - }, function(e) { - console.log("Error " + e.message); - }, "UTF-8" - ); - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess, onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+var documentsDir; +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + console.log("File Name is " + files[i].name); /* Displays file name */ + } + + var testFile = documentsDir.createFile("test.txt"); + + if (testFile != null) + { + testFile.openStream("w", function(fs) + { + fs.write("HelloWorld"); + fs.close(); + }, function(e) + { + console.log("Error " + e.message); + }, "UTF-8"); + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
console.log("The maximum path length is " + tizen.filesystem.maxPathLength); -+
Code example:
+console.log("The maximum path length is " + tizen.filesystem.maxPathLength); +
Code example:
tizen.filesystem.resolve( - 'images', - function(dir) { - console.log("Mount point Name is " + dir.path); - }, function(e) { - console.log("Error: " + e.message); - }, "r" - ); -+
Code example:
+tizen.filesystem.resolve('images', function(dir) +{ + console.log("Mount point Name is " + dir.path); +}, function(e) +{ + console.log("Error: " + e.message); +}, "r"); +
Code example:
function onStorage(storage) { - // Do something - } +Code example:
+function onStorage(storage) +{ + /* Do something */ +} - function onStorageError(e) { - console.log("Storage not found!" + e.message); - } +function onStorageError(e) +{ + console.log("Storage not found!" + e.message); +} - tizen.filesystem.getStorage("music", onStorage, onStorageError); -+tizen.filesystem.getStorage("music", onStorage, onStorageError); +
Code example:
function alertForCorruptedRemovableDrives(storages) { - for (var i = 0; i < storages.length; i++) { - if (storages[i].type != "EXTERNAL") - continue; - if (storages[i].state == "UNMOUNTABLE") - console.log("External drive " + storages[i].label + " is corrupted."); - } - } - - tizen.filesystem.listStorages(alertForCorruptedRemovableDrives); -+
Code example:
+function alertForCorruptedRemovableDrives(storages) +{ + for (var i = 0; i < storages.length; i++) + { + if (storages[i].type != "EXTERNAL") + continue; + if (storages[i].state == "UNMOUNTABLE") + console.log("External drive " + storages[i].label + " is corrupted."); + } +} + +tizen.filesystem.listStorages(alertForCorruptedRemovableDrives); +
Code example:
var watchID; - function onStorageStateChanged(storage) { - if (storage.state == "MOUNTED") - console.log("Storage " + storage.label + " was added!"); - } +Code example:
+var watchID; +function onStorageStateChanged(storage) +{ + if (storage.state == "MOUNTED") + console.log("Storage " + storage.label + " was added!"); +} - watchID = tizen.filesystem.addStorageStateChangeListener(onStorageStateChanged); -+watchID = tizen.filesystem.addStorageStateChangeListener(onStorageStateChanged); +
Code example:
var watchID; - function onStorageStateChanged(storage) { - if (storage.state == "MOUNTED") - console.log("Storage " + storage.label + " was added!"); - tizen.filesystem.removeStorageStateChangeListener(watchID); - } - - watchID = tizen.filesystem.addStorageStateChangeListener(onStorageStateChanged); - -+
Code example:
+var watchID; +function onStorageStateChanged(storage) +{ + if (storage.state == "MOUNTED") + console.log("Storage " + storage.label + " was added!"); + tizen.filesystem.removeStorageStateChangeListener(watchID); +} + +watchID = tizen.filesystem.addStorageStateChangeListener(onStorageStateChanged); +
Code example:
function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - // alerts each name of dir's contents - console.log(files[i].name); - } - } - - function onerror(error) { - console.log("The error " + error.message + - " occurred when listing the files in the selected folder"); - } - - // list directory contents - dir.listFiles(onsuccess, onerror); -+
Code example:
+function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + /* Alerts each name of dir's contents */ + console.log(files[i].name); + } +} + +function onerror(error) +{ + console.log("The error " + error.message + + " occurred when listing the files in the selected folder"); +} + +/* List directory contents */ +dir.listFiles(onsuccess, onerror); +
Code example:
// list directory contents - dir.listFiles(onsuccess, onerror); - - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - // prints the file parent, should contain the - // same value for all the files in the loop - console.log("All the files should have the same parent " + - files[i].parent); - } - } - - function onerror(error) { - console.log("The error " + error.message + - " occurred when listing the files in the selected folder"); - } -+
Code example:
+/* List directory contents */ +dir.listFiles(onsuccess, onerror); + +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + /* + Prints the file parent, must contain the + same value for all the files in the loop + */ + console.log("All the files should have the same parent " + + files[i].parent); + } +} + +function onerror(error) +{ + console.log("The error " + error.message + + " occurred when listing the files in the selected folder"); +} +
Code example:
// lists directory contents - dir.listFiles(onsuccess, onerror); - - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - if (files[i].readOnly) - console.log("Cannot write to file " + files[i].name); - else - console.log("Can write to file " + files[i].name); - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } -+
Code example:
+/* Lists directory contents */ +dir.listFiles(onsuccess, onerror); + +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + if (files[i].readOnly) + console.log("Cannot write to file " + files[i].name); + else + console.log("Can write to file " + files[i].name); + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} +
Code example:
console.log(file.modified); // displays the modification timestamp -+
Code example:
console.log(file.modified); /* Displays the modification timestamp */
Code example:
console.log(file.path); // should be 'music/' if the file is music/foo.mp3 -+
Code example:
console.log(file.path); /* Must be 'music/' if the file is music/foo.mp3 */
Code example:
// should be foo.mp3 if the file path is music/foo.mp3 - console.log(file.name); -+
Code example:
+/* Must be foo.mp3 if the file path is music/foo.mp3 */ +console.log(file.name); +
Code example:
// should be music/track1.mp3 if the file is music/track1.mp3 - console.log(file.fullPath); -+
Code example:
+/* Must be music/track1.mp3 if the file is music/track1.mp3 */ +console.log(file.fullPath); +
Code example:
// displays the file size - console.log(file.fileSize); -+
Code example:
+/* Displays the file size */ +console.log(file.fileSize); +
Code example:
// '3' if the directory contains two files and one sub-directory - console.log(file.length); -+
Code example:
+/* '3' if the directory contains two files and one sub-directory */ +console.log(file.length); +
Code example:
tizen.filesystem.resolve('music/ramones/RockawayBeach.mp3', function(file) { - var audio = new Audio(file.toURI()); - audio.play(); - console.log(file.toURI()); - }); -+
Code example:
+tizen.filesystem.resolve('music/ramones/RockawayBeach.mp3', function(file) +{ + var audio = new Audio(file.toURI()); + audio.play(); + console.log(file.toURI()); +}); +
Code example:
function onsuccess(files) { - console.log("There are " + files.length + " in the selected folder"); - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - "documents", - function(dir) { - dir.listFiles(onsuccess, onerror); - }, function(e) { - console.log("Error " + e.message); - }, "r" - ); -+
Code example:
+function onsuccess(files) +{ + console.log("There are " + files.length + " in the selected folder"); +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +tizen.filesystem.resolve("documents", function(dir) +{ + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error " + e.message); +}, "r"); +
Code example:
var documentsDir; - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - console.log("File Name is " + files[i].name); // displays file name - } - - var testFile = documentsDir.createFile("test.txt"); - if (testFile != null) { - testFile.openStream( - "w", - function(fs) { - fs.write("HelloWorld"); - fs.close(); - }, function(e) { - console.log("Error " + e.message); - }, "UTF-8" - ); - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; dir.listFiles(onsuccess,onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+var documentsDir; +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + console.log("File Name is " + files[i].name); /* Displays file name */ + } + + var testFile = documentsDir.createFile("test.txt"); + if (testFile != null) + { + testFile.openStream("w", function(fs) + { + fs.write("HelloWorld"); + fs.close(); + }, function(e) + { + console.log("Error " + e.message); + }, "UTF-8"); + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - console.log("File Name is " + files[i].name); // displays file name - if (files[i].isDirectory == false) - files[i].readAsText( - function(str) { - console.log("The file content " + str); - }, function(e) { - console.log("Error " + e.message); - }, "UTF-8" - ); - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - var documentsDir; - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess,onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + console.log("File Name is " + files[i].name); /* Displays file name */ + if (files[i].isDirectory == false) + { + files[i].readAsText(function(str) + { + console.log("The file content " + str); + }, function(e) + { + console.log("Error " + e.message); + }, "UTF-8"); + } + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +var documentsDir; +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
var documentsDir; - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - if (files[i].isDirectory == false) { - documentsDir.copyTo(files[i].fullPath, - "images/backup/" + files[i].name, - false, - function() {console.log("file copied");}); - } - } - } - - function onerror(error) { - console.log("The error " + error.message + - " occurred when listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess, onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+var documentsDir; +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + if (files[i].isDirectory == false) + { + documentsDir.copyTo(files[i].fullPath, + "images/backup/" + files[i].name, false, + function() {console.log("file copied");}); + } + } +} + +function onerror(error) +{ + console.log("The error " + error.message + + " occurred when listing the files in the selected folder"); +} + +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
var documentsDir; - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - if (files[i].isDirectory == false) { - documentsDir.moveTo(files[i].fullPath, - "images/newFolder/" + files[i].name, - false, - function() {console.log("file moved");}); - } - } - } - - function onerror(error) { - console.log("The error " + error.message + - " occurred during listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess, onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+var documentsDir; +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + if (files[i].isDirectory == false) + { + documentsDir.moveTo(files[i].fullPath, + "images/newFolder/" + files[i].name, false, + function() {console.log("file moved");}); + } + } +} + +function onerror(error) +{ + console.log("The error " + error.message + + " occurred during listing the files in the selected folder"); +} + +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
var dir; //Directory object obtained from filesystem API - var newDir = dir.createDirectory("newDir"); - var anotherNewDir = dir.createDirectory("newDir1/subNewDir1"); -+
Code example:
+var dir; /* Directory object obtained from filesystem API */ +var newDir = dir.createDirectory("newDir"); +var anotherNewDir = dir.createDirectory("newDir1/subNewDir1"); +
Code example:
var newFile = dir.createFile("newFilePath"); -+
Code example:
var newFile = dir.createFile("newFilePath");
Code example:
var file; - // Resolves helloWorld.doc file that is located in the - // documents root location - tizen.filesystem.resolve( - 'documents', - function(dir) { file = dir.resolve("helloWorld.doc");}, - function(e) { console.log("Error" + e.message);}, - "rw"); -+
Code example:
+var file; +/* + Resolves helloWorld.doc file that is located in the + documents root location +*/ +tizen.filesystem.resolve('documents', function(dir) +{ + file = dir.resolve("helloWorld.doc"); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
var documentsDir; - function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - if (files[i].isDirectory) { - documentsDir.deleteDirectory( - files[i].fullPath, - false, - function() { - console.log("Directory Deleted"); - }, function(e) { - console.log("Error" + e.message); - }); - } - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess,onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+var documentsDir; +function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + if (files[i].isDirectory) + { + documentsDir.deleteDirectory(files[i].fullPath, false, function() + { + console.log("Directory Deleted"); + }, function(e) + { + console.log("Error" + e.message); + }); + } + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess, onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
function onsuccess(files) { - for (var i = 0; i < files.length; i++) { - if (!files[i].isDirectory) { - documentsDir.deleteFile( - files[i].fullPath, - function() { - console.log("File Deleted"); - }, function(e) { - console.log("Error" + e.message); - }); - } - } - } - - function onerror(error) { - console.log("The error " + error.message + " occurred when listing the files in the selected folder"); - } - - var documentsDir; - tizen.filesystem.resolve( - 'documents', - function(dir) { - documentsDir = dir; - dir.listFiles(onsuccess,onerror); - }, function(e) { - console.log("Error" + e.message); - }, "rw" - ); -+
Code example:
+function onsuccess(files) +{ + for (var i = 0; i < files.length; i++) + { + if (!files[i].isDirectory) + { + documentsDir.deleteFile(files[i].fullPath, function() + { + console.log("File Deleted"); + }, function(e) + { + console.log("Error" + e.message); + }); + } + } +} + +function onerror(error) +{ + console.log("The error " + error.message + " occurred when listing the files in the selected folder"); +} + +var documentsDir; +tizen.filesystem.resolve('documents', function(dir) +{ + documentsDir = dir; + dir.listFiles(onsuccess,onerror); +}, function(e) +{ + console.log("Error" + e.message); +}, "rw"); +
Code example:
if (stream.eof) { - // file has been read completely - } -+
Code example:
+if (stream.eof) +{ + /* File has been read completely */ +} +
Code example:
console.log(stream.position); // displays current stream position - // alters current stream position to the begin of the file, - // like seek() in C - stream.position = 0; -+
Code example:
+console.log(stream.position); /* Displays current stream position */ +/* + Alters current stream position to the begin of the file, + like seek() in C +*/ +stream.position = 0; +
Code example:
console.log(stream.bytesAvailable); // displays the available bytes to be read -+
Code example:
+console.log(stream.bytesAvailable); /* Displays the available bytes to be read */
Code example:
stream.close(); // closes this stream, no subsequent access to stream allowed -+
Code example:
+stream.close(); /* Closes this stream, no subsequent access to stream allowed */ +
Code example:
var text = stream.read(file.fileSize); - stream.close(); -+
Code example:
+var text = stream.read(file.fileSize); +stream.close(); +
Code example:
// reads up to 256 bytes from the stream - var raw = stream.readBytes(256); - for (var i = 0; i < raw.length; i++) { - // raw[i] contains the i-th byte of the current data chunk - } -+
Code example:
+/* Reads up to 256 bytes from the stream */ +var raw = stream.readBytes(256); +for (var i = 0; i < raw.length; i++) +{ + /* raw[i] contains the i-th byte of the current data chunk */ +} +
Code example:
// reads up to 256 bytes from the stream - var base64 = stream.readBase64(256); -+
Code example:
+/* Reads up to 256 bytes from the stream */ +var base64 = stream.readBase64(256); +
Code example:
var text = "Hello world"; - stream.write(text); -+
Code example:
+var text = "Hello world"; +stream.write(text); +
Code example:
var bytes = in.readBytes(256); - // writes the bytes read from in to out - out.writeBytes(bytes); -+
Code example:
+var bytes = in.readBytes(256); +/* Writes the bytes read from in to out */ +out.writeBytes(bytes); +
Code example:
var base64 = in.readBase64(256); - // writes the base64 data read from in to out - out.writeBase64(base64); -+
Code example:
+var base64 = in.readBase64(256); +/* Writes the base64 data read from in to out */ +out.writeBase64(base64); +
Code example:
if (!tizen.fmradio.isAntennaConnected) { - console.log("Please plug in the earphones to listen to the radio"); - } -+
Code example:
+if (!tizen.fmradio.isAntennaConnected) +{ + console.log("Please plug in the earphones to listen to the radio"); +} +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - if(radioState == "READY") { - tizen.fmradio.start(87.5); - } - // jump to your favorite radio station (95.9MHz) and start playing - //tizen.fmradio.start(95.9); -+if (radioState == "READY") +{ + tizen.fmradio.start(87.5); +} +/* Jump to your favorite radio station (95.9MHz) and start playing */ +/* tizen.fmradio.start(95.9); */ +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - if(radioState == "PLAYING") { - tizen.fmradio.stop(); - } -+if (radioState == "PLAYING") +{ + tizen.fmradio.stop(); +} +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - function successCallback() { - console.log("The radio find a new frequency successfully"); - } - function errorCallback(err) { - console.log("The following error occurred : " + err.name); - } +function successCallback() +{ + console.log("The radio find a new frequency successfully"); +} +function errorCallback(err) +{ + console.log("The following error occurred: " + err.name); +} - if(radioState == "PLAYING") { - tizen.fmradio.seekUp(successCallback, errorCallback); - } -+if (radioState == "PLAYING") +{ + tizen.fmradio.seekUp(successCallback, errorCallback); +} +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - function successCallback() { - console.log("The radio find a new frequency successfully"); - } - function errorCallback(err) { - console.log("The following error occurred : " + err.name); - } +function successCallback() +{ + console.log("The radio find a new frequency successfully"); +} +function errorCallback(err) +{ + console.log("The following error occurred: " + err.name); +} - if(radioState == "PLAYING") { - tizen.fmradio.seekDown(successCallback, errorCallback); - } -+if (radioState == "PLAYING") +{ + tizen.fmradio.seekDown(successCallback, errorCallback); +} +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - var radioScanCallback = { - onfrequencyfound: function(frequency) { - console.log("A new frequency found: " + frequency); - }, - onfinished: function(frequencies) { - console.log(frequencies.length + "frequencies found!"); - for (var i = 0; i < frequencies.length; i++) { - console.log(i + ": " + frequencies[i]); - } - } - }; - function errorCallback(err) { - console.log("The following error occurred : " + err.name); - } +var radioScanCallback = +{ + onfrequencyfound: function(frequency) + { + console.log("A new frequency found: " + frequency); + }, + onfinished: function(frequencies) + { + console.log(frequencies.length + "frequencies found!"); + for (var i = 0; i < frequencies.length; i++) + { + console.log(i + ": " + frequencies[i]); + } + } +}; +function errorCallback(err) +{ + console.log("The following error occurred: " + err.name); +} - if(radioState == "READY") { - tizen.fmradio.scanStart(radioScanCallback, errorCallback); - } -+if (radioState == "READY") +{ + tizen.fmradio.scanStart(radioScanCallback, errorCallback); +} +
Code example:
var radioState = tizen.fmradio.state; +Code example:
+var radioState = tizen.fmradio.state; - function successCallback() { - console.log("The scanning stops"); - } - function errorCallback(err) { - console.log("The following error occurred : " + err.name); - } +function successCallback() +{ + console.log("The scanning stops"); +} +function errorCallback(err) +{ + console.log("The following error occurred: " + err.name); +} - if (radioState == "SCANNING") { - tizen.fmradio.scanStop(successCallback, errorCallback); - } -+if (radioState == "SCANNING") +{ + tizen.fmradio.scanStop(successCallback, errorCallback); +} +
Code example:
var interruptCallback = { - oninterrupted: function(reason) { - console.log(reason); - }, - oninterruptfinished: function() { - console.log("The radio interruption finished."); - } - }; - tizen.fmradio.setFMRadioInterruptedListener(interruptCallback); -+
Code example:
+var interruptCallback = +{ + oninterrupted: function(reason) + { + console.log(reason); + }, + oninterruptfinished: function() + { + console.log("The radio interruption finished."); + } +}; +tizen.fmradio.setFMRadioInterruptedListener(interruptCallback); +
Code example:
tizen.fmradio.unsetFMRadioInterruptListener(); -+
Code example:
+tizen.fmradio.unsetFMRadioInterruptListener(); +
Code example:
function antennaCallback(isAntennaConnected) { - alert("Antenna status has been changed. It is now " + (isAntennaConnected ? "connected" : "disconnected")); - } - tizen.fmradio.setAntennaChangeListener(antennaCallback); -+
Code example:
+function antennaCallback(isAntennaConnected) +{ + alert("Antenna status has been changed. It is now " + (isAntennaConnected ? "connected" : "disconnected")); +} +tizen.fmradio.setAntennaChangeListener(antennaCallback); +
Code example:
// When you don't want to detect a change in the antenna status - tizen.fmradio.unsetAntennaChangeListener(); -+
Code example:
+/* When you don't want to detect a change in the antenna status */ +tizen.fmradio.unsetAntennaChangeListener(); +
Code example:
function onchangedCB(sleepInfo) { - console.log("Sleep status : " + sleepInfo.status); - console.log("Timestamp : " + sleepInfo.timestamp); - } - - tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB); -+
Code example:
+function onchangedCB(sleepInfo) +{ + console.log("Sleep status: " + sleepInfo.status); + console.log("Timestamp: " + sleepInfo.timestamp); +} + +tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB); +
Output example:
Sleep status : ASLEEP - Timestamp : 1456735296123 +Output example:
Sleep status: ASLEEP + Timestamp: 1456735296123
Code example:
function onsuccessCB(pedometerInfo) { - console.log("Step status : " + pedometerInfo.stepStatus); - console.log("Cumulative total step count : " + pedometerInfo.cumulativeTotalStepCount); - } - - function onerrorCB(error) { - console.log("Error occurs. name:"+error.name + ", message: "+error.message); - } - - function onchangedCB(pedometerdata) { - console.log("From now on, you will be notified when the pedometer data changes."); - // To get the current data information - tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB); - } - - tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB); -+
Code example:
+function onsuccessCB(pedometerInfo) +{ + console.log("Step status: " + pedometerInfo.stepStatus); + console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount); +} + +function onerrorCB(error) +{ + console.log("Error occurs. name:" + error.name + ", message: " + error.message); +} + +function onchangedCB(pedometerdata) +{ + console.log("From now on, you will be notified when the pedometer data changes."); + /* To get the current data information */ + tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB); +} + +tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB); +
Output example:
From now on, you will be notified when the pedometer data changes. - Step status : WALKING - Cumulative total step count : 100 + Step status: WALKING + Cumulative total step count: 100
Code example:
function onchangedCB(pedometerInfo) { - console.log("Step status : " + pedometerInfo.stepStatus); - console.log("Cumulative total step count : " + pedometerInfo.cumulativeTotalStepCount); - } - - tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB); -+
Code example:
+function onchangedCB(pedometerInfo) +{ + console.log("Step status: " + pedometerInfo.stepStatus); + console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount); +} + +tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB); +
Output example:
Step status : WALKING - Cumulative total step count : 100 +Output example:
Step status: WALKING + Cumulative total step count: 100
Code example:
function onchangedCB(info) { - var gpsInfo = info.gpsInfo; - for (var index = 0; index < gpsInfo.length; index++) { - console.log("latitude: " + gpsInfo[index].latitude); - console.log("longitude: " + gpsInfo[index].longitude); - } - } - - function onerrorCB(error) { - console.log("Error occurred. Name:" + error.name + ", message: " + error.message); - } - - try { - tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, {callbackInterval: 150000, sampleInterval: 1000}); - } catch(err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+function onchangedCB(info) +{ + var gpsInfo = info.gpsInfo; + for (var index = 0; index < gpsInfo.length; index++) + { + console.log("latitude: " + gpsInfo[index].latitude); + console.log("longitude: " + gpsInfo[index].longitude); + } +} + +function onerrorCB(error) +{ + console.log("Error occurred. Name:" + error.name + ", message: " + error.message); +} + +try +{ + tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, {callbackInterval: 150000, sampleInterval: 1000}); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
tizen.humanactivitymonitor.stop("PEDOMETER"); -+
Code example:
+tizen.humanactivitymonitor.stop("PEDOMETER"); +
Code example:
function onchangedCB(pedometerInfo) { - console.log("Step status : " + pedometerInfo.stepStatus); - console.log("Accumulative total step count : " + pedometerInfo.accumulativeTotalStepCount); - } - - tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB); -+
Code example:
+function onchangedCB(pedometerInfo) +{ + console.log("Step status: " + pedometerInfo.stepStatus); + console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount); +} + +tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB); +
Output example:
Step status : WALKING - Accumulative total step count : 100 +Output example:
Step status: WALKING + Accumulative total step count: 100
Code example:
tizen.humanactivitymonitor.unsetAccumulativePedometerListener(); -+
Code example:
tizen.humanactivitymonitor.unsetAccumulativePedometerListener(); +
Code example:
function errorCallback(error) { - console.log (error.name +': ' + error.message); - } - - function listener(info) { - console.log('type: ' + info.type); - console.log('timestamp: ' + info.timestamp); - console.log('accuracy: ' + info.accuracy); - } - - try { - var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); - } catch (error) { - console.log (error.name +': ' + error.message); - } -+
Code example:
+function errorCallback(error) +{ + console.log(error.name + ': ' + error.message); +} + +function listener(info) +{ + console.log('type: ' + info.type); + console.log('timestamp: ' + info.timestamp); + console.log('accuracy: ' + info.accuracy); +} + +try +{ + var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); +} +catch (error) +{ + console.log(error.name + ': ' + error.message); +} +
Output example:
type: WALKING @@ -855,26 +879,32 @@ The ErrorCallback method is launched with this error type:
Code example:
var listenerId; - - function errorCallback(error) { - console.log (error.name +': ' + error.message); - } - - function listener(info) { - console.log('type: ' + info.type); - console.log('timestamp: ' + info.timestamp); - console.log('accuracy: ' + info.accuracy); - - tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback); - } - - try { - listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); - } catch (error) { - console.log (error.name +': ' + error.message); - } -+
Code example:
+var listenerId; + +function errorCallback(error) +{ + console.log(error.name + ': ' + error.message); +} + +function listener(info) +{ + console.log('type: ' + info.type); + console.log('timestamp: ' + info.timestamp); + console.log('accuracy: ' + info.accuracy); + + tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback); +} + +try +{ + listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); +} +catch (error) +{ + console.log(error.name + ': ' + error.message); +} +
Output example:
type: WALKING diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/inputdevice.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/inputdevice.html index 41c29bf..e59d4ed 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/inputdevice.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/inputdevice.html @@ -215,22 +215,26 @@ Mandatory keys will not be retrieved by this method.
Code example:
var i, keyCode = {}, supportedKeys; - supportedKeys = tizen.inputdevice.getSupportedKeys(); - for (i = 0; i < supportedKeys.length; i++) { - keyCode[supportedKeys[i].name] = supportedKeys[i].code; - } - if(keyCode.hasOwnProperty("VolumeUp")) { - tizen.inputdevice.registerKey("VolumeUp"); - } - window.addEventListener("keydown", function(keyEvent) { - // identify the key by the numeric code from the keyEvent - if(keyEvent.keyCode === keyCode.VolumeUp) { - console.log("The VOLUME UP was pressed"); - } - }); - -+
Code example:
+var i, keyCode = {}, supportedKeys; +supportedKeys = tizen.inputdevice.getSupportedKeys(); +for (i = 0; i < supportedKeys.length; i++) +{ + keyCode[supportedKeys[i].name] = supportedKeys[i].code; +} +if (keyCode.hasOwnProperty("VolumeUp")) +{ + tizen.inputdevice.registerKey("VolumeUp"); +} +window.addEventListener("keydown", function(keyEvent) +{ + /* Identify the key by the numeric code from the keyEvent */ + if (keyEvent.keyCode === keyCode.VolumeUp) + { + console.log("The VOLUME UP was pressed"); + } +}); +
Code example:
var keys = ["VolumeUp", "VolumeDown"], i; - for (i = 0; i < keys.length; i++) { - try { - tizen.inputdevice.registerKey(keys[i]); - } catch(error) { - console.log("failed to register " + keys[i] + ": " + error); - } - } -+
Code example:
+var keys = ["VolumeUp", "VolumeDown"], i; +for (i = 0; i < keys.length; i++) +{ + try + { + tizen.inputdevice.registerKey(keys[i]); + } + catch (error) + { + console.log("failed to register " + keys[i] + ": " + error); + } +} +
Code example:
tizen.inputdevice.unregisterKey("VolumeDown"); -+
Code example:
+tizen.inputdevice.unregisterKey("VolumeDown"); +
Code example:
function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } +Code example:
+function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} - function successCB() { - console.log('Registsered successfully'); - } +function successCB() +{ + console.log('Registered successfully'); +} - var keys = ["VolumeUp", "VolumeDown"]; - tizen.inputdevice.registerKeyBatch(keys, successCB, errorCB); -+var keys = ["VolumeUp", "VolumeDown"]; +tizen.inputdevice.registerKeyBatch(keys, successCB, errorCB); +
Code example:
function errorCB(err) { - console.log( 'The following error occurred: ' + err.name); - } +Code example:
+function errorCB(err) +{ + console.log('The following error occurred: ' + err.name); +} + +function successCB() +{ + console.log('Unregistsered successfully'); +} - function successCB() { - console.log('Unregistsered successfully'); - } - var keys = ["VolumeUp", "VolumeDown"]; - tizen.inputdevice.unregisterKeyBatch(keys, successCB, errorCB); -+var keys = ["VolumeUp", "VolumeDown"]; +tizen.inputdevice.unregisterKeyBatch(keys, successCB, errorCB); +
Code example:
var data_name = "data1", raw_data = "my data"; +Code example:
+var data_name = "data1", raw_data = "my data"; - function onSave() { - console.log("Successfully saved data"); - } +function onSave() +{ + console.log("Successfully saved data"); +} - tizen.keymanager.saveData(data_name, raw_data, null, onSave); -+tizen.keymanager.saveData(data_name, raw_data, null, onSave); +
Code example:
var data_name = "data1", raw_data = "my data"; - - function onSave() { - - // do something - - // Dictionary does not require package ID because the - // application which is calling removeData() saved "data1" - tizen.keymanager.removeData({ - "name": data_name - }); - } - - tizen.keymanager.saveData(data_name, raw_data, null, onSave); -+
Code example:
+var data_name = "data1", raw_data = "my data"; + +function onSave() +{ + /* Do something */ + + /* + Dictionary does not require package ID because the + application which is calling removeData() saved "data1" + */ + tizen.keymanager.removeData({"name": data_name}); +} + +tizen.keymanager.saveData(data_name, raw_data, null, onSave); +
Code example:
var aliases = tizen.keymanager.getDataAliasList(); - - if (aliases.length != 0) { - // Assuming the application calling removeData() has permission - // to remove aliases[0] - var app_data = tizen.keymanager.removeData(aliases[0]); - } -+
Code example:
+var aliases = tizen.keymanager.getDataAliasList(); + +if (aliases.length != 0) +{ + /* + Assuming the application calling removeData() has permission + to remove aliases[0] + */ + var app_data = tizen.keymanager.removeData(aliases[0]); +} +
Code example:
var data_name = "data1", raw_data = "my data"; - - function onSave() { - // Dictionary does not require package ID because the - // application which is calling getData() saved "data1" - var app_data = tizen.keymanager.getData({ - "name": data_name - }); - console.log("App data: " + app_data + " was retrieved"); - } - - tizen.keymanager.saveData(data_name, raw_data, null, onSave); -+
Code example:
+var data_name = "data1", raw_data = "my data"; + +function onSave() +{ + /* + Dictionary does not require package ID because the + application which is calling getData() saved "data1" + */ + var app_data = tizen.keymanager.getData({"name": data_name}); + console.log("App data: " + app_data + " was retrieved"); +} + +tizen.keymanager.saveData(data_name, raw_data, null, onSave); +
Code example:
var aliases = tizen.keymanager.getDataAliasList(); - - if (aliases.length != 0) { - // Assuming the application calling getData() has permission to read - // aliases[0] - var app_data = tizen.keymanager.getData(aliases[0]); - console.log("App data: " + app_data + " was retrieved"); - } -+
Code example:
+var aliases = tizen.keymanager.getDataAliasList(); + +if (aliases.length != 0) +{ + /* + Assuming the application calling getData() has permission to read + aliases[0] + */ + var app_data = tizen.keymanager.getData(aliases[0]); + console.log("App data: " + app_data + " was retrieved"); +} +
Code example:
var aliases = tizen.keymanager.getDataAliasList(); - - console.log("aliases: "); - for (var i = 0; i < aliases.length; i++) { - console.log("Package ID: " + aliases[i].packageId + ", Name: " - + aliases[i].name); - } -+
Code example:
+var aliases = tizen.keymanager.getDataAliasList(); + +console.log("aliases: "); +for (var i = 0; i < aliases.length; i++) +{ + console.log("Package ID: " + aliases[i].packageId + ", Name: " + + aliases[i].name); +} +
Code example:
var data_name = "data1", raw_data = "my data"; - - function onPermissionSet() { - console.log("Successfully set permssion"); - } - - function onSave() { - // Dictionary does not require package ID because an - // application can only set permission for data which it saved - tizen.keymanager.setPermission({ - "name": data_name - }, "9PdoiICQ4c", "READ_REMOVE", onPermissionSet); - } - - tizen.keymanager.saveData(data_name, raw_data, null, onSave); -+
Code example:
+var data_name = "data1", raw_data = "my data"; + +function onPermissionSet() +{ + console.log("Successfully set permission"); +} + +function onSave() +{ + /* + Dictionary does not require package ID because an + application can only set permission for data which it saved + */ + tizen.keymanager.setPermission({"name": data_name}, "9PdoiICQ4c", "READ_REMOVE", + onPermissionSet); +} + +tizen.keymanager.saveData(data_name, raw_data, null, onSave); +
Code example:
var aliases = tizen.keymanager.getDataAliasList(); - - function onPermissionSet() { - console.log("Successfully set permssion"); - } - - if (aliases.length != 0) { - // Check that the application calling setPermission() saved aliases[0] into - // the KeyManager - if (aliases[0].packageId === tizen.package.getPackageInfo().id) { - tizen.keymanager.setPermission(aliases[0], "9PdoiICQ4c", "READ_REMOVE", - onPermissionSet); - } else { - console.log("This application did not save aliases[0] into the KeyManager"); - } - } -+
Code example:
+var aliases = tizen.keymanager.getDataAliasList(); + +function onPermissionSet() +{ + console.log("Successfully set permssion"); +} + +if (aliases.length != 0) +{ + /* + Check that the application calling setPermission() saved aliases[0] into + the KeyManager + */ + if (aliases[0].packageId === tizen.package.getPackageInfo().id) + { + tizen.keymanager.setPermission(aliases[0], "9PdoiICQ4c", "READ_REMOVE", + onPermissionSet); + } + else + { + console.log("This application did not save aliases[0] into the KeyManager"); + } +} +
Code example:
try { - var mcClient = tizen.mediacontroller.getClient(); - } catch (err) { - console.log (err.name +': ' + err.message); - } -+
Code example:
+try +{ + var mcClient = tizen.mediacontroller.getClient(); +} +catch (err) +{ + console.log(err.name + ': ' + err.message); +} +
Code example:
try { - var mcServer = tizen.mediacontroller.createServer(); - } catch (err) { - console.log (err.name +': ' + err.message); - } -+
Code example:
+try +{ + var mcServer = tizen.mediacontroller.createServer(); +} +catch (err) +{ + console.log(err.name + ': ' + err.message); +} +
Code example:
var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var mcServer = tizen.mediacontroller.createServer(); - mcServer.updatePlaybackState('PLAY'); - console.log('Current playback state is: ' + mcServer.playbackInfo.state); -+mcServer.updatePlaybackState('PLAY'); +console.log('Current playback state is: ' + mcServer.playbackInfo.state); +
Code example:
var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var mcServer = tizen.mediacontroller.createServer(); - mcServer.updatePlaybackPosition(164); - console.log('Current playback position is: ' + mcServer.playbackInfo.position); -+mcServer.updatePlaybackPosition(164); +console.log('Current playback position is: ' + mcServer.playbackInfo.position); +
Code example:
var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var mcServer = tizen.mediacontroller.createServer(); - mcServer.updateShuffleMode(true); - console.log('Current shuffle mode is: ' + mcServer.playbackInfo.shuffleMode); -+mcServer.updateShuffleMode(true); +console.log('Current shuffle mode is: ' + mcServer.playbackInfo.shuffleMode); +
Code example:
var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var mcServer = tizen.mediacontroller.createServer(); - mcServer.updateRepeatMode(true); - console.log('Current repeat mode is: ' + mcServer.playbackInfo.repeatMode); -+mcServer.updateRepeatMode(true); +console.log('Current repeat mode is: ' + mcServer.playbackInfo.repeatMode); +
Code example:
var mcServer = tizen.mediacontroller.createServer(); - var metadata = mcServer.playbackInfo.metadata; +Code example:
+var mcServer = tizen.mediacontroller.createServer(); +var metadata = mcServer.playbackInfo.metadata; - metadata.artist = 'Artist Name'; - mcServer.updateMetadata(metadata); +metadata.artist = 'Artist Name'; +mcServer.updateMetadata(metadata); - console.log('Current metadata is: ' + JSON.stringify(mcServer.playbackInfo.metadata)); -+console.log('Current metadata is: ' + JSON.stringify(mcServer.playbackInfo.metadata)); +
Code example:
var watcherId = 0; // watcher identifier - var mcServer = tizen.mediacontroller.createServer(); - - var playbackRequestListener = { - onplaybackstaterequest: function(state) { - console.log('Playback state requested to: ' + state); - }, - onplaybackpositionrequest: function(position) { - console.log('Playback position requested to: ' + position); - }, - onshufflemoderequest: function(mode) { - console.log('Shuffle mode requested to: ' + mode); - }, - onrepeatmoderequest: function(mode) { - console.log('Repeat mode requested to: ' + mode); - } - }; - - // Registers to receive playback info change requests from client. - watcherId = mcServer.addChangeRequestPlaybackInfoListener(playbackRequestListener); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcServer = tizen.mediacontroller.createServer(); + +var playbackRequestListener = +{ + onplaybackstaterequest: function(state) + { + console.log('Playback state requested to: ' + state); + }, + onplaybackpositionrequest: function(position) + { + console.log('Playback position requested to: ' + position); + }, + onshufflemoderequest: function(mode) + { + console.log('Shuffle mode requested to: ' + mode); + }, + onrepeatmoderequest: function(mode) + { + console.log('Repeat mode requested to: ' + mode); + } +}; + +/* Registers to receive playback info change requests from client */ +watcherId = mcServer.addChangeRequestPlaybackInfoListener(playbackRequestListener); +
Code example:
var watcherId = 0; // watcher identifier - var mcServer = tizen.mediacontroller.createServer(); - - var playbackRequestListener = { - onplaybackstaterequest: function(state) { - console.log('Playback state requested to: ' + state); - }, - onplaybackpositionrequest: function(position) { - console.log('Playback position requested to: ' + position); - }, - onshufflemoderequest: function(mode) { - console.log('Shuffle mode requested to: ' + mode); - }, - onrepeatmoderequest: function(mode) { - console.log('Repeat mode requested to: ' + mode); - } - }; - - // Registers to receive playback info change requests. - watcherId = mcServer.addChangeRequestPlaybackInfoListener(playbackRequestListener); - - // Cancels the watch operation. - mcServer.removeChangeRequestPlaybackInfoListener(watcherId); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcServer = tizen.mediacontroller.createServer(); + +var playbackRequestListener = +{ + onplaybackstaterequest: function(state) + { + console.log('Playback state requested to: ' + state); + }, + onplaybackpositionrequest: function(position) + { + console.log('Playback position requested to: ' + position); + }, + onshufflemoderequest: function(mode) + { + console.log('Shuffle mode requested to: ' + mode); + }, + onrepeatmoderequest: function(mode) + { + console.log('Repeat mode requested to: ' + mode); + } +}; + +/* Registers to receive playback info change requests */ +watcherId = mcServer.addChangeRequestPlaybackInfoListener(playbackRequestListener); + +/* Cancels the watch operation */ +mcServer.removeChangeRequestPlaybackInfoListener(watcherId); +
Code example:
var watcherId = 0; // watcher identifier - var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcServer = tizen.mediacontroller.createServer(); - var commandReceiveListener = function(clientName, command, data) { - console.log('Command ' + command + ' received from: ' + clientName + - ' with data: ' + JSON.stringify(data)); +var commandReceiveListener = function(clientName, command, data) +{ + console.log('Command ' + command + ' received from: ' + clientName + + ' with data: ' + JSON.stringify(data)); - var reply = { - myReply: 'someValue' - }; + var reply = {myReply: 'someValue'}; - return reply; - }; + return reply; +}; - // Registers to receive custom commands from client. - watcherId = mcServer.addCommandListener(commandReceiveListener); -+/* Registers to receive custom commands from client */ +watcherId = mcServer.addCommandListener(commandReceiveListener); +
Code example:
var watcherId = 0; // watcher identifier - var mcServer = tizen.mediacontroller.createServer(); +Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcServer = tizen.mediacontroller.createServer(); - var commandReceiveListener = function(clientName, command, data) { - console.log('Command ' + command + ' received from: ' + clientName + - ' with data: ' + JSON.stringify(data)); +var commandReceiveListener = function(clientName, command, data) +{ + console.log('Command ' + command + ' received from: ' + clientName + + ' with data: ' + JSON.stringify(data)); - var reply = { - myReply: 'someValue' - }; + var reply = {myReply: 'someValue'}; - return reply; - }; + return reply; +}; - // Registers to receive custom commands from client. - watcherId = mcServer.addCommandListener(commandReceiveListener); +/* Registers to receive custom commands from client */ +watcherId = mcServer.addCommandListener(commandReceiveListener); - // Cancels the watch operation. - mcServer.removeCommandListener(watcherId); -+/* Cancels the watch operation */ +mcServer.removeCommandListener(watcherId); +
Code example:
// Access latest server info - var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - console.log('Latest server name is: ' + mcServerInfo.name + - ', server state: ' + mcServerInfo.name); -+
Code example:
+/* Access latest server info */ +var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); +console.log('Latest server name is: ' + mcServerInfo.name + + ', server state: ' + mcServerInfo.name); +
Code example:
var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - mcServerInfo.sendPlaybackState('STOP', function() { - console.log('Playback has stopped'); - }, function(e) { - console.log('Unable to change playback state: ' + e.message); - }); -+
Code example:
+var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +mcServerInfo.sendPlaybackState('STOP', function() +{ + console.log('Playback has stopped'); +}, function(e) +{ + console.log('Unable to change playback state: ' + e.message); +}); +
Code example:
var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - mcServerInfo.sendPlaybackPosition(164, function() { - console.log('Playback position changed'); - }, function(e) { - console.log('Unable to change playback position: ' + e.message); - }); -+
Code example:
+var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +mcServerInfo.sendPlaybackPosition(164, function() +{ + console.log('Playback position changed'); +}, function(e) +{ + console.log('Unable to change playback position: ' + e.message); +}); +
Code example:
var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - mcServerInfo.sendShuffleMode(true, function() { - console.log('Shuffle mode changed'); - }, function(e) { - console.log('Unable to change shuffle mode: ' + e.message); - }); -+
Code example:
+var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +mcServerInfo.sendShuffleMode(true, function() +{ + console.log('Shuffle mode changed'); +}, function(e) +{ + console.log('Unable to change shuffle mode: ' + e.message); +}); +
Code example:
var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - mcServerInfo.sendRepeatMode(false, function() { - console.log('Repeat mode changed'); - }, function(e) { - console.log('Unable to change repeat mode: ' + e.message); - }); -+
Code example:
+var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +mcServerInfo.sendRepeatMode(false, function() +{ + console.log('Repeat mode changed'); +}, function(e) +{ + console.log('Unable to change repeat mode: ' + e.message); +}); +
Code example:
var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - var exampleCustomCommandData = { - myFilter: 'rock' - }; - mcServerInfo.sendCommand('myPlaylistFilter', exampleCustomCommandData, function(response) { - console.log('Command executed with result: ' + JSON.stringify(response)); - }, function(e) { - console.log('Error executing command: ' + e.message); - }); -+
Code example:
+var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +var exampleCustomCommandData = {myFilter: 'rock'}; + +mcServerInfo.sendCommand('myPlaylistFilter', exampleCustomCommandData, function(response) +{ + console.log('Command executed with result: ' + JSON.stringify(response)); +}, function(e) +{ + console.log('Error executing command: ' + e.message); +}); +
Code example:
var watcherId = 0; // watcher identifier - var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - // Registers to be notified when server status changes. - watcherId = mcServerInfo.addServerStatusChangeListener(function(status) { - console.log(mcServerInfo.name + ' server status changed to ' + status); - }); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +/* Registers to be notified when server status changes */ +watcherId = mcServerInfo.addServerStatusChangeListener(function(status) +{ + console.log(mcServerInfo.name + ' server status changed to ' + status); +}); +
Code example:
var watcherId = 0; // watcher identifier - var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); +Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); - // Registers to be notified when server status changes. - watcherId = mcServerInfo.addServerStatusChangeListener(function(status) { - console.log(mcServerInfo.name + ' server status changed to ' + status); - }); +/* Registers to be notified when server status changes */ +watcherId = mcServerInfo.addServerStatusChangeListener(function(status) +{ + console.log(mcServerInfo.name + ' server status changed to ' + status); +}); - // Cancels the watch operation. - mcServerInfo.removeServerStatusChangeListener(watcherId); -+/* Cancels the watch operation */ +mcServerInfo.removeServerStatusChangeListener(watcherId); +
Code example:
var watcherId = 0; // watcher identifier - var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - var playbackListener = { - onplaybackchanged: function(state, position) { - console.log('Current playback state: ' + state); - console.log('Current playback position: ' + position); - }, - onshufflemodechanged: function(mode) { - console.log('Shuffle mode changed to: ' + mode); - }, - onrepeatmodechanged: function(mode) { - console.log('Repeat mode changed to: ' + mode); - }, - onmetadatachanged: function(metadata) { - console.log('Playback metadata changed: ' + JSON.stringify(metadata)); - } - }; - - // Registers to be notified when playback state changes. - watcherId = mcServerInfo.addPlaybackInfoChangeListener(playbackListener); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +var playbackListener = +{ + onplaybackchanged: function(state, position) + { + console.log('Current playback state: ' + state); + console.log('Current playback position: ' + position); + }, + onshufflemodechanged: function(mode) + { + console.log('Shuffle mode changed to: ' + mode); + }, + onrepeatmodechanged: function(mode) + { + console.log('Repeat mode changed to: ' + mode); + }, + onmetadatachanged: function(metadata) + { + console.log('Playback metadata changed: ' + JSON.stringify(metadata)); + } +}; + +/* Registers to be notified when playback state changes */ +watcherId = mcServerInfo.addPlaybackInfoChangeListener(playbackListener); +
Code example:
var watcherId = 0; // watcher identifier - var mcClient = tizen.mediacontroller.getClient(); - var mcServerInfo = mcClient.getLatestServerInfo(); - - // receives playback state changes - var playbackListener = { - onplaybackchanged: function(state, position) { - console.log('Current playback state: ' + state); - console.log('Current playback position: ' + position); - }, - onshufflemodechanged: function(mode) { - console.log('Shuffle mode changed to: ' + mode); - }, - onrepeatmodechanged: function(mode) { - console.log('Repeat mode changed to: ' + mode); - }, - onmetadatachanged: function(metadata) { - console.log('Playback metadata changed: ' + JSON.stringify(metadata)); - } - }; - - // Registers to be notified when playback state changes. - watcherId = mcServerInfo.addPlaybackInfoChangeListener(playbackListener); - - // Cancels the watch operation. - mcServerInfo.removePlaybackInfoChangeListener(watcherId); -+
Code example:
+var watcherId = 0; /* Watcher identifier */ +var mcClient = tizen.mediacontroller.getClient(); +var mcServerInfo = mcClient.getLatestServerInfo(); + +/* Receives playback state changes */ +var playbackListener = +{ + onplaybackchanged: function(state, position) + { + console.log('Current playback state: ' + state); + console.log('Current playback position: ' + position); + }, + onshufflemodechanged: function(mode) + { + console.log('Shuffle mode changed to: ' + mode); + }, + onrepeatmodechanged: function(mode) + { + console.log('Repeat mode changed to: ' + mode); + }, + onmetadatachanged: function(metadata) + { + console.log('Playback metadata changed: ' + JSON.stringify(metadata)); + } +}; + +/* Registers to be notified when playback state changes */ +watcherId = mcServerInfo.addPlaybackInfoChangeListener(playbackListener); + +/* Cancels the watch operation */ +mcServerInfo.removePlaybackInfoChangeListener(watcherId); +
Code example:
tizen.mediakey.setMediaKeyEventListener({ - onpressed: function(key) { - console.log("Pressed key: " + key); - }, - onreleased: function(key) { - console.log("Released key: " + key); - } - }); -+
Code example:
+tizen.mediakey.setMediaKeyEventListener( +{ + onpressed: function(key) + { + console.log("Pressed key: " + key); + }, + onreleased: function(key) + { + console.log("Released key: " + key); + } +}); +
Code example:
tizen.mediakey.unsetMediaKeyEventListener(); -+
Code example:
+tizen.mediakey.unsetMediaKeyEventListener(); +
Code example:
// Requests the LocalMessagePort instance with the specified message port name - var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); -+
Code example:
+/* Requests the LocalMessagePort instance with the specified message port name */ +var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); +
Code example:
// Requests the LocalMessagePort instance with the specified message port name - var localMsgPort = tizen.messageport.requestTrustedLocalMessagePort('MessagePortB'); -+
Code example:
+/* Requests the LocalMessagePort instance with the specified message port name */ +var localMsgPort = tizen.messageport.requestTrustedLocalMessagePort('MessagePortB'); +
Code example:
// Requests the RemoteMessagePort instance with the specified message port name - var remoteMsgPort = tizen.messageport.requestRemoteMessagePort('6xaeuflskd.App1', 'MessagePortA'); -+
Code example:
+/* Requests the RemoteMessagePort instance with the specified message port name */ +var remoteMsgPort = tizen.messageport.requestRemoteMessagePort('6xaeuflskd.App1', 'MessagePortA'); +
Code example:
// Requests the RemoteMessagePort instance with the specified message port name. - var remoteMsgPort = tizen.messageport.requestTrustedRemoteMessagePort('6xauflskd.App1', 'MessagePortB'); -+
Code example:
+/* Requests the RemoteMessagePort instance with the specified message port name */ +var remoteMsgPort = tizen.messageport.requestTrustedRemoteMessagePort('6xauflskd.App1', 'MessagePortB'); +
Code example:
function onreceived(data, remoteMsgPort) { - console.log('Received data to \'' + remoteMsgPort.messagePortName + '\''); - } +Code example:
+function onreceived(data, remoteMsgPort) +{ + console.log('Received data to \'' + remoteMsgPort.messagePortName + '\''); +} - var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); - var watchId = localMsgPort.addMessagePortListener(onreceived); -+var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); +var watchId = localMsgPort.addMessagePortListener(onreceived); +
Code example:
var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); - var watchId = localMsgPort.addMessagePortListener(onreceived); - // Communication routines of your app... - localMsgPort.removeMessagePortListener(watchId); -+
Code example:
+var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); +var watchId = localMsgPort.addMessagePortListener(onreceived); +/* Communication routines of your app */ + +localMsgPort.removeMessagePortListener(watchId); +
Code example:
// Sends string message - var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); - var remoteMsgPort = tizen.messageport.requestRemoteMessagePort('6xaeuflskd.App1', 'MessagePortB'); - localMsgPort.addMessagePortListener(function(items, remoteport) { - // ... - if(remoteport !== null) { - remoteport.sendMessage([{key:'RESULT', value:'OK'}]); - } - }); - // stream - FileStream object - var bytePockets = [], byteCount = 0, i = 0; - while(byteCount stream.bytesAvailable - 256) { - bytePockets[i] = stream.readBytes(256); - byteCount+=256; - i++; - } - bytePockets[i] = stream.readBytes(stream.bytesAvailable - byteCount); - - var messagePortPockets = [{key: "key1", value: "val1"}, - {key: "key2", value: ["val2", "val3", "val4"]}, - {key: "key3", value: bytePockets[0]}, - {key: "key4", value: bytePockets}]; - remoteMsgPort.sendMessage(messagePortPockets, localMsgPort); -+
Code example:
+/* Sends string message */ +var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); +var remoteMsgPort = tizen.messageport.requestRemoteMessagePort('6xaeuflskd.App1', 'MessagePortB'); +localMsgPort.addMessagePortListener(function(items, remoteport) +{ + /* ... */ + if (remoteport !== null) + { + remoteport.sendMessage([{key:'RESULT', value:'OK'}]); + } +}); +/* stream - FileStream object */ +var bytePockets = [], byteCount = 0, i = 0; +while (byteCount < stream.bytesAvailable - 256) +{ + bytePockets[i] = stream.readBytes(256); + byteCount+=256; + i++; +} +bytePockets[i] = stream.readBytes(stream.bytesAvailable - byteCount); + +var messagePortPockets = [{key: "key1", value: "val1"}, + {key: "key2", value: ["val2", "val3", "val4"]}, + {key: "key3", value: bytePockets[0]}, + {key: "key4", value: bytePockets}]; +remoteMsgPort.sendMessage(messagePortPockets, localMsgPort); +
Code example:
// MessagePortCallback instance - function onreceived(data, remoteMsgPort) { - console.log('Received data to \'' + remoteMsgPort.messagePortName + '\''); - } - - var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); - var watchId = localMsgPort.addMessagePortListener(onreceived); -+
Code example:
+/* MessagePortCallback instance */ +function onreceived(data, remoteMsgPort) +{ + console.log('Received data to \'' + remoteMsgPort.messagePortName + '\''); +} + +var localMsgPort = tizen.messageport.requestLocalMessagePort('MessagePortA'); +var watchId = localMsgPort.addMessagePortListener(onreceived); +
Code example:
// Defines the success callback. - var messageSentCallback = function(recipients) { - console.log("Message sent successfully to " + recipients.length + " recipients."); - } - - // Defines the error callback. - function errorCallback(err) { - console.log(err.name + " error: " + err.message); - } - - function serviceListCB(services) { - if (services.length > 0) { - var msg = new tizen.Message("messaging.sms", {plainBody: "Tizen first SMS message."}); - services[0].sendMessage(msg, messageSentCallback, errorCallback); - } - } - - tizen.messaging.getMessageServices("messaging.sms", - serviceListCB, - errorCallback); -+
Code example:
+/* Defines the success callback */ +var messageSentCallback = function(recipients) +{ + console.log("Message sent successfully to " + recipients.length + " recipients."); +} + +/* Defines the error callback */ +function errorCallback(err) +{ + console.log(err.name + " error: " + err.message); +} + +function serviceListCB(services) +{ + if (services.length > 0) + { + var msg = new tizen.Message("messaging.sms", {plainBody: "Tizen first SMS message."}); + services[0].sendMessage(msg, messageSentCallback, errorCallback); + } +} + +tizen.messaging.getMessageServices("messaging.sms", serviceListCB, errorCallback); +
Code example:
// Define the success callback. - function serviceListCB(services) { - if (services.length > 0) { - var msg = new tizen.Message("messaging.email"); - msg.attachments = [new tizen.MessageAttachment("images/myimage.png", "image/png"), - new tizen.MessageAttachment("documents/mydoc.pdf", "text/pdf")]; - } - } - - tizen.messaging.getMessageServices("messaging.email", serviceListCB); - -+
Code example:
+/* Define the success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + var msg = new tizen.Message("messaging.email"); + msg.attachments = [new tizen.MessageAttachment("images/myimage.png", "image/png"), + new tizen.MessageAttachment("documents/mydoc.pdf", "text/pdf")]; + } +} + +tizen.messaging.getMessageServices("messaging.email", serviceListCB); +
Code example:
// Defines the success callback. - function serviceListCB(services) { - if (services.length > 0) { - var msg = new tizen.Message("messaging.email"); - msg.body.htmlBody = "<html><body><img src='myimage.png'></body></html>"; - msg.body.inlineAttachments = [new tizen.MessageAttachment("images/myimage.png")]; - } - } - - tizen.messaging.getMessageServices("messaging.email", serviceListCB); - -+
Code example:
+/* Defines the success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + var msg = new tizen.Message("messaging.email"); + msg.body.htmlBody = "<html><body><img src='myimage.png'></body></html>"; + msg.body.inlineAttachments = [new tizen.MessageAttachment("images/myimage.png")]; + } +} + +tizen.messaging.getMessageServices("messaging.email", serviceListCB); +
Code example:
// Defines the success callback. - function serviceListCB(services) { - if (services.length > 0) { - var msg = new tizen.Message("messaging.sms"); - } - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot get messaging service " + error.message); - } - - tizen.messaging.getMessageServices("messaging.sms", serviceListCB, - errorCallback); -+
Code example:
+/* Defines the success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + var msg = new tizen.Message("messaging.sms"); + } +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot get messaging service " + error.message); +} + +tizen.messaging.getMessageServices("messaging.sms", serviceListCB, + errorCallback); +
Code example:
// Defines the error callback. - function errorCallback(error) { - console.log("Cannot get messaging service " + error.message); - } - - // Defines the success callback. - function serviceListCB(services) { - console.log("Found " + services.length + "email services"); - } - - tizen.messaging.getMessageServices("messaging.email", serviceListCB, - errorCallback); -+
Code example:
+/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot get messaging service " + error.message); +} + +/* Defines the success callback */ +function serviceListCB(services) +{ + console.log("Found " + services.length + "email services"); +} + +tizen.messaging.getMessageServices("messaging.email", serviceListCB, + errorCallback); +
Code example:
// Defines the success callback. - function messageSent(recipients) { - console.log("The SMS has been sent"); - } - - // Defines the error callback. - function messageFailed(error) { - console.log("The SMS could not be sent " + error.message); - } - - // Defines the service error callback. - function serviceErrorCB(error) { - console.log("Cannot get messaging service " + error.message); - } - - // Defines the success callback. - function serviceListCB(services) { - if (services.length > 0) { - // SMS sending example - var msg = new tizen.Message("messaging.sms", {plainBody:"I will arrive in 10 minutes.", - to:["+34666666666"]}); - // Sends request - services[0].sendMessage(msg, messageSent, messageFailed); - } - } - - tizen.messaging.getMessageServices("messaging.sms", - serviceListCB, - serviceErrorCB); -+
Code example:
+/* Defines the success callback */ +function messageSent(recipients) +{ + console.log("The SMS has been sent"); +} + +/* Defines the error callback */ +function messageFailed(error) +{ + console.log("The SMS could not be sent " + error.message); +} + +/* Defines the service error callback */ +function serviceErrorCB(error) +{ + console.log("Cannot get messaging service " + error.message); +} + +/* Defines the success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + /* SMS sending example */ + var msg = new tizen.Message("messaging.sms", {plainBody:"I will arrive in 10 minutes.", + to:["+34666666666"]}); + /* Sends request */ + services[0].sendMessage(msg, messageSent, messageFailed); + } +} + +tizen.messaging.getMessageServices("messaging.sms", serviceListCB, serviceErrorCB); +
Code example:
// Defines the success callback - function messageSent(recipients) { - for (var i = 0; i < recipients.length; i++) { - console.log("The SMS has been sent to " + recipients[i]); - } - } - - // Defines the error callback. - function messageFailed(error) { - console.log("The SMS could not be sent " + error.message); - } - - // Defines the success callback. - function serviceListCB(services) { - if (services.length > 0) { - // SMS sending example - var msg = new tizen.Message("messaging.sms", {plainBody: "I will arrive in 10 minutes.", - to: ["+34666666666", "+34888888888"]}); - // Sends request - services[0].sendMessage(msg, messageSent, messageFailed); - } - } - tizen.messaging.getMessageServices("messaging.sms", serviceListCB); -+
Code example:
+/* Defines the success callback */ +function messageSent(recipients) +{ + for (var i = 0; i < recipients.length; i++) + { + console.log("The SMS has been sent to " + recipients[i]); + } +} + +/* Defines the error callback */ +function messageFailed(error) +{ + console.log("The SMS could not be sent " + error.message); +} + +/* Defines the success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + /* SMS sending example */ + var msg = new tizen.Message("messaging.sms", {plainBody: "I will arrive in 10 minutes.", + to: ["+34666666666", "+34888888888"]}); + /* Sends request */ + services[0].sendMessage(msg, messageSent, messageFailed); + } +} +tizen.messaging.getMessageServices("messaging.sms", serviceListCB); +
Code example:
// ********************************************************************************** +Code example:
+ // ********************************************************************************** // * This sample code works on a device which supports Tizen 2.3 Web Device API. * // ********************************************************************************** - // To get how many SIM cards are available in a device - var count = tizen.systeminfo.getCount("SIM"); - console.log("There is(are) " + count + " SIM card(s) available."); - - // To send a message via the last SIM - services[0].sendMessage(msg, messageSent, messageFailed, count); +/* To get how many SIM cards are available in a device */ +var count = tizen.systeminfo.getCount("SIM"); +console.log("There is(are) " + count + " SIM card(s) available."); -+/* To send a message via the last SIM */ +services[0].sendMessage(msg, messageSent, messageFailed, count); +
Code example:
// Assumes messaging service is initialized. - var service; - // Defines the success body loaded callback. - function successCallback(message) { - console.log ("body for message: " + message.subject + "from: " + message.from + "loaded."); - } - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot load message body" + error.message); - } - - function messageQueryCallback(messages) { - for (var i = 0; i < messages.length; i++) { - var message = messages[i]; - if (!message.body.loaded) { - service.loadMessageBody(message, successCallback, errorCallback); - } - } - } - - service.messageStorage.findMessages(new tizen.AttributeFilter("type", "EXACTLY", "messaging.email"), messageQueryCallback); -+
Code example:
+/* Assumes messaging service is initialized */ +var service; +/* Defines the success body loaded callback */ +function successCallback(message) +{ + console.log("body for message: " + message.subject + "from: " + message.from + "loaded."); +} +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot load message body" + error.message); +} + +function messageQueryCallback(messages) +{ + for (var i = 0; i < messages.length; i++) + { + var message = messages[i]; + if (!message.body.loaded) + { + service.loadMessageBody(message, successCallback, errorCallback); + } + } +} + +service.messageStorage.findMessages(new tizen.AttributeFilter("type", "EXACTLY", "messaging.email"), messageQueryCallback); +
Code example:
// Assumes messaging service is initialized. - var service; - // Defines the success body loaded callback. - function successCallback(attachment) { - console.log("attachment" + attachment.id + "is loaded to:" + attachment.filePath); - } - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot load message attachment" + error.message); - } - - function messagesFoundCB(messages) { - for (var i = 0; i < messages.length; i++) { - var message = messages[i]; - if (!message.attachments[0].loaded) { - service.loadMessageAttachment(message.attachments[0], successCallback, errorCallback); - } - } - } - - service.messageStorage.findMessages(new tizen.AttributeFilter("hasAttachment", "EXACTLY", true), messagesFoundCB); -+
Code example:
+/* Assumes messaging service is initialized */ +var service; +/* Defines the success body loaded callback */ +function successCallback(attachment) +{ + console.log("attachment" + attachment.id + "is loaded to:" + attachment.filePath); +} +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot load message attachment" + error.message); +} + +function messagesFoundCB(messages) +{ + for (var i = 0; i < messages.length; i++) + { + var message = messages[i]; + if (!message.attachments[0].loaded) + { + service.loadMessageAttachment(message.attachments[0], successCallback, errorCallback); + } + } +} + +service.messageStorage.findMessages(new tizen.AttributeFilter("hasAttachment", "EXACTLY", true), messagesFoundCB); +
Code example:
// Defines the success callback. - function serviceSynced() { +Code example:
+/* Defines the success callback */ +function serviceSynced() +{ console.log("New messages are fetched!"); - } +} - // Defines the success callback. - function servicesListSuccessCB(services) { +/* Defines the success callback */ +function servicesListSuccessCB(services) +{ services[0].sync(serviceSynced, null, 30); - // Subscribes to MessageStorage notification - } - tizen.messaging.getMessageServices("messaging.email", servicesListSuccessCB); -+ /* Subscribes to MessageStorage notification */ +} +tizen.messaging.getMessageServices("messaging.email", servicesListSuccessCB); +
Code example:
var emailService; // Assumes email service is initialized - // Defines the error callback. - function errorCallback(err) { - console.log(err.name + " error: " + err.message); - } - function serviceCallback(services) { - emailService = services[0]; - var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", emailService.id); - - emailService.messageStorage.findFolders(filter, folderQueryCallback); - } - - // Defines the success callback. - function folderSynced() { - console.log("New messages are fetched!"); - } - function folderQueryCallback(folders) { - console.log(folders.length + " folders(s) found!"); - for (var i = 0; i < folders.length; i++) { - emailService.syncFolder (folders[i], folderSynced, null, 30); - } - } - - tizen.messaging.getMessageServices("messaging.email", serviceCallback, errorCallback); -+
Code example:
+var emailService; /* Assumes email service is initialized */ +/* Defines the error callback */ +function errorCallback(err) +{ + console.log(err.name + " error: " + err.message); +} +function serviceCallback(services) +{ + emailService = services[0]; + var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", emailService.id); + + emailService.messageStorage.findFolders(filter, folderQueryCallback); +} + +/* Defines the success callback */ +function folderSynced() +{ + console.log("New messages are fetched!"); +} +function folderQueryCallback(folders) +{ + console.log(folders.length + " folders(s) found!"); + for (var i = 0; i < folders.length; i++) + { + emailService.syncFolder (folders[i], folderSynced, null, 30); + } +} + +tizen.messaging.getMessageServices("messaging.email", serviceCallback, errorCallback); +
Code example:
// Defines the success callback. - function successCallback() { - console.log("Draft message added"); - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot add draft message " + error.message); - } - - // Defines the service query success callback. - function serviceListCB(services) { - if (services.length > 0) { - var msg = new tizen.Message("messaging.sms", {plainBody: "Tizen draft SMS message."}); - services[0].messageStorage.addDraftMessage(msg, - successCallback, - errorCallback); - } - } - tizen.messaging.getMessageServices("messaging.sms", serviceListCB); -+
Code example:
+/* Defines the success callback */ +function successCallback() +{ + console.log("Draft message added"); +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot add draft message " + error.message); +} + +/* Defines the service query success callback */ +function serviceListCB(services) +{ + if (services.length > 0) + { + var msg = new tizen.Message("messaging.sms", {plainBody: "Tizen draft SMS message."}); + services[0].messageStorage.addDraftMessage(msg, successCallback, + errorCallback); + } +} +tizen.messaging.getMessageServices("messaging.sms", serviceListCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - function messageArrayCB(messages) { - console.log(messages.length + " message(s) fetched!"); - for (var i = 0; i < messages.length; i++) { - console.log(i + ". message from " + messages[i].from); - } - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot query messages" + error.message); - } - - var filter = new tizen.AttributeFilter("from", "CONTAINS", "2593"); - messageStorage.findMessages(filter, messageArrayCB, errorCallback); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +function messageArrayCB(messages) +{ + console.log(messages.length + " message(s) fetched!"); + for (var i = 0; i < messages.length; i++) + { + console.log(i + ". message from " + messages[i].from); + } +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot query messages" + error.message); +} + +var filter = new tizen.AttributeFilter("from", "CONTAINS", "2593"); +messageStorage.findMessages(filter, messageArrayCB, errorCallback); +
Code example:
// Defines the success callback. - var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - function successCallback() { - console.log("Messages were deleted"); - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot delete messages " + error.message); - } - - function messageArrayCB(messages) { - if (messages.length > 0) { - messageStorage.removeMessages(messages, successCallback, errorCallback); - } else { - console.log("No messages found"); - } - } - - var filter = new tizen.AttributeFilter("from", "CONTAINS", "2593"); - messageStorage.findMessages(filter, messageArrayCB); -+
Code example:
+/* Defines the success callback */ +var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +function successCallback() +{ + console.log("Messages were deleted"); +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot delete messages " + error.message); +} + +function messageArrayCB(messages) +{ + if (messages.length > 0) + { + messageStorage.removeMessages(messages, successCallback, errorCallback); + } + else + { + console.log("No messages found"); + } +} + +var filter = new tizen.AttributeFilter("from", "CONTAINS", "2593"); +messageStorage.findMessages(filter, messageArrayCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - - // Defines the success callback. - function successCallback() { - console.log("Messages were updated"); - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot update messages " + error.message); - } - - function messageArrayCB(messages) { - if (messages.length > 0) { - messages[0].isRead = true; - messageStorage.updateMessages([messages[0]], successCallback, errorCallback); - } else { - console.log("No messages found"); - } - } - - var filter = new tizen.AttributeFilter('isRead', 'EXACTLY', false); - messageStorage.findMessages(filter, messageArrayCB); - -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; + +/* Defines the success callback */ +function successCallback() +{ + console.log("Messages were updated"); +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot update messages " + error.message); +} + +function messageArrayCB(messages) +{ + if (messages.length > 0) + { + messages[0].isRead = true; + messageStorage.updateMessages([messages[0]], successCallback, errorCallback); + } + else + { + console.log("No messages found"); + } +} + +var filter = new tizen.AttributeFilter('isRead', 'EXACTLY', false); +messageStorage.findMessages(filter, messageArrayCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - function conversationsArrayCB(conversations) { - console.log(conversations.length + " conversation(s) found!"); - for (var i = 0; i < conversations.length; i++) { - console.log(i + ". conversation preview " + conversations[i].preview); - } - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot query conversations" + error.message); - } - - var filter = new tizen.AttributeFilter('from', 'CONTAINS', '2593'); - messageStorage.findConversations(filter, conversationsArrayCB, errorCallback); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +function conversationsArrayCB(conversations) +{ + console.log(conversations.length + " conversation(s) found!"); + for (var i = 0; i < conversations.length; i++) + { + console.log(i + ". conversation preview " + conversations[i].preview); + } +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot query conversations" + error.message); +} + +var filter = new tizen.AttributeFilter('from', 'CONTAINS', '2593'); +messageStorage.findConversations(filter, conversationsArrayCB, errorCallback); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - // Defines the success callback. - function successCallback() { - console.log("Conversations deleted"); - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Cannot delete conversations " + error.message); - } - - function conversationsArrayCB(conversations) { - if (conversations.length > 0) { - messageStorage.removeConversations(conversations, successCallback, - errorCallback); - } else { - console.log("No conversations found"); - } - console.log("Deleted " + conversations.length + " conversation(s)"); - } - - // Defines the error callback. - function queryErrorCB(error) { - console.log("Cannot query conversations" + error.message); - } - - var filter = new tizen.AttributeFilter('from', 'CONTAINS', '2593'); - messageStorage.findConversations(filter, conversationsArrayCB, - queryErrorCB); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +/* Defines the success callback */ +function successCallback() +{ + console.log("Conversations deleted"); +} + +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Cannot delete conversations " + error.message); +} + +function conversationsArrayCB(conversations) +{ + if (conversations.length > 0) + { + messageStorage.removeConversations(conversations, successCallback, + errorCallback); + } + else + { + console.log("No conversations found"); + } + console.log("Deleted " + conversations.length + " conversation(s)"); +} + +/* Defines the error callback */ +function queryErrorCB(error) +{ + console.log("Cannot query conversations" + error.message); +} + +var filter = new tizen.AttributeFilter('from', 'CONTAINS', '2593'); +messageStorage.findConversations(filter, conversationsArrayCB, queryErrorCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - function folderArrayCB(folders) { - console.log(folders.length + " folders(s) found!"); - for (var i = 0; i < folders.length; i++) { - console.log(i + ", folder: " + folders[i].name); - } - } - var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id); - messageStorage.findFolders(filter, folderArrayCB); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +function folderArrayCB(folders) +{ + console.log(folders.length + " folders(s) found!"); + for (var i = 0; i < folders.length; i++) + { + console.log(i + ", folder: " + folders[i].name); + } +} +var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id); +messageStorage.findFolders(filter, folderArrayCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - var messageChangeCallback = { - messagesupdated: function(messages) { - console.log(messages.length + " message(s) updated");}, - messagesadded: function(messages) { - console.log(messages.length + " message(s) added");}, - messagesremoved: function(messages) { - console.log(messages.length + " message(s) removed");} - }; - - messageStorage.addMessagesChangeListener(messageChangeCallback); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +var messageChangeCallback = +{ + messagesupdated: function(messages) + { + console.log(messages.length + " message(s) updated"); + }, + messagesadded: function(messages) + { + console.log(messages.length + " message(s) added"); + }, + messagesremoved: function(messages) + { + console.log(messages.length + " message(s) removed"); + } +}; + +messageStorage.addMessagesChangeListener(messageChangeCallback); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - var conversationChangeCB = { - conversationsupdated: function(conversations) { - console.log(conversations.length + " conversations(s) updated");}, - conversationsadded: function(conversations) { - console.log(conversations.length + " conversations(s) added");}, - conversationsremoved: function(conversations) { - console.log(conversations.length + " conversations(s) removed");} - }; - - messageStorage.addConversationsChangeListener(conversationChangeCB); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +var conversationChangeCB = +{ + conversationsupdated: function(conversations) + { + console.log(conversations.length + " conversations(s) updated"); + }, + conversationsadded: function(conversations) + { + console.log(conversations.length + " conversations(s) added"); + }, + conversationsremoved: function(conversations) + { + console.log(conversations.length + " conversations(s) removed"); + } +}; + +messageStorage.addConversationsChangeListener(conversationChangeCB); +
Code example:
var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - var folderChangeCB = { - foldersupdated: function(folders) { - console.log(folders.length + " folders(s) updated");}, - foldersadded: function(folders) { - console.log(folders.length + " folders(s) added");}, - foldersremoved: function(folders) { - console.log(folders.length + " folders(s) removed");} - }; - - messageStorage.addFoldersChangeListener(folderChangeCB); -+
Code example:
+var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +var folderChangeCB = +{ + foldersupdated: function(folders) + { + console.log(folders.length + " folders(s) updated"); + }, + foldersadded: function(folders) + { + console.log(folders.length + " folders(s) added"); + }, + foldersremoved: function(folders) + { + console.log(folders.length + " folders(s) removed"); + } +}; + +messageStorage.addFoldersChangeListener(folderChangeCB); +
Code example:
var watchId; - var service; // Assumes messaging service is initialized - var messageStorage = service.messageStorage; - var folderChangeCB = { - foldersupdated: function(folders) { - console.log(folders.length + " folders(s) updated. Cancel watching."); - messageStorage.removeChangeListener(watchId); }, - foldersadded: function(folders) { - console.log(folders.length + " folders(s) added. Cancel watching."); - messageStorage.removeChangeListener(watchId); }, - foldersremoved: function(folders) { - console.log(folders.length + " folders(s) removed. Cancel watching."); - messageStorage.removeChangeListener(watchId);} - }; - - watchId = messageStorage.addFoldersChangeListener(folderChangeCB); - -+
Code example:
+var watchId; +var service; /* Assumes messaging service is initialized */ +var messageStorage = service.messageStorage; +var folderChangeCB = +{ + foldersupdated: function(folders) + { + console.log(folders.length + " folders(s) updated. Cancel watching."); + messageStorage.removeChangeListener(watchId); + }, + foldersadded: function(folders) + { + console.log(folders.length + " folders(s) added. Cancel watching."); + messageStorage.removeChangeListener(watchId); + }, + foldersremoved: function(folders) + { + console.log(folders.length + " folders(s) removed. Cancel watching."); + messageStorage.removeChangeListener(watchId) + } +}; + +watchId = messageStorage.addFoldersChangeListener(folderChangeCB); +
Code example:
var statuscb = { - onsuccess: function() { console.log("onsuccess func is called"); }, - ondisconnected: function() { console.log("ondisconnected func is called"); } - }; - function ecb(e) { console.log("error callback is called : " + e.message + " : " + e.code); } - tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.tizen.org", statuscb, ecb); -+
Code example:
+var statuscb = +{ + onsuccess: function() {console.log("onsuccess func is called");}, + ondisconnected: function() {console.log("ondisconnected func is called");} +}; +function ecb(e) {console.log("error callback is called: " + e.message + ": " + e.code);} + +tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.tizen.org", statuscb, ecb); +
Code example:
function scb() { console.log("success callback is called"); } - function ecb(e) { console.log("error callback is called : " + e.message + " : " + e.code); } - var statuscb = { - onsuccess: function() { - console.log("onsuccess func is called"); - tizen.networkbearerselection.releaseRouteToHost("CELLULAR", "www.google.com", scb, ecb); - }, - ondisconnected: function() { console.log("ondisconnected func is called"); } - }; - tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.google.com", statuscb, ecb); -+
Code example:
+function scb() {console.log("success callback is called");} +function ecb(e) {console.log("error callback is called: " + e.message + ": " + e.code);} +var statuscb = +{ + onsuccess: function() + { + console.log("onsuccess func is called"); + tizen.networkbearerselection.releaseRouteToHost("CELLULAR", "www.google.com", scb, ecb); + }, + ondisconnected: function() {console.log("ondisconnected func is called");} +}; +tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.google.com", statuscb, ecb); +
Code example:
try { - var adapter = tizen.nfc.getDefaultAdapter(); - } catch (err) { - console.log(err.name +": " + err.message); - } -+
Code example:
+try +{ + var adapter = tizen.nfc.getDefaultAdapter(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - tizen.nfc.setExclusiveMode(true) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + tizen.nfc.setExclusiveMode(true); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var gNfcAdapter; - var onPowerOn = function(){ // Called when NFC adapter is powered on - try { - console.log("Power on succeed"); - // Implement NFC communication routines ... - gNfcAdapter.setPowered( - false, // Disable NFC adapter - function () {console.log("Power off succeed"); }, // Handle success - function () {console.log("Power off failed"); }); // Handle failure - } catch (err) { - console.log(err.name + ": " + err.message); - } - }; - try { - gNfcAdapter = tizen.nfc.getDefaultAdapter(); - if (!gNfcAdapter.powered) { - gNfcAdapter.setPowered( - true, // Enable NFC adapter - onPowerOn, // Handle success - function () {console.log("Power on failed")}); // Handle failure - } else { - onPowerOn(); - } - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+var gNfcAdapter; +var onPowerOn = function() +{ + /* Called when NFC adapter is powered on */ + try + { + console.log("Power on succeed"); + /* Implement NFC communication routines */ + gNfcAdapter.setPowered(false, /* Disable NFC adapter */ + function() {console.log("Power off succeed");}, /* Handle success */ + function() {console.log("Power off failed");}); /* Handle failure */ + } + catch (err) + { + console.log(err.name + ": " + err.message); + } +}; +try +{ + gNfcAdapter = tizen.nfc.getDefaultAdapter(); + if (!gNfcAdapter.powered) + { + gNfcAdapter.setPowered(true, /* Enable NFC adapter */ + onPowerOn, /* Handle success */ + function() {console.log("Power on failed")}); /* Handle failure */ + } + else + { + onPowerOn(); + } +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - var onSuccessCB = {onattach : function(nfcTag) { - console.log("NFC Tag's type is " + nfcTag.type); - }, ondetach : function() { - console.log("NFC Tag is detached"); - }}; - adapter.setTagListener(onSuccessCB); -+
Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); +var onSuccessCB = +{ + onattach: function(nfcTag) + { + console.log("NFC Tag's type is " + nfcTag.type); + }, + ondetach: function() + { + console.log("NFC Tag is detached"); + } +}; +adapter.setTagListener(onSuccessCB); +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - var onSuccessCB = {onattach : function(nfcPeer) { - console.log("NFC Target is detected"); - }, ondetach : function() { - console.log("NFC Target is detached"); - }}; - adapter.setPeerListener(onSuccessCB); -+
Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); +var onSuccessCB = +{ + onattach: function(nfcPeer) + { + console.log("NFC Target is detected"); + }, + ondetach: function() + { + console.log("NFC Target is detached"); + } +}; +adapter.setPeerListener(onSuccessCB); +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - - // Receives NFCTag - var onSuccessCB = { - onattach : function(nfcTag) { - console.log("The attached NFC tag's type is " + nfcTag.type); - }, - ondetach : function() { - console.log("NFC tag is detached."); - - // Unregister the listener when the NFC tag is detached. - adapter.unsetTagListener(); - } - }; +Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); + +/* Receives NFCTag */ +var onSuccessCB = +{ + onattach: function(nfcTag) + { + console.log("The attached NFC tag's type is " + nfcTag.type); + }, + ondetach: function() + { + console.log("NFC tag is detached."); + + /* Unregister the listener when the NFC tag is detached */ + adapter.unsetTagListener(); + } +}; - // Registers to be notified when NFC tag is detected. - adapter.setTagListener(onSuccessCB); -+/* Registers to be notified when NFC tag is detected */ +adapter.setTagListener(onSuccessCB); +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - - // Receives an NFC peer. - var onSuccessCB = { - onattach : function(nfcPeer) { - console.log("NFC peer target is attached."); - }, - ondetach : function() { - console.log("NFC peer target is detached."); - - // Unregisters the listener when NFC peer target is detached. - adapter.unsetPeerListener(); - } - }; +Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); + +/* Receives an NFC peer */ +var onSuccessCB = +{ + onattach: function(nfcPeer) + { + console.log("NFC peer target is attached."); + }, + ondetach: function() + { + console.log("NFC peer target is detached."); + + /* Unregisters the listener when NFC peer target is detached */ + adapter.unsetPeerListener(); + } +}; - // Registers to be notified when NFC peer target is detected. - adapter.setPeerListener(onSuccessCB); -+/* Registers to be notified when NFC peer target is detected */ +adapter.setPeerListener(onSuccessCB); +
Code example:
try { - var onSuccessCB = function(mode) { - console.log("The card emulation mode is " + mode); - }; - var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = function(mode) + { + console.log("The card emulation mode is " + mode); + }; + var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - adapter.removeCardEmulationModeChangeListener(listenerId) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + adapter.removeCardEmulationModeChangeListener(listenerId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var listenerId = adapter.addTransactionEventListener("UICC", function(aid, data){console.log("transaction event occurs");}) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var listenerId = adapter.addTransactionEventListener("UICC", function(aid, data) {console.log("transaction event occurs");}); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - adapter.removeTransactionEventListener(listenerId) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + adapter.removeTransactionEventListener(listenerId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var onSuccessCB = function(seType) { - console.log("Active secure element is " + seType); - }; - var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = function(seType) + { + console.log("Active secure element is " + seType); + }; + var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - adapter.removeActiveSecureElementChangeListener(listenerId) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + adapter.removeActiveSecureElementChangeListener(listenerId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
// Gets the cached message - var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage(); -+
Code example:
+/* Gets the cached message */ +var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage(); +
Code example:
try { - adapter.setExclusiveModeForTransaction(true) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + adapter.setExclusiveModeForTransaction(true); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var onDetectedCB = function(event_data) { - console.log("HCE event type is " + event_data.eventType); - console.log("APDU is " + event_data.apdu); - }; - var listenerId = adapter.addHCEEventListener(onDetectedCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onDetectedCB = function(event_data) + { + console.log("HCE event type is " + event_data.eventType); + console.log("APDU is " + event_data.apdu); + }; + var listenerId = adapter.addHCEEventListener(onDetectedCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - adapter.removeHCEEventListener(listenerId) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + adapter.removeHCEEventListener(listenerId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var successCB = function() { - console.log("Sending APDU reponse was successful."); - }; - - var errorCB = function() { - console.log("Sending APDU reponse failed."); - }; - - var classOfInstruction = 0x00; // No SM or no SM indication - var instructionCode = 0xA4; //Select File - var firstParam = 0x04; //Direct selection by DF name - var secondParam = 0x00; // First record - var dataFieldLength = 0x03; // Variable length 1 or 3 bytes - var bytes = [ 0x20, 0x21, 0x22]; // Variable length equal to dataFieldLength - var maxBytesExpected = 0x02; // Maximum bytes in answer - - var apdu_response= [ classOfInstruction, instructionCode, firstParam, secondParam] + bytes + [ maxBytesExpected ]; //set apdu response. - adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function() + { + console.log("Sending APDU response was successful."); + }; + + var errorCB = function() + { + console.log("Sending APDU response failed."); + }; + + var classOfInstruction = 0x00; /* No SM or no SM indication */ + var instructionCode = 0xA4; /* Select File */ + var firstParam = 0x04; /* Direct selection by DF name */ + var secondParam = 0x00; /* First record */ + var dataFieldLength = 0x03; /* Variable length 1 or 3 bytes */ + var bytes = [ 0x20, 0x21, 0x22]; /* Variable length equal to dataFieldLength */ + var maxBytesExpected = 0x02; /* Maximum bytes in answer */ + + var apdu_response = [classOfInstruction, instructionCode, firstParam, secondParam] + bytes + [maxBytesExpected]; /* Set apdu response */ + adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var aid = "ABC0012345"; - var isActiveHandler = adapter.isActivatedHandlerForAID("HCE", aid); - if(isActiveHandler){ - console.log("current application is activated handler for the AID"); - } - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var aid = "ABC0012345"; + var isActiveHandler = adapter.isActivatedHandlerForAID("HCE", aid); + if (isActiveHandler) + { + console.log("current application is activated handler for the AID"); + } +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var isActiveHandler = adapter.isActivatedHandlerForCategory("ESE", "PAYMENT") ; - if(isActiveHandler){ - console.log("current application is activated handler for the category"); - } - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var isActiveHandler = adapter.isActivatedHandlerForCategory("ESE", "PAYMENT"); + if (isActiveHandler) + { + console.log("current application is activated handler for the category"); + } +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var aid = "ABC0012345"; - adapter.registerAID("HCE", aid, "PAYMENT") ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var aid = "ABC0012345"; + adapter.registerAID("HCE", aid, "PAYMENT"); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var aid = "ABC0012345"; - adapter.unregisterAID("HCE", aid, "PAYMENT") ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var aid = "ABC0012345"; + adapter.unregisterAID("HCE", aid, "PAYMENT"); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var successCB = function(aids) { - var arrayLength = aids.length; - for (var i = 0; i arrayLength; i++) { - console.log("Get AID category was successful."); - console.log("AID type is " + aids[i].type); - console.log("AID is " + aids[i].aid); - console.log("AID isReadOnly is " + aids[i].readOnly); - } - }; - - var errorCB = function() { - console.log("Get AID category failed."); - }; - - adapter.getAIDsForCategory("HCE", "PAYMENT", successCB, errorCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function(aids) + { + var arrayLength = aids.length; + for (var i = 0; i arrayLength; i++) + { + console.log("Get AID category was successful."); + console.log("AID type is " + aids[i].type); + console.log("AID is " + aids[i].aid); + console.log("AID isReadOnly is " + aids[i].readOnly); + } + }; + + var errorCB = function() + { + console.log("Get AID category failed."); + }; + + adapter.getAIDsForCategory("HCE", "PAYMENT", successCB, errorCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - var onSuccessCB = {onattach : function(nfcTag) { - console.log("NFC Tag's type is " + nfcTag.type); - for(var i in nfcTag.properties) { - console.log("key:" + i + " value:" + nfcTag.properties[i]); - } - }, ondetach : function() { - console.log("NFC Tag is detached"); - }}; - adapter.setTagListener(onSuccessCB); - -+
Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); +var onSuccessCB = +{ + onattach: function(nfcTag) + { + console.log("NFC Tag's type is " + nfcTag.type); + for (var i in nfcTag.properties) + { + console.log("key:" + i + " value:" + nfcTag.properties[i]); + } + }, + ondetach: function() + { + console.log("NFC Tag is detached"); + } +}; +adapter.setTagListener(onSuccessCB); +
Code example:
try { - - var successCB = function(ndefMessage) { - console.log("Message read was successful."); - for( var i = 0; i ndefMessage.recordCount; ++i){ - console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf); - console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf); - console.log("Message record type " + ndefMessage.records[i].type.toString()); - ... - } - }; - - var errorCB = function() { - console.log("Message read failed."); - }; - - nfcTag.readNDEF(successCB, errorCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function(ndefMessage) + { + console.log("Message read was successful."); + for (var i = 0; i < ndefMessage.recordCount; ++i) + { + console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf); + console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf); + console.log("Message record type " + ndefMessage.records[i].type.toString()); + } + }; + + var errorCB = function() + { + console.log("Message read failed."); + }; + + nfcTag.readNDEF(successCB, errorCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var successCB = function() { - console.log("Message write was successful."); - } - }; - - var errorCB = function() { - console.log("Message write failed."); - }; - - - var record = new tizen.NDEFRecordText("Hi!", "en-GB"); - var message = new tizen.NDEFMessage([record]); - - nfcTag.writeNDEF(message, successCB, errorCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function() + { + console.log("Message write was successful."); + }; + + var errorCB = function() + { + console.log("Message write failed."); + }; + + var record = new tizen.NDEFRecordText("Hi!", "en-GB"); + var message = new tizen.NDEFMessage([record]); + + nfcTag.writeNDEF(message, successCB, errorCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var successCB = function(data) { - console.log("Message write was successful."); - console.log("Response is " + data.toString()); - } - }; - - var errorCB = function() { - console.log("Message write failed."); - }; - - var message = [0x30, 0x00, 0x02, 0xa8]; // READ command for MIFARE tags - - nfcTag.transceive(message, successCB, errorCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function(data) + { + console.log("Message write was successful."); + console.log("Response is " + data.toString()); + }; + + var errorCB = function() + { + console.log("Message write failed."); + }; + + var message = [0x30, 0x00, 0x02, 0xa8]; /* READ command for MIFARE tags */ + + nfcTag.transceive(message, successCB, errorCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - - // Receives NFCPeer - var onSuccessCB = {onattach : function(nfcPeer) { - console.log("NFC Target is detected"); - nfcPeer.setReceiveNDEFListener( - function(message){ - console.log("Receive message"); - }); - }, ondetach : function() { - console.log("NFC Target is detached"); - }}; - - adapter.setPeerListener(onSuccessCB); -+
Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); + +/* Receives NFCPeer */ +var onSuccessCB = +{ + onattach: function(nfcPeer) + { + console.log("NFC Target is detected"); + nfcPeer.setReceiveNDEFListener(function(message) + { + console.log("Receive message"); + }); + }, + ondetach: function() + { + console.log("NFC Target is detached"); + } +}; + +adapter.setPeerListener(onSuccessCB); +
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); - var onSuccessCB = {onattach : function(nfcPeer) { - console.log("NFC Target is detected"); - nfcPeer.setReceiveNDEFListener( - function(message){ - console.log("Receive message"); - nfcPeer.unsetReceiveNDEFListener(); - }); - }, ondetach : function() { - console.log("NFC Target is detached"); - }}; - } - - adapter.setPeerListener(onSuccessCB); -+
Code example:
+var adapter = tizen.nfc.getDefaultAdapter(); +var onSuccessCB = +{ + onattach: function(nfcPeer) + { + console.log("NFC Target is detected"); + nfcPeer.setReceiveNDEFListener(function(message) + { + console.log("Receive message"); + nfcPeer.unsetReceiveNDEFListener(); + }); + }, + ondetach: function() + { + console.log("NFC Target is detached"); + } +}; + +adapter.setPeerListener(onSuccessCB); +
Code example:
try { - - peerListener = { - onattach: function (peer) { - var record = new tizen.NDEFRecordText("sendNDEF-test", 'en-US'); - var message = new tizen.NDEFMessage([record]); - returned = peer.sendNDEF(ndefMessage); - }, - ondetach: t.step_func(function () { - adapter.unsetPeerListener(); - } - }; - - adapter.setPeerListener(peerListener); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + peerListener = + { + onattach: function(peer) + { + var record = new tizen.NDEFRecordText("sendNDEF-test", 'en-US'); + var message = new tizen.NDEFMessage([record]); + returned = peer.sendNDEF(ndefMessage); + }, + ondetach: t.step_func(function() + { + adapter.unsetPeerListener(); + } + }; + + adapter.setPeerListener(peerListener); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var record = new tizen.NDEFRecordText("Hi!", "en-GB"); - var tempMessage = new tizen.NDEFMessage([record]); - var rawData = tempMessage.toByte(); - - var message = new tizen.NDEFMessage(rawData); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var record = new tizen.NDEFRecordText("Hi!", "en-GB"); + var tempMessage = new tizen.NDEFMessage([record]); + var rawData = tempMessage.toByte(); + + var message = new tizen.NDEFMessage(rawData); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - // prepare two NDEFRecords: - var myRecordURI = new tizen.NDEFRecordURI("https://www.tizen.org/"); - var myRecordTextPlain = new tizen.NDEFRecordMedia("text/plain", [116, 105, 122, 101, 110]); - - // create a NDEFMessage composed of two NDEFRecords: - var myMessage = new NDEFMessage([myRecordURI, myRecordTextPlain]); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + /* Prepare two NDEFRecords */ + var myRecordURI = new tizen.NDEFRecordURI("https://www.tizen.org/"); + var myRecordTextPlain = new tizen.NDEFRecordMedia("text/plain", [116, 105, 122, 101, 110]); + + /* Create a NDEFMessage composed of two NDEFRecords */ + var myMessage = new NDEFMessage([myRecordURI, myRecordTextPlain]); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
// Gets the cached message. - var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage(); - var raw = cachedMessage.toByte(); -+
Code example:
+/* Gets the cached message */ +var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage(); +var raw = cachedMessage.toByte(); +
Code example:
try { - var recordBytes = [217, 1, 2, 3, 202, 219, 218, 217, 240, 241]; - var record = new tizen.NDEFRecord(recordBytes); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var recordBytes = [217, 1, 2, 3, 202, 219, 218, 217, 240, 241]; + var record = new tizen.NDEFRecord(recordBytes); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var type = new Array(255), - var payload = new Array(256), - var recordId = [155, 150], - var newRecord = new tizen.NDEFRecord(tizen.nfc.NFC_RECORD_TNF_UNKNOWN, type, payload, recordId); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var type = new Array(255), + var payload = new Array(256), + var recordId = [155, 150], + var newRecord = new tizen.NDEFRecord(tizen.nfc.NFC_RECORD_TNF_UNKNOWN, type, payload, recordId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
// Creates a new NDEF record. - var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/"); - var payload = newRecord.payload; -+
Code example:
+/* Creates a new NDEF record */ +var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/"); +var payload = newRecord.payload; +
Code example:
var newRecord = new tizen.NDEFRecordText("Tizen", "en-US", "UTF8"); -+
Code example:
+var newRecord = new tizen.NDEFRecordText("Tizen", "en-US", "UTF8"); +
Code example:
// Creates a new NDEF record. - var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/"); - var payload = newRecord.payload; -+
Code example:
+/* Creates a new NDEF record */ +var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/"); +var payload = newRecord.payload; +
Code example:
var myData = [116, 105, 122, 101, 110]; - var newRecord = new tizen.NDEFRecordMedia("text/plain", myData); -+
Code example:
+var myData = [116, 105, 122, 101, 110]; +var newRecord = new tizen.NDEFRecordMedia("text/plain", myData); +
Code example:
try { - var onSuccessCB = { - onattach: function (nfcTag){ - console.log("Successfully detected nfcTag type:" + nfcTag.type); - } - } - - var adapter = tizen.nfc.getDefaultAdapter(); - adapter.setTagListener(onSuccessCB); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = + { + onattach: function(nfcTag) + { + console.log("Successfully detected nfcTag type:" + nfcTag.type); + } + } + + var adapter = tizen.nfc.getDefaultAdapter(); + adapter.setTagListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var adapter; - var onSuccessCB = { - onattach: function (nfcTag){ - console.log("Successfully detected nfcTag type:" + nfcTag.type); - }, - ondetach: function() { - adapter.unsetTagListener(); - } - } - - adapter = tizen.nfc.getDefaultAdapter(); - adapter.setTagListener(onSuccessCB); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var adapter; + var onSuccessCB = + { + onattach: function(nfcTag) + { + console.log("Successfully detected nfcTag type:" + nfcTag.type); + }, + ondetach: function() + { + adapter.unsetTagListener(); + } + } + + adapter = tizen.nfc.getDefaultAdapter(); + adapter.setTagListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var adapter; - var onSuccessCB = { - onattach: function (nfcPeer){ - console.log("Successfully detected nfcPeer :" + nfcPeer.isConnected); - } - } - - adapter = tizen.nfc.getDefaultAdapter(); - adapter.setPeerListener(onSuccessCB); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var adapter; + var onSuccessCB = + { + onattach: function(nfcPeer) + { + console.log("Successfully detected nfcPeer:" + nfcPeer.isConnected); + } + } + + adapter = tizen.nfc.getDefaultAdapter(); + adapter.setPeerListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var adapter; - var onSuccessCB = { - onattach: function (nfcPeer){ - console.log("Successfully detected nfcPeer :" + nfcPeer.isConnected); - }, - ondetach: function() { - adapter.unsetPeerListener(); - } - } - - adapter = tizen.nfc.getDefaultAdapter(); - adapter.setPeerListener(onSuccessCB); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var adapter; + var onSuccessCB = + { + onattach: function(nfcPeer) + { + console.log("Successfully detected nfcPeer:" + nfcPeer.isConnected); + }, + ondetach: function() + { + adapter.unsetPeerListener(); + } + } + + adapter = tizen.nfc.getDefaultAdapter(); + adapter.setPeerListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var adapter; - - var readCallback = function (ndefMessage) { - console.log("NDEFMessageReadCallback called successfully"); - } - - var tagListener = { - onattach: function (nfcTag){ - var result = nfcTag.readNDEF(readCallback); - } - } - - adapter = tizen.nfc.getDefaultAdapter(); - adapter.setTagListener(tagListener); - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var adapter; + + var readCallback = function(ndefMessage) + { + console.log("NDEFMessageReadCallback called successfully"); + } + + var tagListener = + { + onattach: function(nfcTag) + { + var result = nfcTag.readNDEF(readCallback); + } + } + + adapter = tizen.nfc.getDefaultAdapter(); + adapter.setTagListener(tagListener); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var successCB = function(data) { - console.log("ByteArraySuccessCallback called successfully."); - } - }; - - var message = [0x30, 0x00, 0x02, 0xa8]; // READ command for MIFARE tags - - nfcTag.transceive(message, successCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function(data) + { + console.log("ByteArraySuccessCallback called successfully."); + }; + + var message = [0x30, 0x00, 0x02, 0xa8]; /* READ command for MIFARE tags */ + + nfcTag.transceive(message, successCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var onSuccessCB = function(mode) { - console.log("CardEmulationModeChangeCallback called successfully"); - }; - - var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = function(mode) + { + console.log("CardEmulationModeChangeCallback called successfully"); + }; + + var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var onSuccessCB = function(aid, data) { - console.log("TransactionEventCallback called successfully"); - }; - - var listenerId = adapter.addTransactionEventListener("UICC", onSuccessCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = function(aid, data) + { + console.log("TransactionEventCallback called successfully"); + }; + + var listenerId = adapter.addTransactionEventListener("UICC", onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var onSuccessCB = function(seType) { - console.log("ActiveSecureElementChangeCallback called successfully"); - }; - - var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onSuccessCB = function(seType) + { + console.log("ActiveSecureElementChangeCallback called successfully"); + }; + + var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var onDetectedCB = function(event_data) { - console.log("HCEEventReceiveCallback called successfully"); - }; - - var listenerId = adapter.addHCEEventListener(onDetectedCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var onDetectedCB = function(event_data) + { + console.log("HCEEventReceiveCallback called successfully"); + }; + + var listenerId = adapter.addHCEEventListener(onDetectedCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - var successCB = function(aids) { - console.log("AIDArraySuccessCallback called successfully"); - }; - - adapter.getAIDsForCategory("HCE", "PAYMENT", successCB) ; - } catch (err) { - console.log(err.name + ": " + err.message); - } -+
Code example:
+try +{ + var successCB = function(aids) + { + console.log("AIDArraySuccessCallback called successfully"); + }; + + adapter.getAIDsForCategory("HCE", "PAYMENT", successCB); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/create_content", - null, - "image/jpg", - null); - var notificationDict = { - content : "This is a simple notification.", - iconPath : "images/image1.jpg", - soundPath : "music/Over the horizon.mp3", - vibration : true, - appControl : appControl}; - - var notification = new tizen.StatusNotification("SIMPLE", - "Simple notification", notificationDict); - - tizen.notification.post(notification); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/create_content", + null, "image/jpg", null); + var notificationDict = + { + content: "This is a simple notification.", + iconPath: "images/image1.jpg", + soundPath: "music/Over the horizon.mp3", + vibration: true, + appControl: appControl + }; + + var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); + + tizen.notification.post(notification); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - // Uses a variable for the previously posted notification. - notification.content = "My notification"; - tizen.notification.update(notification); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + /* Uses a variable for the previously posted notification */ + notification.content = "My notification"; + tizen.notification.update(notification); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - // Uses a variable for the previously posted notification. - tizen.notification.remove(notification.id); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + /* Uses a variable for the previously posted notification */ + tizen.notification.remove(notification.id); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - tizen.notification.removeAll(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + tizen.notification.removeAll(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - // Uses a variable for the previously posted notification - // Saves the notification ID for future use - var myId = notification.id; - - var myNotification = tizen.notification.get(myId); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + /* Uses a variable for the previously posted notification */ + /* Saves the notification ID for future use */ + var myId = notification.id; + + var myNotification = tizen.notification.get(myId); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var notifications = tizen.notification.getAll(); - var index = 0; - - for ( index = 0; index < notifications.length; index++ ) - { - console.log(notifications[index].id); - console.log(notifications[index].title); - console.log(notifications[index].statusType); - console.log(notifications[index].type); - console.log(notifications[index].content); - console.log(notifications[index].postedTime); - console.log(notifications[index].iconPath); - console.log(notifications[index].soundPath); - console.log(notifications[index].vibration); - console.log(notifications[index].appControl); - } - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + var notifications = tizen.notification.getAll(); + var index = 0; + + for (index = 0; index < notifications.length; index++) + { + console.log(notifications[index].id); + console.log(notifications[index].title); + console.log(notifications[index].statusType); + console.log(notifications[index].type); + console.log(notifications[index].content); + console.log(notifications[index].postedTime); + console.log(notifications[index].iconPath); + console.log(notifications[index].soundPath); + console.log(notifications[index].vibration); + console.log(notifications[index].appControl); + } +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - tizen.notification.playLEDCustomEffect(1000, 1000, "#FFFF0080", ["LED_CUSTOM_DUTY_ON", "LED_CUSTOM_DEFAULT"]); - } catch(e) { - console.log("Error Exception, error name : " + e.name + ", error message : " + e.message); - } -+
Code example:
+try +{ + tizen.notification.playLEDCustomEffect(1000, 1000, "#FFFF0080", ["LED_CUSTOM_DUTY_ON", "LED_CUSTOM_DEFAULT"]); +} +catch (e) +{ + console.log("Error Exception, error name: " + e.name + ", error message: " + e.message); +} +
Code example:
try { - tizen.notification.playLEDCustomEffect(1000, 1000, "#FFFF0080", ["LED_CUSTOM_DUTY_ON", "LED_CUSTOM_DEFAULT"]); - setTimeout(function () { - tizen.notification.stopLEDCustomEffect(); - }, 5000); - } catch(e) { - console.log("Error Exception, error name : " + e.name + ", error message : " + e.message); - } -+
Code example:
+try +{ + tizen.notification.playLEDCustomEffect(1000, 1000, "#FFFF0080", ["LED_CUSTOM_DUTY_ON", "LED_CUSTOM_DEFAULT"]); + setTimeout(function() + { + tizen.notification.stopLEDCustomEffect(); + }, 5000); +} +catch (e) +{ + console.log("Error Exception, error name: " + e.name + ", error message: " + e.message); +} +
Code example:
try { - var notificationDict = { - content : "This is a simple notification.", - iconPath : "images/image1.jpg", - soundPath : "music/Over the horizon.mp3", - vibration : true, - ledColor : "#FFFF00", - ledOnPeriod: 1000, - ledOffPeriod : 500 }; - - var notification = new tizen.StatusNotification("SIMPLE", - "Simple notification", notificationDict); - - tizen.notification.post(notification); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + var notificationDict = + { + content: "This is a simple notification.", + iconPath: "images/image1.jpg", + soundPath: "music/Over the horizon.mp3", + vibration: true, + ledColor: "#FFFF00", + ledOnPeriod: 1000, + ledOffPeriod: 500 + }; + + var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); + + tizen.notification.post(notification); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - - // Gets the current application information with tizen.application.getAppInfo - var myappInfo = tizen.application.getAppInfo(); - - var notificationDict = { - content : "This is a simple notification.", - iconPath : "images/image1.jpg", - soundPath : "music/Over the horizon.mp3", - vibration : true, - appId : myappInfo.id }; - - var notification = new tizen.StatusNotification("SIMPLE", - "Simple notification", notificationDict); - - tizen.notification.post(notification); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + /* Gets the current application information with tizen.application.getAppInfo */ + var myappInfo = tizen.application.getAppInfo(); + + var notificationDict = + { + content: "This is a simple notification.", + iconPath: "images/image1.jpg", + soundPath: "music/Over the horizon.mp3", + vibration: true, + appId: myappInfo.id + }; + + var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); + + tizen.notification.post(notification); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - var appControl = new tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/create_content", - null, - "image/jpg", - null); - - var notificationDict = { - content : "This is a progress notification.", - iconPath : "images/image2.jpg", - soundPath : "music/Over the horizon.mp3", - vibration : true, - appControl : appControl, - progressValue : 20}; - // Constructs the progress notification - var notification = new tizen.StatusNotification("PROGRESS", - "Progress notification", notificationDict); - // Posts the notification - tizen.notification.post(notification); - - // Updates the progress value of the notification - notification.progressValue = 59; - tizen.notification.update(notification); - - - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/create_content", + null, "image/jpg", null); + + var notificationDict = + { + content: "This is a progress notification.", + iconPath: "images/image2.jpg", + soundPath: "music/Over the horizon.mp3", + vibration: true, + appControl: appControl, + progressValue: 20 + }; + /* Constructs the progress notification */ + var notification = new tizen.StatusNotification("PROGRESS", "Progress notification", notificationDict); + /* Posts the notification */ + tizen.notification.post(notification); + + /* Updates the progress value of the notification */ + notification.progressValue = 59; + tizen.notification.update(notification); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var detailInfo1 = new tizen.NotificationDetailInfo('Missed Call from James', 'Feb 11 2013'); - notification.detailInfo = [detailInfo1]; +Code example:
+var detailInfo1 = new tizen.NotificationDetailInfo('Missed Call from James', 'Feb 11 2013'); +notification.detailInfo = [detailInfo1];
Code example:
var onInstallation = { - onprogress: function(packageId, percentage) { - console.log("On installation(" + packageId + ") : progress(" + percentage + ")"); - }, - oncomplete: function(packageId) { - console.log("Installation(" + packageId + ") Complete"); - } - } - - var onError = function (err) { - console.log("Error occurred on installation : " + err.name); - } - - // Let's assume that the "test.wgt" file exists in the downloads directory - tizen.filesystem.resolve("downloads/test.wgt", - function (file) { - console.log("file URI : " + file.toURI()); - tizen.package.install(file.toURI(), onInstallation, onError); - }, - function (err) { - console.log("Error occurred on resolve : " + err.name); - }, - "r"); - -+
Code example:
+var onInstallation = +{ + onprogress: function(packageId, percentage) + { + console.log("On installation(" + packageId + "): progress(" + percentage + ")"); + }, + oncomplete: function(packageId) + { + console.log("Installation(" + packageId + ") Complete"); + } +} + +var onError = function(err) +{ + console.log("Error occurred on installation: " + err.name); +} + +/* Let's assume that the "test.wgt" file exists in the downloads directory */ +tizen.filesystem.resolve("downloads/test.wgt", function(file) +{ + console.log("file URI: " + file.toURI()); + tizen.package.install(file.toURI(), onInstallation, onError); +}, function(err) +{ + console.log("Error occurred on resolve: " + err.name); +}, "r"); +
Code example:
var onUninstallation = { - onprogress: function(packageId, percentage) { - console.log("On Uninstallation(" + packageId + ") : progress(" + percentage + ")"); - }, - oncomplete: function(packageId) { - console.log("Uninstallation(" + packageId + ") Complete"); - } - }; - - var onError = function (err) { - console.log("Error occurred on installation : " + err.name); - }; - - // Let's assume that the package ID to uninstall is "testapp001" - tizen.package.uninstall("testapp001", onUninstallation, onError); -+
Code example:
+var onUninstallation = +{ + onprogress: function(packageId, percentage) + { + console.log("On Uninstallation(" + packageId + "): progress(" + percentage + ")"); + }, + oncomplete: function(packageId) + { + console.log("Uninstallation(" + packageId + ") Complete"); + } +}; + +var onError = function(err) +{ + console.log("Error occurred on installation: " + err.name); +}; + +/* Let's assume that the package ID to uninstall is "testapp001" */ +tizen.package.uninstall("testapp001", onUninstallation, onError); +
Code example:
function onListInstalledPackages(packages) { - for (var i = 0; i < packages.length; i++) { - console.log("Package id["+i+"] : " +packages[i].id); - } - } - - tizen.package.getPackagesInfo( - onListInstalledPackages, - function (err) {console.log("Can't obtain packages list" + err.name);}); -+
Code example:
+function onListInstalledPackages(packages) +{ + for (var i = 0; i < packages.length; i++) + { + console.log("Package id[" + i + "]: " + packages[i].id); + } +} + +tizen.package.getPackagesInfo(onListInstalledPackages, function(err) +{ + console.log("Can't obtain packages list" + err.name); +}); +
Code example:
var packageInfo = tizen.package.getPackageInfo(null); +Code example:
+var packageInfo = tizen.package.getPackageInfo(null); - console.log("Current Package ID : " + packageInfo.id); -+console.log("Current Package ID: " + packageInfo.id); +
Code example:
var packageEventCallback = { - oninstalled: function(packageInfo) { - console.log('The package ' + packageInfo.name + ' is installed'); - }, - onupdated: function(packageInfo) { - console.log('The package ' + packageInfo.name + ' is updated'); - }, - onuninstalled: function(packageId) { - console.log('The package ' + packageId + ' is uninstalled'); - } - }; - - tizen.package.setPackageInfoEventListener(packageEventCallback); -+
Code example:
+var packageEventCallback = +{ + oninstalled: function(packageInfo) + { + console.log('The package ' + packageInfo.name + ' is installed'); + }, + onupdated: function(packageInfo) + { + console.log('The package ' + packageInfo.name + ' is updated'); + }, + onuninstalled: function(packageId) + { + console.log('The package ' + packageId + ' is uninstalled'); + } +}; + +tizen.package.setPackageInfoEventListener(packageEventCallback); +
Code example:
tizen.package.unsetPackageInfoEventListener(); -+
Code example:
+tizen.package.unsetPackageInfoEventListener(); +
Code example:
tizen.power.request("SCREEN", "SCREEN_NORMAL"); -+
Code example:
+tizen.power.request("SCREEN", "SCREEN_NORMAL"); +
Code example:
// Release SCREEN resource. - tizen.power.release("SCREEN"); -+
Code example:
+/* Release SCREEN resource */ +tizen.power.release("SCREEN"); +
Code example:
function onScreenStateChanged(previousState, changedState) { - console.log("Screen state changed from " + previousState + " to " + changedState); - } +Code example:
+function onScreenStateChanged(previousState, changedState) +{ + console.log("Screen state changed from " + previousState + " to " + changedState); +} - // Sets the screen state change listener. - tizen.power.setScreenStateChangeListener(onScreenStateChanged); -+/* Sets the screen state change listener */ +tizen.power.setScreenStateChangeListener(onScreenStateChanged); +
Code example:
// Unsets the screen state change listener. - tizen.power.unsetScreenStateChangeListener(); -+
Code example:
+/* Unsets the screen state change listener */ +tizen.power.unsetScreenStateChangeListener(); +
Code example:
// Gets the current screen brightness value. - var screenBrightness = tizen.power.getScreenBrightness(); -+
Code example:
+/* Gets the current screen brightness value */ +var screenBrightness = tizen.power.getScreenBrightness(); +
Code example:
// Sets the screen brightness value for the application. - tizen.power.setScreenBrightness(1); -+
Code example:
+/* Sets the screen brightness value for the application */ +tizen.power.setScreenBrightness(1); +
Code example:
// Checks whether the screen is on or off. - var isScreenOn = tizen.power.isScreenOn(); -+
Code example:
+/* Checks whether the screen is on or off */ +var isScreenOn = tizen.power.isScreenOn(); +
Code example:
// Restores the screen brightness value to the system default setting value. - tizen.power.restoreScreenBrightness(); -+
Code example:
+/* Restores the screen brightness value to the system default setting value */ +tizen.power.restoreScreenBrightness(); +
Code example:
// Turns the screen on. - tizen.power.turnScreenOn(); -+
Code example:
+/* Turns the screen on */ +tizen.power.turnScreenOn(); +
Code example:
// Turns the screen off. - tizen.power.turnScreenOff(); -+
Code example:
+/* Turns the screen off */ +tizen.power.turnScreenOff(); +
Code example:
var successCB = function(preferences) { - if (preferences.length) { - console.log('The first preference - key: ' + preferences[0].key + ' value: ' + preferences[0].value); - } - }; +Code example:
+var successCB = function(preferences) +{ + if (preferences.length) + { + console.log('The first preference - key: ' + preferences[0].key + ' value: ' + preferences[0].value); + } +}; - tizen.preference.getAll(successCB); -+tizen.preference.getAll(successCB); +
Output example:
The first preference - key: key1 value: Sample value @@ -263,8 +266,9 @@ The tizen.preference object provides access to the Preference service A
Code example:
tizen.preference.setValue('key1', 'New value'); -+
Code example:
+tizen.preference.setValue('key1', 'New value'); +
Code example:
var currentValue = tizen.preference.getValue('key1'); - console.log('The current value of the preference key1 is: ' + currentValue); -+
Code example:
+var currentValue = tizen.preference.getValue('key1'); +console.log('The current value of the preference key1 is: ' + currentValue); +
Output example:
The current value of the preference key1 is: New value @@ -356,8 +361,9 @@ The tizen.preference object provides access to the Preference service A
Code example:
tizen.preference.remove('key1'); -+
Code example:
+tizen.preference.remove('key1'); +
Code example:
tizen.preference.removeAll(); -+
Code example:
+tizen.preference.removeAll(); +
Code example:
if (tizen.preference.exists('key1')) { - console.log('Preference with the key key1 exists'); - } else { - console.log('Preference with the key key1 doesn't exist'); - } -+
Code example:
+if (tizen.preference.exists('key1')) +{ + console.log('Preference with the key key1 exists'); +} +else +{ + console.log('Preference with the key key1 doesn't exist'); +} +
Output example:
Preference with the key key1 exists @@ -486,12 +497,14 @@ The tizen.preference object provides access to the Preference service A
Code example:
var listener = function(data) { - console.log('Preference with the key: ' + data.key + ' has a new value: ' + data.value); - }; +Code example:
+var listener = function(data) +{ + console.log('Preference with the key: ' + data.key + ' has a new value: ' + data.value); +}; - tizen.preference.setChangeListener('key1', listener); -+tizen.preference.setChangeListener('key1', listener); +
Output example:
Preference with the key: key1 has a new value: Sample value @@ -536,12 +549,14 @@ The tizen.preference object provides access to the Preference service A
Code example:
var listener = function(data) { - tizen.preference.unsetChangeListener(data.key); - }; +Code example:
+var listener = function(data) +{ + tizen.preference.unsetChangeListener(data.key); +}; - tizen.preference.setChangeListener('key1', listener); -+tizen.preference.setChangeListener('key1', listener); +
Code example:
var listener = function(data) { - tizen.preference.unsetChangeListener(data.key); - }; +Code example:
+var listener = function(data) +{ + tizen.preference.unsetChangeListener(data.key); +}; - tizen.preference.setChangeListener('key1', listener); -+tizen.preference.setChangeListener('key1', listener); +
Code example:
var successCB = function(preferences) { - if (preferences.length) { - console.log('First preference - key: ' + preferences[0].key + ' value: ' + preferences[0].value); - } - }; +Code example:
+var successCB = function(preferences) +{ + if (preferences.length) + { + console.log('First preference - key: ' + preferences[0].key + ' value: ' + preferences[0].value); + } +}; - tizen.preference.getAll(successCB); -+tizen.preference.getAll(successCB); +
Output example:
First preference - key: key1 value: Sample value diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/push.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/push.html index 095ac44..caa056e 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/push.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/push.html @@ -256,22 +256,25 @@ do not contain a valid value.
Code example:
// Defines the data to be used when this process is launched by notification service. - var service = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/push_test"); +Code example:
+/* Defines the data to be used when this process is launched by notification service */ +var service = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/push_test"); - // Defines the error callback. - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } +/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} - // Defines the registration success callback - function registerSuccessCallback(id) { - console.log("Registration succeeded with id: " + id); - } +/* Defines the registration success callback */ +function registerSuccessCallback(id) +{ + console.log("Registration succeeded with id: " + id); +} - // Requests registration. - tizen.push.registerService(service, registerSuccessCallback, errorCallback); -+/* Requests registration */ +tizen.push.registerService(service, registerSuccessCallback, errorCallback); +
Code example:
// Defines the error callback. - function errorCallback(response) { - console.log("The following error occurred: " + response.name); - } +Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log("The following error occurred: " + response.name); +} - // Defines the registration success callback - function registerSuccessCallback(id) { - console.log("Registration succeeded with id: " + id); - } +/* Defines the registration success callback */ +function registerSuccessCallback(id) +{ + console.log("Registration succeeded with id: " + id); +} - // Requests application registration. - tizen.push.register(registerSuccessCallback, errorCallback); -+/* Requests application registration */ +tizen.push.register(registerSuccessCallback, errorCallback); +
Output example:
Registration succeeded with id: 04a150867a50f48cb79695ac732cbe550b4a6782fffd23cbc14ba8dd5c5ab0025dad29a3e4ef5de8849b95b726bea7a6395c @@ -414,19 +420,22 @@ UnknownError - If an unknown error occurs.
Code example:
// Defines the error callback - function errorCallback(response) { - console.log( 'The following error occurred: ' + response.name); - } +Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log('The following error occurred: ' + response.name); +} - // Defines the unregistration success callback - function unregisterSuccessCallback() { - console.log("Unregistration succeeded."); - } +/* Defines the unregistration success callback */ +function unregisterSuccessCallback() +{ + console.log("Unregistration succeeded."); +} - // Requests unregistration - tizen.push.unregisterService(unregisterSuccessCallback, errorCallback); -+/* Requests unregistration */ +tizen.push.unregisterService(unregisterSuccessCallback, errorCallback); +
Code example:
// Defines the error callback - function errorCallback(response) { - console.log("The following error occurred: " + response.name); - } +Code example:
+/* Defines the error callback */ +function errorCallback(response) +{ + console.log("The following error occurred: " + response.name); +} - // Defines the unregistration success callback - function unregisterSuccessCallback() { - console.log("Unregistration succeeded."); - } +/* Defines the unregistration success callback */ +function unregisterSuccessCallback() +{ + console.log("Unregistration succeeded."); +} - // Requests unregistration - tizen.push.unregister(unregisterSuccessCallback, errorCallback); -+/* Requests unregistration */ +tizen.push.unregister(unregisterSuccessCallback, errorCallback); +
Output example:
Unregistration succeeded. @@ -557,27 +569,31 @@ the register() method must be called before calling the connectServ
Code example:
// Defines the registration error callback. - function errorCallback(response) { - console.log("The following error occurred: " + response.name); - } +Code example:
+/* Defines the registration error callback */ +function errorCallback(response) +{ + console.log("The following error occurred: " + response.name); +} - // Defines the registration success callback - function registerSuccessCallback(id) { - console.log("Registration succeeded with id: " + id); - } +/* Defines the registration success callback */ +function registerSuccessCallback(id) +{ + console.log("Registration succeeded with id: " + id); +} - // Requests application registration. - tizen.push.register(registerSuccessCallback, errorCallback); +/* Requests application registration */ +tizen.push.register(registerSuccessCallback, errorCallback); - // Defines the connect success callback - function notificationCallback(noti) { - console.log("Notification received with alert message: " + noti.alertMessage); - } +/* Defines the connect success callback */ +function notificationCallback(noti) +{ + console.log("Notification received with alert message: " + noti.alertMessage); +} - // Requests for push service connection - tizen.push.connectService(notificationCallback); -+/* Requests for push service connection */ +tizen.push.connectService(notificationCallback); +
Code example:
// Requests disconnection - tizen.push.disconnectService(); -+
Code example:
+/* Requests disconnection */ +tizen.push.disconnectService(); +
Code example:
var registrationId = tizen.push.getRegistrationId(); - if ( registrationId != null ) { - console.log("The registration id: " + registrationId); - } -+
Code example:
+var registrationId = tizen.push.getRegistrationId(); +if (registrationId != null) +{ + console.log("The registration id: " + registrationId); +} +
Code example:
// Defines the connect success callback - function notificationCallback(message) { - console.log("New push message : " + message.alertMessage + ", date : " + message.date + ", data : " + message.appData); - } - } +Code example:
+/* Defines the connect success callback */ +function notificationCallback(message) +{ + console.log("New push message: " + message.alertMessage + ", date: " + message.date + ", data: " + message.appData); +} - // Requests for push service connection - tizen.push.connectService(notificationCallback); - tizen.push.getUnreadNotifications(); -+/* Requests for push service connection */ +tizen.push.connectService(notificationCallback); +tizen.push.getUnreadNotifications(); +
Code example:
try { - var message = tizen.push.getPushMessage(); - console.log('Message received from: ' + message.sender); - } catch (err) { - console.log('Exception - code: ' + err.name + ' message: ' + err.message); - } -+
Code example:
+try +{ + var message = tizen.push.getPushMessage(); + console.log('Message received from: ' + message.sender); +} +catch (err) +{ + console.log('Exception - code: ' + err.name + ' message: ' + err.message); +} +
Output example:
Message received from: xyz.AnotherApp @@ -905,21 +929,23 @@ This data is the message that the sender wants to send and its length must be le 3.0-Code example:
// Defines the connect success callback - function notificationCallback(noti) { - console.log('notification received on ' + noti.date + ' from: ' + noti.sender); - console.log('Details:'); - console.log(' - data: ' + noti.appData); - console.log(' - alert message: ' + noti.alertMessage); - console.log(' - message: ' + noti.message); - console.log(' - session: ' + noti.sessionInfo); - console.log(' - request ID: ' + noti.requestId); - console.log(' - type: ' + noti.type); - } +Code example:
+/* Defines the connect success callback */ +function notificationCallback(noti) +{ + console.log('notification received on ' + noti.date + ' from: ' + noti.sender); + console.log('Details:'); + console.log(' - data: ' + noti.appData); + console.log(' - alert message: ' + noti.alertMessage); + console.log(' - message: ' + noti.message); + console.log(' - session: ' + noti.sessionInfo); + console.log(' - request ID: ' + noti.requestId); + console.log(' - type: ' + noti.type); +} - // Requests for push service connection - tizen.push.connectService(notificationCallback); -+/* Requests for push service connection */ +tizen.push.connectService(notificationCallback); +Output example:
Notification received on Thu Jan 01 2015 from: xyz.AnotherApp diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/se.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/se.html index 3dfc434..57c4f2b 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/se.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/se.html @@ -225,22 +225,30 @@ The ErrorCallback is launched with these error types:-Code example:
try { - function success(readers) { - for (var i = 0; i < readers.length; i++) { - if (readers[i].isPresent) { - console.log ("Reader Name : " + readers[i].getName()); - } - } - } - function error(err) { - console.log (err.name + ": " + err.message); - } - tizen.seService.getReaders(success, error); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+Code example:
+try +{ + function success(readers) + { + for (var i = 0; i < readers.length; i++) + { + if (readers[i].isPresent) + { + console.log("Reader Name: " + readers[i].getName()); + } + } + } + function error(err) + { + console.log(err.name + ": " + err.message); + } + tizen.seService.getReaders(success, error); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var listener = { - onSEReady: function(reader) { - console.log(reader.getName() + " is ready."); - }, - onSENotReady: function(reader) { - console.log(reader.getName() + " is not ready."); - }, - onSEError: function(reader, error) { - console.log(reader.getName() + ": error occurred: " + error.message); - } - }; +Code example:
+var listener = +{ + onSEReady: function(reader) + { + console.log(reader.getName() + " is ready."); + }, + onSENotReady: function(reader) + { + console.log(reader.getName() + " is not ready."); + }, + onSEError: function(reader, error) + { + console.log(reader.getName() + ": error occurred: " + error.message); + } +}; - try { - var seListener = tizen.seService.registerSEListener(listener); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+try +{ + var seListener = tizen.seService.registerSEListener(listener); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var seListener; //seListener obtained from registerSEListener - try { - tizen.seService.unregisterSEListener(seListener); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+var seListener; /* seListener obtained from registerSEListener */ +try +{ + tizen.seService.unregisterSEListener(seListener); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - tizen.seService.shutdown(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + tizen.seService.shutdown(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - function success(readers) { - for (var i = 0; i < readers.length; i++) { - if (readers[i].isPresent) { - console.log ("Reader Name : " + readers[i].getName()); - } - } - } - function error(err) { - console.log (err.name + ": " + err.message); - } - tizen.seService.getReaders(success, error); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + function success(readers) + { + for (var i = 0; i < readers.length; i++) + { + if (readers[i].isPresent) + { + console.log("Reader Name: " + readers[i].getName()); + } + } + } + function error(err) + { + console.log(err.name + ": " + err.message); + } + tizen.seService.getReaders(success, error); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - function success(session) { - console.log ("Open Session Success : " + !session.isClosed); - } - function error(err) { - console.log (err.name + ": " + err.message); - } - reader.openSession(success, error); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + function success(session) + { + console.log("Open Session Success: " + !session.isClosed); + } + function error(err) + { + console.log(err.name + ": " + err.message); + } + reader.openSession(success, error); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - reader.closeSessions(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+try +{ + reader.closeSessions(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
try { - function successChannel(channel) { - if (channel.isBasicChannel) { - console.log ("Basic channel is opened."); - } else { - console.log ("Logical channel is opened."); - } - } - function errorChannel(err) { - console.log ("openBasicChannel Error :" + err.name +": " + err.message); - } +Code example:
+try +{ + function successChannel(channel) + { + if (channel.isBasicChannel) + { + console.log("Basic channel is opened."); + } + else + { + console.log("Logical channel is opened."); + } + } + function errorChannel(err) + { + console.log("openBasicChannel Error:" + err.name +": " + err.message); + } - function successSession(session) { - console.log ("Open Session Success : " + !session.isClosed); - // This aid is for test. Use aid for your applet in secure element. - session.openBasicChannel([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe], successChannel, errorChannel); - } - function errorSession(err) { - console.log ("openSession Error : " + err.name + ": " + err.message); - } - reader.openSession(successSession, errorSession); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+ function successSession(session) + { + console.log("Open Session Success: " + !session.isClosed); + /* This aid is for test. Use aid for your applet in secure element */ + session.openBasicChannel([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe], successChannel, errorChannel); + } + function errorSession(err) + { + console.log("openSession Error: " + err.name + ": " + err.message); + } + reader.openSession(successSession, errorSession); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var session; //Session obtained from openSession callback - try { - function successChannel(channel) { - if (channel.isBasicChannel) { - console.log ("Basic channel is opened."); - } else { - console.log ("Logical channel is opened."); - } - } - function errorChannel(err) { - console.log ("openLogicalChannel Error :" + err.name + ": " + err.message); - } +Code example:
+var session; /* Session obtained from openSession callback */ +try +{ + function successChannel(channel) + { + if (channel.isBasicChannel) + { + console.log("Basic channel is opened."); + } + else + { + console.log("Logical channel is opened."); + } + } + function errorChannel(err) + { + console.log("openLogicalChannel Error:" + err.name + ": " + err.message); + } - // This aid is for test. Use aid for your applet in secure element. - session.openLogicalChannel([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe], successChannel, errorChannel); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+ /* This aid is for test. Use aid for your applet in secure element */ + session.openLogicalChannel([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe], successChannel, errorChannel); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var session; //Session obtained from openSession callback - try { - var atr = session.getATR(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+var session; /* Session obtained from openSession callback */ +try +{ + var atr = session.getATR(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var session; //Session obtained from openSession callback - try { - session.close(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+var session; /* Session obtained from openSession callback */ +try +{ + session.close(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var session; //Session obtained from openSession callback - try { - session.closeChannels(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+var session; /* Session obtained from openSession callback */ +try +{ + session.closeChannels(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var channel; //Obtained from openLogicalChannel or openBasicChannel - try { - channel.close(); - } catch (err) { - console.log (err.name + ": " + err.message); - } -+
Code example:
+var channel; /* Obtained from openLogicalChannel or openBasicChannel */ +try +{ + channel.close(); +} +catch (err) +{ + console.log(err.name + ": " + err.message); +} +
Code example:
var proximityCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity"); - - if (proximityCapability === true) { - // the device supports proximity sensor and you can get proximity sensor's data - var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - } else { - // If tizen.sensorservice.getDefaultSensor("PROXIMITY") is used, NotSupportedError would be thrown. - console.log("Proximity sensor is not supported on this device."); - } -+
Code example:
+var proximityCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity"); + +if (proximityCapability === true) +{ + /* Device supports proximity sensor and you can get proximity sensor's data */ + var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); +} +else +{ + /* If tizen.sensorservice.getDefaultSensor("PROXIMITY") is used, NotSupportedError is thrown */ + console.log("Proximity sensor is not supported on this device."); +} +
Code example:
var sensorCapabilities = tizen.sensorservice.getAvailableSensors(); +Code example:
+var sensorCapabilities = tizen.sensorservice.getAvailableSensors(); - console.log("capable sensor : " + sensorCapabilities[0]); -+console.log("capable sensor: " + sensorCapabilities[0]); +
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); +Code example:
+var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - function onsuccessCB() { - console.log("The proximity sensor started successfully."); - } +function onsuccessCB() +{ + console.log("The proximity sensor started successfully."); +} - proximitySensor.start(onsuccessCB); -+proximitySensor.start(onsuccessCB); +
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); +Code example:
+var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - function onsuccessCB() { - console.log("proximity sensor start"); - proximitySensor.stop(); - } +function onsuccessCB() +{ + console.log("proximity sensor start"); + proximitySensor.stop(); +} - proximitySensor.start(onsuccessCB); -+proximitySensor.start(onsuccessCB); +
Code example:
var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); +Code example:
+var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); - function onsuccessCB() { +function onsuccessCB() +{ console.log("light sensor start"); - } +} - function onchangedCB(sensorData) { +function onchangedCB(sensorData) +{ console.log("light level: " + sensorData.lightLevel); - } +} - // interval and batchLatency can be ommitted. - lightSensor.setChangeListener(onchangedCB, 200, 2000); +/* interval and batchLatency can be omitted */ +lightSensor.setChangeListener(onchangedCB, 200, 2000); - lightSensor.start(onsuccessCB); -+lightSensor.start(onsuccessCB); +
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); +Code example:
+var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - function onchangedCB(sensorData) { - console.log("proximity distance : " + sensorData.proximityState); - } +function onchangedCB(sensorData) +{ + console.log("proximity distance: " + sensorData.proximityState); +} - proximitySensor.setChangeListener(onchangedCB); +proximitySensor.setChangeListener(onchangedCB); - proximitySensor.unsetChangeListener(); -+proximitySensor.unsetChangeListener(); +
Code example:
var gravitySensor = tizen.sensorservice.getDefaultSensor("GRAVITY"); - gravitySensor.getSensorHardwareInfo(onsuccessCB); - - function onsuccessCB(hardwareInfo){ - console.log("name: " + hardwareInfo.name); - console.log("type: " + hardwareInfo.type); - console.log("vendor: " + hardwareInfo.vendor); - console.log("minValue: " + hardwareInfo.minValue); - console.log("maxValue: " + hardwareInfo.maxValue); - console.log("resolution: " + hardwareInfo.resolution); - console.log("minInterval: " + hardwareInfo.minInterval); - console.log("maxBatchCount: " + hardwareInfo.maxBatchCount); - } -+
Code example:
+var gravitySensor = tizen.sensorservice.getDefaultSensor("GRAVITY"); +gravitySensor.getSensorHardwareInfo(onsuccessCB); + +function onsuccessCB(hardwareInfo) +{ + console.log("name: " + hardwareInfo.name); + console.log("type: " + hardwareInfo.type); + console.log("vendor: " + hardwareInfo.vendor); + console.log("minValue: " + hardwareInfo.minValue); + console.log("maxValue: " + hardwareInfo.maxValue); + console.log("resolution: " + hardwareInfo.resolution); + console.log("minInterval: " + hardwareInfo.minInterval); + console.log("maxBatchCount: " + hardwareInfo.maxBatchCount); +} +
Output example:
name: Gravity Sensor @@ -840,24 +856,27 @@ The ErrorCallback method is launched with these error types:
Code example:
var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); - - function onGetSuccessCB(sensorData) { - console.log("light level : " + sensorData.lightLevel); - } +Code example:
+var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); - function onerrorCB(error) { - console.log("error occurs"); - } +function onGetSuccessCB(sensorData) +{ + console.log("light level: " + sensorData.lightLevel); +} - function onsuccessCB() { - console.log("sensor start"); - lightSensor.getLightSensorData(onGetSuccessCB, onerrorCB); - } +function onerrorCB(error) +{ + console.log("error occurred"); +} - lightSensor.start(onsuccessCB); +function onsuccessCB() +{ + console.log("sensor start"); + lightSensor.getLightSensorData(onGetSuccessCB, onerrorCB); +} -+lightSensor.start(onsuccessCB); +
Code example:
var magneticSensor = tizen.sensorservice.getDefaultSensor("MAGNETIC"); - - function onGetSuccessCB(sensorData) { - console.log("magnetic field of the X axis : " + sensorData.x); - console.log("magnetic field of the Y axis : " + sensorData.y); - console.log("magnetic field of the Z axis : " + sensorData.z); - } - - function onerrorCB(error) { - console.log("error occurs"); - } - - function onsuccessCB() { - console.log("sensor start"); - magneticSensor.getMagneticSensorData(onGetSuccessCB, onerrorCB); - } - - magneticSensor.start(onsuccessCB); - -+
Code example:
+var magneticSensor = tizen.sensorservice.getDefaultSensor("MAGNETIC"); + +function onGetSuccessCB(sensorData) +{ + console.log("magnetic field of the X axis: " + sensorData.x); + console.log("magnetic field of the Y axis: " + sensorData.y); + console.log("magnetic field of the Z axis: " + sensorData.z); +} + +function onerrorCB(error) +{ + console.log("error occurred"); +} + +function onsuccessCB() +{ + console.log("sensor start"); + magneticSensor.getMagneticSensorData(onGetSuccessCB, onerrorCB); +} + +magneticSensor.start(onsuccessCB); +
Code example:
var pressureSensor = tizen.sensorservice.getDefaultSensor("PRESSURE"); +Code example:
+var pressureSensor = tizen.sensorservice.getDefaultSensor("PRESSURE"); - function onGetSuccessCB(sensorData) { - console.log("pressure : " + sensorData.pressure); - } +function onGetSuccessCB(sensorData) +{ + console.log("pressure: " + sensorData.pressure); +} - function onerrorCB(error) { - console.log("error occurs"); - } +function onerrorCB(error) +{ + console.log("error occurred"); +} - function onsuccessCB() { - console.log("sensor start"); - pressureSensor.getPressureSensorData(onGetSuccessCB, onerrorCB); - } +function onsuccessCB() +{ + console.log("sensor start"); + pressureSensor.getPressureSensorData(onGetSuccessCB, onerrorCB); +} - pressureSensor.start(onsuccessCB); - -+pressureSensor.start(onsuccessCB); +
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - - function onGetSuccessCB(sensorData) { - console.log("proximity state : " + sensorData.proximityState); - } +Code example:
+var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); - function onerrorCB(error) { - console.log("error occurs"); - } +function onGetSuccessCB(sensorData) +{ + console.log("proximity state: " + sensorData.proximityState); +} - function onsuccessCB() { - console.log("proximity sensor start"); - proximitySensor.getProximitySensorData(onGetSuccessCB, onerrorCB); - } +function onerrorCB(error) +{ + console.log("error occurred"); +} - proximitySensor.start(onsuccessCB); +function onsuccessCB() +{ + console.log("proximity sensor start"); + proximitySensor.getProximitySensorData(onGetSuccessCB, onerrorCB); +} -+proximitySensor.start(onsuccessCB); +
Code example:
var ultravioletSensor = tizen.sensorservice.getDefaultSensor("ULTRAVIOLET"); - - function onGetSuccessCB(sensorData) { - console.log("ultraviolet level : " + sensorData.ultravioletLevel); - } +Code example:
+var ultravioletSensor = tizen.sensorservice.getDefaultSensor("ULTRAVIOLET"); - function onerrorCB(error) { - console.log("error occurs"); - } +function onGetSuccessCB(sensorData) +{ + console.log("ultraviolet level: " + sensorData.ultravioletLevel); +} - function onsuccessCB() { - console.log("ultraviolet sensor start"); - ultravioletSensor.getUltravioletSensorData(onGetSuccessCB, onerrorCB); - } +function onerrorCB(error) +{ + console.log("error occurred"); +} - ultravioletSensor.start(onsuccessCB); +function onsuccessCB() +{ + console.log("ultraviolet sensor start"); + ultravioletSensor.getUltravioletSensorData(onGetSuccessCB, onerrorCB); +} -+ultravioletSensor.start(onsuccessCB); +
Code example:
var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW"); - - function onGetSuccessCB(sensorData) { - console.log("HRMRaw light intensity : " + sensorData.lightIntensity); - } +Code example:
+var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW"); - function onerrorCB(error) { - console.log("error occurs"); - } +function onGetSuccessCB(sensorData) +{ + console.log("HRMRaw light intensity: " + sensorData.lightIntensity); +} - function onsuccessCB() { - console.log("HRMRaw sensor start"); - HRMrawsensor.getHRMRawSensorData(onGetSuccessCB, onerrorCB); - } +function onerrorCB(error) +{ + console.log("error occurred"); +} - HRMrawsensor.start(onsuccessCB); +function onsuccessCB() +{ + console.log("HRMRaw sensor start"); + HRMrawsensor.getHRMRawSensorData(onGetSuccessCB, onerrorCB); +} -+HRMrawsensor.start(onsuccessCB); +
Code example:
var gravitySensor = tizen.sensorservice.getDefaultSensor("GRAVITY"); - - function onGetSuccessCB(sensorData) { - console.log("######## Get the gravity sensor data ########"); - console.log("x: " + sensorData.x); - console.log("y: " + sensorData.y); - console.log("z: " + sensorData.z); - } - - function onerrorCB(error) { - console.log("error occurs"); - } - - function onsuccessCB() { - console.log("sensor start"); - gravitySensor.getGravitySensorData(onGetSuccessCB, onerrorCB); - } - - gravitySensor.start(onsuccessCB); -+
Code example:
+var gravitySensor = tizen.sensorservice.getDefaultSensor("GRAVITY"); + +function onGetSuccessCB(sensorData) +{ + console.log("######## Get the gravity sensor data ########"); + console.log("x: " + sensorData.x); + console.log("y: " + sensorData.y); + console.log("z: " + sensorData.z); +} + +function onerrorCB(error) +{ + console.log("error occurred"); +} + +function onsuccessCB() +{ + console.log("sensor start"); + gravitySensor.getGravitySensorData(onGetSuccessCB, onerrorCB); +} + +gravitySensor.start(onsuccessCB); +
Output example:
sensor start @@ -1491,26 +1529,30 @@ The ErrorCallback method is launched with these error types:
Code example:
var gyroscopeSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE"); - - function onGetSuccessCB(sensorData) { - console.log("######## Get the gyroscope sensor date ########"); - console.log("x: " + sensorData.x); - console.log("y: " + sensorData.y); - console.log("z: " + sensorData.z); - } - - function onerrorCB(error) { - console.log("error occurs"); - } - - function onsuccessCB() { - console.log("sensor start"); - gyroscopeSensor.getGyroscopeSensorData(onGetSuccessCB, onerrorCB); - } - - gyroscopeSensor.start(onsuccessCB); -+
Code example:
+var gyroscopeSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE"); + +function onGetSuccessCB(sensorData) +{ + console.log("######## Get the gyroscope sensor date ########"); + console.log("x: " + sensorData.x); + console.log("y: " + sensorData.y); + console.log("z: " + sensorData.z); +} + +function onerrorCB(error) +{ + console.log("error occurred"); +} + +function onsuccessCB() +{ + console.log("sensor start"); + gyroscopeSensor.getGyroscopeSensorData(onGetSuccessCB, onerrorCB); +} + +gyroscopeSensor.start(onsuccessCB); +
Output example:
sensor start @@ -1590,27 +1632,31 @@ The ErrorCallback method is launched with these error types:
Code example:
var gyroscopeRotationVectorSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE_ROTATION_VECTOR"); - - function onGetSuccessCB(sensorData) { - console.log("######## Get the gyroscope rotation vector sensor data ########"); - console.log("x: " + sensorData.x); - console.log("y: " + sensorData.y); - console.log("z: " + sensorData.z); - console.log("w: " + sensorData.w); - } - - function onerrorCB(error) { - console.log("error occurs"); - } - - function onsuccessCB() { - console.log("sensor start"); - gyroscopeRotationVectorSensor.getGyroscopeRotationVectorSensorData(onGetSuccessCB, onerrorCB); - } - - gyroscopeRotationVectorSensor.start(onsuccessCB); -+
Code example:
+var gyroscopeRotationVectorSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE_ROTATION_VECTOR"); + +function onGetSuccessCB(sensorData) +{ + console.log("######## Get the gyroscope rotation vector sensor data ########"); + console.log("x: " + sensorData.x); + console.log("y: " + sensorData.y); + console.log("z: " + sensorData.z); + console.log("w: " + sensorData.w); +} + +function onerrorCB(error) +{ + console.log("error occurred"); +} + +function onsuccessCB() +{ + console.log("sensor start"); + gyroscopeRotationVectorSensor.getGyroscopeRotationVectorSensorData(onGetSuccessCB, onerrorCB); +} + +gyroscopeRotationVectorSensor.start(onsuccessCB); +
Output example:
sensor start @@ -1691,26 +1737,30 @@ The ErrorCallback method is launched with these error types:
Code example:
var linearAccelerationSensor = tizen.sensorservice.getDefaultSensor("LINEAR_ACCELERATION"); - - function onGetSuccessCB(sensorData) { - console.log("######## Get the linear acceleration sensor data ########"); - console.log("x: " + sensorData.x); - console.log("y: " + sensorData.y); - console.log("z: " + sensorData.z); - } - - function onerrorCB(error) { - console.log("error occured"); - } - - function onsuccessCB() { - console.log("linear acceleration sensor start"); - linearAccelerationSensor.getLinearAccelerationSensorData(onGetSuccessCB, onerrorCB); - } - - linearAccelerationSensor.start(onsuccessCB); -+
Code example:
+var linearAccelerationSensor = tizen.sensorservice.getDefaultSensor("LINEAR_ACCELERATION"); + +function onGetSuccessCB(sensorData) +{ + console.log("######## Get the linear acceleration sensor data ########"); + console.log("x: " + sensorData.x); + console.log("y: " + sensorData.y); + console.log("z: " + sensorData.z); +} + +function onerrorCB(error) +{ + console.log("error occurred"); +} + +function onsuccessCB() +{ + console.log("linear acceleration sensor start"); + linearAccelerationSensor.getLinearAccelerationSensorData(onGetSuccessCB, onerrorCB); +} + +linearAccelerationSensor.start(onsuccessCB); +
Output example:
linear acceleration sensor start diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/sound.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/sound.html index c2fc956..594fc9c 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/sound.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/sound.html @@ -551,12 +551,14 @@ There is a tizen.sound object that allows accessing the functionality of the Sou
Code example:
var infoArr = tizen.sound.getConnectedDeviceList(); +Code example:
+var infoArr = tizen.sound.getConnectedDeviceList(); - for (var i = 0; i < infoArr.length; i++) { - console.log( infoArr[i].device ); - } -+for (var i = 0; i < infoArr.length; i++) +{ + console.log(infoArr[i].device); +} +
Code example:
var infoArr = tizen.sound.getActivatedDeviceList(); +Code example:
+var infoArr = tizen.sound.getActivatedDeviceList(); - for (var i = 0; i < infoArr.length; i++) { - console.log( infoArr[i].device ); - } -+for (var i = 0; i < infoArr.length; i++) +{ + console.log(infoArr[i].device); +} +
Code example:
// A callback - var onChanged = function(info) { - // Some code to execute when a sound device state is changed - if (info.isConnected) { - // Some code to execute if the device is connected. - console.log( info.device + " is connected" ); - } else { - // Some code to execute if the device is not connected. - console.log( info.device + " is not connected" ); - } +Code example:
+/* Callback */ +var onChanged = function(info) +{ + /* Some code to execute when a sound device state is changed */ + if (info.isConnected) + { + /* Some code to execute if the device is connected */ + console.log(info.device + " is connected"); + } + else + { + /* Some code to execute if the device is not connected */ + console.log(info.device + " is not connected"); + } - if (info.isActivated) { - // Some code to execute if the device is activated. - console.log( info.device + " is activated" ); - } else { - // Some code to execute if the device is not activated. - console.log( info.device + " is not activated" ); - } - } + if (info.isActivated) + { + /* Some code to execute if the device is activated */ + console.log(info.device + " is activated"); + } + else + { + /* Some code to execute if the device is not activated */ + console.log(info.device + " is not activated"); + } +} - var id = tizen.sound.addDeviceStateChangeListener(onChanged); -+var id = tizen.sound.addDeviceStateChangeListener(onChanged); +
Code example:
// If a listener to be called was registered previously. - tizen.sound.removeDeviceStateChangeListener(id); -+
Code example:
+/* If a listener to be called was registered previously */ +tizen.sound.removeDeviceStateChangeListener(id); +
Code example:
// To get total amount of system memory - console.log("The total memory size is " + tizen.systeminfo.getTotalMemory() + " bytes."); -+
Code example:
+/* To get total amount of system memory */ +console.log("The total memory size is " + tizen.systeminfo.getTotalMemory() + " bytes."); +
Code example:
// To get total amount of system memory - console.log("The available memory size is " + tizen.systeminfo.getAvailableMemory() + " bytes."); -+
Code example:
+/* To get total amount of system memory */ +console.log("The available memory size is " + tizen.systeminfo.getAvailableMemory() + " bytes."); +
Code example:
var deviceCapabilities; - deviceCapabilities = tizen.systeminfo.getCapabilities(); - if (deviceCapabilities.bluetooth) { - console.log("Bluetooth is supported"); - } -+
Code example:
+var deviceCapabilities; +deviceCapabilities = tizen.systeminfo.getCapabilities(); +if (deviceCapabilities.bluetooth) +{ + console.log("Bluetooth is supported"); +} +
Code example:
try { - // Checks if a device supports bluetooth API or not - var bluetooth = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth"); - console.log(" Bluetooth = " + bluetooth); - } catch (error) { - console.log("Error name: " + error.name + ", message: " + error.message); - } -+
Code example:
+try +{ + /* Checks if a device supports bluetooth API */ + var bluetooth = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth"); + console.log(" Bluetooth = " + bluetooth); +} +catch (error) +{ + console.log("Error name: " + error.name + ", message: " + error.message); +} +
Code example:
var count = tizen.systeminfo.getCount("SIM"); - if (count === 0) { - console.log("There is no available SIM card."); - } else { - console.log("There is(are) " + count + " SIM card(s) available."); - } -+
Code example:
+var count = tizen.systeminfo.getCount("SIM"); +if (count === 0) +{ + console.log("There is no available SIM card."); +} +else +{ + console.log("There is(are) " + count + " SIM card(s) available."); +} +
Code example:
function onSuccessCallback(cpu) { - console.log("The cpu load is " + cpu.load); - } +Code example:
+function onSuccessCallback(cpu) +{ + console.log("The cpu load is " + cpu.load); +} - function onErrorCallback(error) { - console.log("An error occurred " + error.message); - } +function onErrorCallback(error) +{ + console.log("An error occurred " + error.message); +} - tizen.systeminfo.getPropertyValue("CPU", onSuccessCallback, onErrorCallback); -+tizen.systeminfo.getPropertyValue("CPU", onSuccessCallback, onErrorCallback); +
Code example:
function onSuccessCallback(cellular) { - console.log("The status of the cellular network is " + cellular.status); - } - - function onErrorCallback(error) { - console.log("An error occurred " + error.message); - // if telephony_capability is false but getPropertyValue("CELLULAR_NETWORK, ..) is called, NotSupportedError would be passed. - } - - var telephony_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.telephony"); - - if (telephony_capability === true) { - // onSuccessCallback will be invoked. - tizen.systeminfo.getPropertyValue("CELLULAR_NETWORK", onSuccessCallback, onErrorCallback); - } else { - console.log("Telephony feature is not supported. Cellular network related information cannot be retrieved."); - } -+
Code example:
+function onSuccessCallback(cellular) +{ + console.log("The status of the cellular network is " + cellular.status); +} + +function onErrorCallback(error) +{ + console.log("An error occurred " + error.message); + /* If telephony_capability is false but getPropertyValue("CELLULAR_NETWORK, ..) is called, NotSupportedError is passed */ +} + +var telephony_capability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.telephony"); + +if (telephony_capability === true) +{ + /* onSuccessCallback will be invoked */ + tizen.systeminfo.getPropertyValue("CELLULAR_NETWORK", onSuccessCallback, onErrorCallback); +} +else +{ + console.log("Telephony feature is not supported. Cellular network related information cannot be retrieved."); +} +
Code example:
function successCB(property) { - console.log("The SIM's current state is " + property.state); - } - - function successArrayCB(properties) { - console.log("The number of the returned system properties is " + properties.length); - for (var i = 0; i < properties.length; i++) { - console.log("[" + i + "] SIM's state is " + properties[i].state); - } - } - - var count = tizen.systeminfo.getCount("SIM"); - if (count === 0) { - console.log("This device does not provide SIM card."); - } else if (count > 1) { - tizen.systeminfo.getPropertyValueArray("SIM", successArrayCB); - } else { - tizen.systeminfo.getPropertyValue("SIM", successCB); - } -+
Code example:
+function successCB(property) +{ + console.log("The SIM's current state is " + property.state); +} + +function successArrayCB(properties) +{ + console.log("The number of the returned system properties is " + properties.length); + for (var i = 0; i < properties.length; i++) + { + console.log("[" + i + "] SIM's state is " + properties[i].state); + } +} + +var count = tizen.systeminfo.getCount("SIM"); +if (count === 0) +{ + console.log("This device does not provide SIM card."); +} +else if (count > 1) +{ + tizen.systeminfo.getPropertyValueArray("SIM", successArrayCB); +} +else +{ + tizen.systeminfo.getPropertyValue("SIM", successCB); +} +
Code example:
function onSuccessCallback(cpu) { - console.log("The cpu load : " + cpu.load); - } +Code example:
+function onSuccessCallback(cpu) +{ + console.log("The cpu load: " + cpu.load); +} - tizen.systeminfo.addPropertyValueChangeListener("CPU", onSuccessCallback, {lowThreshold : 0.2}); -+tizen.systeminfo.addPropertyValueChangeListener("CPU", onSuccessCallback, {lowThreshold: 0.2}); +
Code example:
var id = null; - function onSuccessCallback(cpu) { - console.log("New value for CPU load is " + cpu.load); - if (id != null) { // After receiving the first notification, we clear it - tizen.systeminfo.removePropertyValueChangeListener(id); - } - } - - id = tizen.systeminfo.addPropertyValueChangeListener("CPU", onSuccessCallback); -+
Code example:
+var id = null; +function onSuccessCallback(cpu) +{ + console.log("New value for CPU load is " + cpu.load); + if (id != null) + { + /* After receiving the first notification, clear it */ + tizen.systeminfo.removePropertyValueChangeListener(id); + } +} + +id = tizen.systeminfo.addPropertyValueChangeListener("CPU", onSuccessCallback); +
Code example:
tizen.systeminfo.getPropertyValue("CAMERA_FLASH", - function (flash) { - console.log("Flash brightness is set to: " + (flash.brightness * 100).toFixed(0) + "%"); - }, - function (error) { - console.log("Error, name: " + error.name + ", message: " + error.message); - } - ); -+
Code example:
+tizen.systeminfo.getPropertyValue("CAMERA_FLASH", function(flash) +{ + console.log("Flash brightness is set to: " + (flash.brightness * 100).toFixed(0) + "%"); +}, function(error) +{ + console.log("Error, name: " + error.name + ", message: " + error.message); +}); +
Code example:
tizen.systeminfo.getPropertyValue("CAMERA_FLASH", - function (flash) { - try { - flash.setBrightness(1); - } catch (error) { - console.log("Setting flash brightness failed: " + error.message); - } - }, - function (error) { - console.log("Error, name: " + error.name + ", message: " + error.message); - } - ); -+
Code example:
+tizen.systeminfo.getPropertyValue("CAMERA_FLASH", function(flash) +{ + try + { + flash.setBrightness(1); + } + catch (error) + { + console.log("Setting flash brightness failed: " + error.message); + } +}, function(error) +{ + console.log("Error, name: " + error.name + ", message: " + error.message); +}); +
Code example:
// Checks whether SystemSetting API is supported. - var systemsetting_api_supported = tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting"); +Code example:
+/* Checks whether SystemSetting API is supported */ +var systemsetting_api_supported = tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting"); - // Checks whether the picture on home screen can be changed or retrieved through SystemSetting API. - var home_screen_system_setting = tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting.home_screen"); +/* Checks whether the picture on home screen can be changed or retrieved through SystemSetting API */ +var home_screen_system_setting = tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting.home_screen"); - // Defines the success callback. - function successCallback() { - console.log("Succeeded in changing the property"); - } +/* Defines the success callback */ +function successCallback() +{ + console.log("Succeeded in changing the property"); +} - // Defines the error callback. - function errorCallback(error) { - console.log("Failed to change the property. Error : " + error.message); - } +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Failed to change the property. Error: " + error.message); +} - if (systemsetting_api_supported === true) { - // tizen.systemsetting will be available. - if (home_screen_system_setting === true) { - // Sets the home screen image. - // The newHomeScreenImagePath variable should hold the path of the image to be set as home screen background - tizen.systemsetting.setProperty("HOME_SCREEN", newHomeScreenImagePath, successCallback, errorCallback); - } else { - // if tizen.systemsetting.setProperty("HOME_SCREEN", ..) is invoked, NotSupportedError would be returned through ErrorCallback. - } - } else { - // tizen.systemsetting will be 'undefined'. - console.log("SystemSetting API is not supported on the device."); - } - -+if (systemsetting_api_supported === true) +{ + /* tizen.systemsetting will be available */ + if (home_screen_system_setting === true) + { + /* Sets the home screen image */ + /* newHomeScreenImagePath variable should hold the path of the image to be set as home screen background */ + tizen.systemsetting.setProperty("HOME_SCREEN", newHomeScreenImagePath, successCallback, errorCallback); + } + else + { + /* if tizen.systemsetting.setProperty("HOME_SCREEN", ..) is invoked, NotSupportedError is returned through ErrorCallback */ + } +} +else +{ + /* tizen.systemsetting will be 'undefined' */ + console.log("SystemSetting API is not supported on the device."); +} +
Code example:
// Defines the success callback - function getPropertySuccessCallback(value) { - // the case : tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting.home_screen") returns 'true'. - console.log("Succeeded in retrieving the property. The value is " + value); - } - - // Defines the error callback. - function errorCallback(error) { - console.log("Failed to get the property. Error : " + error.message); - // If the device does not support to get the image on home screen, NotSupportedError would be thrown. - } +Code example:
+/* Defines the success callback */ +function getPropertySuccessCallback(value) +{ + /* Case: tizen.systeminfo.getCapability("http://tizen.org/feature/systemsetting.home_screen") returns 'true' */ + console.log("Succeeded in retrieving the property. The value is " + value); +} - tizen.systemsetting.getProperty("HOME_SCREEN", getPropertySuccessCallback, errorCallback); +/* Defines the error callback */ +function errorCallback(error) +{ + console.log("Failed to get the property. Error: " + error.message); + /* If the device does not support to get the image on home screen, NotSupportedError is thrown */ +} -+tizen.systemsetting.getProperty("HOME_SCREEN", getPropertySuccessCallback, errorCallback); +
Code example:
var current_dt = tizen.time.getCurrentDateTime(); - console.log("current date/time is " + current_dt.toLocaleString()); -+
Code example:
+var current_dt = tizen.time.getCurrentDateTime(); +console.log("current date/time is " + current_dt.toLocaleString()); +
Code example:
console.log("The local time zone is " + tizen.time.getLocalTimezone()); -+
Code example:
+console.log("The local time zone is " + tizen.time.getLocalTimezone()); +
Code example:
// Note that it is possible to get the time zone description in other formats, e.g. by calling: - now = new tizen.TZDate(new Date(), 'Asia/Manila'); +Code example:
+/* Note that it is possible to get the time zone description in other formats, e.g. by calling */ +now = new tizen.TZDate(new Date(), 'Asia/Manila'); - // Outputs "Wednesday, January 27, 2016, 8:46:00 PM GMT+0800 Philippines Time" - console.log(now.toString()); -+/* Outputs "Wednesday, January 27, 2016, 8:46:00 PM GMT+0800 Philippines Time" */ +console.log(now.toString()); +
Code example:
var tzids = tizen.time.getAvailableTimezones(); - console.log("The device supports " + tzids.length + " time zones."); -+
Code example:
+var tzids = tizen.time.getAvailableTimezones(); +console.log("The device supports " + tzids.length + " time zones."); +
Code example:
var tzids = tizen.time.getAvailableTimezones(); - var currentLocation = 'Europe/Berlin'; +Code example:
+var tzids = tizen.time.getAvailableTimezones(); +var currentLocation = 'Europe/Berlin'; - // checks whether an entry 'Europe/Berlin' exists in the array. - if (tzids.indexOf(currentLocation) > -1) { - console.log('The device supports ' + currentLocation + ' timezone.'); - } else { - console.log('The device does not support ' + currentLocation + ' timezone.'); - } -+/* Checks whether an entry 'Europe/Berlin' exists in the array */ +if (tzids.indexOf(currentLocation) > -1) +{ + console.log('The device supports ' + currentLocation + ' timezone.'); +} +else +{ + console.log('The device does not support ' + currentLocation + ' timezone.'); +} +
Code example:
// Gets the long date format, e.g. "D, M d y". - var dateFormat = tizen.time.getDateFormat(); +Code example:
+/* Gets the long date format, e.g. "D, M d y" */ +var dateFormat = tizen.time.getDateFormat(); - // Gets the short date format, e.g. "d/m/y". - var shortDateFormat = tizen.time.getDateFormat(true); +/* Gets the short date format, e.g. "d/m/y" */ +var shortDateFormat = tizen.time.getDateFormat(true); - console.log("Long date format: " + dateFormat); -+console.log("Long date format: " + dateFormat); +
Code example:
// Gets the time format, e.g. "h:m:s ap". - var timeFormat = tizen.time.getTimeFormat(); +Code example:
+/* Gets the time format, e.g. "h:m:s ap" */ +var timeFormat = tizen.time.getTimeFormat(); - console.log(timeFormat); -+console.log(timeFormat); +
Code example:
var current_dt = tizen.time.getCurrentDateTime(); - var is_leap = tizen.time.isLeapYear(current_dt.getFullYear()); - if (is_leap) { - console.log("This year is a leap year."); - } -+
Code example:
+var current_dt = tizen.time.getCurrentDateTime(); +var is_leap = tizen.time.isLeapYear(current_dt.getFullYear()); +if (is_leap) +{ + console.log("This year is a leap year."); +} +
Code example:
var changedCallback = function() { - try { - var current_dt = tizen.time.getCurrentDateTime(); - console.log("current date/time is " + current_dt.toLocaleString()); - - } catch (err) { - console.log (err.name + ": " + err.message); - } - }; - - tizen.time.setDateTimeChangeListener(changedCallback); - -+
Code example:
+var changedCallback = function() +{ + try + { + var current_dt = tizen.time.getCurrentDateTime(); + console.log("current date/time is " + current_dt.toLocaleString()); + } + catch (err) + { + console.log(err.name + ": " + err.message); + } +}; + +tizen.time.setDateTimeChangeListener(changedCallback); +
Code example:
var changedCallback = function() { - try { - var current_dt = tizen.time.getCurrentDateTime(); - console.log("current date/time is " + current_dt.toLocaleString()); - tizen.time.unsetDateTimeChangeListener(); - } catch (err) { - console.log (err.name + ": " + err.message); - } - }; - - tizen.time.setDateTimeChangeListener(changedCallback); - -+
Code example:
+var changedCallback = function() +{ + try + { + var current_dt = tizen.time.getCurrentDateTime(); + console.log("current date/time is " + current_dt.toLocaleString()); + tizen.time.unsetDateTimeChangeListener(); + } + catch (err) + { + console.log(err.name + ": " + err.message); + } +}; + +tizen.time.setDateTimeChangeListener(changedCallback); +
Code example:
var changedCallback = function() { - try { - // The new time zone can be retrieved through tizen.time.getLocalTimezone() - var zone = tizen.time.getLocalTimezone(); - console.log("current time zone is " + zone); - } catch (err) { - console.log (err.name + ": " + err.message); - } - }; - - tizen.time.setTimezoneChangeListener(changedCallback); - -+
Code example:
+var changedCallback = function() +{ + try + { + /* New time zone can be retrieved through tizen.time.getLocalTimezone() */ + var zone = tizen.time.getLocalTimezone(); + console.log("current time zone is " + zone); + } + catch (err) + { + console.log(err.name + ": " + err.message); + } +}; + +tizen.time.setTimezoneChangeListener(changedCallback); +
Code example:
var changedCallback = function() { - try { - var zone = tizen.time.getLocalTimezone(); - console.log("current time zone is " + zone); - tizen.time.unsetTimezoneChangeListener(); - } catch (err) { - console.log (err.name + ": " + err.message); - } - }; - - tizen.time.setTimezoneChangeListener(changedCallback); -+
Code example:
+var changedCallback = function() +{ + try + { + var zone = tizen.time.getLocalTimezone(); + console.log("current time zone is " + zone); + tizen.time.unsetTimezoneChangeListener(); + } + catch (err) + { + console.log(err.name + ": " + err.message); + } +}; + +tizen.time.setTimezoneChangeListener(changedCallback); +
Code example:
// Creates a new TZDate object with current date/time and timezone: - var now = new tizen.TZDate(); +Code example:
+/* Creates a new TZDate object with current date/time and timezone */ +var now = new tizen.TZDate(); - // Creates a new TZDate object with date set to 1st of January 2016 in time zone for Germany: - var newYear = new tizen.TZDate(new Date("2016-01-01"), 'Europe/Berlin'); +/* Creates a new TZDate object with date set to 1st of January 2016 in time zone for Germany */ +var newYear = new tizen.TZDate(new Date("2016-01-01"), 'Europe/Berlin'); - // Creates a new TZDate object with values set explicitly: - var myDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/Berlin'); -+/* Creates a new TZDate object with values set explicitly */ +var myDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/Berlin'); +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getDate()); // should output 31. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getDate()); /* Outputs 31 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setDate(1); // Changes the day of month to 1. - console.log(someDate.getDate()); // should output 1. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setDate(1); /* Changes the day of month to 1 */ +console.log(someDate.getDate()); /* Outputs 1 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getDay()); // should output "5", because 31st of December 1999 was friday. - +Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getDay()); /* Outputs "5", because 31st of December 1999 was Friday */
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getFullYear()); // should output 1999. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getFullYear()); /* Outputs 1999 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setFullYear(2099); // Changes the year to 2099. - console.log(someDate.getFullYear()); // should output 2099. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setFullYear(2099); /* Changes the year to 2099 */ +console.log(someDate.getFullYear()); /* Outputs 2099 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getHours()); // should output 23. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getHours()); /* Outputs 23 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setHours(15); // Sets the hour to 3 PM. - console.log(someDate.getHours()); // should output 15. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setHours(15); /* Sets the hour to 3 PM */ +console.log(someDate.getHours()); /* Outputs 15 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getMilliseconds()); // should output 999. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getMilliseconds()); /* Outputs 999 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setMilliseconds(42); - console.log(someDate.getMilliseconds()); // should output 42. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setMilliseconds(42); +console.log(someDate.getMilliseconds()); /* Outputs 42 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getMinutes()); // should output 59. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getMinutes()); /* Outputs 59 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setMinutes(58); - console.log(someDate.getMinutes()); // should output 58. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setMinutes(58); +console.log(someDate.getMinutes()); /* Outputs 58 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getMonth()); // should output 11. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getMonth()); /* Outputs 11 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setMonth(2); // Changes the month to March. - console.log(someDate.getMonth()); // should output 2. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setMonth(2); /* Changes the month to March */ +console.log(someDate.getMonth()); /* Outputs 2 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getSeconds()); // should output 59. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getSeconds()); /* Outputs 59 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setSeconds(23); - console.log(someDate.getSeconds()); // should output 23. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setSeconds(23); +console.log(someDate.getSeconds()); /* Outputs 23 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCDate()); // should output 31. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCDate()); /* Outputs 31 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCDate(5) // Change the day of month to 5th. - console.log(someDate.getUTCDate()); // should output 5. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCDate(5) /* Change the day of month to 5th */ +console.log(someDate.getUTCDate()); /* Outputs 5 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCDay()); // should output 5, since 31st of December 1999 was friday. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCDay()); /* Outputs 5, since 31st of December 1999 was Friday */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCFullYear()); // should output 1999. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCFullYear()); /* Outputs 1999 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCFullYear(2099); // Change the year to 2099, universal time. - console.log(someDate.getUTCFullYear()); // should output 2099. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCFullYear(2099); /* Change the year to 2099, universal time */ +console.log(someDate.getUTCFullYear()); /* Outputs 2099 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCHours()); // should output 23. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCHours()); /* Outputs 23 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCHours(15); - console.log(someDate.getUTCHours()); // should output 15. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCHours(15); +console.log(someDate.getUTCHours()); /* Outputs 15 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCMilliseconds()); // should output 999. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCMilliseconds()); /* Outputs 999 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCMillisecond(42); - console.log(someDate.getUTCMilliseconds()); // should output 42. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCMillisecond(42); +console.log(someDate.getUTCMilliseconds()); /* Outputs 42 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCMinutes()); // should output 59. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCMinutes()); /* Outputs 59 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCMinutes(58); - console.log(someDate.getUTCMinutes()); // should output 58. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCMinutes(58); +console.log(someDate.getUTCMinutes()); /* Outputs 58 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCMonth()); // should output 11. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCMonth()); /* Outputs 11 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCMonth(2); // Sets the month to March, according to the universal time. - console.log(someDate.getUTCMonth()); // should output 2. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCMonth(2); /* Sets the month to March, according to the universal time */ +console.log(someDate.getUTCMonth()); /* Outputs 2 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getUTCSeconds()); // should output 59. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getUTCSeconds()); /* Outputs 59 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - someDate.setUTCSeconds(23); - console.log(someDate.getUTCSeconds()); // should output 23. -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +someDate.setUTCSeconds(23); +console.log(someDate.getUTCSeconds()); /* Outputs 23 */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - console.log(someDate.getTimezone()); // should output "Europe/London". -+
Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +console.log(someDate.getTimezone()); /* Outputs "Europe/London" */ +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - var koreanDate = someDate.toTimezone("Asia/Seoul"); +Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +var koreanDate = someDate.toTimezone("Asia/Seoul"); - // Should output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" - console.log(someDate.toString()); -+/* Output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" */ +console.log(someDate.toString()); +
Code example:
// This example assumes that the device's local time zone is set to Asia/Seoul. - // You may get different results depending on your local time zone settings. - var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); - var localDate = someDate.toLocalTimezone(); +Code example:
+/* + This example assumes that the device's local time zone is set to Asia/Seoul + You may get different results depending on your local time zone settings +*/ +var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London"); +var localDate = someDate.toLocalTimezone(); - // Should output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" - console.log(localDate.toString()); -+/* Output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" */ +console.log(localDate.toString()); +
Code example:
var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Asia/Seoul"); - var utcDate = someDate.toUTC(); +Code example:
+var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Asia/Seoul"); +var utcDate = someDate.toUTC(); - // Should output: "Friday, December 31, 1999, 2:59:59 PM GMT+0000 GMT" - console.log(utcDate.toString()); -+/* Output: "Friday, December 31, 1999, 2:59:59 PM GMT+0000 GMT" */ +console.log(utcDate.toString()); +
Code example:
// Prepares two TZDates pointing at new year eves in 2011 and 2012, respectively: - var newYearEve2011 = new tizen.TZDate(2011, 0, 0, 0, 0, 0, 0, "Europe/London"); - var newYearEve2012 = new tizen.TZDate(2012, 0, 0, 0, 0, 0, 0, "Europe/London"); +