Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added initial repository for Windows Mobile - only a couple of device…

… functionalities work right now. Also updated JS for BlackBerry.
  • Loading branch information...
commit 1d9ce3ef68947338f2cbe011f511056289326195 1 parent 04e2e6c
@filmaj filmaj authored
View
30 javascripts/blackberry/camera.js
@@ -0,0 +1,30 @@
+/**
+ * This class provides access to the device camera.
+ * @constructor
+ */
+function Camera() {
+ this.picture = null;
+}
+
+Camera.prototype.launch = function () {
+ if (device.hasCamera) device.exec("camera", ["obtain"], true);
+ else alert("Camera not supported on this device.");
+}
+
+/**
+ *
+ * @param {Function} successCallback
+ * @param {Function} errorCallback
+ * @param {Object} options
+ */
+Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
+ if (device.hasCamera) {
+ if (successCallback) this.onSuccess = successCallback;
+ else this.onSuccess = null;
+ if (errorCallback) this.onError = errorCallback;
+ else this.onError = null;
+ device.exec("camera", ["picture"], true);
+ } else alert("Camera not supported");
+}
+
+if (typeof navigator.camera == "undefined") navigator.camera = new Camera();
View
56 javascripts/blackberry/contacts.js
@@ -0,0 +1,56 @@
+/**
+ * This class represents a Contact in the manager.
+ * @constructor
+ */
+function Contact() {
+ this.name = "";
+ this.phone = "";
+ this.address = "";
+ this.email = "";
+}
+
+function ContactManager() {
+ this.contacts = [];
+ this.timestamp = new Date().getTime();
+ // Options used when calling ContactManager functions.
+ this.options = {
+ 'pageSize':0,
+ 'pageNumber':0,
+ 'nameFilter':''
+ };
+}
+ContactManager.prototype.formParams = function(options, startArray) {
+ var params = [];
+ if (startArray) params = startArray;
+ if (options.pageSize && options.pageSize > 0) params.push("pageSize:" + options.pageSize);
+ if (options.pageNumber) params.push("pageNumber:" + options.pageNumber);
+ if (options.nameFilter) params.push("nameFilter:" + options.nameFilter);
+ return params;
+}
+ContactManager.prototype.displayContact = function(successCallback, errorCallback, options) {
+ if (options.nameFilter && options.nameFilter.length > 0) {
+ var params = ["search"];
+ params = this.formParams(options,params);
+ this.search_onSuccess = successCallback;
+ this.search_onError = errorCallback;
+ device.exec("contacts", params, true);
+ } else {
+ ContactManager.getAllContacts(successCallback,errorCallback,options);
+ return;
+ }
+}
+ContactManager.prototype.getAllContacts = function(successCallback, errorCallback, options) {
+ this.global_onSuccess = successCallback;
+ this.global_onError = errorCallback;
+ var params = ["getall"];
+ params = this.formParams(options,params);
+ device.exec("contacts", params, true);
+}
+ContactManager.prototype.chooseContact = function(successCallback, options) {
+ this.choose_onSuccess = successCallback;
+ var params = ["choose"];
+ params = this.formParams(options,params);
+ device.exec("contacts", params, true);
+}
+
+if (typeof navigator.ContactManager == "undefined") navigator.ContactManager = new ContactManager();
View
31 javascripts/blackberry/device.js
@@ -0,0 +1,31 @@
+window.device = {
+ isIPhone: false,
+ isIPod: false,
+ isBlackBerry: true,
+
+ init: function() {
+ this.exec("initialize");
+ this.poll(function() {
+ device.available = typeof device.name == "string";
+ });
+ },
+ exec: function(command, params, sync) {
+ if (device.available || command == "initialize") {
+ try {
+ var cookieCommand = "PhoneGap=" + command;
+ if (params) cookieCommand += "/" + params.join("/");
+ document.cookie = cookieCommand;
+ if (sync) this.poll();
+ } catch(e) {
+ console.log("Command '" + command + "' has not been executed, because of exception: " + e);
+ alert("Error executing command '" + command + "'.")
+ }
+ } else {
+ alert("Device not available YET - still loading.");
+ }
+ },
+ poll: function(callback) {
+ eval(document.cookie + (callback ? ";callback();" : ""));
+ }
+};
+window.device.init();
View
5 javascripts/blackberry/media.js
@@ -0,0 +1,5 @@
+navigator.media = {
+ playSound: function(media) {
+ window.device.exec("media",[media],true);
+ }
+};
View
8 javascripts/blackberry/notification.js
@@ -0,0 +1,8 @@
+navigator.notification = {
+ vibrate: function(secs) {
+ window.device.exec("notification/vibrate",[secs]);
+ },
+ beep: function(times) {
+ window.device.exec("notification/beep",[times]);
+ }
+};
View
72 javascripts/blackberry/position.js
@@ -0,0 +1,72 @@
+/**
+ * This class contains position information.
+ * @param {Object} lat
+ * @param {Object} lng
+ * @param {Object} acc
+ * @param {Object} alt
+ * @param {Object} altacc
+ * @param {Object} head
+ * @param {Object} vel
+ * @constructor
+ */
+function Position(coords) {
+ this.coords = coords;
+ this.timestamp = new Date().getTime();
+}
+
+function Coordinates(lat, lng, alt, acc, head, vel) {
+ /**
+ * The latitude of the position.
+ */
+ this.latitude = lat;
+ /**
+ * The longitude of the position,
+ */
+ this.longitude = lng;
+ /**
+ * The accuracy of the position.
+ */
+ this.accuracy = acc;
+ /**
+ * The altitude of the position.
+ */
+ this.altitude = alt;
+ /**
+ * The direction the device is moving at the position.
+ */
+ this.heading = head;
+ /**
+ * The velocity with which the device is moving at the position.
+ */
+ this.speed = vel;
+}
+
+/**
+ * This class specifies the options for requesting position data.
+ * @constructor
+ */
+function PositionOptions() {
+ /**
+ * Specifies the desired position accuracy.
+ */
+ this.enableHighAccuracy = true;
+ /**
+ * The timeout after which if position data cannot be obtained the errorCallback
+ * is called.
+ */
+ this.timeout = 10000;
+}
+
+/**
+ * This class contains information about any GSP errors.
+ * @constructor
+ */
+function PositionError() {
+ this.code = null;
+ this.message = "";
+}
+
+PositionError.UNKNOWN_ERROR = 0;
+PositionError.PERMISSION_DENIED = 1;
+PositionError.POSITION_UNAVAILABLE = 2;
+PositionError.TIMEOUT = 3;
View
18 javascripts/blackberry/telephony.js
@@ -0,0 +1,18 @@
+/**
+ * This class provides access to the telephony features of the device.
+ * @constructor
+ */
+function Telephony() {
+ this.number = null;
+}
+
+/**
+ * Calls the specifed number.
+ * @param {Integer} number The number to be called.
+ */
+Telephony.prototype.call = function(number) {
+ this.number = number;
+ device.exec("call", [this.number]);
+}
+
+if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony();
View
12 winmo/Command.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PhoneGap {
+
+ public interface Command {
+ String execute(String instruction);
+ Boolean accept(String instruction);
+ }
+
+}
View
30 winmo/CommandManager.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PhoneGap {
+
+ class CommandManager {
+
+ private Command[] commands = new Command[1];
+
+ public CommandManager() {
+ commands[0] = new InitializationCommand();
+ //commands[1] = new MediaCommand();
+ }
+
+ public String processInstruction(String instruction) {
+ for (int index = 0; index < commands.Length; index++) {
+ Command command = (Command) commands[index];
+ if (command.accept(instruction))
+ try {
+ return command.execute(instruction);
+ } catch(Exception e) {
+
+ }
+ }
+ return null;
+ }
+ }
+
+}
View
148 winmo/InitializationCommand.cs
@@ -0,0 +1,148 @@
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace PhoneGap
+{
+
+ internal partial class PInvoke
+ {
+ private static Int32 FILE_DEVICE_HAL = 0x00000101;
+ private static Int32 FILE_ANY_ACCESS = 0x0;
+ private static Int32 METHOD_BUFFERED = 0x0;
+ private static Int32 IOCTL_HAL_GET_DEVICEID = ((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14) | ((21) << 2) | (METHOD_BUFFERED);
+ private const Int32 ERROR_NOT_SUPPORTED = 0x32;
+ private const Int32 ERROR_INSUFFICIENT_BUFFER = 0x7A;
+
+ [DllImport("Coredll.dll", EntryPoint = "SystemParametersInfoW", CharSet = CharSet.Unicode)]
+ static extern int SystemParametersInfo4Strings(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWinIni);
+
+ public enum SystemParametersInfoActions : uint
+ {
+ SPI_GETPLATFORMTYPE = 257, // this is used elsewhere for Smartphone/PocketPC detection
+ SPI_GETOEMINFO = 258,
+ }
+
+ public static string GetOemInfo()
+ {
+ StringBuilder oemInfo = new StringBuilder(50);
+ if (SystemParametersInfo4Strings((uint)SystemParametersInfoActions.SPI_GETOEMINFO,
+ (uint)oemInfo.Capacity, oemInfo, 0) == 0)
+ throw new Exception("Error getting OEM info.");
+ return oemInfo.ToString();
+ }
+ [DllImport("coredll.dll", SetLastError = true)]
+ private static extern bool KernelIoControl(Int32 dwIoControlCode,
+ IntPtr lpInBuf, Int32 nInBufSize, byte[] lpOutBuf,
+ Int32 nOutBufSize, ref Int32 lpBytesReturned);
+
+ public static string GetDeviceID()
+ {
+ // Initialize the output buffer to the size of a
+ // Win32 DEVICE_ID structure.
+ byte[] outbuff = new byte[20];
+ Int32 dwOutBytes;
+ bool done = false;
+
+ Int32 nBuffSize = outbuff.Length;
+
+ // Set DEVICEID.dwSize to size of buffer. Some platforms look at
+ // this field rather than the nOutBufSize param of KernelIoControl
+ // when determining if the buffer is large enough.
+ BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
+ dwOutBytes = 0;
+
+ // Loop until the device ID is retrieved or an error occurs.
+ while (!done)
+ {
+ if (KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero,
+ 0, outbuff, nBuffSize, ref dwOutBytes))
+ {
+ done = true;
+ }
+ else
+ {
+ int error = Marshal.GetLastWin32Error();
+ switch (error)
+ {
+ case ERROR_NOT_SUPPORTED:
+ throw new NotSupportedException(
+ "IOCTL_HAL_GET_DEVICEID is not supported on this device",
+ new Win32Exception(error));
+
+ case ERROR_INSUFFICIENT_BUFFER:
+
+ // The buffer is not big enough for the data. The
+ // required size is in the first 4 bytes of the output
+ // buffer (DEVICE_ID.dwSize).
+ nBuffSize = BitConverter.ToInt32(outbuff, 0);
+ outbuff = new byte[nBuffSize];
+
+ // Set DEVICEID.dwSize to size of buffer. Some
+ // platforms look at this field rather than the
+ // nOutBufSize param of KernelIoControl when
+ // determining if the buffer is large enough.
+ BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
+ break;
+
+ default:
+ throw new Win32Exception(error, "Unexpected error");
+ }
+ }
+ }
+
+ // Copy the elements of the DEVICE_ID structure.
+ Int32 dwPresetIDOffset = BitConverter.ToInt32(outbuff, 0x4);
+ Int32 dwPresetIDSize = BitConverter.ToInt32(outbuff, 0x8);
+ Int32 dwPlatformIDOffset = BitConverter.ToInt32(outbuff, 0xc);
+ Int32 dwPlatformIDSize = BitConverter.ToInt32(outbuff, 0x10);
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = dwPresetIDOffset;
+ i < dwPresetIDOffset + dwPresetIDSize; i++)
+ {
+ sb.Append(String.Format("{0:X2}", outbuff[i]));
+ }
+
+ sb.Append("-");
+
+ for (int i = dwPlatformIDOffset;
+ i < dwPlatformIDOffset + dwPlatformIDSize; i++)
+ {
+ sb.Append(String.Format("{0:X2}", outbuff[i]));
+ }
+ return sb.ToString();
+ }
+ }
+
+ internal partial class PlatformDetection
+ {
+ private const string MicrosoftEmulatorOemValue = "Microsoft DeviceEmulator";
+ public static bool IsEmulator()
+ {
+ return PInvoke.GetOemInfo() == MicrosoftEmulatorOemValue;
+ }
+ }
+
+ class InitializationCommand : Command
+ {
+
+ #region Command Members
+
+ Boolean Command.accept(String instruction)
+ {
+ return "/initialize".Equals(instruction);
+ }
+
+ String Command.execute(string instruction)
+ {
+ string retVal = ";device.name = '" + PInvoke.GetOemInfo() + "';";
+ retVal += "device.uuid = '" + PInvoke.GetDeviceID() + "';";
+ return retVal;
+ }
+
+ #endregion
+ }
+
+}
View
16 winmo/Program.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace PhoneGap {
+
+ static class Program {
+
+ [MTAThread]
+ static void Main() {
+ Application.Run(new WebForm());
+ }
+
+ }
+
+}
View
66 winmo/WebForm.Designer.cs
@@ -0,0 +1,66 @@
+namespace PhoneGap
+{
+ partial class WebForm
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.webBrowser = new System.Windows.Forms.WebBrowser();
+ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.SuspendLayout();
+ //
+ // webBrowser
+ //
+ this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.webBrowser.Location = new System.Drawing.Point(0, 0);
+ this.webBrowser.Name = "webBrowser";
+ this.webBrowser.Size = new System.Drawing.Size(176, 200);
+ this.webBrowser.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.webBrowser_Navigating);
+ //
+ // openFileDialog1
+ //
+ this.openFileDialog1.FileName = "openFileDialog1";
+ //
+ // WebForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(176, 200);
+ this.Controls.Add(this.webBrowser);
+ this.Name = "WebForm";
+ this.Text = "WebForm";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.WebBrowser webBrowser;
+ private CommandManager commandManager;
+ private System.Windows.Forms.OpenFileDialog openFileDialog1;
+ }
+}
View
61 winmo/WebForm.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using System.Reflection;
+
+namespace PhoneGap {
+
+ public partial class WebForm : Form {
+ // TODO: Shouldn't create the HTML to display from resources all in memory. Should create a file and send html/js/css resources to the file.
+ // Less memory used.
+ public WebForm() {
+ // use this for certain file/audio i/o operations - grab embedded resources and add
+ // dynamically to the manifestmodule. Cool hack - thanks Ran!
+ //string s = Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
+
+ InitializeComponent();
+ commandManager = new CommandManager();
+ webBrowser.ScriptErrorsSuppressed = false;
+ webBrowser.DocumentText = parseDataProtocol(readEmbedded("/www/index.html"));
+ }
+
+ private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
+ if (e.Url.Host.Equals("gap.exec")) {
+ e.Cancel = true;
+ String res = commandManager.processInstruction(e.Url.AbsolutePath);
+ webBrowser.Navigate(new Uri("javascript:" + res + ";abc.x=1;//JS error!"));
+ }
+ }
+ private String readEmbedded(String fileName)
+ {
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ String path = assembly.GetName().Name + ".www." + (fileName.StartsWith("/www/") ? fileName.Substring(5) : fileName).Replace("/", ".");
+ Stream stream = assembly.GetManifestResourceStream(path);
+ StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
+ return reader.ReadToEnd();
+ }
+
+ private String parseDataProtocol(String documentText) {
+ string toMatch = "<script src=\"data://";
+ int matchLength = toMatch.Length;
+ int position = documentText.IndexOf("<script src=\"data://");
+ if (position > 0) {
+ String parsedText = documentText.Substring(position + matchLength);
+ int endName = parsedText.IndexOf("type");
+ int endScript = documentText.IndexOf("</script>",position);
+ int scriptTagLength = endScript + "</script>".Length - position;
+ String jsName = parsedText.Substring(0, endName - 2);
+ parsedText = documentText.Remove(position, scriptTagLength);
+ parsedText = parsedText.Insert(position, "<script type='text/javascript'>\n" + readEmbedded(jsName) + "</script>");
+ return parseDataProtocol(parsedText);
+ }
+ return documentText;
+ }
+ }
+
+}
View
129 winmo/WebForm.resx
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Pocket_PC</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
View
28 winmo/www/index.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Nothing important</title>
+ <script src="data:///www/js/device.js" type="text/javascript"></script>
+ <script src="data:///www/js/media.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ function showLabel(newText) {
+ document.getElementById('resultText').innerText = newText;
+ }
+ function playApplause() {
+ media.playSound('data:///www/media/applause.wav');
+ showLabel('CLAP CLAP CLAP!');
+ }
+ </script>
+ </head>
+ <body onload="device.init();"> <!-- on load call init to make sure we bridge to device properly-->
+ <p>This is an HTML page.</p><br />
+ <a href="javascript:showLabel(device.name);">Show me the device model/name</a><br />
+ <a href='javascript:showLabel(device.uuid);'>Show me the device UUID</a><br />
+ <!--<a href="javascript:playApplause();">Play expected audience response ;)</a><br />-->
+ <br />
+ <div id="resultLabel" style="width:100%;height:20px;background-color:#dddddd;padding:2px;margin:5px;border:solid 1px black;"><p id="resultText" style="margin:0 auto;"></p></div>
+ <br />
+ <p>For more information, please visit <a href="http://www.phonegap.com">www.phonegap.com</a>.</p>
+ <p>PhoneGap source is available on <a href="http://www.github.com/sintaxi/phonegap/tree">GitHub (http://www.github.com/sintaxi/phonegap/tree)</a>.</p>
+ </body>
+</html>
View
20 winmo/www/js/device.js
@@ -0,0 +1,20 @@
+var device = {
+ init: function() {
+ this.exec("initialize");
+ // For some reason, in WinMo v6.0, we need to delay setting device.available because device.name does not exist yet.
+ // A 10ms delay is sufficient for the variable to be visible.
+ setTimeout('device.available = typeof(device.name) == "string";',10);
+ },
+ exec: function(command, params) {
+ if (device.available || command == "initialize") {
+ try {
+ var url = "http://gap.exec/" + command;
+ if (params) url += "/" + params.join("/");
+ window.location.href = url;
+ } catch(e) {
+ console.log("Command '" + command + "' has not been executed, because of exception: " + e);
+ alert("Error executing command '" + command + "'.");
+ }
+ }
+ }
+};
Please sign in to comment.
Something went wrong with that request. Please try again.