Extending your own and others' sites with HTML5
-
Upload
mark-reeder -
Category
Technology
-
view
408 -
download
0
Transcript of Extending your own and others' sites with HTML5
![Page 1: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/1.jpg)
Extending your own and others' sites with HTML5
Mark Reeder
![Page 2: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/2.jpg)
About Me
• UI Developer at Beatport• Front-end developer working in the online music space for
the past 5 years• http://twitter.com/Mark_Reeder• https://github.com/MarkReeder
![Page 3: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/3.jpg)
• Employed by• Read/write access to
source code• Able to change data that is
available
• No official connection• No ability to officially
modify code• Stuck with the data they
provide (and anything else I can infer or record)
![Page 4: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/4.jpg)
![Page 5: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/5.jpg)
![Page 6: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/6.jpg)
• pushState URLs• data- attributes• Local storage• HTML5 elements
![Page 7: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/7.jpg)
• pushState URLso Allow site URL to be updated without refreshing the
whole page and without resorting to # or #! URLs• data- attributes• Local storage• HTML5 elements
![Page 8: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/8.jpg)
• pushState URLso Allow site URL to be updated without refreshing the
whole page and without resorting to # or #! URLso Important for Beatport because of music playback
• data- attributes• Local storage• HTML5 elements
![Page 9: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/9.jpg)
• pushState URLso Allow site URL to be updated without refreshing the
whole page and without resorting to # or #! URLso Important for Beatport because of music playbacko Examples: github Beatport
• data- attributes• Local storage• HTML5 elements
![Page 10: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/10.jpg)
• pushState URLso Allow site URL to be updated without refreshing the
whole page and without resorting to # or #! URLso Important for Beatport because of music playbacko Examples: github Beatporto Using the history.js jQuery plugin
• data- attributes• Local storage• HTML5 elements
![Page 11: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/11.jpg)
• pushState URLs• data- attributes
o Used to embed data on elements• Local storage• HTML5 elements
![Page 12: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/12.jpg)
• pushState URLs• data- attributes
o Used to embed data on elementso data-queue-position in player queue
• Local storage• HTML5 elements
![Page 13: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/13.jpg)
• pushState URLs• data- attributes
o Used to embed data on elementso data-queue-position in player queueo data-json for track elements
• Local storage• HTML5 elements
![Page 14: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/14.jpg)
• pushState URLs• data- attributes• Local storage
o Persist user settings (items per page, for example)• HTML5 elements
![Page 15: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/15.jpg)
• pushState URLs• data- attributes• Local storage
o Persist user settings (items per page, for example)o Persist player queue
• HTML5 elements
![Page 16: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/16.jpg)
• pushState URLs• data- attributes• Local storage• HTML5 elements
o <!DOCTYPE html>
![Page 17: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/17.jpg)
• pushState URLs• data- attributes• Local storage• HTML5 elements
o <!DOCTYPE html>o <nav>
![Page 18: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/18.jpg)
• pushState URLs• data- attributes• Local storage• HTML5 elements
o <!DOCTYPE html>o <nav>o <input type="search">
![Page 19: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/19.jpg)
• pushState URLs• data- attributes• Local storage• HTML5 elements
o <!DOCTYPE html>o <nav>o <input type="search">o Why not <audio>?
![Page 20: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/20.jpg)
![Page 21: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/21.jpg)
![Page 22: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/22.jpg)
![Page 23: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/23.jpg)
• Extension started out as a bookmarklet
![Page 24: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/24.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-end
![Page 25: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/25.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UI
![Page 26: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/26.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UIo My Music Hack Day Boston project: Living Playlist
![Page 27: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/27.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UIo My Music Hack Day Boston project: Living Playlist
• Outgrew bookmarklet when I wanted to add scrobbling
![Page 28: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/28.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UIo My Music Hack Day Boston project: Living Playlist
• Outgrew bookmarklet when I wanted to add scrobblingo http://gabek.github.com/TurntableScrobbler/
![Page 29: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/29.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UIo My Music Hack Day Boston project: Living Playlist
• Outgrew bookmarklet when I wanted to add scrobblingo http://gabek.github.com/TurntableScrobbler/
• Learned about manifest.json and isolated worlds: Google Chrome Extensions: Content Scripts
![Page 30: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/30.jpg)
Getting around Isolated Worlds - injectScript.js
(function() { var js, css; js = document.createElement('script'); js.src = chrome.extension.getURL("js/turntable.fm.extend.js?v=0.6_" + new Date().getTime()); document.body.appendChild(js); css = document.createElement('link'); css.rel = "stylesheet"; css.type = "text/css"; css.href=chrome.extension.getURL("css/turntable.fm.extend.css?v=0.6_" + new Date().getTime()); document.body.appendChild(css);
var themeCSS = document.createElement('link'); themeCSS.rel = "stylesheet"; themeCSS.type = "text/css"; themeCSS.href=chrome.extension.getURL("css/tt-ext-ui-theme/jquery-ui-1.8.14.custom.css?v=0.6_" + new Date().getTime()); document.body.appendChild(themeCSS);
})();
![Page 31: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/31.jpg)
• Extension started out as a bookmarklet• Motivations
o Rich front-endo Started exploring, found data that wasn't surfaced in
the UIo My Music Hack Day Boston project: Living Playlist
• Outgrew bookmarklet when I wanted to add scrobblingo http://gabek.github.com/TurntableScrobbler/
• Learned about manifest.json and isolated worlds: Google Chrome Extensions: Content Scripts
• Paid the $5 and registered with the Chrome Web Store: Turntable.fm Extended
![Page 32: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/32.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotification
![Page 33: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/33.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song change
![Page 34: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/34.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chat
![Page 35: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/35.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changes
![Page 36: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/36.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changes
![Page 37: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/37.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
![Page 38: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/38.jpg)
Desktop Notifications
• Natively they're not highly configurable• Chrome Extension to use Growl
o Custom Growl Build for Mac
![Page 39: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/39.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
• localStorage to persist data
![Page 40: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/40.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
• localStorage to persist datao Extension Settings
![Page 41: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/41.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
• localStorage to persist datao Extension Settingso Tags
![Page 42: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/42.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
• localStorage to persist datao Extension Settingso Tags
• data- attributes for message passing via the DOM
![Page 43: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/43.jpg)
Message Passing
• Message Passing Div (MPD) created in contentscript.js
![Page 44: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/44.jpg)
Message Passing
• Message Passing Div (MPD) created in contentscript.js • Messages are passed through dispatchEventToContentScript
![Page 45: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/45.jpg)
Message Passing
• Message Passing Div (MPD) created in contentscript.js • Messages are passed through dispatchEventToContentScript• Event Listeners in contentscript on MPD
![Page 46: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/46.jpg)
Message Passing
• Message Passing Div (MPD) created in contentscript.js • Messages are passed through dispatchEventToContentScript• Event Listeners in contentscript on MPD
o Listeners get data from data- attributes on elements
![Page 47: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/47.jpg)
Extension Features
• Desktop Notifications: window.webkitNotifications.createNotificationo song changeo chato room users changeso DJ changeso vote notifications, both up and down
• localStorage to persist datao Extension Settingso Tags
• data- attributes for message passing via the DOM• Canvas behind the scenes for local file saving
![Page 48: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/48.jpg)
Dangers of unofficially working with 3rd party code
• The weekend of June 25/26, the extension broke
![Page 49: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/49.jpg)
Dangers of unofficially working with 3rd party code
• The weekend of June 25/26, the extension brokeo Random names were introduced for certain objects
within the turntable object
![Page 50: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/50.jpg)
Dangers of unofficially working with 3rd party code
• The weekend of June 25/26, the extension brokeo Random names were introduced for certain objects
within the turntable objecto getTurntableObjects workaround
![Page 51: Extending your own and others' sites with HTML5](https://reader036.fdocuments.us/reader036/viewer/2022062513/5550d74eb4c905e8318b50c9/html5/thumbnails/51.jpg)
Questions?
http://twitter.com/Mark_Reederhttps://github.com/MarkReeder