SlideShare una empresa de Scribd logo
1 de 38
JavaScript Coding for the Touch
Interface, Device and Operating
System Resources, and More
Lesson 10
Exam Objective Matrix
Skills/Concepts

MTA Exam Objectives

Responding to the Touch
Interface
Coding Additional HTML5
APIs
Accessing Device and
Operating System
Resources

Respond to the touch interface. (4.5)
Code additional HTML5 APIs. (4.6)
Access device and operating system
resources. (4.7)

2
Touch Screens
• Resistive: Made up of several layers;
topmost layer flexes when pressed;
sensors detect the pressure
• Capacitive: Uses electrodes to sense
objects touching the screen; object must
have conductive properties
– A finger works but something like a stylus
does not
3
Overview of Touch Gestures
Gesture
Tap

Mouse
Equivalent
Left-click

Double tap

Left double-click

Two-finger tap

N/A

Press and tap

Right-click

Press and hold

Right-click

Description
Tap a finger on the screen
Quickly tap a finger twice on the
screen
Tap two fingers on the screen
simultaneously
Press and hold one finger while
tapping another
Press and hold a finger on the screen,
then release

4
Overview of Touch Gestures (Continued)
Gesture
Selection/drag
Panning with
inertia
Flick

Rotate
Zoom

Mouse
Equivalent
Mouse drag
(selection)
Scrolling
Move back or
forward
Pan up or down
N/A
CTRL + mouse
wheel forward or
backward

Description
Drag a finger to the left or right
Press and hold a finger on the screen
and then drag the finger
Press a finger on the screen, move it in
any direction, and then lift the finger to
scroll
Move two fingers over an object on the
screen in a circular motion
Pinch an object inwards or outwards

5
Primary JavaScript Touch Events
• Every new finger touch triggers a
touchstart event.
• When a finger moves around the surface of
the screen, a touchmove event occurs, which
tracks the finger movement.
• Lifting the finger from the screen triggers a
touchend event.
• The touchcancel event is triggered when the
device launches another application.
6
Touch Object and Touchlist
• In JavaScript, the touch object detects
input from touch-enabled devices. You
reference touch objects in the touchlist,
which includes all of the points of contact
with a touch screen.
• A single tap has one entry in the touchlist,
whereas a three-finger gesture would have
a total of three entries.
7
Touchlists
• touches: A list of all touch points currently in

contact with the screen
• targetTouches: A list of touch points currently
in contact with the screen and whose
touchstart event occurred within the same
node (inside the same target element as the
current target element)
• changedTouches: A list of touch points that
caused the current event to be fired; for
example, in a touchend event, this is the finger
that was removed
8
addEventListener method
• Used to attach an event handler to an
HTML element
– Can be a div, link, or anything you want.

• General syntax:
object.addEventListener(event,
eventListenerFunction);

9
startup() Function Example

10
handleStart Function Example

11
Gesture Events
• Every new two-finger gesture triggers a
gesturestart event.
• When both fingers move around the
screen, a gesturechange event occurs.
• Lifting both fingers from the screen
triggers a gestureend event.

12
Scale and Rotation Properties
• scale: Indicates the amount of two-finger

pinch zooming that occurred
• rotation: Indicates the amount of twofinger rotation that occurred

13
WHATWG
• Web Hypertext Application Technology
Working Group (WHATWG)
• Formed by Apple, the Mozilla Foundation,
and Opera Software to define and
document the HTML5 specification
• http://developers.whatwg.org/

14
Geolocation API
• Defines an interface that provides a
device’s location, usually using latitude
and longitude coordinates
• API exposes the latitude and longitude to
JavaScript in a Web page using the
geolocation object

15
Geolocation Methods
• getCurrentPosition: Gets the device’s

current geographic position
• watchPosition: Watches the device’s
position as it changes over time and
generates an event if a change occurs
– Calling clearWatch stops the watch

16
Example of a Call to getCurrentPosition

17
Geodetic and Civic Data
• You can present location data to users in
two ways:
– Geodetic data provides raw location data,
such as longitude and latitude, or meters.
– Civic data is location data that’s more
easily understood by humans, such as a
map or an address like 637 Park Street.

