diff --git a/cordova-plugin-battery-status/tests.ts b/cordova-plugin-battery-status/tests.ts
new file mode 100644
index 0000000000..4dafa2e966
--- /dev/null
+++ b/cordova-plugin-battery-status/tests.ts
@@ -0,0 +1,7 @@
+///
+
+window.addEventListener('batterystatus',
+ (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
+
+window.addEventListener('batterycritical',
+ () => { alert('Battery is critical low!'); });
\ No newline at end of file
diff --git a/cordova-plugin-battery-status/tsconfig.json b/cordova-plugin-battery-status/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-battery-status/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-camera/tests.ts b/cordova-plugin-camera/tests.ts
new file mode 100644
index 0000000000..00edf02b0a
--- /dev/null
+++ b/cordova-plugin-camera/tests.ts
@@ -0,0 +1,13 @@
+///
+
+navigator.camera.getPicture(
+ (data: string) => { alert('Got photo!'); },
+ (message: string)=> { alert('Failed!: ' + message); },
+ {
+ allowEdit: true,
+ cameraDirection: Camera.Direction.BACK,
+ destinationType: Camera.DestinationType.FILE_URI,
+ encodingType: Camera.EncodingType.JPEG,
+ sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
+ quality: 80
+ });
diff --git a/cordova-plugin-camera/tsconfig.json b/cordova-plugin-camera/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-camera/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-contacts/tests.ts b/cordova-plugin-contacts/tests.ts
new file mode 100644
index 0000000000..c50912c3ba
--- /dev/null
+++ b/cordova-plugin-contacts/tests.ts
@@ -0,0 +1,18 @@
+///
+
+var contact: Contact = navigator.contacts.create({
+ nickname: 'John Smith',
+ displayName: 'John Smith',
+ phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }]
+});
+
+navigator.contacts.find(["phoneNumbers"],
+ (contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); },
+ (error: ContactError) => { alert('Error: ' + error.message); },
+ new ContactFindOptions("+1", true)
+);
+
+navigator.contacts.pickContact(
+ (contact: Contact)=> { console.log(contact); },
+ (err: ContactError)=> { console.log(err.message); }
+);
diff --git a/cordova-plugin-contacts/tsconfig.json b/cordova-plugin-contacts/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-contacts/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-device-motion/tests.ts b/cordova-plugin-device-motion/tests.ts
new file mode 100644
index 0000000000..17b1e49930
--- /dev/null
+++ b/cordova-plugin-device-motion/tests.ts
@@ -0,0 +1,12 @@
+///
+
+navigator.accelerometer.getCurrentAcceleration(
+ (acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
+ () => { alert('Error!'); });
+
+var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration(
+ (acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
+ () => { alert('Error!'); },
+ { frequency: 10 });
+
+navigator.accelerometer.clearWatch(acchandle);
diff --git a/cordova-plugin-device-motion/tsconfig.json b/cordova-plugin-device-motion/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-device-motion/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-device-orientation/tests.ts b/cordova-plugin-device-orientation/tests.ts
new file mode 100644
index 0000000000..097a66e99e
--- /dev/null
+++ b/cordova-plugin-device-orientation/tests.ts
@@ -0,0 +1,13 @@
+///
+
+navigator.compass.getCurrentHeading(
+ (heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); },
+ (error: CompassError)=> { alert('Error! ' + error.code); },
+ { frequency: 10 });
+
+var accelhandle = navigator.compass.watchHeading(
+ (heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); },
+ (error: CompassError) => { alert('Error! ' + error.code); },
+ { frequency: 10 });
+
+navigator.compass.clearWatch(accelhandle);
diff --git a/cordova-plugin-device-orientation/tsconfig.json b/cordova-plugin-device-orientation/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-device-orientation/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-device/tests.ts b/cordova-plugin-device/tests.ts
new file mode 100644
index 0000000000..450eadb1f0
--- /dev/null
+++ b/cordova-plugin-device/tests.ts
@@ -0,0 +1,3 @@
+///
+
+console.log(JSON.stringify(device));
\ No newline at end of file
diff --git a/cordova-plugin-device/tsconfig.json b/cordova-plugin-device/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-device/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-dialogs/tests.ts b/cordova-plugin-dialogs/tests.ts
new file mode 100644
index 0000000000..dd9396f36f
--- /dev/null
+++ b/cordova-plugin-dialogs/tests.ts
@@ -0,0 +1,4 @@
+///
+
+navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok');
+navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); });
diff --git a/cordova-plugin-dialogs/tsconfig.json b/cordova-plugin-dialogs/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-dialogs/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-file-transfer/tests.ts b/cordova-plugin-file-transfer/tests.ts
new file mode 100644
index 0000000000..4050b2c4aa
--- /dev/null
+++ b/cordova-plugin-file-transfer/tests.ts
@@ -0,0 +1,39 @@
+///
+
+var file = new FileTransfer();
+
+file.onprogress = (ev: ProgressEvent) => {
+ if (ev.lengthComputable) {
+ console.log(ev.loaded + '/' + ev.total);
+ }
+};
+
+file.download('http://some.server.com/download.php',
+ 'cdvfile://localhost/persistent/path/to/downloads/',
+ (file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); },
+ (err: FileTransferError) => {
+ console.error('Error ' + err.code);
+ if (err.exception) {
+ console.error('Failed with exception ' + err.exception);
+ }
+ },
+ true,
+ {
+ headers: {
+ "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
+ }
+ });
+
+file.upload('cdvfile://localhost/persistent/path/to/downloads/',
+ 'http://some.server.com/download.php',
+ (result: FileUploadResult)=> { console.log('File uploaded. Bytes uploaded: ' + result.bytesSent); },
+ (err: FileTransferError) => {
+ console.error('Error ' + err.code);
+ if (err.exception) {
+ console.error('Failed with exception ' + err.exception);
+ }
+ },
+ { headers: {"X-Email": "user@mail.com", 'X-Token': "asdf3w234"}, httpMethod: "PUT" },
+ true);
+
+file.abort();
diff --git a/cordova-plugin-file-transfer/tsconfig.json b/cordova-plugin-file-transfer/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-file-transfer/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-file/tests.ts b/cordova-plugin-file/tests.ts
new file mode 100644
index 0000000000..a95872a229
--- /dev/null
+++ b/cordova-plugin-file/tests.ts
@@ -0,0 +1,40 @@
+///
+///
+
+function fsaccessor(fs: FileSystem) {
+ console.log('FS root is: ' + fs.root.name);
+ var fsreader: DirectoryReader = fs.root.createReader();
+ fsreader.readEntries(
+ (entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); },
+ (err: FileError)=> { alert('Error: ' + err.code); });
+}
+
+window.requestFileSystem(
+ window.TEMPORARY,
+ 1024 * 1024 * 5,
+ fsaccessor,
+ (err: FileError) => { alert('Error: ' + err.code); }
+);
+
+window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
+ (entry: Entry)=> {
+ if (entry.isDirectory) {
+ console.log('successfully resolved ' + entry.fullPath + 'directory');
+ console.log(entry.toURL());
+ console.log(entry.toInternalURL());
+ } else {
+ var fentry = entry;
+ fentry.file((f: File) => { console.log(f.slice(f.size - 10, f.size)); });
+ fentry.createWriter((writer: FileWriter)=> {
+ if (writer.readyState == FileWriter.INIT) {
+ console.log('Init FileWriter');
+ writer.write(new Blob(['sdfdsfsdf']));
+ writer.onprogress = function(ev: ProgressEvent) {
+ console.log('Writing ' + ev.target);
+ };
+ }
+ });
+ }
+ },
+ (error: FileError) => { console.log(error.code); }
+);
\ No newline at end of file
diff --git a/cordova-plugin-file/tsconfig.json b/cordova-plugin-file/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-file/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-globalization/tests.ts b/cordova-plugin-globalization/tests.ts
new file mode 100644
index 0000000000..0a58703a32
--- /dev/null
+++ b/cordova-plugin-globalization/tests.ts
@@ -0,0 +1,13 @@
+///
+
+navigator.globalization.dateToString(new Date(),
+ (date) => { console.log(JSON.stringify(date)); },
+ (error) => { alert(error.message); },
+ { formatLength: "short", selector: "date" });
+
+navigator.globalization.getDateNames(
+ (names) => {
+ names.value.forEach((name) => { console.log(name); });
+ },
+ (error) => { alert(error.message); },
+ { item: "months", type: "wide" });
\ No newline at end of file
diff --git a/cordova-plugin-globalization/tsconfig.json b/cordova-plugin-globalization/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-globalization/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-inappbrowser/tests.ts b/cordova-plugin-inappbrowser/tests.ts
new file mode 100644
index 0000000000..43b0d28153
--- /dev/null
+++ b/cordova-plugin-inappbrowser/tests.ts
@@ -0,0 +1,15 @@
+///
+
+// InAppBrowser plugin
+//----------------------------------------------------------------------
+
+// signature of window.open() added by InAppBrowser plugin
+// is similar to native window.open signature, so the compiler can's
+// select proper overload, but we cast result to InAppBrowser manually.
+var iab = window.open('google.com', '_self');
+iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
+iab.show();
+iab.executeScript(
+ { code: "console.log('Injected script in action')" },
+ ()=> { console.log('Script is executed'); }
+);
\ No newline at end of file
diff --git a/cordova-plugin-inappbrowser/tsconfig.json b/cordova-plugin-inappbrowser/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-inappbrowser/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-keyboard/tests.ts b/cordova-plugin-keyboard/tests.ts
new file mode 100644
index 0000000000..3dce2776bf
--- /dev/null
+++ b/cordova-plugin-keyboard/tests.ts
@@ -0,0 +1,25 @@
+///
+
+Keyboard.shrinkView(true);
+Keyboard.shrinkView(false);
+Keyboard.hideFormAccessoryBar(true);
+Keyboard.hideFormAccessoryBar(false);
+Keyboard.disableScrollingInShrinkView(true);
+Keyboard.disableScrollingInShrinkView(false);
+if (Keyboard.isVisible) {
+ console.log('Keyboard is visible');
+}
+Keyboard.automaticScrollToTopOnHiding = true;
+Keyboard.onshow = function () {
+ console.log('onshow');
+};
+Keyboard.onhide = function () {
+ console.log('onhide');
+};
+Keyboard.onshowing = function () {
+ console.log('onshowing');
+};
+Keyboard.onhiding= function () {
+ console.log('onhiding');
+};
+
diff --git a/cordova-plugin-keyboard/tsconfig.json b/cordova-plugin-keyboard/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-keyboard/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-media-capture/tests.ts b/cordova-plugin-media-capture/tests.ts
new file mode 100644
index 0000000000..8bd56c714f
--- /dev/null
+++ b/cordova-plugin-media-capture/tests.ts
@@ -0,0 +1,13 @@
+///
+
+console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
+
+navigator.device.capture.captureAudio(
+ (captures: MediaFile[]) => { console.log(captures.length + ' captured'); },
+ (err: CaptureError) => { alert('Error ' + err.message); },
+ {
+ limit: 3,
+ duration: 10
+ }
+);
+
diff --git a/cordova-plugin-media-capture/tsconfig.json b/cordova-plugin-media-capture/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-media-capture/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-media/tests.ts b/cordova-plugin-media/tests.ts
new file mode 100644
index 0000000000..a36df13cc3
--- /dev/null
+++ b/cordova-plugin-media/tests.ts
@@ -0,0 +1,13 @@
+///
+
+// Media and Media Capture
+//----------------------------------------------------------------------
+
+var media = new Media('',
+ () => { console.log('Media opened'); },
+ (err: MediaError) => { alert('Error: ' + err.code); });
+media.play();
+media.setVolume(10);
+
+console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
+
diff --git a/cordova-plugin-media/tsconfig.json b/cordova-plugin-media/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-media/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-network-information/tests.ts b/cordova-plugin-network-information/tests.ts
new file mode 100644
index 0000000000..702aeb5714
--- /dev/null
+++ b/cordova-plugin-network-information/tests.ts
@@ -0,0 +1,8 @@
+///
+
+var connType = navigator.connection.type;
+if (connType == Connection.WIFI) {
+ console.log('Congratulations, you\'re with fast Internet!');
+}
+
+document.addEventListener('offline', () => { alert('You\'re offline!'); });
diff --git a/cordova-plugin-network-information/tsconfig.json b/cordova-plugin-network-information/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-network-information/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-splashscreen/tests.ts b/cordova-plugin-splashscreen/tests.ts
new file mode 100644
index 0000000000..d24720eb1d
--- /dev/null
+++ b/cordova-plugin-splashscreen/tests.ts
@@ -0,0 +1,4 @@
+///
+
+navigator.splashscreen.show();
+navigator.splashscreen.hide();
\ No newline at end of file
diff --git a/cordova-plugin-splashscreen/tsconfig.json b/cordova-plugin-splashscreen/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-splashscreen/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-statusbar/StatusBar-tests.ts b/cordova-plugin-statusbar/tests.ts
similarity index 91%
rename from cordova-plugin-statusbar/StatusBar-tests.ts
rename to cordova-plugin-statusbar/tests.ts
index 01ab0bf945..9d22ca912c 100644
--- a/cordova-plugin-statusbar/StatusBar-tests.ts
+++ b/cordova-plugin-statusbar/tests.ts
@@ -1,5 +1,4 @@
-// Licensed under the MIT license.
-
+///
var statusBar: StatusBar = window.StatusBar;
diff --git a/cordova-plugin-statusbar/tsconfig.json b/cordova-plugin-statusbar/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-statusbar/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-vibration/tests.ts b/cordova-plugin-vibration/tests.ts
new file mode 100644
index 0000000000..b34cd23675
--- /dev/null
+++ b/cordova-plugin-vibration/tests.ts
@@ -0,0 +1,8 @@
+///
+
+var notification: Notification;
+
+notification.vibrate(100);
+notification.vibrateWithPattern([100, 200, 200, 150, 50], 3);
+setTimeout(notification.cancelVibration, 1000);
+
diff --git a/cordova-plugin-vibration/tsconfig.json b/cordova-plugin-vibration/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-vibration/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova-plugin-websql/tests.ts b/cordova-plugin-websql/tests.ts
new file mode 100644
index 0000000000..8679b3d5c3
--- /dev/null
+++ b/cordova-plugin-websql/tests.ts
@@ -0,0 +1,16 @@
+///
+
+
+var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5);
+db.transaction(
+ (tx: SqlTransaction) => {
+ tx.executeSql('CREATE TABLE Sample IF NOT EXIST...');
+ tx.executeSql('INSERT INTO Sample VALUES...');
+ },
+ (err: SqlError) => {
+ if (err.code = SqlError.SYNTAX_ERR) {
+ alert('Error ' + err.message);
+ }
+ },
+ () => { console.log('Transaction completed successfully'); }
+);
\ No newline at end of file
diff --git a/cordova-plugin-websql/tsconfig.json b/cordova-plugin-websql/tsconfig.json
new file mode 100644
index 0000000000..b999e403b2
--- /dev/null
+++ b/cordova-plugin-websql/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": false,
+ "strictNullChecks": false,
+ "noEmit": true
+ },
+ "files": [
+ "index.d.ts",
+ "tests.ts"
+ ]
+}
\ No newline at end of file
diff --git a/cordova/cordova-tests.ts b/cordova/cordova-tests.ts
index d3f790967c..8b578b8a15 100644
--- a/cordova/cordova-tests.ts
+++ b/cordova/cordova-tests.ts
@@ -4,23 +4,6 @@
// Apache Cordova core
//----------------------------------------------------------------------
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
///
///
@@ -50,285 +33,6 @@ declare var app: Application;
document.addEventListener('deviceready', () => { app.start(); });
document.addEventListener('pause', ()=> { app.pause(); });
-// Battery status plugin
-//----------------------------------------------------------------------
-window.addEventListener('batterystatus',
- (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
-
-window.addEventListener('batterycritical',
- () => { alert('Battery is critical low!'); });
-
-// Camera plugin
-//----------------------------------------------------------------------
-
-navigator.camera.getPicture(
- (data: string) => { alert('Got photo!'); },
- (message: string)=> { alert('Failed!: ' + message); },
- {
- allowEdit: true,
- cameraDirection: Camera.Direction.BACK,
- destinationType: Camera.DestinationType.FILE_URI,
- encodingType: Camera.EncodingType.JPEG,
- sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
- quality: 80
- });
-
-// Contacts plugin
-//----------------------------------------------------------------------
-
-var contact: Contact = navigator.contacts.create({
- nickname: 'John Smith',
- displayName: 'John Smith',
- phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }]
-});
-
-navigator.contacts.find(["phoneNumbers"],
- (contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); },
- (error: ContactError) => { alert('Error: ' + error.message); },
- new ContactFindOptions("+1", true)
-);
-
-navigator.contacts.pickContact(
- (contact: Contact)=> { console.log(contact); },
- (err: ContactError)=> { console.log(err.message); }
-);
-
-// Device API
-//----------------------------------------------------------------------
-
-console.log(JSON.stringify(device));
-
-// DeviceMotion plugin
-//----------------------------------------------------------------------
-
-navigator.accelerometer.getCurrentAcceleration(
- (acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
- () => { alert('Error!'); });
-
-var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration(
- (acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
- () => { alert('Error!'); },
- { frequency: 10 });
-
-navigator.accelerometer.clearWatch(acchandle);
-
-// DeviceOrientation plugin
-//----------------------------------------------------------------------
-
-navigator.compass.getCurrentHeading(
- (heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); },
- (error: CompassError)=> { alert('Error! ' + error.code); },
- { frequency: 10 });
-
-var accelhandle = navigator.compass.watchHeading(
- (heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); },
- (error: CompassError) => { alert('Error! ' + error.code); },
- { frequency: 10 });
-
-navigator.compass.clearWatch(accelhandle);
-
-// Dialogs plugin
-//----------------------------------------------------------------------
-
-navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok');
-navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); });
-
-// FileSystem plugin
-//----------------------------------------------------------------------
-
-function fsaccessor(fs: FileSystem) {
- console.log('FS root is: ' + fs.root.name);
- var fsreader: DirectoryReader = fs.root.createReader();
- fsreader.readEntries(
- (entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); },
- (err: FileError)=> { alert('Error: ' + err.code); });
-}
-
-window.requestFileSystem(
- window.TEMPORARY,
- 1024 * 1024 * 5,
- fsaccessor,
- (err: FileError) => { alert('Error: ' + err.code); }
-);
-
-window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
- (entry: Entry)=> {
- if (entry.isDirectory) {
- console.log('successfully resolved ' + entry.fullPath + 'directory');
- console.log(entry.toURL());
- console.log(entry.toInternalURL());
- } else {
- var fentry = entry;
- fentry.file((f: File) => { console.log(f.slice(f.size - 10, f.size)); });
- fentry.createWriter((writer: FileWriter)=> {
- if (writer.readyState == FileWriter.INIT) {
- console.log('Init FileWriter');
- writer.write(new Blob(['sdfdsfsdf']));
- writer.onprogress = function(ev: ProgressEvent) {
- console.log('Writing ' + ev.target);
- };
- }
- });
- }
- },
- (error: FileError) => { console.log(error.code); }
-);
-
-// FileTransfer plugin
-//----------------------------------------------------------------------
-
-var file = new FileTransfer();
-
-file.onprogress = (ev: ProgressEvent) => {
- if (ev.lengthComputable) {
- console.log(ev.loaded + '/' + ev.total);
- }
-};
-
-file.download('http://some.server.com/download.php',
- 'cdvfile://localhost/persistent/path/to/downloads/',
- (file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); },
- (err: FileTransferError) => {
- console.error('Error ' + err.code);
- if (err.exception) {
- console.error('Failed with exception ' + err.exception);
- }
- },
- true,
- {
- headers: {
- "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
- }
- });
-
-file.upload('cdvfile://localhost/persistent/path/to/downloads/',
- 'http://some.server.com/download.php',
- (result: FileUploadResult)=> { console.log('File uploaded. Bytes uploaded: ' + result.bytesSent); },
- (err: FileTransferError) => {
- console.error('Error ' + err.code);
- if (err.exception) {
- console.error('Failed with exception ' + err.exception);
- }
- },
- { headers: {"X-Email": "user@mail.com", 'X-Token': "asdf3w234"}, httpMethod: "PUT" },
- true);
-
-file.abort();
-
-file.abort();
-// InAppBrowser plugin
-//----------------------------------------------------------------------
-
-// signature of window.open() added by InAppBrowser plugin
-// is similar to native window.open signature, so the compiler can's
-// select proper overload, but we cast result to InAppBrowser manually.
-var iab = window.open('google.com', '_self');
-iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
-iab.show();
-iab.executeScript(
- { code: "console.log('Injected script in action')" },
- ()=> { console.log('Script is executed'); }
-);
-
-// Globalization plugin
-//----------------------------------------------------------------------
-
-navigator.globalization.dateToString(new Date(),
- (date) => { console.log(JSON.stringify(date)); },
- (error) => { alert(error.message); },
- { formatLength: "short", selector: "date" });
-
-navigator.globalization.getDateNames(
- (names) => {
- names.value.forEach((name) => { console.log(name); });
- },
- (error) => { alert(error.message); },
- { item: "months", type: "wide" });
-
-// Media and Media Capture
-//----------------------------------------------------------------------
-
-var media = new Media('',
- () => { console.log('Media opened'); },
- (err: MediaError) => { alert('Error: ' + err.code); });
-media.play();
-media.setVolume(10);
-
-console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
-
-navigator.device.capture.captureAudio(
- (captures: MediaFile[])=> { console.log(captures.length + ' captured'); },
- (err: CaptureError)=> { alert('Error ' + err.message); },
- {
- limit: 3,
- duration: 10
- });
-
-
-// Network Plugin
-//----------------------------------------------------------------------
-
-var connType = navigator.connection.type;
-if (connType == Connection.WIFI) {
- console.log('Congratulations, you\'re with fast Internet!');
-}
-
-document.addEventListener('offline', () => { alert('You\'re offline!'); });
-
-// SplashScreen plugin
-//----------------------------------------------------------------------
-
-navigator.splashscreen.show();
-navigator.splashscreen.hide();
-
-
-// WebSQL plugin
-//----------------------------------------------------------------------
-
-var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5);
-db.transaction(
- (tx: SqlTransaction) => {
- tx.executeSql('CREATE TABLE Sample IF NOT EXIST...');
- tx.executeSql('INSERT INTO Sample VALUES...');
- },
- (err: SqlError) => {
- if (err.code = SqlError.SYNTAX_ERR) {
- alert('Error ' + err.message);
- }
- },
- () => { console.log('Transaction completed successfully'); }
-);
-
-// Vibration plugin
-//----------------------------------------------------------------------
-navigator.notification.vibrate(100);
-navigator.notification.vibrateWithPattern([100, 200, 200, 150, 50], 3);
-setTimeout(navigator.notification.cancelVibration, 1000);
-
-// Keyboard plugin
-//----------------------------------------------------------------------
-Keyboard.shrinkView(true);
-Keyboard.shrinkView(false);
-Keyboard.hideFormAccessoryBar(true);
-Keyboard.hideFormAccessoryBar(false);
-Keyboard.disableScrollingInShrinkView(true);
-Keyboard.disableScrollingInShrinkView(false);
-if (Keyboard.isVisible) {
- console.log('Keyboard is visible');
-}
-Keyboard.automaticScrollToTopOnHiding = true;
-Keyboard.onshow = function () {
- console.log('onshow');
-};
-Keyboard.onhide = function () {
- console.log('onhide');
-};
-Keyboard.onshowing = function () {
- console.log('onshowing');
-};
-Keyboard.onhiding= function () {
- console.log('onhiding');
-};