SlideShare une entreprise Scribd logo
1  sur  75
shkrubbelOr, how to make a mobile app using web technologies
Hi.
Why?
@snookca
Why not?
div.tile { float: left; }div.tile { display: grid }table td
.tile {float: left;  width: 3em;  height: 3em;}<div class=“board”>  <div class=“tilerow”>    <div class=“tile”></div>     <div class=“tile”></div>     …    <div class=“tile last”></div>  …</div>
display: grid; http://caniuse.com/css-grid http://dev.w3.org/csswg/css3-grid-align/
Really now, tables for layout?
styling the board
one giant background image
http://wordswithfriends.com/
single tile images
http://www.flickr.com/photos/lwr/3034478627/  by Leo Reynolds
all CSS, all the time
-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;
http://tileabl.es/
$(’.tile').noisy({    'intensity' : 1,     'size' : 200,     'opacity' : 0.08,     'fallback' : '',     'monochrome' : false}).css('background-color', '#EDEBDE'); https://github.com/DanielRapp/Noisy
(You may hate me now.)
http://www.fontyukle.net/en/DownLoad-News+Gothic+Std+Medium.ttf
http://www.fontsquirrel.com/fontface/generator
<div class="tile">  <span class="letter">O</span>  <span class="val">1</span></div>
<!DOCTYPE html><html><head><scriptsrc="js/jquery-1.6.2.js"></script><scriptsrc=”js/jquery-ui-1.8.14.js"></script><style>…
$(document).ready(function() {   $(".tile").draggable();});
.tile {   opacity: .9;  background-color: AntiqueWhite; }
 $(".tile").draggable( { snap: "#board td" });
.dropped { border: 1px solid red; } $("#board td").droppable({      drop: function(event, ui) {        $(this).addClass("dropped");        ...      }  }
Keep track of the played tile locations
SHK.board = new Array(15); …for (vari = 0; i < 15; i++) {SHK.board[i] = new Array(15);   for (varj = 0; j < 15; j++) {SHK.board[i][j] = '';   }}
<div class="tilenum">14</div>.tilenum { display: none;}
data-* to save the day!
<td id="l1">  <div id="t1" class="tile" data-tilenum="1">    <span class="letter">U</span>    <span class="val">2</span>  </div> </td>
// if previously placed on a board tile, clear the last positionvarp = ui.helper.data('prevloc');if (ui.helper.data('prevloc')) {varp = ui.helper.data('prevloc');     SHK.board[p[0]][p[1]] = '’;}// set the new positionui.helper.data('prevloc', [row, col]);
<td id=”r9b"><div class="it"></div></td>var row = id.substring(1, 2); // 9varcol = id.substring(2, 3); // bb = 11, so need to convert from hex to decimalconvert to decimal this way:parseInt(row, 16);
Submit the word!
rc = 0 or rc = 1, depending on checking for row or column vart = false;  for (vari in SHK.inplay) {    if (i && SHK.inplay[i]) {      if (t) {        if (t != SHK.inplay[i][rc]) { return false; }      } else {t = SHK.inplay[i][rc];      }    }  }
But is it a word?
localStorage FTW!
// See if the property we want is pre-cached in localStorage if ( window.localStorage !== null && window.localStorage.shkrubbeldict ) {var words = window.localStorage.shkrubbeldict.split("");    for ( vari = 0; i < words.length; i++ ) {SHK.dict[words[i]] = true;   }… http://diveintohtml5.org/storage.html
// easy check now… if (SHK.dict[word.toLowerCase()]) {  // we have a word!}
did I mention, don’t do this?read these instead:http://ejohn.org/blog/dictionary-lookups-in-javascript/http://ejohn.org/blog/javascript-trie-performance-analysis/http://ejohn.org/blog/revised-javascript-dictionary-search/
While we’re here…
    for (vari = 0; i < 7; i++) {      // we're using this in several places, so store in varvart = $('#t' + i);      // move the tile back to its starting spott.animate({'top': '0px', 'left' : '0px'});      // clear the inplay tiles from the boardSHK.inplay[i] = false;      // clear the tile from the board varp = t.data('prevloc');      if (p) {        SHK.board[p[0]][p[1]] = '';t.data(‘prevloc’) = ‘’;      }    }
Wait a second…
http://www.techradar.com/reviews/pc-mac/tablets/apple-ipad-681021/review
O_O
http://phonegap.github.com/weinre
Performance
Send only what you need
And I determine that how?
Server side browser detection?(Have you seen a recent User-Agent list?)
http://www.user-agents.org/
Feature detection
http://www.modernizr.com/
Media Queries
<link rel="stylesheet" href="theme.css" /><link rel="stylesheet” href="print.css" media="print” />
/* iPhone Portrait */@media screen and (max-width: 320px) {    …}/* iPhone Landscape */@media screen and (min-width: 321px) and (max-width: 480px) {    …}/* iPad */@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {    …}
Adapt.jshttp://adapt.960.gs/
Compress fileshttp://developer.yahoo.com/yui/compressor/http://www.phpied.com/cssmin-js/
Reduce image sizeshttp://developer.yahoo.com/yslow/smushit/http://www.imageoptimizer.net/Pages/Home.aspx
Use data URIs if you can
background:    url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSAAA…)    no-repeat    left center;  padding: 5px 0 5px 25px;data:[<mime type>][;charset=<charset>][;base64],<encoded data>
Taking it all offline
Generate a MANIFESTwhy:http://diveintohtml5.org/offline.htmlhttp://bit.ly/g01Her (apple.com)how:https://github.com/jamesgpearce/confess
Tell the mobile browser about it.
<meta name="apple-mobile-web-app-capable" content="yes" /><link rel="apple-touch-startup-image" href="home.png" /><link rel="apple-touch-icon" href="icon.png" />
Push it
http://shkrubbel.com/https://github.com/kitt/shkrubbel@shkrubbel
phew!http://ki.tt/owc3

Contenu connexe

Tendances

WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011John Ford
 
Oh, you’re the NY times guy
Oh, you’re the NY times guyOh, you’re the NY times guy
Oh, you’re the NY times guyDavid Hayes
 
Pattern matching in Elixir by example - Alexander Khokhlov
Pattern matching in Elixir by example - Alexander KhokhlovPattern matching in Elixir by example - Alexander Khokhlov
Pattern matching in Elixir by example - Alexander KhokhlovElixir Club
 
Empowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public DisplayEmpowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public DisplayTetsuo Yamabe
 
Intro to OAuth
Intro to OAuthIntro to OAuth
Intro to OAuthmfrost503
 
Javascript - The Good, the Bad and the Ugly
Javascript - The Good, the Bad and the UglyJavascript - The Good, the Bad and the Ugly
Javascript - The Good, the Bad and the UglyThorsten Suckow-Homberg
 
sanya's Bug database
sanya's Bug databasesanya's Bug database
sanya's Bug databasesanyabhasin18
 
Replica Sets
Replica SetsReplica Sets
Replica SetsMongoDB
 
jQuery Foot-Gun Features
jQuery Foot-Gun FeaturesjQuery Foot-Gun Features
jQuery Foot-Gun Featuresdmethvin
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2ady36
 
Front-End Developers Can Makes Games, Too!
Front-End Developers Can Makes Games, Too!Front-End Developers Can Makes Games, Too!
Front-End Developers Can Makes Games, Too!FITC
 
Возможности, особенности и проблемы AR::Relation
Возможности, особенности и проблемы AR::RelationВозможности, особенности и проблемы AR::Relation
Возможности, особенности и проблемы AR::RelationАлександр Ежов
 

Tendances (20)

Nop2
Nop2Nop2
Nop2
 
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
 
Oh, you’re the NY times guy
Oh, you’re the NY times guyOh, you’re the NY times guy
Oh, you’re the NY times guy
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
 
Pattern matching in Elixir by example - Alexander Khokhlov
Pattern matching in Elixir by example - Alexander KhokhlovPattern matching in Elixir by example - Alexander Khokhlov
Pattern matching in Elixir by example - Alexander Khokhlov
 
Empowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public DisplayEmpowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public Display
 
Intro to OAuth
Intro to OAuthIntro to OAuth
Intro to OAuth
 
Javascript - The Good, the Bad and the Ugly
Javascript - The Good, the Bad and the UglyJavascript - The Good, the Bad and the Ugly
Javascript - The Good, the Bad and the Ugly
 
Sk.php
Sk.phpSk.php
Sk.php
 
sanya's Bug database
sanya's Bug databasesanya's Bug database
sanya's Bug database
 
Borrador del blog
Borrador del blogBorrador del blog
Borrador del blog
 
Pruebas de hipotesis
Pruebas de hipotesisPruebas de hipotesis
Pruebas de hipotesis
 
Replica Sets
Replica SetsReplica Sets
Replica Sets
 
jQuery Foot-Gun Features
jQuery Foot-Gun FeaturesjQuery Foot-Gun Features
jQuery Foot-Gun Features
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
 
Front-End Developers Can Makes Games, Too!
Front-End Developers Can Makes Games, Too!Front-End Developers Can Makes Games, Too!
Front-End Developers Can Makes Games, Too!
 
Speeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorallSpeeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorall
 
Czzawk
CzzawkCzzawk
Czzawk
 
Theme
ThemeTheme
Theme
 
Возможности, особенности и проблемы AR::Relation
Возможности, особенности и проблемы AR::RelationВозможности, особенности и проблемы AR::Relation
Возможности, особенности и проблемы AR::Relation
 

Similaire à Shkrubbel for Open Web Camp 3

Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2tonvanbart
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011Scalac
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinChad Cooper
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Tatsuhiko Miyagawa
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertextfrankieroberto
 
Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstartguestfd47e4c7
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdatedoscon2007
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6umapst
 
Illuminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 TutorialIlluminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 Tutorialmikel_maron
 
Forum Presentation
Forum PresentationForum Presentation
Forum PresentationAngus Pratt
 

Similaire à Shkrubbel for Open Web Camp 3 (20)

Php Sq Lite
Php Sq LitePhp Sq Lite
Php Sq Lite
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
 
Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
OpenStreetMap (en Zzzinc)
OpenStreetMap (en Zzzinc)OpenStreetMap (en Zzzinc)
OpenStreetMap (en Zzzinc)
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
 
Php My Sql
Php My SqlPhp My Sql
Php My Sql
 
Theme verdadeiro
Theme verdadeiroTheme verdadeiro
Theme verdadeiro
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 
Groovy
GroovyGroovy
Groovy
 
Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstart
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6
 
Illuminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 TutorialIlluminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 Tutorial
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Forum Presentation
Forum PresentationForum Presentation
Forum Presentation
 
Prototype js
Prototype jsPrototype js
Prototype js
 

Dernier

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Dernier (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

Shkrubbel for Open Web Camp 3

Notes de l'éditeur

  1. Hi! My name is Kitt hodsden!
  2. A few months I went to a web tech workshop, expecting not much other than a day of head nodding and thoughts of, &quot;yeah, I know that.&quot; To my delight, I walked out with pages of notes, tips and new topics to look up, and I thought to myself, next tech talk I do, I&apos;m so way going to try for that. So, my hope is that you leave this talk with a spring in your step and more than a few inspirations on your next project.
  3. My inspiration for this particular project was a conversation I had with Jonathan Snook*, who gives a number of talks* about HTML5 and CSS3 and javascript and mobile stuff. He commented that a number of the apps available in the Apple App Store could be done as web applications, and went on to build a number of them* and tweet* about them.
  4. One of the applications he wanted to do was Words With Friends*, and I thought, eh, why not? It&apos;ll make a great walk through in creating a mobile application, because the hard part is done: figuring out WHAT you want to make, making it is the easy part.So, let&apos;s start out, with a Scrabble or Words with Friends board. That&apos;s easy, you need a grid for the board, a tray for the tiles, a few buttons for actions and a few extra elements for the game details like score and who&apos;s playing.
  5. A board.Can even something as simple as a board have options?Yeah.
  6. You can do a grid with a specified width and height and float them all to the left, clearing the floats on the last element. Need to make sure the row and board have widths, though.
  7. Another option is { display: grid; } grid is a propose option for the display attribute that creates a layout grid much as tables were used for page layouts. You can have grid columns and rows and the equivalent of spans, and everything just lays out nicely. Unfortunately, unless your browser is IE 10, and pretty much no one&apos;s is quite yet, { display: grid; } isn&apos;t available. But sometimes &quot;soon&quot; we can use the { display: grid; } on our elements and have the browser generate the grid for us.
  8. As a toss up between floating divs and using a table for the grid layout, I used the table. Floating divs have the advantage of fewer elements to get the rounded corners, as you can&apos;t style rounded corners on a table cell, but you add a div and style that inside the table data element.
  9. Okay, so, the board. Technically, the board can be any number of tiles across that we want. Using both Scrabble and Words with Friends as inspiration, we&apos;ll have a 15 by 15 board. If you&apos;re inspiring younger players, fewer board spaces might be less intimidating.Now, how do we style the background?
  10. We could style it exactly as we want it, we can do fun and exciting things with the background image, we can get pixel perfect across every single browser that supports background images, which is nominally all of them.
  11. This approach has some disadvantages: you&apos;ll need to update your image when your colors change, or have multiple images for different board sizes, and you&apos;ll need to have different images for every screen resolution, including some of those that don&apos;t yet exist. If you decide to add a feature that the background won&apos;t support (in this case, say, random placement of the Double and Triple Words and Letters), you&apos;ll need new background images for the &quot;random&quot; boards.While the single background image isn&apos;t terribly flexible, but IS the correct solution for some applications. A side scrolling game with multiple repeating backgrounds sliding at different rates to fake parallax, for example, could be served with background images.
  12. Okay, other than the single background image, we could still use images to style the individual tiles, also using background images. If you do this, you&apos;ll want to use sprites, merging all of your tile images together into one image. The round trip HTTP request for multiple images is more of a performance hit on mobile than it is on the desktop, though it is on the desktop also: better to have one big image than 110 small images each with its own request.
  13. This technique has some of the issues of the previous image technique: having less flexibility, needing to scale the images or having differing images altogether for different screen resolutions, but you don&apos;t have the variable board size issue.
  14. So, what are the characteristics of a tile? Well, it has rounded edges. We can get rounded corners with CSS with no effort these days:
  15. So, what are the characteristics of a tile? Well, it has rounded edges. We can get rounded corners with CSS with no effort these days:&lt;pre&gt;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;&lt;/pre&gt;
  16. It also has texture. Okay, for texture, one of the easiest ways to get the texture is to use a patterned, tiling background. Want a site for such patterns? http://tileabl.es/ is a good one.
  17. We can, however, use javascript to generate a random noise for a background. https://github.com/DanielRapp/Noisy
  18. Okay, so we have the background, we have the colors, what about the big part staring at us in the face?The font face.
  19. A quick search and we see that a consensus is that the font is &quot;News Gothic&quot;. Now, this isn&apos;t one of the supported-by-default browser fonts. While we can choose another font that looks very similar, or use the background image technique we decided against earlier, we can use @font-face to render new fonts in the browser.And designers everywhere had a field day.Okay, so we download our new font from the &apos;net, and look at it.http://www.fontyukle.net/en/DownLoad-News+Gothic+Std+Medium.ttfIt&apos;s a True Type Font. We can go through the process of converting the font to the different formats, eot: embedded open type, .woff: web open font format, or we can do what Snook suggested, just use Font Squirrel.
  20. Font Squirrel&apos;s font face generator gives a fantastic interface for converting various font formats to font-face web embeddable fonts. Be sure you have the right to distribute your font before creating and using a font on your site.There are font services available, use one of them if you are unsure:http://fontsquirrel.com/http://fontspring.com/http://typekit.com/http://www.google.com/webfonts
  21. Okay, so, we have our basic page done, we&apos;re happy with the layout, we have the board, we have the tray, we have our starting buttons for the game.
  22. Our default tile.&lt;div class=&quot;tile&quot;&gt;&lt;span class=&quot;letter&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;val&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;Let&apos;s start making it work!First thing we want to do, is start dragging the tiles from the tray to the board. Time to load in the javascript. Following the thought that many eyes make all bugs shallow, and idea of standing on the shoulders of giants, and the realization that there are some darn smart people who have worked on this stuff before me, instead of using the native HTML5 Drag and Drop or reinventing the wheel, I&apos;m going to use a javascript library. For me, that means jQuery.For mobile apps, there are a number of framework options available, depending on what development style, approach and feature requirements, the big ones being jQTouch, Sencha Touch, jquery mobile, and phonegap. I&apos;m a big believer in using the tools you&apos;re comfortable with, the ones you know, but continue to expand your knowledge. If you can&apos;t decide when starting out, use the ones that have the best documentation (and how do you define best? Can _you_ understand it? Great! Choose that.)In this case, we need drag and drop, and submit capabilities, and not much else: no location, no accelerometer, no GPS, no camera, which makes things considerably simpler.So, starting out, added jQuery to the document.
  23. First thing we want to do, is start dragging the tiles from the tray to the board. Time to load in the javascript. Following the thought that many eyes make all bugs shallow, and idea of standing on the shoulders of giants, and the realization that there are some darn smart people who have worked on this stuff before me, instead of using the native HTML5 Drag and Drop or reinventing the wheel, I&apos;m going to use a javascript library. For me, that means jQuery.For mobile apps, there are a number of framework options available, depending on what development style, approach and feature requirements, the big ones being jQTouch, Sencha Touch, jquery mobile, and phonegap. I&apos;m a big believer in using the tools you&apos;re comfortable with, the ones you know, but continue to expand your knowledge. If you can&apos;t decide when starting out, use the ones that have the best documentation (and how do you define best? Can _you_ understand it? Great! Choose that.)In this case, we need drag and drop, and submit capabilities, and not much else: no location, no accelerometer, no GPS, no camera, which makes things considerably simpler.So, starting out, added jQuery to the document.Also added jQuery UI, which has drag and drop functionality with it. While I was at it, I also moved the CSS into an external style sheet, and created a new javascript file for the project. All of them included at the top of the page, along with the !DOCTYPE. Love that new doctype.
  24. Preliminaries in, let&apos;s start dragging tiles, by adding draggable to the letters:
  25. That&apos;s great!Except our letters are now floating out in the middle of nowhere. With no styling of their own, the letters appear to float.
  26. Need to add opacity so that we see the board background, and a tile background color so that we can actually see it.
  27. We want the letters to drop on the board tiles, not just randomly. jQuery UI makes it Easy enough to snap to the board squares:$(&quot;.tile&quot;).draggable( { snap: &quot;#board td&quot; });
  28. Now, there are draggable objects in jQuery along with items that can be used as containers to receive the dropped elements, appropriately called &quot;droppables&quot;: HTML elements that can have draggables dropped on them. We&apos;ll limit the tiles being dropped on the board for the moment, and give it red border around it so that we can see it dropped.
  29. We need to keep track of of the changes to the board that we&apos;re making. We can let the board be the canonical source, extracting the data from the DOM (which can be slow) or we can keep track of the state elsewhere.Advantage of the board is that what is displayed is what we have, we don&apos;t have to keep two different sources. The disadvantage of that is that we&apos;re mixing our data with our view.
  30. When a tile is dropped we can save its state this board array.This works fine with tiles from the tray, but not the board to board.But wait, if a tile is moved from one space to another, we need to remove its previous state from our board array. Do we need to keep track of every tray tile&apos;s placement? How do we identify which of the tray tiles we&apos;re playing?While we can use an extra div to store information, and just hide it:&lt;div class=&quot;tilenum&quot;&gt;14&lt;/div&gt;.tilenum { display: none;}I
  31. When a tile is dropped we can save its state this board array.This works fine with tiles from the tray, but not the board to board.But wait, if a tile is moved from one space to another, we need to remove its previous state from our board array. Do we need to keep track of every tray tile&apos;s placement? How do we identify which of the tray tiles we&apos;re playing?While we can use an extra div to store information, and just hide it:&lt;div class=&quot;tilenum&quot;&gt;14&lt;/div&gt;.tilenum { display: none;}I
  32. &quot;Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.&quot;http://html5doctor.com/html5-custom-data-attributes/We can store the previous location in the tile itself, just as we store the tile number. A tile in the tray has no previous board location. Once a tile is dropped on the board, we can save its location.
  33. data- attributes can be used for all sorts of things, just don&apos;t use them for things that should be public, like microformats, or an existing attribute.
  34. SidenoteThe board space divs are named with an id of r followed by two hexadecimal numbers. The first is the row number, the second is the column number. Recalling we&apos;re in hex, we need to convert to decimal for storing into our array (okay, no, but it made it easier earlier):&lt;td id=&quot;r9b&quot;&gt;&lt;div class=&quot;it&quot;&gt;&lt;/div&gt;&lt;/td&gt;var row = id.substring(1, 2); // 9varcol = id.substring(2, 3); // bb = 11, so need to convert from hex to decimalDo it this way:parseInt(row, 16);
  35. Okay, so, we&apos;ve dragged tiles to the board. As soon as we&apos;ve dragged a tile, we can submit it to the server, right? Sure!A quick adjustment to the button to change it from a pass to a play link and we&apos;re good to go.// submit the board$(&apos;#bp&apos;).attr(&apos;href&apos;, (SHK.inplaycount()) ? &apos;go/play&apos;:&apos;go/pass&apos;);$(&apos;#bp&apos;).html((SHK.inplaycount()) ? &apos;submit&apos; : &apos;pass&apos;);Or, maybe not.
  36. While dropping a tile on the board means we can submit the board, we should really verify all tiles are placed legally. In particular, we need to check the tiles are all in a row, and that they are all contiguous with the all letters on the board.
  37. To check if all the placed letters are in a line, we can loop through the positions of the placed tiles and check that the row is the same for all the placed tiles or the column is the same. When only one tile is placed, we&apos;ll have both cases being true.To check if the tiles were placed contiguously, using whichever direction the line of letters were placed (up/down or left/right, as previously determined), find the minimum index on the board (so if the tiles were all placed on row 4, find the lowest indexed tile in row 4), then find the maximum index of all tiles onthe board in that same line, then loop through the line and check there are no gaps, by incrementing by one from the minimum to the maximum in that line.
  38. At this point, we have a board, the player has played a word, how do we know it&apos;s a valid word? Can we submit the board now?In traditional scrabble games, one player plays a word and the other player challenges the word if she believes the word played isn&apos;t a valid word. At this point, however, not only do we want to demo more of the HTML5 features, but I also told you we were going to download a dictionary and store it in HTML5 local storage, so we&apos;re going to go the Words with Friends route: instead of challenge, we&apos;re going to check the word is valid before sending it to the server.To do that, though, we need to first get the dictionary. The uncompressed dictionary I have is just under 2MB in size. That is not going to fit into our 4K cookie space allotted.
  39. Seriously, this is NOT the way to build a highly scalable multi-player application. Having users download 1.9MB of dictionary? Yeah, don&apos;t do that.There&apos;s another dictionary that we&apos;re going to go with, it&apos;s only 620kB, so let&apos;s download that, but do it only once so that people don&apos;t start throwing fits
  40. // See if the property that we want is pre-cached in the localStorage if ( window.localStorage !== null &amp;&amp; window.localStorage.shkrubbeldict ) {var words = window.localStorage.shkrubbeldict.split(&quot;\\n&quot;); for ( vari = 0; i &amp;lt; words.length; i++ ) {SHK.dict[words[i]] = true; } } ... // Cache the dictionary, if possible if ( window.localStorage !== null ) {window.localStorage.shkrubbeldict = txt; }See: http://diveintohtml5.org/storage.html
  41. Once we have it loaded into our dictionary array (did I mention don&apos;t do this?), we can check if the word is valid with a simple check:if (SHK.dict[word.toLowerCase()]) { // we have a word!}
  42. Did I mention don&apos;t do this? There are more efficient ways of storing large dictionaries. http://ejohn.org/blog/dictionary-lookups-in-javascript/http://ejohn.org/blog/javascript-trie-performance-analysis/http://ejohn.org/blog/revised-javascript-dictionary-search/
  43. While we&apos;re here, and I&apos;m taking a breather, let&apos;s just implement that recall button...1. move the tiles back to the tray2. clear our inplay tiles3. clear their spots out of the board, using data prevloc as beforeAnd the resign button, that one&apos;s easy, too.
  44. While we&apos;re here, and I&apos;m taking a breather, let&apos;s just implement that recall button...1. move the tiles back to the tray2. clear our inplay tiles3. clear their spots out of the board, using data prevloc as beforeAnd the resign button, that one&apos;s easy, too.
  45. Wait a second... you know what&apos;s been missing from this entire process?
  46. Yeah, we should test this on an actual mobile device, eh?
  47. First time I brought this up on an ipad and went to drag the tile, and the whole window dragged. While that happened to be a pretty simple issue to fix, and this project doesn&apos;t require a lot of interaction from the server, that isn&apos;t always the case
  48. When testing across multiple devices, or on mobile devices in a non-test environments, when I need remote debugging, yeah, &quot;winery&quot; for the win: http://phonegap.github.com/weinre/While testing, wow, remember that part where I said don&apos;t do this? When you have a desktop or even laptop computer with a fast connection and lots of member, even running an emulator doesn&apos;t seem too bad or slow. You can fake the connection by having a proxy that can slow things down.http://www.charlesproxy.com/
  49. This isn&apos;t a big application, but as the features and code base grow, we&apos;re going to need to start paying attention to performance, as well as loading time. One way to reduce loading time is, well, not to load resources you don&apos;t need. If we had gone with the background images, for example, wow, what a pain in the download to fetch that large background image, only not to use it.
  50. Blech.So, downloading and handling those extra files, how do we avoid them?
  51. Well, we *could* do browser detection, but have you seen the list of User-Agent strings (which is what you use to detect the browser)? The list grows,
  52. Well, we *could* do browser detection, but have you seen the list of User-Agent strings (which is what you use to detect the browser)? The list grows,
  53. People now do browser feature detection: what can the browser support?
  54. Easiest way is with Modernizr, which includes yepnope.js. yepnope lets you choose which files are downloaded based on browser support (yep) and lack of browser support (nope).Depending on which features you need for your application, you can follow Modernizr&apos;s links for libraries and tools that fill in the missing pieces so that you can fake the features.
  55. In this case, though, we can use media queries to adjust the CSS3 that we load.As long as we&apos;ve been using the link element, we&apos;ve pretty much been using the media attribute. Used to be, you&apos;d see them for only print style sheets.&amp;lt;linkrel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;theme.css&quot; /&gt;&amp;lt;linkrel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;print.css&quot; media=&quot;print&quot;/&gt;
  56. ut now with media queries in CSS3, we can be more selective based on browser information and our specified links./* iphone portrait */@media screen and {max-width: 320px) { ...}/* iphone landscape */@media screen and {min-width: 321px) and (max-width: 480px) { ...}See how that’s for only for iphone and ipad? Yeah, don’t do that either.
  57. Alternately, we can use Adapt.js to dynamically load different style sheets based on changing browser size.Though, really, except for rotating between portrait and landscape, no one changes their browser sizes except designers.
  58. http://developer.yahoo.com/yui/compressor/http://www.phpied.com/cssmin-js/
  59. Reduce the image sizes, using compression or different image formats depending on your need (JPG is not always the smallest image). Use Smush.it or Image Optimizer to reduce image sizes.http://developer.yahoo.com/yslow/smushit/http://www.imageoptimizer.net/Pages/Home.aspxSprite your images when you can, reducing the number of calls for resources. Combine your CSS files into one cached version and send that over. On the server, gzip the files and send the compressed version to the browser. Remove unneeded whitespace when compressing: in production, white space is overrated.
  60. Save the round trip for the HTTP requestWon’t have any 404s
  61. If you can, maybe use Data URIs for images.http://css-tricks.com/5970-data-uris/
  62. So, all of this is great, but I don&apos;t want to be connected to the internet in order to play. I&apos;d like to have all of my games loaded up so that I can think about the game as I&apos;m swinging in my hammock.First step, is back to localStorage. When saving the game to the server, we can save the game locally also, and on successful submit of a word, update the game&apos;s local copy with the new tray letters.
  63. To be able to save to the device, however, we need to generate and deliver a MANIFESThttp://diveintohtml5.org/offline.htmlhttp://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.htmleasier way:https://github.com/jamesgpearce/confess
  64. Tell the mobile browser (well, apple anyway) that the app is available:&amp;lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; /&gt;&amp;lt;linkrel=&quot;apple-touch-icon&quot; href=&quot;icon.png&quot; /&gt;&amp;lt;linkrel=&quot;apple-touch-startup-image&quot; href=&quot;home.png&quot; /&gt;
  65. Push notificationsOkay, so I&apos;ve played my game, and now it&apos;s time for &quot;not kitt&quot; to play her turn. With native applications, you have the ability to send notifications to other people for installed applications.Web applications are missing a number of these core features, but using web technologies doesn&apos;t mean your left out. Recall that point before about a lot of really smart people doing really cool shit?Yeah. http://www.phonegap.com/http://www.appcelerator.com/It&apos;s possible to access the phone features with other kits, if those are needed. Alternately, you could create a native application that wraps the application in a, say, UIWebView (for iPhone) so that the user sees the web app, but you can register for push notifications.Or just go with the smart guys.
  66. So, what&apos;s next?I can think of a giant list of features that I&apos;d like to put in.http://caniuse.com/#feat=dragndropI&apos;m still trying to figure out how to get canvas or video into the application in a meaningful way.