18
Web Workers
• Web Workers are scripts that run in the
background, performing calculations or other
actions that allow for a more responsive user
interface.
• Uses:
– Fetch real-time data like stock updates
– Make network requests
– Access local storage while the main HTML
document responds to the user input like tapping,
scrolling, and typing.
19
Web Workers (Continued)
• Web Worker objects run in isolated threads—
they do not act directly on the main HTML
document or the DOM.
• You don’t use getElementById in your script.
(You can use setTimeout, setInterval, and
XMLHttpRequest.)
• Instead, Web Workers pass information through
messages, executing code from a JavaScript file
separate from the main HTML document.
20
Web Workers Example
• Main HTML document:

• doWork.js file:

21
WebSockets
• WebSockets is an API that offers fullduplex communication through a single
socket over the Internet.
• Uses:
– Real-time Web applications like chat,
multiplayer online gaming, and stock
quotes

22
WebSockets (Continued)
• Primary events associated with
WebSocket communications:
– onopen: When a socket opens
– onmessage: When a message has been

received from the Web server
– onclose: When a socket closes

23
WebSockets (Continued)
• The JavaScript that opens a WebSocket
connection is:
var host = 'ws://example.com';

• ws replaces http in the URL
• wss for secure WebSocket connections,
just like https for secure HTTP
connections

24
WebSockets (Continued)
• Test an initialized Web connection using one of these
methods
– Opens an alert box:

socket.onopen = function(){
alert("Socket open");
}
– Displays a message:

socket.onopen = function (openEvent) {
document.getElementById("serverStatus").
innerHTML =
'Socket open';
};
25
WebSockets (Continued)
• The code for sending a text-based
message:
socket.send('message');

