Sie sind auf Seite 1von 3

Javascript API Cheat Sheet

Listed here are Intels available JavaScript APIs. For a complete description of all APIs, articles, samples and tutorials please visit our online documentation at: http://www.html5dev-software.intel.com/documentation To enhance your apps with native like experience, download the Intels App Framework. A Javascript framework targeted at HTML5 browsers with a blazingly fast query selector library that supports W3C queries. app-framework-software.intel.com

3.4.0

Application Preparation:
Include the appMobi Javascript library in your index.html file <script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/appmobi.js"></script> Create an event handler to detect when appMobi is ready to roll document.addEventListener("appMobi.device.ready",onDeviceReady,false); If you plan to use AJAX requests in your app, include the xhr.js file already contained in the XDK bundle: <script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/xhr.js ></script>

AppMobi.display
Take control of the devices video display properties Methods
useViewport(widthPortrait,widthLandscape) size down an application for a smaller device lockViewportWindow(widthPortrait,heightPortrait,widthLandscape,heightLandscape) - guarantees that the values you send in are always completely visible startAR() triggers appMobis augmented reality mode stopAR() turns off augmented reality mode

AppMobi.notification
Alert applications user about applications state Methods Events
beep(x) beep the device x times vibrate() vibrate the device alert(message,title,buttonText) display a modal alert box confirm(message, confirmEventID, title, confirmButtonText, dismissButtonText) display a modal alert box with confirmation options showBusyIndicator() turns on devices busy state graphic hideBusyIndicator() turns off devices busy state graphic getNotificationList() get list of id keys to obtain access to the list of available notificaitons for a user getNotificationData(id) gets data associated with a notification checkPushUser(userID,password) confirms credentials of a user, or log existing user in on different device addPushUser(userID,password,email) register a new user ID on a particular appMobi app editPushUser(newEmail,newPassword) change email and password associated with the push notification service sendPusUserPass() send email message to a user including password for push notifications setPushUserAttributes(attributesObj) associates attributes to a user (attributesObj includes 6 string fields s1-s6, and 4 numeric fields n1-n4) findPushUser(userID,email) allow users to find other users refreshPushNotifications() allow users to for a device to re-synchronize notifications between device and database on server deletePushNotifications(notificationIDs) removes notifications from the server. sendPushNotification(userID,message,data) send a push notification to another user of the application showRichPushViewer(notificationID, closeImagePortraitX, closeImagePortraitY,closeImageLandscapeX, closeImageLandscapeY,closeImageWidth, closeImageHeight) display a rich push message closeRichPushViewer() force a rich push message to close appMobi.notification.push.enable appMobi.notification.confirm

AppMobi.player
Play audio and video Methods
startAudio(relativeURL,boolLooping) load and start specified audio file

Events
appMobi.player.audio.start appMobi.player.audio.stop appMobi.player.audio.busy appMobi.player.audio.error appMobi.player.audio.currenttime.set

setAudioCurrentTime(timeInSeconds) causes player to seek to time in file specified in seconds watchCurrentAudioTime(callback, interval) start a watch on the current audio track clearAudioCurrentTimeWatch(watchID) stops the process started by watchCurrentAudioTime toggleAudio() Pause/Play audio started with startAudio stopAudio() Stop audio started with a call to startAudio

appMobi.player.audio.stop appMobi.player.audio.busy appMobi.player.audio.error appMobi.player.track.change appMobi.player.shoutcast.start appMobi.player.shoutcast.stop appMobi.player.shoutcast.play appMobi.player.shoutcast.pause appMobi.player.shoutcast.busy appMobi.player.shoutcast.error appMobi.player.podcast.start appMobi.player.podcast.stop appMobi.player.podcast.busy appMobi.player.podcast.error appMobi.player.sound.error

startShoutcast(shoutcastURL,showPlayer) load and play a station hosted by Shoutcast

appMobi.notification.push.enable

appMobi.notification.push.user.edit playPodcast(podcastURL) load a specified podcast (audio or video) from the web appMobi.notification.push.sendpassword

appMobi.notification.push.user. editattributes

loadSound(releativeURL) preload specified sound file to avoid lag unloadSound(relativeURL) unload a specified sound file to free resources unloadAllSounds() unloads all sound files loaded via loadSound or playSound methods playSound(relativeURL) play a specified sound file

