Slide 1

Slide 1 text

Mashing up JavaScript @BastianHofmann Advanced techniques for modern web applications

Slide 2

Slide 2 text

Wtf?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

• JavaScript Apps • CORS and OAuth2 • Local Storage • OEmbed and Caja • WebSockets, ActivityStrea.ms and PubsubHubbub • What‘s next?

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Questions? Ask!

Slide 22

Slide 22 text

http://speakerdeck.com/u/bastianhofmann

Slide 23

Slide 23 text

Let‘s write a JS App

Slide 24

Slide 24 text

https://github.com/bashofmann/statusnet_js_mashup_2nd

Slide 25

Slide 25 text

CSS Bastian

Slide 26

Slide 26 text

http://twitter.github.com/bootstrap

Slide 27

Slide 27 text

History & Bookmarking

Slide 28

Slide 28 text

www.example.com#Page

Slide 29

Slide 29 text

www.example.com/Page

Slide 30

Slide 30 text

http://sammyjs.org/

Slide 31

Slide 31 text

API Access

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Same Origin Policy

Slide 34

Slide 34 text

Cross-Origin Resource Sharing Backend api.twitter.com Client client.net AJAX Access-Control-Allow-Origin: * http://www.w3.org/TR/cors/

Slide 35

Slide 35 text

var html="
    "; for (var i=0; i < viewers.length; i++) { html += "
  • " + viewers[i].displayName + "
  • "; } html += "
      "; document.getElementById("#div").innerHTML = html; Where is the error?

Slide 36

Slide 36 text

Templates

Slide 37

Slide 37 text

Mustache.JS https://github.com/janl/mustache.js }

Slide 38

Slide 38 text

DEMO

Slide 39

Slide 39 text

Authorization

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

http://oauth.net/

Slide 42

Slide 42 text

User-Agent Profile

Slide 43

Slide 43 text

http://twitter.com/authorize?&clientId=... Open Popup lanyrd.com

Slide 44

Slide 44 text

http://twitter.com/authorize?&clientId=... Open Popup lanyrd.com HTTPS GET twitter.co m/ authorize

Slide 45

Slide 45 text

http://twitter.com/authorize?&clientId=... Open Popup lanyrd.com Login twitter.co m/ authorize

Slide 46

Slide 46 text

http://twitter.com/authorize?&clientId=... Open Popup lanyrd.com Grant Permission twitter.co m/ authorize

Slide 47

Slide 47 text

lanyrd.com HTTPS Redirect RedirectURI# accessToken twitter.co m/ authorize RedirectURI# accessToken lanyrd.com

Slide 48

Slide 48 text

lanyrd.com RedirectURI# accessToken Parse Access Token from Fragment Send it to opening window Close popup lanyrd.com

Slide 49

Slide 49 text

Same Origin Policy

Slide 50

Slide 50 text

lanyrd.com HTTPS Ajax Request to API Access Token twitter.com

Slide 51

Slide 51 text

Storing the access token

Slide 52

Slide 52 text

Local Storage http://www.w3.org/TR/webstorage/

Slide 53

Slide 53 text

DEMO

Slide 54

Slide 54 text

Mash it up!

Slide 55

Slide 55 text

cool video: http://www.youtube.com/ watch?v=OFzkTxiwziQ

Slide 56

Slide 56 text

OEmbed http://oembed.com/

Slide 57

Slide 57 text

http://www.youtube.com/watch?v=OyJd2qsRkNk

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

http://www.youtube.com/oembed?url=http%3A%2F %2Fwww.youtube.com%2Fwatch%3Fv %3DOyJd2qsRkNk&maxwidth=500&format=json

Slide 60

Slide 60 text

{ "provider_url":"http:\/\/www.youtube.com\/", "title":"Jupiter Jones - Das Jahr in dem ich schlief (Musik Video)", "html":"\u003cobject width=\"500\" height=\"306\"\u003e \u003cparam name=\"movie\" value=\"http:\/\/www.youtube.com\/v\/ OyJd2qsRkNk?version=3\"\u003e\u003c\/param\u003e\u003cparam name= \"allowFullScreen\" value=\"true\"\u003e\u003c\/param\u003e \u003cparam name=\"allowscriptaccess\" value=\"always\"\u003e \u003c\/param\u003e\u003cembed src=\"http:\/\/www.youtube.com\/v\/ OyJd2qsRkNk?version=3\" type=\"application\/x-shockwave-flash \" width=\"500\" height=\"306\" allowscriptaccess=\"always \" allowfullscreen=\"true\"\u003e\u003c\/embed\u003e\u003c\/object \u003e", "author_name":"St182", "height":306, "thumbnail_width":480, "width":500, "version":"1.0", "author_url":"http:\/\/www.youtube.com\/user\/Stinkfist182", "provider_name":"YouTube", "thumbnail_url":"http:\/\/i4.ytimg.com\/vi\/OyJd2qsRkNk\/ hqdefault.jpg", "type":"video", "thumbnail_height":360 }

Slide 61

Slide 61 text

cool video:

Slide 62

Slide 62 text

http://embed.ly/

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Caja http://code.google.com/p/google-caja/

Slide 65

Slide 65 text

DEMO

Slide 66

Slide 66 text

Instant updates without reloading

Slide 67

Slide 67 text

PubSubHubbub retrieves Atom feed with Hub URL Hub posts sth pings every subscriber subscribes for feed acks subscription http://code.google.com/p/pubsubhubbub/

Slide 68

Slide 68 text

Slide 69

Slide 69 text

http://activitystrea.ms/schema/1.0/ note http://status.net.xyz:8061/index.php/notice/20 hello from client hello from client http://activitystrea.ms/schema/1.0/post 2011-05-23T21:07:33+00:00 2011-05-23T21:07:33+00:00 52.52437 13.41053

Slide 70

Slide 70 text

http://activitystrea.ms/

Slide 71

Slide 71 text

Slide 72

Slide 72 text

PubSubHubbub retrieves Atom feed with Hub URL Hub posts sth pings every subscriber subscribes for feed acks subscription http://code.google.com/p/pubsubhubbub/

Slide 73

Slide 73 text

http://nodejs.org/

Slide 74

Slide 74 text

WebSockets http://dev.w3.org/html5/websockets/

Slide 75

Slide 75 text

socket.io http://socket.io/

Slide 76

Slide 76 text

http://search.npmjs.org/#/socket.io

Slide 77

Slide 77 text

Browser Notifications

Slide 78

Slide 78 text

retrieve Stream with Hub Ajax: request Subscription WebSockets: new Post subscribe at hub challenge ack new post Notification new post

Slide 79

Slide 79 text

DEMO

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Meteor http://www.meteor.com

Slide 82

Slide 82 text

https://github.com/bashofmann/meteor_shoutbox_demo

Slide 83

Slide 83 text

DEMO

Slide 84

Slide 84 text

http://meteor-shoutbox-demo.meteor.com/

Slide 85

Slide 85 text

Rate and Comment https://joind.in/6233

Slide 86

Slide 86 text

h"p://twi"er.com/Bas2anHofmann h"p://profiles.google.com/bashofmann h"p://lanyrd.com/people/Bas2anHofmann/ h"p://speakerdeck.com/u/bas2anhofmann [email protected]