• A Blob is a data type that can store binary
data, like images or multimedia files. To
send a file as a Blob:
var file =
document.querySelector('input[type="fi
le"]').files[0];
socket.send(file);
26
WebSockets (Continued)
• To receive messages from the server, you
could use the onmessage callback:
socket.onmessage = function(msg){
alert(msg); //Received!
}

• To close a connection, use the onclose
event handler:
socket.onclose = function() {
alert("Connection closed.");
};

27
File API
• Allows a browser or application to upload
files from local storage to a remote server
without the need for a plug-in

28
File API Interfaces
• File: Includes read-only informational

attributes about an individual file, such as its
name and media type, and reads in the file as
a URL
• FileList: An array-like sequence of File
objects; includes dragging a folder of files
from local storage
• Blob: Provides access to raw binary data
• FileReader: Provides methods to read and
display a file
29
File API Interfaces
• Use the input type="file" element to
get the list of selected File objects as a
FileList

30
Web Storage API
• Provides a client-side method for saving
session information locally within the browser
or device memory
• localStorage method allows users to save
larger amounts of data from session to
session (persistent data)
• sessionStorage method keeps data only for
one session (until the browser is closed)
• Data stored in key/value pairs for both types
of Web storage
31
Web Storage API (Continued)
• sessionStorage is isolated to a specific

window or browser tab.
• Stores temporary data during an HTTP
session that occurs in a single window or tab
• Multiple windows or tabs can maintain their
own session data
• Ideal for user with multiple open browser
tabs, can have different shopping carts open
in each tab (for example)
32
Platform Independence
• Describes an application that can run on
different desktop and mobile device
operating systems, such as Microsoft
Windows, Internet Explorer, Windows
Phone, Mac OS X, Android, iOS, and
Blackberry OS

33
Global Positioning System (GPS)
• Hardware, which is usually a chip or circuit
board, is a receiver that communicates
with satellites to provide a device’s precise
location in longitude and latitude
coordinates
• Found in most modern phones and
laptops with WiFi and/or cellular
broadband
• Geolocation API works with the GPS chip
to gather raw geolocation data 34
Accelerometer
• A device that measures acceleration
• Accelerometer sensor detects forces
applied to the device, such as movement
(up, down, sideways) and gravity
• Specific APIs retrieve raw motion data
from Accelerometer sensors, and then the
Motion API combines the data from those
sensors and crunches the numbers that
result in easy-to-use values
35
Accelerometer (Continued)
• devicemotion event provides the acceleration

of the device, in Cartesian coordinates, and the
rotation rate
• JavaScript that receives devicemotion events:
window.addEventListener("devicemotion",
function(event) {
// Process event.acceleration,
event.accelerationIncludingGravity,
// event.rotationRate and event.interval
}, true);
36
Camera
• W3C HTML Media Capture specification
uses a capture attribute with the input
element to capture data from cameras,
camcorders, webcams, microphones, and
so on
• Generic code that uploads an image from
a device’s camera:
<input type="file" accept="image/*"
capture="camera"
id="capture">
37
Recap
•
•
•
•
•
•
•
•
•
•

Touch interface
Gestures
Capturing geolocation data
Web Workers
WebSockets
File API
Accessing in-memory resources
GPS
Accelerometer
Camera

38

Más contenido relacionado

Similar a MTA java script coding for the touch interface

Developing Rich Interfaces in JavaFX for Ultrabooks
Developing Rich Interfaces in JavaFX for UltrabooksDeveloping Rich Interfaces in JavaFX for Ultrabooks
Developing Rich Interfaces in JavaFX for UltrabooksFelipe Pedroso
 
3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - Monospace3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - MonospaceFrank Krueger
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaMobileNepal
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
IoT Supercharged: Complex event processing for MQTT with Eclipse technologies
IoT Supercharged: Complex event processing for MQTT with Eclipse technologiesIoT Supercharged: Complex event processing for MQTT with Eclipse technologies
IoT Supercharged: Complex event processing for MQTT with Eclipse technologiesIstvan Rath
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkMiguel de Icaza
 
Linux Inter Process Communication
Linux Inter Process CommunicationLinux Inter Process Communication
Linux Inter Process CommunicationAbhishek Sagar
 
WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2Shahzad
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0Aarti P
 
OS in mobile devices [Android]
OS in mobile devices [Android]OS in mobile devices [Android]
OS in mobile devices [Android]Yatharth Aggarwal
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Adam Dunkels
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introductionsaivvit
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global dominationStfalcon Meetups
 

Similar a MTA java script coding for the touch interface (20)

Developing Rich Interfaces in JavaFX for Ultrabooks
Developing Rich Interfaces in JavaFX for UltrabooksDeveloping Rich Interfaces in JavaFX for Ultrabooks
Developing Rich Interfaces in JavaFX for Ultrabooks
 
3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - Monospace3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - Monospace
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan Gupta
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Android by Swecha
Android by SwechaAndroid by Swecha
Android by Swecha
 
Windows 1809 Timeline
Windows 1809 TimelineWindows 1809 Timeline
Windows 1809 Timeline
 
IoT Supercharged: Complex event processing for MQTT with Eclipse technologies
IoT Supercharged: Complex event processing for MQTT with Eclipse technologiesIoT Supercharged: Complex event processing for MQTT with Eclipse technologies
IoT Supercharged: Complex event processing for MQTT with Eclipse technologies
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections Talk
 
Real time web
Real time webReal time web
Real time web
 
Linux Inter Process Communication
Linux Inter Process CommunicationLinux Inter Process Communication
Linux Inter Process Communication
 
WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2
 
6. TinyOS_2.pdf
6. TinyOS_2.pdf6. TinyOS_2.pdf
6. TinyOS_2.pdf
 
Measuring Continuity
Measuring ContinuityMeasuring Continuity
Measuring Continuity
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
From Data Push to WebSockets
From Data Push to WebSocketsFrom Data Push to WebSockets
From Data Push to WebSockets
 
OS in mobile devices [Android]
OS in mobile devices [Android]OS in mobile devices [Android]
OS in mobile devices [Android]
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
 

Último

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

MTA java script coding for the touch interface

  • 1. JavaScript Coding for the Touch Interface, Device and Operating System Resources, and More Lesson 10
  • 2. Exam Objective Matrix Skills/Concepts MTA Exam Objectives Responding to the Touch Interface Coding Additional HTML5 APIs Accessing Device and Operating System Resources Respond to the touch interface. (4.5) Code additional HTML5 APIs. (4.6) Access device and operating system resources. (4.7) 2
  • 3. Touch Screens • Resistive: Made up of several layers; topmost layer flexes when pressed; sensors detect the pressure • Capacitive: Uses electrodes to sense objects touching the screen; object must have conductive properties – A finger works but something like a stylus does not 3
  • 4. Overview of Touch Gestures Gesture Tap Mouse Equivalent Left-click Double tap Left double-click Two-finger tap N/A Press and tap Right-click Press and hold Right-click Description Tap a finger on the screen Quickly tap a finger twice on the screen Tap two fingers on the screen simultaneously Press and hold one finger while tapping another Press and hold a finger on the screen, then release 4
  • 5. Overview of Touch Gestures (Continued) Gesture Selection/drag Panning with inertia Flick Rotate Zoom Mouse Equivalent Mouse drag (selection) Scrolling Move back or forward Pan up or down N/A CTRL + mouse wheel forward or backward Description Drag a finger to the left or right Press and hold a finger on the screen and then drag the finger Press a finger on the screen, move it in any direction, and then lift the finger to scroll Move two fingers over an object on the screen in a circular motion Pinch an object inwards or outwards 5
  • 6. Primary JavaScript Touch Events • Every new finger touch triggers a touchstart event. • When a finger moves around the surface of the screen, a touchmove event occurs, which tracks the finger movement. • Lifting the finger from the screen triggers a touchend event. • The touchcancel event is triggered when the device launches another application. 6
  • 7. Touch Object and Touchlist • In JavaScript, the touch object detects input from touch-enabled devices. You reference touch objects in the touchlist, which includes all of the points of contact with a touch screen. • A single tap has one entry in the touchlist, whereas a three-finger gesture would have a total of three entries. 7
  • 8. Touchlists • touches: A list of all touch points currently in contact with the screen • targetTouches: A list of touch points currently in contact with the screen and whose touchstart event occurred within the same node (inside the same target element as the current target element) • changedTouches: A list of touch points that caused the current event to be fired; for example, in a touchend event, this is the finger that was removed 8
  • 9. addEventListener method • Used to attach an event handler to an HTML element – Can be a div, link, or anything you want. • General syntax: object.addEventListener(event, eventListenerFunction); 9
  • 12. Gesture Events • Every new two-finger gesture triggers a gesturestart event. • When both fingers move around the screen, a gesturechange event occurs. • Lifting both fingers from the screen triggers a gestureend event. 12
  • 13. Scale and Rotation Properties • scale: Indicates the amount of two-finger pinch zooming that occurred • rotation: Indicates the amount of twofinger rotation that occurred 13
  • 14. WHATWG • Web Hypertext Application Technology Working Group (WHATWG) • Formed by Apple, the Mozilla Foundation, and Opera Software to define and document the HTML5 specification • http://developers.whatwg.org/ 14
  • 15. Geolocation API • Defines an interface that provides a device’s location, usually using latitude and longitude coordinates • API exposes the latitude and longitude to JavaScript in a Web page using the geolocation object 15
  • 16. Geolocation Methods • getCurrentPosition: Gets the device’s current geographic position • watchPosition: Watches the device’s position as it changes over time and generates an event if a change occurs – Calling clearWatch stops the watch 16
  • 17. Example of a Call to getCurrentPosition 17
  • 18. Geodetic and Civic Data • You can present location data to users in two ways: – Geodetic data provides raw location data, such as longitude and latitude, or meters. – Civic data is location data that’s more easily understood by humans, such as a map or an address like 637 Park Street. 18
  • 19. Web Workers • Web Workers are scripts that run in the background, performing calculations or other actions that allow for a more responsive user interface. • Uses: – Fetch real-time data like stock updates – Make network requests – Access local storage while the main HTML document responds to the user input like tapping, scrolling, and typing. 19
  • 20. Web Workers (Continued) • Web Worker objects run in isolated threads— they do not act directly on the main HTML document or the DOM. • You don’t use getElementById in your script. (You can use setTimeout, setInterval, and XMLHttpRequest.) • Instead, Web Workers pass information through messages, executing code from a JavaScript file separate from the main HTML document. 20
  • 21. Web Workers Example • Main HTML document: • doWork.js file: 21
  • 22. WebSockets • WebSockets is an API that offers fullduplex communication through a single socket over the Internet. • Uses: – Real-time Web applications like chat, multiplayer online gaming, and stock quotes 22
  • 23. WebSockets (Continued) • Primary events associated with WebSocket communications: – onopen: When a socket opens – onmessage: When a message has been received from the Web server – onclose: When a socket closes 23
  • 24. WebSockets (Continued) • The JavaScript that opens a WebSocket connection is: var host = 'ws://example.com'; • ws replaces http in the URL • wss for secure WebSocket connections, just like https for secure HTTP connections 24
  • 25. WebSockets (Continued) • Test an initialized Web connection using one of these methods – Opens an alert box: socket.onopen = function(){ alert("Socket open"); } – Displays a message: socket.onopen = function (openEvent) { document.getElementById("serverStatus"). innerHTML = 'Socket open'; }; 25
  • 26. WebSockets (Continued) • The code for sending a text-based message: socket.send('message'); • A Blob is a data type that can store binary data, like images or multimedia files. To send a file as a Blob: var file = document.querySelector('input[type="fi le"]').files[0]; socket.send(file); 26
  • 27. WebSockets (Continued) • To receive messages from the server, you could use the onmessage callback: socket.onmessage = function(msg){ alert(msg); //Received! } • To close a connection, use the onclose event handler: socket.onclose = function() { alert("Connection closed."); }; 27
  • 28. File API • Allows a browser or application to upload files from local storage to a remote server without the need for a plug-in 28
  • 29. File API Interfaces • File: Includes read-only informational attributes about an individual file, such as its name and media type, and reads in the file as a URL • FileList: An array-like sequence of File objects; includes dragging a folder of files from local storage • Blob: Provides access to raw binary data • FileReader: Provides methods to read and display a file 29
  • 30. File API Interfaces • Use the input type="file" element to get the list of selected File objects as a FileList 30
  • 31. Web Storage API • Provides a client-side method for saving session information locally within the browser or device memory • localStorage method allows users to save larger amounts of data from session to session (persistent data) • sessionStorage method keeps data only for one session (until the browser is closed) • Data stored in key/value pairs for both types of Web storage 31
  • 32. Web Storage API (Continued) • sessionStorage is isolated to a specific window or browser tab. • Stores temporary data during an HTTP session that occurs in a single window or tab • Multiple windows or tabs can maintain their own session data • Ideal for user with multiple open browser tabs, can have different shopping carts open in each tab (for example) 32
  • 33. Platform Independence • Describes an application that can run on different desktop and mobile device operating systems, such as Microsoft Windows, Internet Explorer, Windows Phone, Mac OS X, Android, iOS, and Blackberry OS 33
  • 34. Global Positioning System (GPS) • Hardware, which is usually a chip or circuit board, is a receiver that communicates with satellites to provide a device’s precise location in longitude and latitude coordinates • Found in most modern phones and laptops with WiFi and/or cellular broadband • Geolocation API works with the GPS chip to gather raw geolocation data 34
  • 35. Accelerometer • A device that measures acceleration • Accelerometer sensor detects forces applied to the device, such as movement (up, down, sideways) and gravity • Specific APIs retrieve raw motion data from Accelerometer sensors, and then the Motion API combines the data from those sensors and crunches the numbers that result in easy-to-use values 35
  • 36. Accelerometer (Continued) • devicemotion event provides the acceleration of the device, in Cartesian coordinates, and the rotation rate • JavaScript that receives devicemotion events: window.addEventListener("devicemotion", function(event) { // Process event.acceleration, event.accelerationIncludingGravity, // event.rotationRate and event.interval }, true); 36
  • 37. Camera • W3C HTML Media Capture specification uses a capture attribute with the input element to capture data from cameras, camcorders, webcams, microphones, and so on • Generic code that uploads an image from a device’s camera: <input type="file" accept="image/*" capture="camera" id="capture"> 37
  • 38. Recap • • • • • • • • • • Touch interface Gestures Capturing geolocation data Web Workers WebSockets File API Accessing in-memory resources GPS Accelerometer Camera 38

Notas del editor

  1. Tip: Add your own speaker notes here.
  2. Tip: Add your own speaker notes here.
  3. Tip: Add your own speaker notes here.
  4. Tip: Add your own speaker notes here.
  5. Tip: Add your own speaker notes here.
  6. Tip: Add your own speaker notes here.
  7. Tip: Add your own speaker notes here.
  8. Tip: Add your own speaker notes here.
  9. Tip: Add your own speaker notes here.
  10. Tip: Add your own speaker notes here.
  11. Tip: Add your own speaker notes here.
  12. Tip: Add your own speaker notes here.
  13. Tip: Add your own speaker notes here.
  14. Tip: Add your own speaker notes here.
  15. Tip: Add your own speaker notes here.
  16. Tip: Add your own speaker notes here.
  17. Tip: Add your own speaker notes here.
  18. Tip: Add your own speaker notes here.
  19. Tip: Add your own speaker notes here.
  20. Tip: Add your own speaker notes here.
  21. Tip: Add your own speaker notes here.
  22. Tip: Add your own speaker notes here.
  23. Tip: Add your own speaker notes here.
  24. Tip: Add your own speaker notes here.
  25. Tip: Add your own speaker notes here.
  26. Tip: Add your own speaker notes here.
  27. Tip: Add your own speaker notes here.
  28. Tip: Add your own speaker notes here.
  29. Tip: Add your own speaker notes here.
  30. Tip: Add your own speaker notes here.
  31. Tip: Add your own speaker notes here.
  32. Tip: Add your own speaker notes here.
  33. Tip: Add your own speaker notes here.
  34. Tip: Add your own speaker notes here.
  35. Tip: Add your own speaker notes here.
  36. Tip: Add your own speaker notes here.