appMobi.notification.push.user.find

appMobi.notification.push.refresh

appMobi.player.sound.error

appMobi.notification.push.read

play() restarts playback of a paused player that was started via startShoutcast pause() pauses the playback of a loaded player that was started via startShoutcast stop() Stop playback of a loaded player that was started via startShoutcast volume(volumePercentage) controls the volume of streaming audio

appMobi.notification.push.delete

appMobi.notification.push.send appMobi.notification.push.rich.busy appMobi.notification.push.rich.close

appMobi.notification.push.rich.close rewind() rewinds the play head to beginning of track or 30 seconds from current position ffwd() advances the play head to end of track or 30 seconds from current position show() shows the native appMobi player UI hide() hides the native appMobi player UI setPosition(portraitX,portraitY,landscapeX, landscapeY) set the position of native player on screen setColors(backColor,fillColor,doneColor,playColor) change colors of the progress bar of the appMobi native player appMobi.player.show appMobi.player.hide

AppMobi.device
Configure settings of the device itself Methods
managePower(stayOn,onlyWhenPluggedIn) variables are booleans that determine how device behaves in different power states installUpdate() immediately install a waiting over the air application update setAutoRotate(boolean) Controls whether device automatically handles rotation or not setRotateOrientation(orientation) Locks orientation of device to either landscape or portrait updateConnection() queries the device to determine current connection to internet setBasicAuthentication(domain,user,pass) sets header data required for basic authentication over the internet addVirtualPage() intercepts single press of device hardware back button and fires event instead removeVirtualPage() removes the interception of device hardware back button launchExternal(url) opens specified URL in devices native browser showRemoteSiteExt(url,closeImagePortraitX,closeImagePortraitY,closeImageLandscapeX,closeImageLandscapeY,closeImageWidth,closeImageHeight) shows a remote website in a different web view closeRemoteSite() - force a remote site opened with showRemoteSiteExt to close getRemoteData(url,reqMethod,reqBody,success,error) makes background POST/GET requests of XML data getRemoteDataExt(paramsObj) - makes background POST/GET requests of XML data (paramsObj includes url,id,method,body,headers) scanBarcode() opens a full-screen QR code reader in the app hideSplashScreen() hides application splash screen earlier than it automatically does hideStatusBar() hides the status bar on the device blockRemotePages(shouldblock,whitelist) blocks remote pages, and sets up white list of allowable pages mainViewExecute(command) - Call this command from within a new web view created by the showRemoteSiteExt to execute JavaScript commands within the main web view runInstallNativeApp(appName, protocolHandler, appLocation, bundleID) run or install a native app on the device sendEmail(bodyText, toString, subjectText, isHTML, ccString, bccString) opens an email view to send an email without exiting the application sendSMS(bodyText, toNumber) sends an SMS message to the provided number appMobi.device.remote.block appMobi.device.remote.data appMobi.device.barcode.scan appMobi.device.remote.close appMobi.device.hardware.back appMobi.device.connection.update

Events

Properties
platform returns either iOS or Android model returns model of the device app is running on uuid returns devices unique identification id osversion returns the devices current OS version info appmobiversion returns version of appMobi container software app is using initialOrientation returns one of following 0 = Portrait 180 = Updside Down Portrait 90 = Landscape Right -90 = Landscape Left orientation returns current orientation of device (see possible values above for initialOrientation) phonegapversion returns version of PhoneGap running below appMobi layer. hasAnalytics indicates whether analytics have been enabled for app hasCaching says whether caching has been enabled for this application. Functions under AppMobi.cache (See above) for mediacache will not be available if this is false hasStreaming indicates whether streaming has been enabled for app queryString returns any query string parameters passed with a protocol handler call to start an app

