$("#configuration-window-save-btn").bind("click", function () { var _type, _device, _custom_width = 0, _custom_height = 0, programs, deviceInfo, _settings; deviceInfo = db.retrieveObject(_PERSISTENCE_KEY); db.saveObject(_DEVICESETTING_SAVE_KEY, deviceInfo); _device = jQuery("#device-select").val(); _type = jQuery('input:radio[name="resolution-type"]:checked').val(); if (_type === "custom") { _device = "custom"; _custom_width = jQuery("#resolution-custom-width").val(); _custom_height = jQuery("#resolution-custom-height").val(); } _settings = { platformId : jQuery("#platform-select").val(), version : jQuery("#version-select").val(), device : _device, type : _type, custom_width : _custom_width, custom_height : _custom_height }; db.saveObject(_KEY, _settings); programs = db.retrieveObject(_DB_APPLICATION_KEY); db.saveObject(_DB_APPLICATION_SAVE_KEY, programs); });
function _initialize() { var adapterName, devs; _data.bluetoothClassDeviceMajor = new BluetoothClassDeviceMajor(); _data.bluetoothClassDeviceMinor = new BluetoothClassDeviceMinor(); _data.bluetoothClassDeviceService = new BluetoothClassDeviceService(); adapterName = db.retrieveObject(_data.DB_BLUETOOTH_KEY) || _data.DEFAULT_ADAPTER_NAME; _data.adapter = new BluetoothAdapter(adapterName, _data.DEFAULT_ADAPTER_ADDRESS); // get defalt nearby devices devs = db.retrieveObject("bt-simulated-devices"); utils.forEach(devs, function (item) { if (!_data.availableDevs[item.address]) { _data.availableDevs[item.address] = new BluetoothDevice({ name: item.name, address: item.address, deviceClass: item.deviceClass, isBonded: false, isTrusted: item.isTrusted, isConnected: false, services: item.services, metaData: _security }); } }); }
function _initContacts() { var data = db.retrieveObject(_CONTACT_KEY), contactsSelect = document.getElementById("call-local-phone-number"), displayName = null, number = null, index = 0, i; contactsSelect.innerHTML = ""; utils.forEach(data, function (addrBook) { utils.forEach(addrBook._contacts, function (contact) { if (contact.name && contact.name && contact.phoneNumbers && contact.phoneNumbers.length > 0) { displayName = contact.name.firstName + ' ' + contact.name.lastName; number = contact.phoneNumbers[0].number; _contactMap[number] = displayName; contactsSelect.appendChild(utils.createElement("option", { "innerText": displayName + ':' + number, "value": index })); index++; } }); }); if (displayName === null && number === null) { for (i in _contactMap) { displayName = _contactMap[i]; number = i; contactsSelect.appendChild(utils.createElement("option", { "innerText": displayName + ':' + number, "value": index })); } } }
function flightModeChangedCB(value) { var networkSettings = {}; if (value === true) { networkSettings['wifiSetting'] = deviceSettings.retrieve("WIFI_NETWORK.status"); networkSettings['cellularSetting'] = deviceSettings.retrieve("CELLULAR_NETWORK.status"); //networkSettings['bluetoothSetting'] = deviceSettings.retrieve("CELLULAR_NETWORK.status"); //networkSettings['nfcSetting'] = deviceSettings.retrieve("CELLULAR_NETWORK.status"); db.saveObject(DBNETWORKSETTING_KEY, networkSettings); deviceSettings.persist("CELLULAR_NETWORK.status", false); deviceSettings.persist("WIFI_NETWORK.status", false); event.trigger("nfc-power-setting", [false]); event.trigger("bt-power-setting", [false]); document.getElementById("device-settings-WIFI_NETWORK-status").checked = false; document.getElementById("device-settings-CELLULAR_NETWORK-status").checked = false; $("#device-settings-CELLULAR_NETWORK-status").parent().append("<span id='config_flight_mode_notice' style='color:#555555;'> (Disabled for Flight Mode)</span>"); document.getElementById("device-settings-CELLULAR_NETWORK-status").disabled = true; } else { networkSettings = db.retrieveObject(DBNETWORKSETTING_KEY)||{"wifiSetting": true, "cellularSetting": true}; deviceSettings.persist("WIFI_NETWORK.status", networkSettings['wifiSetting']); deviceSettings.persist("CELLULAR_NETWORK.status", networkSettings['cellularSetting']); document.getElementById("device-settings-WIFI_NETWORK-status").checked = networkSettings['wifiSetting']; document.getElementById("device-settings-CELLULAR_NETWORK-status").checked = networkSettings['cellularSetting']; $("#config_flight_mode_notice").remove(); document.getElementById("device-settings-CELLULAR_NETWORK-status").disabled = false; } }
pendingObj.pendingID = setTimeout(function () { pendingObj.setCancelFlag(false); cal = db.retrieveObject(_DB_CALENDARS_KEY) || []; _calendars = []; if (cal.length === 0) { _calendars.push(new Calendar(_SIM_CALENDAR, "sim cal", {})); _calendars.push(new Calendar(_DEVICE_CALENDAR, "dev cal", {})); } else { for (i = 0; i < cal.length; i++) { /* after getting Date out of DB, Date will become a string, so need to recast it back to Date */ /* NOTE: id becomes writable, so need to recast it before passing to application */ for (var e in cal[i].events) { if ((cal[i].events[e].startTime !== undefined) && cal[i].events[e].startTime !== null) { cal[i].events[e].startTime = new Date(cal[i].events[e].startTime); } if ((cal[i].events[e].expires !== undefined) && cal[i].events[e].expires !== null) { cal[i].events[e].expires = new Date(cal[i].events[e].expires); } } _calendars.push(new Calendar(cal[i].type, cal[i].name, cal[i].events)); } } if (_calendars.length !== 0) { onSuccess(utils.copy(_calendars)); } else { if (onError) { onError(new DeviceApiError(errorcode.UNKNOWN_ERR)); } } }, _FAKEWAITTIME);
getCallRecordCnt: function (callRecordType) { utils.validateNumberOfArguments(1, 1, arguments.length, ExceptionTypes.INVALID_PARAMETER, "getCallRecordCnt invalid number of parameters", new Exception()); var calls = db.retrieveObject(constants.TELEPHONY.CALL_LIST_KEY); return utils.sum(calls, function (call) { return call.callRecordType === callRecordType; }); },
function _initializeTelephonyView() { var calls = db.retrieveObject(constants.TELEPHONY.CALL_LIST_KEY); utils.forEach(calls, function (call) { _addRow(call.callRecordType, call.callRecordAddress, call.callRecordName); }); }
event.on("nfc-peer-sending-ndef", function () { if (isPeerConnected) { peer = db.retrieveObject(_NFC_PEER); if (_data.listener.onNDEFReceived) { _data.listener.onNDEFReceived(peer.ndef); } } });
$("#configuration-window-load-btn").bind("click", function () { var platformList, programs, deviceInfo, _settings, versionSelect = document.getElementById("version-select"); if (db.retrieveObject(_DEVICESETTING_SAVE_KEY) === undefined) { //Never saving data exist return; } //reload system & network setting deviceInfo = db.retrieveObject(_DEVICESETTING_SAVE_KEY); db.saveObject("devicesettings", deviceInfo); jQuery("#devicesettings-content-container").empty(); jQuery("#networksettings-content-container").empty(); require('ripple/deviceSettings').initialize(); require('ripple/ui/plugins/deviceSettings').terminate(); require('ripple/ui/plugins/deviceSettings').initialize(); //reload device setting jQuery(versionSelect).empty(); _settings = db.retrieveObject(_KEY); jQuery("#platform-select").val(_settings.platformId); jQuery("#device-select").val(_settings.device); if (_settings.type === "custom") { $('input:radio[name="resolution-type"][value="custom"]').click(); jQuery("#resolution-custom-width").val(parseInt(_settings.custom_width, 10)); jQuery("#resolution-custom-height").val(parseInt(_settings.custom_height, 10)); } else { $('input:radio[name="resolution-type"][value="predefined"]').click(); } platformList = platform.getList(); utils.forEach(platformList, function (platform) { utils.forEach(platform, function (version, versionNumber) { if (_settings.platformId === version.id) { versionSelect.appendChild(utils.createElement("option", { "innerText": versionNumber, "value": versionNumber })); } }); }); jQuery("#version-select").val(_settings.version); });
function _retrieve() { var index; _data.callHistory = db.retrieveObject(_DB_CALL_KEY) || []; for (index = 0; index < _data.callHistory.length; index++) { _data.callHistory[index].startTime = new Date(_data.callHistory[index].startTime); } }
function _get() { _data = db.retrieveObject(DB_APPLICATION_KEY); if (_data === undefined) { _data = { appList: _apps, installedAppList: _installedAppList }; } }
getCallRecord: function (callRecordType, id) { utils.validateNumberOfArguments(2, 2, arguments.length, ExceptionTypes.INVALID_PARAMETER, "getCallRecord invalid number of parameters", new Exception()); var calls = db.retrieveObject(constants.TELEPHONY.CALL_LIST_KEY); return utils.map(calls, function (call) { return call.callRecordType === callRecordType ? call : null; }).reduce(function (match, call) { return match || call.callRecordId === id || null; }, null); },
xit("saveObject_doesnt_retreive_without_prefix", function () { var testJSON = { test: "test value" }, storedValue; db.saveObject("testKey", testJSON, "testPrefix-"); storedValue = db.retrieveObject("testKey"); expect(storedValue).toEqual(undefined); });
it("saveObject_without_custom_prefix", function () { var testJSON = { test: "test value" }, storedValue; db.saveObject("testKey", testJSON); storedValue = db.retrieveObject("testKey"); expect(storedValue).toEqual(testJSON); });
it("saveObject_saves_an_array", function () { var testArray = [ {a: 1}, {a: 2} ], storedValue; db.saveObject("testKey", testArray); storedValue = db.retrieveObject("testKey"); expect(storedValue).toEqual(testArray); });
initialize: function () { // TODO: Initialize at bootstrap and emulatorBridge.link _cache = db.retrieveObject("tizen1-db-filesystem") || {}; // create real root paths if empty _self.roots.every(function (root) { _createPath(root); return true; }); // build the file system cache so that we could access information synchronously _walk("/", _cache); },
function triggerAlarm() { time = new Date(); alarms = db.retrieveObject("tizen1.0-db-alarms"); if (alarms !== null) { utils.forEach(alarms, function (obj) { if (obj.id !== undefined) { event.trigger("CheckAlarm", [obj.id]); } }); } }
function _getContacts() { return db.retrieveObject("phonegap-contacts") || _defaultContacts.map(function (person) { var contact = new Contact(); contact.updated = new Date(); utils.forEach(person, function (value, prop) { contact[prop] = value; }); return contact; }); }
initialize: function () { var settings = db.retrieveObject("geosettings"); if (settings) { utils.forEach(_positionInfo, function (value, key) { _positionInfo[key] = parseFloat(settings.position[key] || value); }); self.timeout = settings.timeout; self.delay = settings.delay || 0; } },
initialize: function () { var firstAvailablePlatform = utils.map(this.getList(), function (platform) { return utils.map(platform, function (details, version) { return {name: details.id, version: version}; })[0]; })[0]; _current = _getRequestedPlatform() || db.retrieveObject("api-key") || firstAvailablePlatform; _current = _validatePlatform(_current, firstAvailablePlatform); db.saveObject("api-key", _current); _console.prefix = _current.name; },
function _get() { _data = db.retrieveObject(DB_PACKAGE_KEY); if (_data === undefined) { _data = { packageList: _packages, installedList: _installedList }; _save(); } utils.forEach(_data.installedList, function (item) { item.lastModified = new Date(item.lastModified); }); }
deleteCallRecord: function (callRecordType, id) { utils.validateNumberOfArguments(2, 2, arguments.length, ExceptionTypes.INVALID_PARAMETER, "deleteCallRecord invalid number of parameters", new Exception()); var calls = db.retrieveObject(constants.TELEPHONY.CALL_LIST_KEY), indexToDelete = calls.reduce(function (result, call, index) { return call.callRecordType === callRecordType && call.callRecordId === id ? index : result; }, -1); if (indexToDelete >= 0) { calls.splice(indexToDelete, 1); db.saveObject(constants.TELEPHONY.CALL_LIST_KEY, calls); } },
event.on("nfc-peer-sending-ndef", function () { var peer, _records = [], rec, _ndef, i; if (_data.isPeerConnected) { peer = db.retrieveObject(_data.DB_NFC_PEER); for (i in peer.ndef.records) { rec = peer.ndef.records[i]; _records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload, rec.id)); } _ndef = new NDEFMessage(_records); if (_data.listener.onNDEFReceived) { _data.listener.onNDEFReceived(_ndef); } } });
function _retrive() { var callHistoryList, callHistory, index; if (_data.callHistory.length === 0) { callHistoryList = db.retrieveObject(_data.DB_CALL_KEY) || []; for (index = 0; index < callHistoryList.length; index++) { callHistory = callHistoryList[index]; _data.callHistory.push(_getCallHistoryEntry(callHistory.serviceId, callHistory.callType, callHistory.tags, callHistory.callParticipants, callHistory.forwardedFrom, callHistory.startTime, callHistory.duration, callHistory.endReason, callHistory.direction, callHistory.recording, callHistory.cost, callHistory.currency)); } } return tizen1_utils.copy(_data.callHistory); }
initialize: function () { var firstAvailablePlatform = utils.map(this.getList(), function (platform) { return utils.map(platform, function (details, version) { return {name: details.id, version: version}; })[0]; })[0]; _current = db.retrieveObject(constants.PLATFORM.SAVED_KEY); if (_current) { _checkForDeprecatedPlatforms(firstAvailablePlatform); } else { _current = firstAvailablePlatform; } _console.prefix = _getPlatform().name; },
event.on("nfc-tag-send", function (status) { if (status) { tag = db.retrieveObject(_NFC_TAG); if (tag.isSupportedNDEF) { _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF, tag.ndefSize, null, true, tag.ndefs); } else { _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF, tag.ndefSize, null, true, tag.rawData); } if (_data.listener.onTagDetected) { _data.listener.onTagDetected.onattach(_data.nfcTag); } } else { tag = {}; if (_data.listener.onTagDetected) { _data.listener.onTagDetected.ondetach(); } } });
$("#settings-menu-save-btn").bind("click", function (event) { $("input[name='panel-display-setting']").each(function (i, a) { settings.push(a.checked); }); utils.forEach(_applicationState, function (obj) { if (!settings[i]) obj.collapsed = true; obj.display = settings[i]; i++ }, this); db.saveObject(_applicationStateId, _applicationState); _applicationStateTmp = db.retrieveObject(_applicationStateId) || []; $("#settings-menu-popup").hide("slide", {direction: "up"},"slow"); $("#overlayBackground").hide("fade", "slow"); setTimeout(reload, 500); });
function _addHistory(uri) { var i = 0, thehistories = db.retrieveObject(constants.LAUNCHING_HISTORY); if (thehistories !== undefined) { for (i; i < thehistories.length; i++) { if (uri === thehistories[i]) { return; } } if (thehistories.length >= 20) { thehistories.reverse(); thehistories.pop(); thehistories.reverse(); } } else { thehistories = []; } thehistories.push(uri); db.saveObject(constants.LAUNCHING_HISTORY, thehistories); }
function _initializeFirstRunCheck() { var savedPlatform = db.retrieveObject("api-key"), firstRunOverlayNode, firstRunOptionsNode, width, p; if (!savedPlatform) { width = jQuery(document).width(); p = (width / 2) - 277; firstRunOverlayNode = jQuery(".first-run-window").css({display: 'block'}); firstRunOptionsNode = jQuery(".platform-select-dialog").css({display: 'block', left: p + "px"}); utils.forEach(_platform.getList(), function (platform) { utils.forEach(platform, function (details, version) { _addPlatformButton(details, version); }); }); } }
deleteAllCallRecords: function (callRecordType) { utils.validateNumberOfArguments(1, 1, arguments.length, ExceptionTypes.INVALID_PARAMETER, "deleteAllCallRecords invalid number of parameters", new Exception()); var calls = db.retrieveObject(constants.TELEPHONY.CALL_LIST_KEY), indexesToDelete = calls.reduce(function (result, call, index) { if (call.callRecordType === callRecordType) { result.push(index); } return result; }, []); utils.forEach(indexesToDelete, function (index) { calls.splice(index, 1); }); if (indexesToDelete.length > 0) { db.saveObject(constants.TELEPHONY.CALL_LIST_KEY, calls); } },