<commit_before>/// <reference path="phonegap.d.ts" />

function test_accelerometer() {
    var watchID = null;
    var options = { frequency: 3000 };

    watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);

    if (watchID) {
        navigator.accelerometer.clearWatch(watchID);
        watchID = null;
    }
    function onSuccess(acceleration: Acceleration) {
        var element = document.getElementById('accelerometer');
        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
                            'Acceleration Y: ' + acceleration.y + '<br />' +
                            'Acceleration Z: ' + acceleration.z + '<br />' +
                            'Timestamp: ' + acceleration.timestamp + '<br />';
    }
    function onError() {
        alert('onError!');
    }
}

function test_camera() {
    var pictureSource;
    var destinationType;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        pictureSource = navigator.camera.PictureSourceType;
        destinationType = navigator.camera.DestinationType;
    }
    function onPhotoDataSuccess(imageData) {
        var smallImage = <HTMLImageElement>document.getElementById('smallImage');
        smallImage.style.display = 'block';
        smallImage.src = "data:image/jpeg;base64," + imageData;
    }
    function onPhotoURISuccess(imageURI) {
        var largeImage = <HTMLImageElement>document.getElementById('largeImage');
        largeImage.style.display = 'block';
        largeImage.src = imageURI;
    }
    function capturePhoto() {
        navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
            quality: 50,
            destinationType: destinationType.DATA_URL
        });
    }
    function capturePhotoEdit() {
        navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
            quality: 20, allowEdit: true,
            destinationType: destinationType.DATA_URL
        });
    }
    function getPhoto(source) {
        navigator.camera.getPicture(onPhotoURISuccess, onFail, {
            quality: 50,
            destinationType: destinationType.FILE_URI,
            sourceType: source
        });
    }
    function onFail(message) {
        alert('Failed because: ' + message);
    }

    var popover = new CameraPopoverOptions(300, 300, 100, 100, 1);
    var options = <CameraOptions>{ quality: 50, destinationType: 1, sourceType: 1, popoverOptions: popover };

    navigator.camera.getPicture(onSuccess, onFail, options);

    function onSuccess(imageData) {
        var image = <HTMLImageElement>document.getElementById('myImage');
        image.src = "data:image/jpeg;base64," + imageData;
    }

}

function test_capture() {
    var capture = navigator.device.capture;
    function captureSuccess(mediaFiles) {
        var i, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            uploadFile(mediaFiles[i]);
        }
    }
    function captureError(error) {
        var msg = 'An error occurred during capture: ' + error.code;
        navigator.notification.alert(msg, null, 'Uh oh!');
    }
    function captureAudio() {
        navigator.device.capture.captureAudio(captureSuccess, captureError, { limit: 2 });
    }
    function uploadFile(mediaFile) {
        var ft = new FileTransfer(),
            path = mediaFile.fullPath,
            name = mediaFile.name;
        ft.upload(path,
            "http://my.domain.com/upload.php",
            function (result) {
                console.log('Upload success: ' + result.responseCode);
                console.log(result.bytesSent + ' bytes sent');
            },
            function (error) {
                console.log('Error uploading file ' + path + ': ' + error.code);
            },
            { fileName: name });
    }
    var options = { limit: 3, duration: 10 };
    navigator.device.capture.captureAudio(captureSuccess, captureError, options);
    var captureSuccess = function (mediaFiles) {
        var i, path, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
        }
    };
    var captureError = function (error) {
        navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
    };
    navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
    function captureImage() {
        navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
    }
    function captureVideo() {
        navigator.device.capture.captureVideo(captureSuccess, captureError, { limit: 2 });
    }
}

function test_compass() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        navigator.compass.getCurrentHeading(onSuccess, onError);
    }
    function onSuccess(heading) {
        alert('Heading: ' + heading.magneticHeading);
    }
    function onError(compassError) {
        alert('Compass Error: ' + compassError.code);
    }
}

function test_compass2() {
    var watchID = null;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        startWatch();
    }
    function startWatch() {
        var options = { frequency: 3000 };
        watchID = navigator.compass.watchHeading(onSuccess, onError, options);
    }
    function stopWatch() {
        if (watchID) {
            navigator.compass.clearWatch(watchID);
            watchID = null;
        }<commit_msg>PhoneGap: fixed two "Duplicate identifier" errors in tests<commit_after>/// <reference path="phonegap.d.ts" />

function test_accelerometer() {
    var watchID = null;
    var options = { frequency: 3000 };

    watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);

    if (watchID) {
        navigator.accelerometer.clearWatch(watchID);
        watchID = null;
    }
    function onSuccess(acceleration: Acceleration) {
        var element = document.getElementById('accelerometer');
        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
                            'Acceleration Y: ' + acceleration.y + '<br />' +
                            'Acceleration Z: ' + acceleration.z + '<br />' +
                            'Timestamp: ' + acceleration.timestamp + '<br />';
    }
    function onError() {
        alert('onError!');
    }
}