AppMobi.cache
Used to provide local storage (cache) for data to speed up applications Methods Events
addToMediaCacheExt(url,id) get a file or files from the Internet and cache it locally on the device removeFromMediaCache(url) removes a file from local cache clearMediaCache() removes all files from local cache on the device getMediaCacheList() gets array containing names of all previously cached files (returns cacheArray) getMediaCacheLocalURL(url) returns a url that can be used to access a cached media file (returns localURL) setCookie(name,value,expiration) sets data that persists from session to session getCookie(name) retrieve value of cookie saved using setCookie getCookieList()- returns an array containing names of all previously saved cookies removeCookie(name) clear data previously saved with setCookie clearAllCookies() clears all data stored using setCookie appMobi.cache.media.add appMobi.cache.media.update appMobi.cache.media.remove

AppMobi.camera
Use device camera and access the device camera library Methods Events
takePicture(quality,saveToLibrary,picType) take a picture with device camera appMobi.camera.picture.add appMobi.camera.picture.busy appMobi.camera.picture.cancel appMobi.camera.picture.add appMobi.camera.picture.busy appMobi.camera.picture.cancel appMobi.camera.picture.remove

importPicture() move photo from apps native camera file service to picture list appMbi.cache.media.clear deletePicture(picFilename) remove photo from app picture list clearPictures() removes all photos from app picture list getPictureList() returns list of all photos stored in app picture list getPictureURL(picFilename) return URL of the specified picture on local webserver

appMobi.camera.picture.clear

AppMobi.file
Transfer files over the internet Methods
uploadToServer(localurl,uploadURL,folder, mimeType,uploadProgressCallback) uploads files to a remote server over the Internet cancelUpload() cancels a previous uploadToServer call

AppMobi.oauth
Events
appMobi.file.upload appMobi.file.upload.busy

Application authorization for services such as Twitter, LinkedIn, and Yelp Methods Events
getProtectedData(paramsObj) gets oauth authorization for a service, or updates oauth protected data once authorization is received (paramsObj includes service,url,id,method,body,headers) unauthorizeService(service) removes authorization for a service that has been previously authorized appMobi.oauth.busy appMobi.oauth.unavailable appMobi.oauth.protected.data

appMobi.oauth.busy appMobi.oauth.unavailable appMobi.oauth.unauthorize

AppMobi.accelerometer
Listen to the devices motion sensor Methods
watchAcceleration(success,options) asynchronously acquire device acceleration at given interval (returns watchID) clearWatch(watchID) stops process started with watchAcceleration

AppMobi.geolocation
Make application aware of current location Methods
getCurrentPosition(success,error) gets current location (latitude/longitude) of the device watchPosition(success,error,options) track progress during a trip rather than a single location clearWatch(watchTimer) stops process started by watchPosition when watch timer is passed

AppMobi.contacts
Maintain a list of contacts Methods
getContacts() retrieves/refreshes the local contact list getContactList() returns an array of contact IDs obtained via a getContacts call getContactData(contactID) get the contact info for a single contact addContact() adds a contact to the contacts list appMobi.contacts.add appMobi.contacts.busy appMobi.contacts.choose appMobi.contacts.busy appMobi.contacts.edit appMobi.contacts.busy appMobi.contacts.remove appMobi.contacts.busy

AppMobi.facebook
Events
appMobi.contacts.get

Integrate application with Facebook Methods


login(permissions) logs the user into Facebook logout() logs the user out of Facebook enableFrictionlessRequests() ensures news feed requests are frictionless requestWithGraphAPI(path,method, permissions) make a request from the newer Facebook Graph API requestWithRestAPI(command, method, parameters) make a request from the older Facebook REST API showAppRequestDialog(parametersObj) displays the Facebook application request dialog showNewsFeedDialog(parametersObj) displays the Facebook news feed submission dialog

Events
appMobi.facebook.login appMobi.facebook.logout

appMobi.facebook.request.response

appMobi.facebook.request.response

chooseContact() select a contact from the list

editContact(contactID) edit a specific contact

appMobi.facebook.dialog.complete appMobi.facebook.dialog.fail appMobi.facebook.dialog.complete appMobi.facebook.dialog.fail

removeContact(contactID) removes a contact from the list

AppMobi.multitouch
Listen for simultaneous touch events on Android Device Methods Events
enable() starts listening for Android multitouch events on HTML elements. This method MUST be called if your app requires multitouch.

View this Cheat Sheet online at: http://www.html5dev-software.intel.com/documentation/index.php?DOC=CHEAT_JSAPI

Das könnte Ihnen auch gefallen