Created
May 13, 2009 20:25
-
-
Save jhubert/111276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof(DeviceInfo)!="object"){DeviceInfo={}} | |
PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]}; | |
PhoneGap.available=DeviceInfo.uuid!=undefined; | |
PhoneGap.addConstructor=function(a){var b=document.readyState;if(b!="loaded"&&b!="complete"){PhoneGap._constructors.push(a)}else{a()}}; | |
(function(){var a=setInterval(function(){var c=document.readyState;if(c!="loaded"&&c!="complete"){return}clearInterval(a);while(PhoneGap._constructors.length>0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})(); | |
PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}}; | |
PhoneGap.run_command=function(){}; | |
function Device(){this.available=PhoneGap.available;this.model=null;this.version=null;this.gap=null;this.uuid=null;try{if(window.DroidGap!=undefined&&window.DroidGap.exists()){this.available=true;this.isAndroid=true;this.uuid=window.DroidGap.getUuid();this.gapVersion=window.DroidGap.getVersion()}else{this.model=DeviceInfo.platform;this.version=DeviceInfo.version;this.gap=DeviceInfo.gap;this.uuid=DeviceInfo.uuid}}catch(a){this.available=false}}PhoneGap.addConstructor(function(){navigator.device=window.device=new Device()}); | |
PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;e<d.length;e++){if(typeof(d[e])=="object"){g=d[e]}else{f.push(encodeURIComponent(d[e]))}}var c="gap://"+d[0]+"/"+f.join("/");if(g!=null){var a=[];for(var b in g){if(typeof(b)!="string"){continue}a.push(encodeURIComponent(b)+"="+encodeURIComponent(g[b]))}if(a.length>0){c+="?"+a.join("&")}}document.location=c}; | |
function Acceleration(a,c,b){this.x=a;this.y=c;this.z=b;this.timestamp=new Date().getTime()} | |
function AccelerationOptions(){this.timeout=10000} | |
function Accelerometer(){this.lastAcceleration=null} | |
Accelerometer.prototype.getCurrentAcceleration=function(a,b,c){if(typeof a=="function"){var d=new Acceleration(_accel.x,_accel.y,_accel.z);Accelerometer.lastAcceleration=d;a(d)}}; | |
Accelerometer.prototype.watchAcceleration=function(a,b,c){this.getCurrentAcceleration(a,b,c);var d=(c!=undefined)?c.frequency:10000;return setInterval(function(){navigator.accelerometer.getCurrentAcceleration(a,b,c)},d)};Accelerometer.prototype.clearWatch=function(a){clearInterval(a)};PhoneGap.addConstructor(function(){if(typeof navigator.accelerometer=="undefined"){navigator.accelerometer=new Accelerometer()}}); | |
Accelerometer.prototype.getCurrentAcceleration=function(a,b,c){if(typeof a=="function"){var d=new Acceleration(_accel.x,_accel.y,_accel.z);Accelerometer.lastAcceleration=d;a(d)}}; | |
function Media(a){this.src=a}; | |
Media.prototype.play=function(){}; | |
Media.prototype.pause=function(){}; | |
Media.prototype.stop=function(){}; | |
function MediaError(){this.code=null,this.message=""} | |
MediaError.MEDIA_ERR_ABORTED=1; | |
MediaError.MEDIA_ERR_NETWORK=2; | |
MediaError.MEDIA_ERR_DECODE=3; | |
MediaError.MEDIA_ERR_NONE_SUPPORTED=4; | |
Media.prototype.play=function(){if(this.src!=null){PhoneGap.exec("Sound.play",this.src)}}; | |
function Camera(){} | |
Camera.prototype.getPicture=function(a,b,c){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.camera=="undefined"){navigator.camera=new Camera()}}); | |
function Contact(){this.name="";this.phone="";this.address=""} | |
Contact.prototype.get=function(a,b,c){}; | |
function ContactManager(){this.contacts=[];this.timestap=new Date().getTime()} | |
ContactManager.prototype.get=function(a,b,c){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.ContactManager=="undefined"){navigator.ContactManager=new ContactManager()}}); | |
ContactManager.prototype.get=function(a,c,d){alert('running');PhoneGap.exec("Contacts.get");if(typeof a=="function"){alert(_contacts.length);for(var e=0;e<_contacts.length;e++){var b=new Contact();b.name=_contacts[e].name;b.phone=_contacts[e].phone;this.contacts.push(b)}a(this)}}; | |
function UIControls(){this.tabBarTag=0;this.tabBarCallbacks={}}UIControls.prototype.createTabBar=function(){}; | |
UIControls.prototype.showTabBar=function(a){}; | |
UIControls.prototype.hideTabBar=function(a){}; | |
UIControls.prototype.createTabBarItem=function(c,b,d,a){}; | |
UIControls.prototype.updateTabBarItem=function(b,a){}; | |
UIControls.prototype.showTabBarItems=function(b,a){}; | |
UIControls.prototype.selectTabBarItem=function(a){}; | |
UIControls.prototype.tabBarItemSelected=function(a){if(typeof(this.tabBarCallbacks[a])=="function"){this.tabBarCallbacks[a]()}}; | |
UIControls.prototype.createToolBar=function(){}; | |
UIControls.prototype.setToolBarTitle=function(a){}; | |
PhoneGap.addConstructor(function(){window.uicontrols=new UIControls()}); | |
UIControls.prototype.createTabBar=function(){PhoneGap.exec("UIControls.createTabBar")}; | |
UIControls.prototype.showTabBar=function(a){PhoneGap.exec("UIControls.showTabBar",a)}; | |
UIControls.prototype.hideTabBar=function(a){PhoneGap.exec("UIControls.hideTabBar",{animate:a})}; | |
UIControls.prototype.createTabBarItem=function(d,c,e,b){var a=this.tabBarTag++;if(b&&"onSelect" in b&&typeof(b.onSelect)=="function"){this.tabBarCallbacks[a]=b.onSelect}PhoneGap.exec("UIControls.createTabBarItem",d,c,e,a,b)}; | |
UIControls.prototype.updateTabBarItem=function(b,a){PhoneGap.exec("UIControls.updateTabBarItem",b,a)}; | |
UIControls.prototype.showTabBarItems=function(){var b=["UIControls.showTabBarItems"];for(var a=0;a<arguments.length;a++){b.push(arguments[a])}PhoneGap.exec.apply(this,b)}; | |
UIControls.prototype.selectTabBarItem=function(a){PhoneGap.exec("UIControls.selectTabBarItem",a)}; | |
UIControls.prototype.createToolBar=function(){PhoneGap.exec("UIControls.createToolBar")}; | |
UIControls.prototype.setToolBarTitle=function(a){PhoneGap.exec("UIControls.setToolBarTitle",a)}; | |
function DebugConsole(){}; | |
DebugConsole.prototype.processMessage=function(b){if(typeof(b)!="object"){return encodeURIComponent(b)}else{function a(d){return d.replace(/^/mg," ")}function c(g){var h="";for(var d in g){try{if(typeof(g[d])=="object"){h+=d+":\n"+a(c(g[d]))+"\n"}else{h+=d+" = "+a(String(g[d])).replace(/^ /,"")+"\n"}}catch(f){h+=d+" = EXCEPTION: "+f.message+"\n"}}return h}return encodeURIComponent("Object:\n"+c(b))}}; | |
DebugConsole.prototype.log=function(a){}; | |
DebugConsole.prototype.warn=function(a){}; | |
DebugConsole.prototype.error=function(a){}; | |
PhoneGap.addConstructor(function(){window.debug=new DebugConsole()}); | |
DebugConsole.prototype.log=function(a){if(PhoneGap.available){PhoneGap.exec("DebugConsole.log",this.processMessage(a),{logLevel:"INFO"})}else{console.log(a)}}; | |
DebugConsole.prototype.warn=function(a){if(PhoneGap.available){PhoneGap.exec("DebugConsole.log",this.processMessage(a),{logLevel:"WARN"})}else{console.error(a)}}; | |
DebugConsole.prototype.error=function(a){if(PhoneGap.available){PhoneGap.exec("DebugConsole.log",this.processMessage(a),{logLevel:"ERROR"})}else{console.error(a)}}; | |
function File(){this.data="";this.name=""} | |
File.prototype.read=function(c,a,b){}; | |
File.prototype.write=function(a){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.file=="undefined"){navigator.file=new File()}}); | |
function Geolocation(){this.lastPosition=null;this.lastError=null;this.callbacks={onLocationChanged:[],onError:[]}} | |
Geolocation.prototype.getCurrentPosition=function(c,f,i){var g=0;if(this.lastPosition){g=this.lastPosition.timeout}else{this.start(i)}var h=20000;var b=500;if(typeof(i)=="object"&&i.interval){b=i.interval}if(typeof(c)!="function"){c=function(){}}if(typeof(f)!="function"){f=function(){}}var d=this;var e=0;var a=setInterval(function(){e+=b;if(typeof(d.lastPosition)=="object"&&d.lastPosition.timestamp>g){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)}; | |
Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)}; | |
Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;b<this.callbacks.onLocationChanged.length;b++){var c=this.callbacks.onLocationChanged.shift();c(a)}}; | |
Geolocation.prototype.setError=function(b){this.lastError=b;for(var a=0;a<this.callbacks.onError.length;a++){var c=this.callbacks.onError.shift();c(b)}}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.geolocation=="undefined"){navigator.geolocation=new Geolocation()}}); | |
Geolocation.prototype.start=function(a){PhoneGap.exec("Location.start",a)}; | |
Geolocation.prototype.stop=function(){PhoneGap.exec("Location.stop")}; | |
function Map(){}; | |
Map.prototype.show=function(a){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.map=="undefined"){navigator.map=new Map()}}); | |
function Notification(){}; | |
Notification.prototype.alert=function(a,c,b){alert(a)}; | |
Notification.prototype.activityStart=function(){}; | |
Notification.prototype.activityStop=function(){}; | |
Notification.prototype.blink=function(a,b){}; | |
Notification.prototype.vibrate=function(a){}; | |
Notification.prototype.beep=function(b,a){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.notification=="undefined"){navigator.notification=new Notification()}}); | |
Notification.prototype.vibrate=function(a){PhoneGap.exec("Notification.vibrate")}; | |
Notification.prototype.beep=function(b,a){new Media("beep.wav").play()}; | |
Notification.prototype.alert=function(b,d,c){var a={};if(d){a.title=d}if(c){a.buttonLabel=c}if(PhoneGap.available){PhoneGap.exec("Notification.alert",b,a)}else{alert(b)}}; | |
Notification.prototype.activityStart=function(){PhoneGap.exec("Notification.activityStart")}; | |
Notification.prototype.activityStop=function(){PhoneGap.exec("Notification.activityStop")}; | |
function Orientation(){this.lastOrientation=null}; | |
Orientation.prototype.getCurrentOrientation=function(a,b){}; | |
Orientation.prototype.watchOrientation=function(a,b){this.getCurrentPosition(a,b);return setInterval(function(){navigator.orientation.getCurrentOrientation(a,b)},10000)}; | |
Orientation.prototype.clearWatch=function(a){clearInterval(a)}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.orientation=="undefined"){navigator.orientation=new Orientation()}}); | |
function Position(g,b,e,f,a,c,d){this.latitude=g;this.longitude=b;this.accuracy=e;this.altitude=f;this.altitudeAccuracy=a;this.heading=c;this.velocity=d;this.timestamp=new Date().getTime()} | |
function PositionOptions(){this.enableHighAccuracy=true;this.timeout=10000} | |
function PositionError(){this.code=null;this.message=""} | |
PositionError.UNKNOWN_ERROR=0; | |
PositionError.PERMISSION_DENIED=1; | |
PositionError.POSITION_UNAVAILABLE=2; | |
PositionError.TIMEOUT=3; | |
function Sms(){}; | |
Sms.prototype.send=function(e,d,a,b,c){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.sms=="undefined"){navigator.sms=new Sms()}}); | |
function Telephony(){}; | |
Telephony.prototype.call=function(a){}; | |
PhoneGap.addConstructor(function(){if(typeof navigator.telephony=="undefined"){navigator.telephony=new Telephony()}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment