mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
fixed. phonegap-tests errors.
This commit is contained in:
@@ -64,12 +64,12 @@ function test_camera() {
|
||||
}
|
||||
|
||||
var popover = new CameraPopoverOptions(300, 300, 100, 100, 1);
|
||||
var options = { quality: 50, destinationType: 1, sourceType: 1, popoverOptions: popover };
|
||||
var options = <CameraOptions>{ quality: 50, destinationType: 1, sourceType: 1, popoverOptions: popover };
|
||||
|
||||
navigator.camera.getPicture(onSuccess, onFail, options);
|
||||
|
||||
function onSuccess(imageData) {
|
||||
var image = document.getElementById('myImage');
|
||||
var image = <HTMLImageElement>document.getElementById('myImage');
|
||||
image.src = "data:image/jpeg;base64," + imageData;
|
||||
}
|
||||
|
||||
@@ -256,8 +256,7 @@ function test_contacts() {
|
||||
function onDeviceReady() {
|
||||
var options = new ContactFindOptions();
|
||||
options.filter = "Bob";
|
||||
var fields = ["displayName", "name"];
|
||||
navigator.contacts.find(fields, onSuccess, onError, options);
|
||||
navigator.contacts.find(["displayName", "name"], onSuccess, onError, options);
|
||||
}
|
||||
function onSuccess(contacts) {
|
||||
for (var i = 0; i < contacts.length; i++) {
|
||||
@@ -303,6 +302,7 @@ function test_contacts() {
|
||||
options.filter = "";
|
||||
var filter = ["displayName", "addresses"];
|
||||
navigator.contacts.find(filter, onSuccess, onError, options);
|
||||
var contacts: Contact[] = [];
|
||||
|
||||
for (var i = 0; i < contacts.length; i++) {
|
||||
for (var j = 0; j < contacts[i].addresses.length; j++) {
|
||||
@@ -423,6 +423,8 @@ function test_file() {
|
||||
}
|
||||
var onGetFileWin = function (parent) {
|
||||
var data = {};
|
||||
var metadataKey: any;
|
||||
var metadataValue: any;
|
||||
data[metadataKey] = metadataValue;
|
||||
parent.setMetadata(onSetMetadataWin, onSetMetadataFail, data);
|
||||
}
|
||||
@@ -430,15 +432,18 @@ function test_file() {
|
||||
console.log("error getting file")
|
||||
}
|
||||
var onFSWin = function (fileSystem) {
|
||||
var filePath = '';
|
||||
fileSystem.root.getFile(filePath, { create: true, exclusive: false }, onGetFileWin, onGetFileFail);
|
||||
}
|
||||
var onFSFail = function (evt) {
|
||||
console.log(evt.target.error.code);
|
||||
}
|
||||
var localFileSystem:any;
|
||||
window.requestFileSystem(localFileSystem, 0, onFSWin, onFSFail);
|
||||
|
||||
var success: any;
|
||||
var entry: FileEntry;
|
||||
var parent = document.getElementById('parent').value,
|
||||
var parent = (<any>document.getElementById('parent')).value,
|
||||
parentName = parent.substring(parent.lastIndexOf('/') + 1),
|
||||
parentEntry = new DirectoryEntry(parentName, parent);
|
||||
entry.moveTo(parentEntry, "newFile.txt", success, fail);
|
||||
@@ -460,11 +465,12 @@ function test_file() {
|
||||
console.log("upload error target " + error.target);
|
||||
}
|
||||
var uri = encodeURI("http://some.server.com/upload.php");
|
||||
var fileURI = "";
|
||||
var options = new FileUploadOptions();
|
||||
options.fileKey = "file";
|
||||
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
|
||||
options.mimeType = "text/plain";
|
||||
var params = {};
|
||||
var params:any = {};
|
||||
params.headers = { 'headerParam': 'headerValue' };
|
||||
options.params = params;
|
||||
var ft = new FileTransfer();
|
||||
@@ -600,7 +606,7 @@ function test_inAppBrowser() {
|
||||
}
|
||||
|
||||
function test_media() {
|
||||
var my_media = new Media(src, onSuccess, onError);
|
||||
var my_media = new Media(src, ()=>{}, ()=>{});
|
||||
var mediaTimer = setInterval(function () {
|
||||
my_media.getCurrentPosition(
|
||||
function (position) {
|
||||
@@ -637,7 +643,7 @@ function test_media() {
|
||||
});
|
||||
my_media.play();
|
||||
setTimeout(function () {
|
||||
media.pause();
|
||||
my_media.pause();
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
@@ -652,6 +658,9 @@ function test_media() {
|
||||
my_media.play();
|
||||
}
|
||||
|
||||
var onSuccess: any;
|
||||
var onError: any;
|
||||
|
||||
var my_media = new Media(src, onSuccess, onError);
|
||||
my_media.play();
|
||||
my_media.stop();
|
||||
@@ -659,7 +668,7 @@ function test_media() {
|
||||
setTimeout(function () {
|
||||
my_media.seekTo(10000);
|
||||
}, 5000);
|
||||
media.stopRecord();
|
||||
my_media.stopRecord();
|
||||
|
||||
var src = "myrecording.mp3";
|
||||
var mediaRec = new Media(src,
|
||||
@@ -673,6 +682,8 @@ function test_media() {
|
||||
mediaRec.startRecord();
|
||||
}
|
||||
|
||||
var onConfirm: any;
|
||||
|
||||
function test_notification() {
|
||||
function alertDismissed() { }
|
||||
navigator.notification.alert(
|
||||
@@ -716,13 +727,13 @@ function test_storage() {
|
||||
function queryDB(tx) {
|
||||
tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
|
||||
}
|
||||
function querySuccess(tx, results) {
|
||||
console.log("Returned rows = " + results.rows.length);
|
||||
function querySuccess(tx, resultSet) {
|
||||
console.log("Returned rows = " + resultSet.rows.length);
|
||||
if (!resultSet.rowsAffected) {
|
||||
console.log('No rows affected!');
|
||||
return false;
|
||||
}
|
||||
console.log("Last inserted row ID = " + results.insertId);
|
||||
console.log("Last inserted row ID = " + resultSet.insertId);
|
||||
}
|
||||
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
|
||||
db.transaction(queryDB, errorCB);
|
||||
|
||||
139
phonegap/phonegap.d.ts
vendored
139
phonegap/phonegap.d.ts
vendored
@@ -3,6 +3,14 @@
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface EventTarget {
|
||||
result: any;
|
||||
}
|
||||
|
||||
interface GeolocationError {
|
||||
code: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface Acceleration {
|
||||
x: number;
|
||||
@@ -10,6 +18,9 @@ interface Acceleration {
|
||||
z: number;
|
||||
timestamp: number; //DOMTimeStamp;
|
||||
}
|
||||
declare var Acceleration: {
|
||||
new(): Acceleration;
|
||||
}
|
||||
|
||||
interface AccelerometerOptions {
|
||||
frequency?: number;
|
||||
@@ -28,6 +39,9 @@ interface CameraPopoverOptions {
|
||||
height?: number;
|
||||
arrowDir?: number;
|
||||
}
|
||||
declare var CameraPopoverOptions: {
|
||||
new(x: number, y: number, width: number, height: number, arrowDir: number): CameraPopoverOptions;
|
||||
}
|
||||
|
||||
interface CameraOptions {
|
||||
quality?: number;
|
||||
@@ -43,7 +57,43 @@ interface CameraOptions {
|
||||
popoverOptions?: number;
|
||||
}
|
||||
|
||||
interface CameraPictureSourceTypeObject {
|
||||
CAMERA: number;
|
||||
PHOTOLIBRARY: number;
|
||||
SAVEDPHOTOALBUM: number;
|
||||
}
|
||||
|
||||
interface CameraDestinationTypeObject {
|
||||
FILE_URI: number;
|
||||
DATA_URL: number;
|
||||
}
|
||||
|
||||
interface CameraEncodingTypeObject {
|
||||
JPEG: number;
|
||||
PNG: number;
|
||||
}
|
||||
|
||||
interface CameraMediaTypeObject {
|
||||
PICTURE: number;
|
||||
VIDEO: number;
|
||||
ALLMEDIA: number;
|
||||
}
|
||||
|
||||
interface CameraPopoverArrowDirectionObject {
|
||||
ARROW_UP: number;
|
||||
ARROW_DOWN: number;
|
||||
ARROW_LEFT: number;
|
||||
ARROW_RIGHT: number;
|
||||
ARROW_ANY: number;
|
||||
}
|
||||
|
||||
interface Camera {
|
||||
sourceType: any;
|
||||
PictureSourceType: CameraPictureSourceTypeObject;
|
||||
DestinationType: CameraDestinationTypeObject;
|
||||
EncodingType: CameraEncodingTypeObject;
|
||||
MediaType: CameraMediaTypeObject;
|
||||
PopoverArrowDirection: CameraPopoverArrowDirectionObject;
|
||||
getPicture(cameraSuccess: (imageData: string) => void , cameraError: (message: string) => void , cameraOptions?: CameraOptions): void;
|
||||
cleanup(cameraSuccess: (imageData: string) => void , cameraError: (message: string) => void ): void;
|
||||
}
|
||||
@@ -54,6 +104,11 @@ interface CaptureAudioOptions {
|
||||
mode?: number;
|
||||
}
|
||||
|
||||
interface CaptureImageOptions {
|
||||
limit?: number;
|
||||
mode?: number;
|
||||
}
|
||||
|
||||
interface MediaFile {
|
||||
name: string;
|
||||
fullPath: string;
|
||||
@@ -71,8 +126,21 @@ interface CaptureError {
|
||||
|
||||
interface Capture {
|
||||
captureAudio(captureSuccess: (mediaFiles: MediaFile[]) => void , captureError: (error: CaptureError) =>void , options?: CaptureAudioOptions);
|
||||
captureImage(captureSuccess: (mediaFiles: MediaFile[]) => void , captureError: (error: CaptureError) =>void , options?: CaptureImageOptions);
|
||||
captureVideo(captureSuccess: (mediaFiles: MediaFile[]) => void , captureError: (error: CaptureError) =>void , options?: CaptureImageOptions);
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
UNKNOWN: number;
|
||||
ETHERNET: number;
|
||||
WIFI: number;
|
||||
CELL_2G: number;
|
||||
CELL_3G: number;
|
||||
CELL_4G: number;
|
||||
NONE: number;
|
||||
}
|
||||
declare var Connection: Connection;
|
||||
|
||||
interface CompassOptions {
|
||||
frequency?: number;
|
||||
filter?: number;
|
||||
@@ -115,6 +183,9 @@ interface ContactField {
|
||||
value: string;
|
||||
pref: bool;
|
||||
}
|
||||
declare var ContactField: {
|
||||
new(type: string, calue: string, perf: bool): ContactField;
|
||||
}
|
||||
|
||||
interface Contact {
|
||||
id: string;
|
||||
@@ -131,12 +202,19 @@ interface Contact {
|
||||
photos: ContactField[];
|
||||
categories: ContactField[];
|
||||
urls: ContactField[];
|
||||
|
||||
save(onSuccess?: (contacts: Contacts) => any, onError?: (contactError: ContactError) => any);
|
||||
remove(onSuccess?: (contacts: Contacts) => any, onError?: (contactError: ContactError) => any);
|
||||
clone(): Contact;
|
||||
}
|
||||
|
||||
interface ContactFindOptions {
|
||||
filter?: string;
|
||||
multiple?: bool;
|
||||
}
|
||||
declare var ContactFindOptions : {
|
||||
new(): ContactFindOptions;
|
||||
}
|
||||
|
||||
interface ContactName {
|
||||
formatted: string;
|
||||
@@ -146,6 +224,9 @@ interface ContactName {
|
||||
honorificPrefix: string;
|
||||
honorificSuffix: string;
|
||||
}
|
||||
declare var ContactName: {
|
||||
new(): ContactName;
|
||||
}
|
||||
|
||||
interface ContactOrganization {
|
||||
pref: bool;
|
||||
@@ -160,7 +241,7 @@ interface ContactError {
|
||||
}
|
||||
|
||||
interface Contacts {
|
||||
create(properties: any): void;
|
||||
create(properties?: any): Contact;
|
||||
find(contactFields: string[], contactSuccess: (contacts: Contact[]) => void , contactError: (error: ContactError) => void , contactFindOptions?: ContactFindOptions): void;
|
||||
}
|
||||
|
||||
@@ -171,6 +252,7 @@ interface Device {
|
||||
uuid: string;
|
||||
version: string;
|
||||
model: string;
|
||||
capture: Capture;
|
||||
}
|
||||
|
||||
/* Defined in lib.d.ts
|
||||
@@ -205,6 +287,9 @@ interface FileSystem {
|
||||
name: string;
|
||||
root: DirectoryEntry;
|
||||
}
|
||||
declare var DirectoryEntry: {
|
||||
new(name: string, root: DirectoryEntry): DirectoryEntry;
|
||||
}
|
||||
|
||||
interface FileSystemEntry {
|
||||
isFile: bool;
|
||||
@@ -213,18 +298,18 @@ interface FileSystemEntry {
|
||||
fullPath: string;
|
||||
filesystem: FileSystem;
|
||||
|
||||
getMetadata();
|
||||
setMetadata();
|
||||
getMetadata(onSuccess?: (arg) => any, onError?: (arg) => any);
|
||||
setMetadata(onSuccess?: (arg) => any, onError?: (arg) => any, options?);
|
||||
toURL();
|
||||
remove();
|
||||
getParent();
|
||||
remove(onSuccess?: (arg) => any, onError?: (arg) => any);
|
||||
getParent(onSuccess?: (arg) => any, onError?: (arg) => any);
|
||||
}
|
||||
|
||||
interface FileEntry extends FileSystemEntry {
|
||||
moveTo();
|
||||
copyTo();
|
||||
createWriter();
|
||||
file();
|
||||
moveTo(parentEntry: DirectoryEntry, file: string, onSuccess: (arg) => any, onError: (arg) => any);
|
||||
copyTo(parentEntry: DirectoryEntry, file: string, onSuccess: (arg) => any, onError: (arg) => any);
|
||||
createWriter(onSuccess?: (arg) => any, onError?: (arg) => any);
|
||||
file(onSuccess?: (arg) => any, onError?: (arg) => any);
|
||||
}
|
||||
|
||||
interface DirectoryEntry extends FileSystemEntry {
|
||||
@@ -241,10 +326,14 @@ interface DirectoryReader {
|
||||
interface FileTransfer {
|
||||
onprogress: Function;
|
||||
|
||||
upload(filePath: string, server: string, successCallback: (metadata: Metadata) => void , errorCallback: (error: FileError) => void , options: any): void;
|
||||
download(source: string, target: string, successCallback: (fileEntry: FileEntry) => void , errorCallback: (error: FileError) => void ): void;
|
||||
//upload(filePath: string, server: string, successCallback: (metadata: Metadata) => void , errorCallback: (error: FileError) => void , options?: any): void;
|
||||
upload(filePath: string, server: string, successCallback: (result: FileUploadResult) => void , errorCallback: (error: FileError) => void , options?: any): void;
|
||||
download(source: string, target: string, successCallback: (fileEntry: FileEntry) => void , errorCallback: (error: FileError) => void, options?: any): void;
|
||||
abort(): void;
|
||||
}
|
||||
declare var FileTransfer: {
|
||||
new(): FileTransfer;
|
||||
}
|
||||
|
||||
interface FileUploadOptions {
|
||||
fileKey?: string;
|
||||
@@ -254,6 +343,9 @@ interface FileUploadOptions {
|
||||
chunkedMode?: bool;
|
||||
headers?: any;
|
||||
}
|
||||
declare var FileUploadOptions: {
|
||||
new(): FileUploadOptions;
|
||||
}
|
||||
|
||||
interface FileUploadResult {
|
||||
bytesSent: number;
|
||||
@@ -263,10 +355,16 @@ interface FileUploadResult {
|
||||
|
||||
// TODO Flags
|
||||
|
||||
/*
|
||||
interface LocalFileSystem {
|
||||
requestFileSystem: Function;
|
||||
resolveLocalFileSystemURI: Function;
|
||||
}*/
|
||||
|
||||
interface LocalFileSystem {
|
||||
PERSISTENT: number;
|
||||
}
|
||||
declare var LocalFileSystem: LocalFileSystem;
|
||||
|
||||
interface Metadata {
|
||||
modificationTime: Date;
|
||||
@@ -319,9 +417,9 @@ interface InAppBrowser {
|
||||
*/
|
||||
|
||||
interface Media {
|
||||
new (src: string, mediaSuccess: Function, mediaError?: MediaError, mediaStatus?: Function);
|
||||
getCurrentPosition(mediaSuccess: Function, mediaError?: MediaError): void;
|
||||
getDuration(): void;
|
||||
new (src: string, mediaSuccess: Function, mediaError?: (mediaError: MediaError) => any, mediaStatus?: Function);
|
||||
getCurrentPosition(mediaSuccess: Function, mediaError?: (mediaError: MediaError) => any): void;
|
||||
getDuration(): any;
|
||||
play(): void;
|
||||
pause(): void;
|
||||
release(): void;
|
||||
@@ -330,6 +428,9 @@ interface Media {
|
||||
stopRecord(): void;
|
||||
stop(): void;
|
||||
}
|
||||
declare var Media: {
|
||||
new(src: string, onSuccess: (arg) => any, onError: (arg) => any): Media;
|
||||
}
|
||||
|
||||
interface Notification {
|
||||
alert(message: string, alertCallback: Function, title?: string, buttonName?: string): void;
|
||||
@@ -344,8 +445,8 @@ interface Splashscreen {
|
||||
}
|
||||
|
||||
interface Database {
|
||||
transaction();
|
||||
changeVersion();
|
||||
transaction(populateDB?: (tx: SQLTransaction) => any, errorCB?: (err) => any, successCB?: () => any);
|
||||
changeVersion(var1: string, var2: string);
|
||||
}
|
||||
|
||||
interface SQLResultSetRowList {
|
||||
@@ -379,7 +480,7 @@ interface LocalStorage {
|
||||
}
|
||||
*/
|
||||
|
||||
interface PhoneGapNavigator extends Navigator {
|
||||
interface /*PhoneGapNavigator extends*/ Navigator {
|
||||
accelerometer: Accelerometer;
|
||||
camera: Camera;
|
||||
capture: Capture;
|
||||
@@ -387,15 +488,15 @@ interface PhoneGapNavigator extends Navigator {
|
||||
connection: Connection;
|
||||
contacts: Contacts;
|
||||
device: Device;
|
||||
geolocation: Geolocation;
|
||||
globalization: Globalization;
|
||||
notification: Notification;
|
||||
splashscreen: Splashscreen;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
requestFileSystem: any;
|
||||
openDatabase(database_name: string, database_version: string, database_displayname: string, database_size: number): Database;
|
||||
}
|
||||
|
||||
declare var device: Device;
|
||||
declare var phoneGapNavigator: PhoneGapNavigator;
|
||||
declare var phoneGapNavigator: Navigator /*PhoneGapNavigator*/;
|
||||
Reference in New Issue
Block a user