function test_camera() {
    var pictureSource;
    var destinationType;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        pictureSource = navigator.camera.PictureSourceType;
        destinationType = navigator.camera.DestinationType;
    }
    function onPhotoDataSuccess(imageData) {
        var smallImage = <HTMLImageElement>document.getElementById('smallImage');
        smallImage.style.display = 'block';
        smallImage.src = "data:image/jpeg;base64," + imageData;
    }
    function onPhotoURISuccess(imageURI) {
        var largeImage = <HTMLImageElement>document.getElementById('largeImage');
        largeImage.style.display = 'block';
        largeImage.src = imageURI;
    }
    function capturePhoto() {
        navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
            quality: 50,
            destinationType: destinationType.DATA_URL
        });
    }
    function capturePhotoEdit() {
        navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
            quality: 20, allowEdit: true,
            destinationType: destinationType.DATA_URL
        });
    }
    function getPhoto(source) {
        navigator.camera.getPicture(onPhotoURISuccess, onFail, {
            quality: 50,
            destinationType: destinationType.FILE_URI,
            sourceType: source
        });
    }
    function onFail(message) {
        alert('Failed because: ' + message);
    }

    var popover = new CameraPopoverOptions(300, 300, 100, 100, 1);
    var options = <CameraOptions>{ quality: 50, destinationType: 1, sourceType: 1, popoverOptions: popover };

    navigator.camera.getPicture(onSuccess, onFail, options);

    function onSuccess(imageData) {
        var image = <HTMLImageElement>document.getElementById('myImage');
        image.src = "data:image/jpeg;base64," + imageData;
    }

}

function test_capture() {
    var capture = navigator.device.capture;
    function captureSuccess(mediaFiles) {
        var i, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            uploadFile(mediaFiles[i]);
        }
    }
    function captureError(error) {
        var msg = 'An error occurred during capture: ' + error.code;
        navigator.notification.alert(msg, null, 'Uh oh!');
    }
    function captureAudio() {
        navigator.device.capture.captureAudio(captureSuccess, captureError, { limit: 2 });
    }
    function uploadFile(mediaFile) {
        var ft = new FileTransfer(),
            path = mediaFile.fullPath,
            name = mediaFile.name;
        ft.upload(path,
            "http://my.domain.com/upload.php",
            function (result) {
                console.log('Upload success: ' + result.responseCode);
                console.log(result.bytesSent + ' bytes sent');
            },
            function (error) {
                console.log('Error uploading file ' + path + ': ' + error.code);
            },
            { fileName: name });
    }
    var options = { limit: 3, duration: 10 };
    navigator.device.capture.captureAudio(captureSuccess, captureError, options);
    function captureSuccess2(mediaFiles) {
        var i, path, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
        }
    };
    function captureError2(error) {
        navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
    };
    navigator.device.capture.captureImage(captureSuccess2, captureError2, { limit: 2 });
    function captureImage() {
        navigator.device.capture.captureImage(captureSuccess2, captureError2, { limit: 2 });
    }
    function captureVideo() {
        navigator.device.capture.captureVideo(captureSuccess2, captureError2, { limit: 2 });
    }
}

function test_compass() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        navigator.compass.getCurrentHeading(onSuccess, onError);
    }
    function onSuccess(heading) {
        alert('Heading: ' + heading.magneticHeading);
    }
    function onError(compassError) {
        alert('Compass Error: ' + compassError.code);
    }
}

function test_compass2() {
    var watchID = null;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        startWatch();
    }
    function startWatch() {
        var options = { frequency: 3000 };
        watchID = navigator.compass.watchHeading(onSuccess, onError, options);
    }
    function stopWatch() {
        if (watchID) {
            navigator.compass.clearWatch(watchID);
            watchID = null;
        }
{'fraction_non_alphanumeric': 0.11753545939109224, 'fraction_numerical': 0.009214924564097931, 'mean_word_length': 2.5344827586206895, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1045151', 'n_tokens_mistral': 3183, 'n_tokens_neox': 3020, 'n_words': 627}