http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/package.appxmanifest ---------------------------------------------------------------------- diff --git a/samples/TestAppCordova/TestAppCordova/package.appxmanifest b/samples/TestAppCordova/TestAppCordova/package.appxmanifest deleted file mode 100644 index ebaf9c9..0000000 --- a/samples/TestAppCordova/TestAppCordova/package.appxmanifest +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest"> - <Identity Name="a2bef493-a029-424e-b455-47c772af0d0e" Version="1.0.0.0" Publisher="CN=Cordova" /> - <Properties> - <DisplayName>Cordova-Metro</DisplayName> - <PublisherDisplayName>Cordova</PublisherDisplayName> - <Logo>images\storelogo.png</Logo> - </Properties> - <Prerequisites> - <OSMinVersion>6.2.0</OSMinVersion> - <OSMaxVersionTested>6.2.0</OSMaxVersionTested> - </Prerequisites> - <Resources> - <Resource Language="x-generate" /> - </Resources> - <Applications> - <Application Id="App" StartPage="default.html"> - <VisualElements DisplayName="Cordova-MetroApp" Logo="images\logo.png" SmallLogo="images\smalllogo.png" Description="Cordova-MetroApp" ForegroundText="light" BackgroundColor="#464646"> - <DefaultTile ShowName="allLogos" /> - <SplashScreen Image="images\splashscreen.png" /> - </VisualElements> - <Extensions> - <Extension Category="windows.fileOpenPicker"> - <FileOpenPicker> - <SupportedFileTypes> - <SupportsAnyFileType /> - </SupportedFileTypes> - </FileOpenPicker> - </Extension> - <Extension Category="windows.fileSavePicker"> - <FileSavePicker> - <SupportedFileTypes> - <SupportsAnyFileType /> - </SupportedFileTypes> - </FileSavePicker> - </Extension> - <Extension Category="windows.fileTypeAssociation"> - <FileTypeAssociation Name="all"> - <EditFlags OpenIsSafe="true" /> - <SupportedFileTypes> - <FileType>.uri</FileType> - <FileType>.txt</FileType> - <FileType>.file</FileType> - <FileType>.methods</FileType> - <FileType>.createWriter</FileType> - <FileType>.dir</FileType> - <FileType>.empty</FileType> - <FileType>.err</FileType> - <FileType>.xml</FileType> - <FileType>.json</FileType> - <FileType>.js</FileType> - <FileType>.jpg</FileType> - <FileType>.png</FileType> - <FileType>.mp4</FileType> - <FileType>.mp3</FileType> - <FileType>.path</FileType> - </SupportedFileTypes> - </FileTypeAssociation> - </Extension> - </Extensions> - </Application> - </Applications> - <Capabilities> - <Capability Name="documentsLibrary" /> - <Capability Name="videosLibrary" /> - <Capability Name="picturesLibrary" /> - <Capability Name="musicLibrary" /> - <Capability Name="enterpriseAuthentication" /> - <Capability Name="internetClient" /> - <DeviceCapability Name="microphone" /> - <DeviceCapability Name="location" /> - <DeviceCapability Name="webcam" /> - </Capabilities> -</Package> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/cordova-win8.jsproj ---------------------------------------------------------------------- diff --git a/src/cordova-win8/cordova-win8.jsproj b/src/cordova-win8/cordova-win8.jsproj deleted file mode 100644 index 28a8d75..0000000 --- a/src/cordova-win8/cordova-win8.jsproj +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|AnyCPU"> - <Configuration>Debug</Configuration> - <Platform>AnyCPU</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|ARM"> - <Configuration>Debug</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x86"> - <Configuration>Debug</Configuration> - <Platform>x86</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|AnyCPU"> - <Configuration>Release</Configuration> - <Platform>AnyCPU</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|ARM"> - <Configuration>Release</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x86"> - <Configuration>Release</Configuration> - <Platform>x86</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>ac81dc10-b726-47b1-8521-ebfdda2ca496</ProjectGuid> - </PropertyGroup> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" /> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" /> - <PropertyGroup> - <TargetPlatformIdentifier>Windows</TargetPlatformIdentifier> - <TargetPlatformVersion>8.0</TargetPlatformVersion> - <DefaultLanguage>en-US</DefaultLanguage> - <PackageCertificateKeyFile>cordova-win8_TemporaryKey.pfx</PackageCertificateKeyFile> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> - <OutputPath>bin\$(Platform)\$(Configuration)</OutputPath> - </PropertyGroup> - <ItemGroup> - <AppxManifest Include="package.appxmanifest"> - <SubType>Designer</SubType> - </AppxManifest> - <Content Include="js\accelerometer.js" /> - <Content Include="js\camera.js" /> - <Content Include="js\capture.js" /> - <Content Include="js\compass.js" /> - <Content Include="js\device.js" /> - <Content Include="js\file.js" /> - <Content Include="js\filetransfer.js" /> - <Content Include="js\geolocation.js" /> - <Content Include="js\notification.js" /> - <Content Include="js\storage.js" /> - <Content Include="js\media.js" /> - <Content Include="js\network.js" /> - <Content Include="lib\SQLite\SQLite3\Constants.cpp" /> - <Content Include="lib\SQLite\SQLite3\Constants.h" /> - <Content Include="lib\SQLite\SQLite3\Database.cpp" /> - <Content Include="lib\SQLite\SQLite3\Database.h" /> - <Content Include="lib\SQLite\SQLite3\sqlite3.c" /> - <Content Include="lib\SQLite\SQLite3\sqlite3.h" /> - <Content Include="lib\SQLite\SQLite3\SQLite3.vcxproj" /> - <Content Include="lib\SQLite\SQLite3\SQLite3.vcxproj.filters" /> - <Content Include="lib\SQLite\SQLite3\Statement.cpp" /> - <Content Include="lib\SQLite\SQLite3\Statement.h" /> - <Content Include="lib\Jscex\src\jscex-async.js" /> - <Content Include="lib\Jscex\src\jscex.js" /> - <Content Include="lib\Jscex\src\jscexc.js" /> - <Content Include="lib\Jscex\src\jscex-async-powerpack.js" /> - <Content Include="lib\Jscex\src\jscex-builderbase.js" /> - <Content Include="lib\Jscex\src\jscex-jit.js" /> - <Content Include="lib\Jscex\src\jscex-parser.js" /> - <Content Include="lib\Jscex\src\jscex-promise.js" /> - <Content Include="lib\Jscex\src\incubations\jscex.async.xhr.js" /> - <Content Include="lib\Jscex\src\incubations\jscex.seq.js" /> - <Content Include="lib\Jscex\src\incubations\jscex.seq.powerpack.js" /> - <Content Include="lib\Jscex\src\incubations\jscex-async-agent.js" /> - <Content Include="lib\Jscex\src\incubations\jscex-async-include.js" /> - <Content Include="test\cordova.js" /> - <Content Include="test\css\default.css" /> - <Content Include="test\default.html" /> - <Content Include="test\views\HtmlReporter.js" /> - <Content Include="test\views\HtmlReporterHelpers.js" /> - <Content Include="test\views\ReporterView.js" /> - <Content Include="test\views\SpecView.js" /> - <Content Include="test\views\SuiteView.js" /> - <Content Include="test\views\TrivialReporter.js" /> - <Content Include="test\images\logo.png" /> - <Content Include="test\images\smalllogo.png" /> - <Content Include="test\images\splashscreen.png" /> - <Content Include="test\images\storelogo.png" /> - <Content Include="test\jasmine.css" /> - <Content Include="test\jasmine.js" /> - <Content Include="test\pages\accelerometer.html" /> - <Content Include="test\pages\all.html" /> - <Content Include="test\pages\battery.html" /> - <Content Include="test\pages\camera.html" /> - <Content Include="test\pages\capture.html" /> - <Content Include="test\pages\compass.html" /> - <Content Include="test\pages\contacts.html" /> - <Content Include="test\pages\cordova-1.6.1.js" /> - <Content Include="test\pages\device.html" /> - <Content Include="test\pages\file.html" /> - <Content Include="test\pages\filetransfer.html" /> - <Content Include="test\pages\geolocation.html" /> - <Content Include="test\pages\media.html" /> - <Content Include="test\pages\network.html" /> - <Content Include="test\pages\notification.html" /> - <Content Include="test\pages\platform.html" /> - <Content Include="test\pages\storage.html" /> - <Content Include="test\test-runner.js" /> - <Content Include="test\tests\accelerometer.tests.js" /> - <Content Include="test\tests\battery.tests.js" /> - <Content Include="test\tests\camera.tests.js" /> - <Content Include="test\tests\capture.tests.js" /> - <Content Include="test\tests\compass.tests.js" /> - <Content Include="test\tests\contacts.tests.js" /> - <Content Include="test\tests\device.tests.js" /> - <Content Include="test\tests\file.tests.js" /> - <Content Include="test\tests\filetransfer.tests.js" /> - <Content Include="test\tests\geolocation.tests.js" /> - <Content Include="test\tests\media.tests.js" /> - <Content Include="test\tests\network.tests.js" /> - <Content Include="test\tests\notification.tests.js" /> - <Content Include="test\tests\platform.tests.js" /> - <Content Include="test\tests\storage.tests.js" /> - <Content Include="test\uploadTestServer.js" /> - <None Include="cordova-win8_TemporaryKey.pfx" /> - </ItemGroup> - <ItemGroup> - <SDKReference Include="Microsoft.WinJS.1.0.RC, Version=1.0" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="lib\SQLite\SQLite3\SQLite3.vcxproj" /> - </ItemGroup> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/cordova-win8_TemporaryKey.pfx ---------------------------------------------------------------------- diff --git a/src/cordova-win8/cordova-win8_TemporaryKey.pfx b/src/cordova-win8/cordova-win8_TemporaryKey.pfx deleted file mode 100644 index 37cb134..0000000 Binary files a/src/cordova-win8/cordova-win8_TemporaryKey.pfx and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/accelerometer.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/accelerometer.js b/src/cordova-win8/js/accelerometer.js deleted file mode 100644 index d4e320c..0000000 --- a/src/cordova-win8/js/accelerometer.js +++ /dev/null @@ -1,207 +0,0 @@ -var utils = { - clone: function (obj) { - if (!obj) { - return obj; - } - - var retVal, i; - - if (obj instanceof Array) { - retVal = []; - for (i = 0; i < obj.length; ++i) { - retVal.push(_self.clone(obj[i])); - } - return retVal; - } - - if (obj instanceof Function) { - return obj; - } - - if (!(obj instanceof Object)) { - return obj; - } - - if (obj instanceof Date) { - return obj; - } - - retVal = {}; - for (i in obj) { - if (!(i in retVal) || retVal[i] != obj[i]) { - retVal[i] = _self.clone(obj[i]); - } - } - return retVal; - }, - - close: function (context, func, params) { - if (typeof params === 'undefined') { - return function () { - return func.apply(context, arguments); - }; - } else { - return function () { - return func.apply(context, params); - }; - } - }, - - /** - * Extends a child object from a parent object using classical inheritance - * pattern. - */ - extend: (function () { - var F = function () { }; - return function (Child, Parent) { - - F.prototype = Parent.prototype; - Child.prototype = new F(); - Child.__super__ = Parent.prototype; - Child.prototype.constructor = Child; - }; - }()), - - /** - * Alerts a message in any available way: alert or console.log. - */ - alert: function (msg) { - if (alert) { - alert(msg); - } else if (console && console.log) { - console.log(msg); - } - } -}; - -Jscex.Promise.create = function (init) { - return new WinJS.Promise(init); -} - - -/** - * This contains device acceleration information. - * @param {Object} x - * @param {Object} y - * @param {Object} z - * @param {Object} timestamp - * @constructor - */ -function Acceleration(x, y, z, timestamp) { - /** - * The x acceleration of the device. - */ - this.x = x; - /** - * The y acceleration of the device. - */ - this.y = y; - /** - * The z acceleration of the device. - */ - this.z = z; - /** - * The timestamp for the accelerations of the device. - */ - this.timestamp = timestamp || new Date().getTime(); -}; - -var accelerometerTimers = {}; // dictionary of timers in use - -// Returns default param, overrides if provided with value -function accelerometerOptions(options) { - var opt = { - frequency: 10000 - }; - if (options) { - if (options.frequency !== undefined) { - opt.frequency = options.frequency; - } - } - return opt; -} - - -/* - * This class provides access to device acceleration data. - * @constructor - */ -function Accelerometer() { } - - -/** - * Aquires the current 3d acceleration. - * - * @param {Function} accelerometerSuccess The Function to call when the acceleration data is available - * @param {Function} accelerometerError The function to call when there is an error getting the acceleration data - */ -Accelerometer.prototype.getCurrentAcceleration = function (accelerometerSuccess, accelerometerError) { - var win = function (a) { - accelerometerSuccess(new Acceleration(a.accelerationX, - a.accelerationY, - a.accelerationZ, - a.timestamp.getTime() - ) - ) - }; - - var fail = function () { - accelerometerError(); - }; - - var accel = Windows.Devices.Sensors.Accelerometer.getDefault(); - - var reading = accel.getCurrentReading(); - if (reading) { - win(reading); - } else { - fail(); - } -}; - -/** - * Watches the acceleration. Calls acceleromterSuccess at a regular time interval - * defined in options. - * - * @param {Function} accelerometerSuccess The function to call at the regular interval. - * @param {Function} accelerometerError The function to call when there is an error getting the acceleartion data. - * @param {accelerationOptions} options The option for frequency to call accelerometerSuccess. (OPTIONAL) - * @return String The watch id that must be passed to #clearWatch to stop watching. - */ - -Accelerometer.prototype.watchAcceleration = function (accelerometerSuccess, accelerometerError, options) { - options = accelerometerOptions(options); - var minimumReportInterval = this.minimumReportInterval; - if (options.frequency < minimumReportInterval) { - options.frequency < minimumReportInterval; - } - - var thisAcc = this; - var id = createUUID(); - accelerometerTimers[id] = window.setInterval(function () { - thisAcc.getCurrentAcceleration(accelerometerSuccess, accelerometerError); - }, options.frequency); - - return id; -}; - -/** - * Stop watching the acceleration referenced by the watchId param. - * - * @param {String} watchId The ID of the watch returned from #watchAcceleration - */ - -Accelerometer.prototype.clearWatch = function (watchId) { - if ((watchId !== undefined)&&(accelerometerTimers[watchId] !== undefined)) { - window.clearInterval(accelerometerTimers[watchId]); - delete accelerometerTimers[watchId]; - } -}; - -if (typeof navigator.accelerometer == "undefined") { - // Win RT support the object Accelerometer , and is Read-Only , So for test , must to change the methods of Object - navigator.accelerometer = new Accelerometer(); - //navigator.accelerometer.getCurrentAcceleration = new Accelerometer().getCurrentAcceleration; - //navigator.accelerometer.clearWatch = new Accelerometer().clearWatch; - //navigator.accelerometer.watchAcceleration = new Accelerometer().watchAcceleration; -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/camera.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/camera.js b/src/cordova-win8/js/camera.js deleted file mode 100755 index 2a87e6c..0000000 --- a/src/cordova-win8/js/camera.js +++ /dev/null @@ -1,461 +0,0 @@ -/** - * This class provides access to the device camera. - * - * @constructor - */ -function Camera() { - this.successCallback = null; - this.errorCallback = null; - this.options = null; -}; - -/** - * Format of image that returned from getPicture. - * - * Example: navigator.camera.getPicture(success, fail, - * { quality: 80, - * destinationType: Camera.DestinationType.DATA_URL, - * sourceType: Camera.PictureSourceType.PHOTOLIBRARY}) - */ -Camera.DestinationType = { - DATA_URL: 0, // Return base64 encoded string - FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android) -}; -Camera.prototype.DestinationType = Camera.DestinationType; - -/** - * Encoding of image returned from getPicture. - * - * Example: navigator.camera.getPicture(success, fail, - * { quality: 80, - * destinationType: Camera.DestinationType.DATA_URL, - * sourceType: Camera.PictureSourceType.CAMERA, - * encodingType: Camera.EncodingType.PNG}) -*/ -Camera.EncodingType = { - JPEG: 0, // Return JPEG encoded image - PNG: 1 // Return PNG encoded image -}; -Camera.prototype.EncodingType = Camera.EncodingType; - -/** - * Source to getPicture from. - * - * Example: navigator.camera.getPicture(success, fail, - * { quality: 80, - * destinationType: Camera.DestinationType.DATA_URL, - * sourceType: Camera.PictureSourceType.PHOTOLIBRARY}) - */ -Camera.PictureSourceType = { - PHOTOLIBRARY: 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android) - CAMERA: 1, // Take picture from camera - SAVEDPHOTOALBUM: 2 // Choose image from picture library (same as PHOTOLIBRARY for Android) -}; -Camera.prototype.PictureSourceType = Camera.PictureSourceType; - -Camera.MediaType = { - PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType - VIDEO: 1, // allow selection of video only, ONLY RETURNS URL - ALLMEDIA: 2 // allow selection from all media types -}; -Camera.prototype.MediaType = Camera.MediaType; - -/** - * Gets a picture from source defined by "options.sourceType", and returns the - * image as defined by the "options.destinationType" option. - - * The defaults are sourceType=CAMERA and destinationType=DATA_URL. - * - * @param {Function} successCallback - * @param {Function} errorCallback - * @param {Object} options - */ -Camera.prototype.getPicture = function (successCallback, errorCallback, options) { - - // successCallback required - if (typeof successCallback !== "function") { - console.log("Camera Error: successCallback is not a function"); - return; - } - - // errorCallback optional - if (errorCallback && (typeof errorCallback !== "function")) { - console.log("Camera Error: errorCallback is not a function"); - return; - } - - var quality = 50; - if (options && typeof options.quality == "number") { - quality = options.quality; - } else if (options && typeof options.quality == "string") { - var qlity = parseInt(options.quality, 10); - if (isNaN(qlity) === false) { - quality = qlity.valueOf(); - } - } - - var destinationType = Camera.DestinationType.FILE_URI; - if (typeof options.destinationType == "number") { - destinationType = options.destinationType; - } - - var sourceType = Camera.PictureSourceType.CAMERA; - if (typeof options.sourceType == "number") { - sourceType = options.sourceType; - } - - var targetWidth = -1; - if (typeof options.targetWidth == "number") { - targetWidth = options.targetWidth; - } else if (typeof options.targetWidth == "string") { - var width = parseInt(options.targetWidth, 10); - if (isNaN(width) === false) { - targetWidth = width.valueOf(); - } - } - - var targetHeight = -1; - if (typeof options.targetHeight == "number") { - targetHeight = options.targetHeight; - } else if (typeof options.targetHeight == "string") { - var height = parseInt(options.targetHeight, 10); - if (isNaN(height) === false) { - targetHeight = height.valueOf(); - } - } - - if ((targetWidth > 0 && targetHeight < 0) || (targetWidth < 0 && targetHeight > 0)) { - errorCallback("targetWidth should be used with targetHeight."); - } - - var encodingType = Camera.EncodingType.JPEG; - if (typeof options.encodingType == "number") { - encodingType = options.encodingType; - } - - var mediaType = Camera.MediaType.PICTURE; - if (typeof options.mediaType == "number") { - mediaType = options.mediaType; - } - var allowEdit = false; - if (typeof options.allowEdit == "boolean") { - allowEdit = options.allowEdit; - } else if (typeof options.allowEdit == "number") { - allowEdit = options.allowEdit <= 0 ? false : true; - } - var correctOrientation = false; - if (typeof options.correctOrientation == "boolean") { - correctOrientation = options.correctOrientation; - } else if (typeof options.correctOrientation == "number") { - correctOrientation = options.correctOrientation <= 0 ? false : true; - } - var saveToPhotoAlbum = false; - if (typeof options.saveToPhotoAlbum == "boolean") { - saveToPhotoAlbum = options.saveToPhotoAlbum; - } else if (typeof options.saveToPhotoAlbum == "number") { - saveToPhotoAlbum = options.saveToPhotoAlbum <= 0 ? false : true; - } - - - // get the path of photo album. - /*var parentPath - var username = Windows.System.UserProfile.UserInformation.getDisplayNameAsync().then(function (displayName) { - parentPath = "C:\\Users\\" + username + "\\Pictures"; - });*/ - var package = Windows.ApplicationModel.Package.current; - var packageId = package.installedLocation; - - // resize method :) - var resizeImage = function (file) { - var tempPhotoFileName = ""; - if (encodingType == Camera.EncodingType.PNG) { - tempPhotoFileName = "camera_cordova_temp_return.png"; - } else { - tempPhotoFileName = "camera_cordova_temp_return.jpg"; - } - var imgObj = new Image(); - var success = function (fileEntry) { - var successCB = function (filePhoto) { - var filePhoto = filePhoto, - fileType = file.contentType, - reader = new FileReader(); - reader.onloadend = function () { - var image = new Image(); - image.src = reader.result; - image.onload = function () { - var imageWidth = targetWidth, - imageHeight = targetHeight; - var canvas = document.createElement('canvas'); - - canvas.width = imageWidth; - canvas.height = imageHeight; - - var ctx = canvas.getContext("2d"); - ctx.drawImage(this, 0, 0, imageWidth, imageHeight); - - // The resized file ready for upload - var _blob = canvas.msToBlob(); - var _stream = _blob.msRandomAccessStream(); - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (file) { - file.openAsync(Windows.Storage.FileAccessMode.readWrite).done( function (fileStream) { - Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(_stream, fileStream).done(function () { - successCallback(file.name); - }, function () { errorCallback("Resize picture error."); }) - }, function () { errorCallback("Resize picture error."); }) - }, function () { errorCallback("Resize picture error."); }) - }) - - - /*var finalFile = canvas.toDataURL(fileType); - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (file) { - var arr = finalFile.split(","); - var newStr = finalFile.substr(arr[0].length + 1); - - var buffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(newStr); - Windows.Storage.FileIO.writeBufferAsync(file, buffer).done(function () { - successCallback(file.name); - - }, function () { errorCallback("Resize picture error.");}) - }, function () { errorCallback("Resize picture error."); }) - - }, function () { errorCallback("Resize picture error."); })*/ - } - } - - reader.readAsDataURL(filePhoto); - - } - var failCB = function () { - errorCallback("File not found.") - } - fileEntry.file(successCB, failCB); - } - - var fail = function (fileError) { - errorCallback("FileError, code:" + fileError.code); - } - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) { - success(new FileEntry(storageFile.name, storageFile.path)); - }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); - }, function () { - errorCallback("Folder not access."); - }); - }) - - } - - // because of asynchronous method, so let the successCallback be called in it. - var resizeImageBase64 = function (file) { - var imgObj = new Image(); - var success = function (fileEntry) { - var successCB = function (filePhoto) { - var filePhoto = filePhoto, - fileType = file.contentType, - reader = new FileReader(); - reader.onloadend = function () { - var image = new Image(); - image.src = reader.result; - - image.onload = function () { - var imageWidth = targetWidth, - imageHeight = targetHeight; - var canvas = document.createElement('canvas'); - - canvas.width = imageWidth; - canvas.height = imageHeight; - - var ctx = canvas.getContext("2d"); - ctx.drawImage(this, 0, 0, imageWidth, imageHeight); - - // The resized file ready for upload - var finalFile = canvas.toDataURL(fileType); - - // Remove the prefix such as "data:" + contentType + ";base64," , in order to meet the Cordova API. - var arr = finalFile.split(","); - var newStr = finalFile.substr(arr[0].length + 1); - successCallback(newStr); - } - } - - reader.readAsDataURL(filePhoto); - - } - var failCB = function () { - errorCallback("File not found.") - } - fileEntry.file(successCB, failCB); - } - - var fail = function (fileError) { - errorCallback("FileError, code:" + fileError.code); - } - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) { - success(new FileEntry(storageFile.name, storageFile.path)); - }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); - }, function () { - errorCallback("Folder not access."); - }); - }) - - } - - if (sourceType != Camera.PictureSourceType.CAMERA) { - var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker(); - fileOpenPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary; - if (mediaType == Camera.MediaType.PICTURE) { - fileOpenPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]); - } else if (mediaType == Camera.MediaType.VIDEO) { - fileOpenPicker.fileTypeFilter.replaceAll([".avi", ".flv", ".asx", ".asf", ".mov", ".mp4", ".mpg", ".rm", ".srt", ".swf", ".wmv", ".vob"]); - } else { - fileOpenPicker.fileTypeFilter.replaceAll(["*"]); - } - fileOpenPicker.pickSingleFileAsync().then(function (file) { - if (file) { - if (destinationType == Camera.DestinationType.FILE_URI) { - if (targetHeight > 0 && targetWidth > 0) { - resizeImage(file); - } else { - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) { - successCallback(storageFile.name); - }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); - }, function () { - errorCallback("Folder not access."); - }); - }) - - } - } - else { - if (targetHeight > 0 && targetWidth > 0) { - resizeImageBase64(file); - } else { - Windows.Storage.FileIO.readBufferAsync(file).done(function (buffer) { - var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer); - successCallback(strBase64); - }) - } - - } - - } else { - errorCallback("User didn't choose a file."); - } - }, function () { - errorCallback("User didn't choose a file.") - }) - } - else { - - var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI(); - cameraCaptureUI.photoSettings.allowCropping = true; - if (encodingType == Camera.EncodingType.PNG) { - cameraCaptureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png; - } else { - cameraCaptureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg; - } - // decide which max pixels should be supported by targetWidth or targetHeight. - if (targetWidth >= 1280 || targetHeight >= 960) { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.large3M; - } else if (targetWidth >= 1024 || targetHeight >= 768) { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.mediumXga; - } else if (targetWidth >= 800 || targetHeight >= 600) { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.mediumXga; - } else if (targetWidth >= 640 || targetHeight >= 480) { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.smallVga; - } else if (targetWidth >= 320 || targetHeight >= 240) { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.verySmallQvga; - } else { - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable; - } - - cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (picture) { - if (picture) { - // save to photo album successCallback - var success = function (fileEntry) { - if (destinationType == Camera.DestinationType.FILE_URI) { - if (targetHeight > 0 && targetWidth > 0) { - resizeImage(picture); - } else { - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) { - successCallback(storageFile.name); - }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); - }, function () { - errorCallback("Folder not access."); - }); - }) - } - } else { - if (targetHeight > 0 && targetWidth > 0) { - resizeImageBase64(picture); - } else { - Windows.Storage.FileIO.readBufferAsync(picture).done(function (buffer) { - var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer); - successCallback(strBase64); - }) - } - } - } - // save to photo album errorCallback - var fail = function () { - //errorCallback("FileError, code:" + fileError.code); - errorCallback("Save fail."); - } - - if (saveToPhotoAlbum) { - Windows.Storage.StorageFile.getFileFromPathAsync(picture.path).then(function (storageFile) { - storageFile.copyAsync(Windows.Storage.KnownFolders.picturesLibrary, picture.name, Windows.Storage.NameCollisionOption.generateUniqueName).then(function (storageFile) { - success(storageFile); - }, function () { - fail(); - }) - }) - //var directory = new DirectoryEntry("Pictures", parentPath); - //new FileEntry(picture.name, picture.path).copyTo(directory, null, success, fail); - } else { - if (destinationType == Camera.DestinationType.FILE_URI) { - if (targetHeight > 0 && targetWidth > 0) { - resizeImage(picture); - } else { - Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) { - picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) { - successCallback(storageFile.name); - }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); - }, function () { - errorCallback("Folder not access."); - }); - }) - } - } else { - if (targetHeight > 0 && targetWidth > 0) { - resizeImageBase64(picture); - } else { - Windows.Storage.FileIO.readBufferAsync(picture).done(function (buffer) { - var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer); - successCallback(strBase64); - }) - } - } - } - } else { - errorCallback("User didn't capture a photo."); - } - }, function () { - errorCallback("Fail to capture a photo."); - }) - } -}; - -if (typeof navigator.camera === "undefined") { - navigator.camera = new Camera(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/capture.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/capture.js b/src/cordova-win8/js/capture.js deleted file mode 100644 index f319d64..0000000 --- a/src/cordova-win8/js/capture.js +++ /dev/null @@ -1,264 +0,0 @@ - /** - * Encapsulates all audio capture operation configuration options. - */ -function CaptureAudioOptions() { - // Upper limit of sound clips user can record. Value must be equal or greater than 1. - this.limit = 1; - // Maximum duration of a single sound clip in seconds. - this.duration = 0; - // The selected audio mode. Must match with one of the elements in supportedAudioModes array. - this.mode = null; -}; - - /** - * The CaptureError interface encapsulates all errors in the Capture API. - */ -function CaptureError(c) { - this.code = c || null; -}; - -// Camera or microphone failed to capture image or sound. -CaptureError.CAPTURE_INTERNAL_ERR = 0; -// Camera application or audio capture application is currently serving other capture request. -CaptureError.CAPTURE_APPLICATION_BUSY = 1; -// Invalid use of the API (e.g. limit parameter has value less than one). -CaptureError.CAPTURE_INVALID_ARGUMENT = 2; -// User exited camera application or audio capture application before capturing anything. -CaptureError.CAPTURE_NO_MEDIA_FILES = 3; -// The requested capture operation is not supported. -CaptureError.CAPTURE_NOT_SUPPORTED = 20; - - - /** - * Encapsulates all image capture operation configuration options. - */ -function CaptureImageOptions() { - // Upper limit of images user can take. Value must be equal or greater than 1. - this.limit = 1; - // The selected image mode. Must match with one of the elements in supportedImageModes array. - this.mode = null; -}; - - - /** - * Encapsulates all video capture operation configuration options. - */ -function CaptureVideoOptions() { - // Upper limit of videos user can record. Value must be equal or greater than 1. - this.limit = 1; - // Maximum duration of a single video clip in seconds. - this.duration = 0; - // The selected video mode. Must match with one of the elements in supportedVideoModes array. - this.mode = null; -}; - -/** - * Represents a single file. - * - * name {DOMString} name of the file, without path information - * fullPath {DOMString} the full path of the file, including the name - * type {DOMString} mime type - * lastModifiedDate {Date} last modified date - * size {Number} size of the file in bytes - */ -function MediaFile(name, fullPath, type, lastModifiedDate, size) { - MediaFile.__super__.constructor.apply(this, arguments); -}; - -utils.extend(MediaFile, File); - -/** - * Request capture format data for a specific file and type - * - * @param {Function} successCB - * @param {Function} errorCB - */ -MediaFile.prototype.getFormatData = function (successCallback, errorCallback) { - var contentType = this.type; - if (typeof this.fullPath === "undefined" || this.fullPath === null) { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } else { - Windows.Storage.StorageFile.getFileFromPathAsync(this.fullPath).then(function (storageFile) { - var mediaTypeFlag = String(contentType).split("/")[0].toLowerCase(); - if (mediaTypeFlag === "audio") { - storageFile.properties.getMusicPropertiesAsync().then(function (audioProperties) { - successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration/1000)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - }) - } - else if (mediaTypeFlag === "video") { - storageFile.properties.getVideoPropertiesAsync().then(function (videoProperties) { - successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration/1000)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - }) - } - else if (mediaTypeFlag === "image") { - storageFile.properties.getImagePropertiesAsync().then(function (imageProperties) { - successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - }) - } - else { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)) } - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - }) - } -}; - -/** - * MediaFileData encapsulates format information of a media file. - * - * @param {DOMString} codecs - * @param {long} bitrate - * @param {long} height - * @param {long} width - * @param {float} duration - */ -function MediaFileData (codecs, bitrate, height, width, duration) { - this.codecs = codecs || null; - this.bitrate = bitrate || 0; - this.height = height || 0; - this.width = width || 0; - this.duration = duration || 0; -}; -/** - * The Capture interface exposes an interface to the camera and microphone of the hosting device. - */ -function Capture() { - this.supportedAudioModes = []; - this.supportedImageModes = ["image/jpeg", "image/png"]; - this.supportedVideoModes = ["video/mp4", "video/wmv"]; -} - -/** - * Launch audio recorder application for recording audio clip(s). - * - * @param {Function} successCB - * @param {Function} errorCB - * @param {CaptureAudioOptions} options - */ - -// No UI support. The duration of the audio recording. -var cameraCaptureAudioDuration; -Capture.prototype.captureAudio = function (successCallback, errorCallback, options) { - var audioOptions = new CaptureAudioOptions(); - if (options.duration && options.duration > 0) { - audioOptions.duration = options.duration; - cameraCaptureAudioDuration = audioOptions.duration; - } else { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - return; - } - var mediaCaputreSettings; - var initCaptureSettings = function () { - mediaCaputreSettings = null; - mediaCaputreSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings(); - mediaCaputreSettings.streamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.audio; - } - initCaptureSettings(); - var mediaCapture = new Windows.Media.Capture.MediaCapture(); - mediaCapture.initializeAsync(mediaCaputreSettings).done(function () { - Windows.Storage.KnownFolders.musicLibrary.createFileAsync("captureAudio.mp3", Windows.Storage.NameCollisionOption.generateUniqueName).then(function (storageFile) { - var mediaEncodingProfile = new Windows.Media.MediaProperties.MediaEncodingProfile.createMp3(Windows.Media.MediaProperties.AudioEncodingQuality.auto); - var stopRecord = function () { - mediaCapture.stopRecordAsync().then(function (result) { - storageFile.getBasicPropertiesAsync().then(function (basicProperties) { - successCallback(new MediaFile(storageFile.name, storageFile.path, storageFile.contentType, basicProperties.dateModified, basicProperties.size)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }) - }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }) - } - mediaCapture.startRecordToStorageFileAsync(mediaEncodingProfile, storageFile).then(function () { - setTimeout(stopRecord, cameraCaptureAudioDuration*1000); - }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }) - }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }) - }) -}; - -/** - * Launch camera application for taking image(s). - * - * @param {Function} successCB - * @param {Function} errorCB - * @param {CaptureImageOptions} options - */ -Capture.prototype.captureImage = function (successCallback, errorCallback, options) { - var imageOptions = new CaptureImageOptions(); - var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI(); - cameraCaptureUI.photoSettings.allowCropping = true; - cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable; - cameraCaptureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg; - cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (file) { - file.moveAsync(Windows.Storage.KnownFolders.picturesLibrary, "cameraCaptureImage.jpg", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { - file.getBasicPropertiesAsync().then(function (basicProperties) { - successCallback(new MediaFile(file.name, file.path, file.contentType, basicProperties.dateModified, basicProperties.size)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }) - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }); - }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }) -}; - -/** - * Launch device camera application for recording video(s). - * - * @param {Function} successCB - * @param {Function} errorCB - * @param {CaptureVideoOptions} options - */ -Capture.prototype.captureVideo = function (successCallback, errorCallback, options) { - var videoOptions = new CaptureVideoOptions(); - if (options.duration && options.duration > 0) { - videoOptions.duration = options.duration; - } - if (options.limit > 1) { - videoOptions.limit = options.limit; - } - var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI(); - cameraCaptureUI.videoSettings.allowTrimming = true; - cameraCaptureUI.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4; - cameraCaptureUI.videoSettings.maxDurationInSeconds = videoOptions.duration; - cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).then(function (file) { - file.moveAsync(Windows.Storage.KnownFolders.videosLibrary, "cameraCaptureVedio.mp4", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { - file.getBasicPropertiesAsync().then(function (basicProperties) { - successCallback(new MediaFile(file.name, file.path, file.contentType, basicProperties.dateModified, basicProperties.size)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }) - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }); - }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }) -}; - - -/** - * Encapsulates a set of parameters that the capture device supports. - */ -function ConfigurationData() { - // The ASCII-encoded string in lower case representing the media type. - this.type = null; - // The height attribute represents height of the image or video in pixels. - // In the case of a sound clip this attribute has value 0. - this.height = 0; - // The width attribute represents width of the image or video in pixels. - // In the case of a sound clip this attribute has value 0 - this.width = 0; -} - -// Just for test(because of the unimplementation of channnel and device) -function Device() { } - -if (typeof navigator.device === "undefined") { - navigator.device = new Device(); -} - -if (typeof navigator.device.capture === "undefined") { - navigator.device.capture = new Capture(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/compass.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/compass.js b/src/cordova-win8/js/compass.js deleted file mode 100644 index ff313c8..0000000 --- a/src/cordova-win8/js/compass.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * This class contains compass information. - * @param {Object} magnHead Magnetic heading - * @param {Object} trueHead True heading - * @param {Object} headAcc Heading accuracy - * @param {Object} timeSt Timestamp - */ -function CompassHeading(magnHead, trueHead, headAcc, timeSt) { - /** - * The magnetic north heading of the compass. - */ - this.magneticHeading = magnHead || 0; - /** - * The heading of the compass relative to the geographic North Pole. - */ - this.trueHeading = trueHead || this.magneticHeading; - /** - * The deviation between the report heading and the true heading of the compass. - */ - this.headingAccuracy = headAcc || 0; - /** - * The time at which the heading was determined. - */ - this.timestamp = (timeSt !== undefined) ? timeSt : new Date().getTime(); // need to check the validity of this statment -}; - -/** - * Compass error object - * - * @constructor - * @param code - */ -function CompassError(code) { - this.code = code || null; -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -var compassTimers = {}; // list of timers in use - -// Returns default params, overrides if provided with values -function compassOptions(options) { - var opt = { - frequency: 100 - }; - - if (options) { - if (options.frequency !== undefined) { - opt.frequency = options.frequency; - } - } - return opt; -}; - -/** - * This class provides access to device compass data. - * @constructor - */ -function Compass() { } - - -/** - * Aquires the current compass data - * - * @param {Function} successCallback The function to call when the compass data is available. - * @param {Function} errorCallback The function to call when there is an error getting the compass data. - * @param {CompassOptions} options The option for getting compass data. - */ -Compass.prototype.getCurrentHeading = function (successCallback, errorCallback, options) { - - // options = compassOptions(options); This is not needed as options are not used. - var win = function (c) { - successCallback(new CompassHeading(c.headingMagneticNorth, - c.headingTrueNorth, - (c.headingMagneticNorth - c.headingTrueNorth), - c.timestamp.getTime() - ) - ) - }; - var fail = function (e) { - errorCallback(new CompassError(e)); - }; - - var comp = Windows.Devices.Sensors.Compass.getDefault() - var reading = comp.getCurrentReading(); - - if (reading) { - win(reading); - } else { - fail(CompassError.COMPASS_INTERNAL_ERR); - }; -} - -/** - * Watches the compass for changes to the heading. When a change occures, the - * compassSuccess is called with the new heading - * - * @param {Function} successCallback The function to call each time compass data is available - * @param {Function} errorCallback The function to call when there is an error retreiving the heading - * @param {compassOptions} options The options for getting the compass heading (OPTIONAL) - * @return String The watch id that must be passed to #clearWatch - */ -Compass.prototype.watchHeading = function (successCallback, errorCallback, options) { - options = compassOptions(options); - var minimumReportInterval = this.minimumReportInterval; - if (options.frequency < minimumReportInterval) { - options.frequency < minimumReportInterval; - } - - var thisComp = this; - var id = createUUID(); - compassTimers[id] = window.setInterval(function () { - thisComp.getCurrentHeading(successCallback, errorCallback, options); - }, options.frequency); - - return id; -}; - -/** - * Clears the specified heading watch. - * - * @param {String} watchId The ID of the watch returned from #watchHeading - */ - -Compass.prototype.clearWatch = function (watchId) { - if ((watchId !== undefined) && (compassTimers[watchId] !== undefined)) { - window.clearInterval(compassTimers[watchId]); - delete compassTimers[watchId]; - } -} - -if (typeof navigator.compass == "undefined") { - // Win RT support of the object compas, and is Read-Only. So for test, must change the methods of the object - //navigator.compass.getCurrentHeading = new compass().getCurrentHeading; - //navigator.compass.clearWatch = new compass().clearWatch; - //navigator.compass.watchPosition = new compass().watchHeading; */ - navigator.compass = new Compass(); - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/device.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/device.js b/src/cordova-win8/js/device.js deleted file mode 100644 index 7a04da3..0000000 --- a/src/cordova-win8/js/device.js +++ /dev/null @@ -1,13 +0,0 @@ -var device = function () { - - //this.name = ; - // Windows.Networking.Connectivity.NetworkInformation.GetHostNames() - this.cordova = "1.7.0"; - - // Gets the OS - this.platform = "Win8"; - - // this.uuid = ; Not possible with current Metro apps - - // this.version = ; Not possible with current Metro apps -}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/src/cordova-win8/js/events.js ---------------------------------------------------------------------- diff --git a/src/cordova-win8/js/events.js b/src/cordova-win8/js/events.js deleted file mode 100644 index 06ac73e..0000000 --- a/src/cordova-win8/js/events.js +++ /dev/null @@ -1,16 +0,0 @@ -/** fireEvent fires off event to target - * name specifies the name of the vent - * type specifies type of event - * HTMLEvents - * KeyEvents - * MouseEvents - * MutationEvents - * UIEvents - */ -function fireEvent(name, target, type) { - var evt = target.createEvent(type); - - evt.initEvent(name, true, true); - - target.dispatchEvent(evt); -}; \ No newline at end of file