SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
INFORMATION ORGANIZATION LAB                                                                     SEPTEMBER 8, 2009




                LAST WEEK ON IO LAB
            If you haven’t done these things already, please do them before we begin today’s lecture



                                   Install Firebug and Greasemonkey.


                                   Complete the online skills assessment.


                                   Join the iolab@ischool mailing list.


                       You can find links to help with all of these on the course website at
                                 http://courses.ischool.berkeley.edu/i290-4/f09/
INFORMATION ORGANIZATION LAB                                                           SEPTEMBER 8, 2009




             INFORMATION ORGANIZATION LAB
                                Faculty: Bob Glushko
                 Student Instructors: Nick Doty & Ryan Greenberg

A warning: Today is going to be a full-on crash course in the web client technologies we'll be
using for much of this class (HTML/CSS and Javascript/JQuery) followed by actually building
on that with web browser extensions like Greasemonkey. This should begin to explain the
basics behind the tutorial you worked on this past week and the demo that Ryan did last
week, but it may still be a lot to take in and we'll be talking a lot today. We promise that you'll
have time to learn this stuff beyond just today and that we won't be talking as much every
class.
INFORMATION ORGANIZATION LAB                                      SEPTEMBER 8, 2009




                               OFFICE HOURS
                                   Room 210


                   Nick                             Ryan
            Friday                            Wednesday
          1:00-2:00                           1:00–2:00

                            And by appointment.
              Email ryan@ischool or npdoty@ischool to schedule.
INFORMATION ORGANIZATION LAB                                                           SEPTEMBER 8, 2009




                           WHAT WE KNOW




                       HTML                   CSS                         Javascript


Based on the results of the unscientific survey you completed last week.
INFORMATION ORGANIZATION LAB                                                                SEPTEMBER 8, 2009




   DOCUMENT OBJECT MODEL
    <html>                                                             body
    <body>
    <div id="header">
        <h1>Document Object Model</h1>
    </div>                                                 div                       div
                                                          header                    content
    <div id="content">
        <p>This is my first paragraph</p>
        <p>My second paragraph has a list:
             <ul>                                           h1                p       p           p
                  <li>Item One</li>
                  <li>Item Two</li>
                  <li>Item Three</li>
             </ul>
                                                                                      ul
        </p>
        <p>This is the third paragraph</p>
    </div>
    </body>
    </html>                                                                    li      li         li




Here on the right side is a short HTML document. When your web browser loads this
document, it generates a representation called the Document Object Model.
If your code is properly indented, your can see that the hierarchy of the DOM corresponds to
the indentation level.

The big idea here is that the left is just a bunch of text. On the right there is a collection of
objects that you can manipulate and change.

See http://en.wikipedia.org/wiki/Document_Object_Model for more information.
INFORMATION ORGANIZATION LAB                                                    SEPTEMBER 8, 2009




       CASCADING STYLE SHEETS
Separate presentation from structure and content.
If you want to be impressed by what’s possible with CSS, see http://csszengarden.com.
INFORMATION ORGANIZATION LAB                                                                   SEPTEMBER 8, 2009




                          RULE STRUCTURE




                                                                     From CSS: The Definitive Guide




A stylesheet consists of a series of rules. Here you see the structure of a style rule. You start
with a selector, which specifies what elements in the DOM you want this rule to apply to.
Then you write one or more declarations to apply styles to that selection. Declarations are
separated by semi-colons.
INFORMATION ORGANIZATION LAB                                                          SEPTEMBER 8, 2009




                               SELECTORS
                                             CSS                         HTML

               Type (Tag)                      p                          <p>

                       Id                 #header                    id="header"

                    Class                  .author                 class="author"

              Descendent                     div p                   <div><p>

                Grouping                    h1, h2               <h1> and <h2>

Who can explain the difference between IDs and classes? IDs are unique, only occur once on
the page. Classes are recurring elements.
Both can add semantic meaning to the page.
For a complete list of selectors in CSS2, see http://www.w3.org/TR/CSS2/selector.html.
For a list of all the selectors that jQuery can use (which are a lot more than CSS2), see http://
docs.jquery.com/Selectors.
INFORMATION ORGANIZATION LAB                                                                        SEPTEMBER 8, 2009




               COMMON PROPERTIES
         font-family                  color                  border                  display



             margin                font-size                  width                  padding



        background                  position               text-align                  float


              See http://htmldog.com/reference/cssproperties/ for a good list of CSS2 properties.
Let’s do some examples.
(1) I want to make the blog
(2) Align the text in the header: #header { text-align: center; }
(3) Make every author’s name’s much bigger. .author
(4) I want to make the titles of the blog entries blue Papyrus.
INFORMATION ORGANIZATION LAB                                                     SEPTEMBER 8, 2009




                           THE BOX MODEL
                                        Margin
                                        Border
                                        Padding

                                          Width
                               Height




Every object on the page consists of a rectangular box. The content area, plus padding,
border, margin. When you set the width of an element using CSS, that is the width of the
content area, not the entire box. If you set {width: 500px; padding: 20px; border: 1px solid
black}, the box will be 542px wide: 500, plus 20 padding on each side, plus 1 border on each
side.
INFORMATION ORGANIZATION LAB                                                                 SEPTEMBER 8, 2009




                               CSS RESOURCES




                     Available free for students at http://proquest.safaribooksonline.com.

CSS Definitive Guide: http://proquest.safaribooksonline.com/0596527330
CSS Missing Manual:

Heads-First XHTML & CSS: http://proquest.safaribooksonline.com/059610197X/hfhtmlcss-
CHP-8?imagepage=285
“Expanding your vocabulary” http://proquest.safaribooksonline.com/059610197X/
hfhtmlcss-CHP-8?imagepage=285
INFORMATION ORGANIZATION LAB                                                       SEPTEMBER 8, 2009




      JAVASCRIPT CRASH COURSE
Everyone open up a copy of Firefox and Firebug. If you would like, you can also use Safari’s
web inspector. Some things in Safari are much better, but I’ll be using Firebug. Cross-
platform, has a few more developed features.
INFORMATION ORGANIZATION LAB                                                    SEPTEMBER 8, 2009




                       FIRST THINGS FIRST

       JavaScript is a high-level, object-oriented language used most
                            often in web browsers.

              You can write comments in your code with // or /* */

                 A semi-colon goes at the end of every statement.




It’s a dynamic, scripting language. Prototype-based inheritance, not class-based. See
Douglas Crockford’s explanation for more information: http://javascript.crockford.com/
prototypal.html
INFORMATION ORGANIZATION LAB                                                        SEPTEMBER 8, 2009




                               VARIABLES
               29                        'Bob'                              true
          Numbers                          Strings                         Boolean


              ['Bob', 'John', 'Coye', 'Deirdre']
                                           Arrays


            {'name': 'Arnold', 'weight': 240}
                                          Objects
Variables can be of different types. We’re going to cover these basic data types.
INFORMATION ORGANIZATION LAB                                                         SEPTEMBER 8, 2009




                               VARIABLES


                 var stateName = 'California';




You use the word ‘var’ to declare a variable. You don’t have to say what type of variable it
is--variables in JavaScript are untyped. Convention is to use camelCase.
INFORMATION ORGANIZATION LAB                                    SEPTEMBER 8, 2009




                                 STRINGS
                         A sequence of characters.
             Use single- or double-quotes to indicate a string.

                                      Examples
                                    var myName = "Larry";
                                       myName → "Larry"
                                      myName.length → 5
                               myName.toUpperCase() → "LARRY"
                                   myName.indexOf('a') → 1
INFORMATION ORGANIZATION LAB                                                 SEPTEMBER 8, 2009




                                   ARRAYS
                        An ordered collection of elements.
                      Use square brackets to indicate an array.

                                       Examples
                             var myArray = ['dog', 'fish', 'cat'];
                                       myArray.length → 3
                                      myArray[0] → ['dog']
              myArray.push('horse') → myArray == ['dog', 'fish', 'cat', 'horse']
                                  myArray.indexOf('fish') → 1
                           myArray.sort() → ['cat', 'dog', 'fish'];
INFORMATION ORGANIZATION LAB                                                           SEPTEMBER 8, 2009




                                   OBJECTS
          A collection of key-value pairs or named properties.
                    Use braces to indicate an object.

                                          Examples
                 var person = {'name': 'Arnold', 'weight': 240, 'height': 6.2 }
                                     person.name → "Arnold"
                                       person.height → 6.2
                                     person.wife = 'Maria';
                                      person.wife → 'Maria'
                                    person['wife'] → 'Maria'




The most confusing thing about objects in JavaScript is that they’re used for so many
different things. First, they fill the role of the data structure: hashes/dictionaries (in Python)/
associative arrays. Second, objects are naturally used for JavaScript’s object-oriented
programming. Third, JavaScript objects are also the basis for JSON.

You can access the properties of an object using the dot notation or bracket notation.
INFORMATION ORGANIZATION LAB                                                     SEPTEMBER 8, 2009




                               FUNCTIONS

                       function add(x, y) {
                           return x + y;
                       }
                       add(2,4) → 6

                       var add = function(x, y) {
                           return x + y;
                       }

JavaScript functions are defined with the keyword function and they return a value. Functions
can have names, as in the top example, or they can be anonymous.
INFORMATION ORGANIZATION LAB                                                         SEPTEMBER 8, 2009




                BROWSER FUNCTIONS
                          alert('…')
                        confirm('…')
                         prompt('…')
                       console.log('…')
console.log is better to use when debugging because alert (1) doesn’t give you any history,
(2) you have to click each button. That said, there are times when alert(‘Testing!’) is simply
more convenient.
INFORMATION ORGANIZATION LAB                                                       SEPTEMBER 8, 2009




             CONTROL STRUCTURES

                         if (3 > 2) {
                             alert('3 is greater than 2');
                         }


                         for (var i=0; i < myArray.length; i++) {
                             myArray[i];
                         }




The for loop in JavaScript is a standard C-style for loop. The first statement (here var i=0)
sets the starting condition. The second statement (i < myArray.length) sets how long the loop
will run--until this condition is false. The third statement (i++) says what will happen at the
end of each loop.
INFORMATION ORGANIZATION LAB                                                        SEPTEMBER 8, 2009




                                   +


                                    JQUERY
                                 CSS meets JavaScript


jQuery is a JavaScript library (intro. 2006) written by John Resig. When learning: great when
you can apply something you know to something else. A lot of JS in browser has to do with
selecting objects from the DOM. And we already have something to do that...CSS!
INFORMATION ORGANIZATION LAB                                                         SEPTEMBER 8, 2009




                         NEW HOTNESS VS.
                         OLD AND BUSTED




                           (But with JavaScript instead of computers)
Javascript has been around for awhile. Tutorials on the internet are old. Used to put your
Javascript inline with your HTML. onclick...onload...document.writeln(). Like CSS, the current
best practice is to separate your Javascript from the HTML. We don’t use onevent anymore.

Also, using JavaScript in browsers has often been onerous. To change all the elements with a
certain class, you used to write document.getElementsByTagName(‘*’) ... and a bunch of
other stuff. But new libraries like jQuery let you do this more efficiently: $(‘.name-of-class’)
INFORMATION ORGANIZATION LAB                                      SEPTEMBER 8, 2009




                                       JQUERY

                               Using jQuery involves two steps:

  • Selects        objects from the DOM using CSS selectors.
  • Do      something with the selected elements.
INFORMATION ORGANIZATION LAB                                                       SEPTEMBER 8, 2009




       MAIN JQUERY OPERATIONS


  • Attributes:                Changing existing elements.
  • Traversing:                Moving from selected elements in the DOM to
     others.
  • Manipulating:                 Inserting or removing elements.
  • Events:           Attaching functions to events in the browser.



The jQuery Documentation (http://docs.jquery.com), which is well organized and written,
uses these names as well. Examples:
- Attributes: $(‘h1’).text() gives you the text from the selected elements. $(‘h1’).text(‘New
Text Here’) sets the text in the selected elements.
- Traversing: Moves from selected elements elsewhere in the DOM.
- Manipulating: $(‘p’).after(‘This text will be added after every paragraph’); $
(‘body’).prepend(‘This will appear at the top of the page’)
- Events: You select the elements you want to attach an event to and provide an anonymous
function: $(‘h2’).click( function() { alert(‘You clicked on an h2’); });
INFORMATION ORGANIZATION LAB                                                         SEPTEMBER 8, 2009




                       WEB BROWSER EXTENSIONS
                    Greasemonkey and Jetpack and bears, oh my!


A general overview: we’ll be looking at a class of tools that extend the functionality of a web
browser, either to change the browser chrome (like the status bar or the menu options) or
modify an existing webpage.
INFORMATION ORGANIZATION LAB                                                    SEPTEMBER 8, 2009




                               EXTEND WHAT?

                        Browser chrome
                        Page content
                        Page style
                        Page behavior
Chrome: an image in the status bar that lets you know when you have new email
Content: removing an advertisement or adding a map
Style: giving Craiglist any kind of style at all
Behavior: make a button
INFORMATION ORGANIZATION LAB                                                      SEPTEMBER 8, 2009




                  Greasemonkey                             Mozilla Jetpack




                Firefox Extensions                        Chrome Extensions

Relative advantages and disadvantages. The left-hand column is fairly mature compared to
the right. The top row is fairly light-weight (for development and installation) than the
bottom row. Firefox Extensions have the best performance but are the hardest to develop.
We’ll use Greasemonkey here -- it’s easy to develop, easy to install, and fairly widespread.
But these others have their advantages -- Jetpack makes it particularly easy to add to the
browser’s chrome and Firefox gives you a lot of power that Greasemonkey doesn’t have -- if
you want to use one, go for it! But Greasemonkey is a good start for us and development is
just like modifying an existing webpage.

Anyone know of others? (Safari Saft, IE Activities....)
INFORMATION ORGANIZATION LAB                                                      SEPTEMBER 8, 2009




      GOOD FOR THE BROWSERS

                               GOOD FOR US


For the browsers:
Let users customize and extend the browser, but keep the core small.

For us:
Let us prototype website and browser features without building either from scratch.
INFORMATION ORGANIZATION LAB                                   SEPTEMBER 8, 2009




                               LET’S TRY IT
                               To the browser / text editor!
INFORMATION ORGANIZATION LAB                                                                  SEPTEMBER 8, 2009




                               FOR NEXT WEEK
                         For practice, make sure you can build the Delicious
                         Trailmaker all by yourself. Add a feature to it.


                         Write your first Greasemonkey script. Come with
                         questions next class.


                         Decide on an idea for Project 1.

                       You can find links to help with all of these on the course website at
                                 http://courses.ischool.berkeley.edu/i290-4/f09/

Mais conteúdo relacionado

Semelhante a lecture2_public

GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1Heather Rock
 
Document Object Model
Document Object ModelDocument Object Model
Document Object ModelMayur Mudgal
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)Ivy Rueb
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingAshok Modi
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)Ivy Rueb
 
Web development resources brackets
Web development resources bracketsWeb development resources brackets
Web development resources bracketsLaurence Svekis ✔
 
Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityAshok Modi
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascripttutorialsruby
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascripttutorialsruby
 
Chapter15-Presentation.pptx
Chapter15-Presentation.pptxChapter15-Presentation.pptx
Chapter15-Presentation.pptxGFRomano
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LAJake Johnson
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQueryDanWooster1
 
Lesson 3
Lesson 3Lesson 3
Lesson 3hstryk
 
Web Development Training Report.docx
Web Development Training Report.docxWeb Development Training Report.docx
Web Development Training Report.docxCuriosityKlinic
 

Semelhante a lecture2_public (20)

GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
Web technologies part-2
Web technologies part-2Web technologies part-2
Web technologies part-2
 
Web development resources brackets
Web development resources bracketsWeb development resources brackets
Web development resources brackets
 
Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and Scalability
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript
 
Chapter15-Presentation.pptx
Chapter15-Presentation.pptxChapter15-Presentation.pptx
Chapter15-Presentation.pptx
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LA
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Web Development Training Report.docx
Web Development Training Report.docxWeb Development Training Report.docx
Web Development Training Report.docx
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 

Mais de tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

Mais de tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Último

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
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
 
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
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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...
 
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
 
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...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

lecture2_public

  • 1. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 LAST WEEK ON IO LAB If you haven’t done these things already, please do them before we begin today’s lecture Install Firebug and Greasemonkey. Complete the online skills assessment. Join the iolab@ischool mailing list. You can find links to help with all of these on the course website at http://courses.ischool.berkeley.edu/i290-4/f09/
  • 2. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 INFORMATION ORGANIZATION LAB Faculty: Bob Glushko Student Instructors: Nick Doty & Ryan Greenberg A warning: Today is going to be a full-on crash course in the web client technologies we'll be using for much of this class (HTML/CSS and Javascript/JQuery) followed by actually building on that with web browser extensions like Greasemonkey. This should begin to explain the basics behind the tutorial you worked on this past week and the demo that Ryan did last week, but it may still be a lot to take in and we'll be talking a lot today. We promise that you'll have time to learn this stuff beyond just today and that we won't be talking as much every class.
  • 3. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 OFFICE HOURS Room 210 Nick Ryan Friday Wednesday 1:00-2:00 1:00–2:00 And by appointment. Email ryan@ischool or npdoty@ischool to schedule.
  • 4. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 WHAT WE KNOW HTML CSS Javascript Based on the results of the unscientific survey you completed last week.
  • 5. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 DOCUMENT OBJECT MODEL <html> body <body> <div id="header"> <h1>Document Object Model</h1> </div> div div header content <div id="content"> <p>This is my first paragraph</p> <p>My second paragraph has a list: <ul> h1 p p p <li>Item One</li> <li>Item Two</li> <li>Item Three</li> </ul> ul </p> <p>This is the third paragraph</p> </div> </body> </html> li li li Here on the right side is a short HTML document. When your web browser loads this document, it generates a representation called the Document Object Model. If your code is properly indented, your can see that the hierarchy of the DOM corresponds to the indentation level. The big idea here is that the left is just a bunch of text. On the right there is a collection of objects that you can manipulate and change. See http://en.wikipedia.org/wiki/Document_Object_Model for more information.
  • 6. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 CASCADING STYLE SHEETS Separate presentation from structure and content. If you want to be impressed by what’s possible with CSS, see http://csszengarden.com.
  • 7. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 RULE STRUCTURE From CSS: The Definitive Guide A stylesheet consists of a series of rules. Here you see the structure of a style rule. You start with a selector, which specifies what elements in the DOM you want this rule to apply to. Then you write one or more declarations to apply styles to that selection. Declarations are separated by semi-colons.
  • 8. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 SELECTORS CSS HTML Type (Tag) p <p> Id #header id="header" Class .author class="author" Descendent div p <div><p> Grouping h1, h2 <h1> and <h2> Who can explain the difference between IDs and classes? IDs are unique, only occur once on the page. Classes are recurring elements. Both can add semantic meaning to the page. For a complete list of selectors in CSS2, see http://www.w3.org/TR/CSS2/selector.html. For a list of all the selectors that jQuery can use (which are a lot more than CSS2), see http:// docs.jquery.com/Selectors.
  • 9. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 COMMON PROPERTIES font-family color border display margin font-size width padding background position text-align float See http://htmldog.com/reference/cssproperties/ for a good list of CSS2 properties. Let’s do some examples. (1) I want to make the blog (2) Align the text in the header: #header { text-align: center; } (3) Make every author’s name’s much bigger. .author (4) I want to make the titles of the blog entries blue Papyrus.
  • 10. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 THE BOX MODEL Margin Border Padding Width Height Every object on the page consists of a rectangular box. The content area, plus padding, border, margin. When you set the width of an element using CSS, that is the width of the content area, not the entire box. If you set {width: 500px; padding: 20px; border: 1px solid black}, the box will be 542px wide: 500, plus 20 padding on each side, plus 1 border on each side.
  • 11. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 CSS RESOURCES Available free for students at http://proquest.safaribooksonline.com. CSS Definitive Guide: http://proquest.safaribooksonline.com/0596527330 CSS Missing Manual: Heads-First XHTML & CSS: http://proquest.safaribooksonline.com/059610197X/hfhtmlcss- CHP-8?imagepage=285 “Expanding your vocabulary” http://proquest.safaribooksonline.com/059610197X/ hfhtmlcss-CHP-8?imagepage=285
  • 12. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 JAVASCRIPT CRASH COURSE Everyone open up a copy of Firefox and Firebug. If you would like, you can also use Safari’s web inspector. Some things in Safari are much better, but I’ll be using Firebug. Cross- platform, has a few more developed features.
  • 13. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 FIRST THINGS FIRST JavaScript is a high-level, object-oriented language used most often in web browsers. You can write comments in your code with // or /* */ A semi-colon goes at the end of every statement. It’s a dynamic, scripting language. Prototype-based inheritance, not class-based. See Douglas Crockford’s explanation for more information: http://javascript.crockford.com/ prototypal.html
  • 14. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 VARIABLES 29 'Bob' true Numbers Strings Boolean ['Bob', 'John', 'Coye', 'Deirdre'] Arrays {'name': 'Arnold', 'weight': 240} Objects Variables can be of different types. We’re going to cover these basic data types.
  • 15. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 VARIABLES var stateName = 'California'; You use the word ‘var’ to declare a variable. You don’t have to say what type of variable it is--variables in JavaScript are untyped. Convention is to use camelCase.
  • 16. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 STRINGS A sequence of characters. Use single- or double-quotes to indicate a string. Examples var myName = "Larry"; myName → "Larry" myName.length → 5 myName.toUpperCase() → "LARRY" myName.indexOf('a') → 1
  • 17. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 ARRAYS An ordered collection of elements. Use square brackets to indicate an array. Examples var myArray = ['dog', 'fish', 'cat']; myArray.length → 3 myArray[0] → ['dog'] myArray.push('horse') → myArray == ['dog', 'fish', 'cat', 'horse'] myArray.indexOf('fish') → 1 myArray.sort() → ['cat', 'dog', 'fish'];
  • 18. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 OBJECTS A collection of key-value pairs or named properties. Use braces to indicate an object. Examples var person = {'name': 'Arnold', 'weight': 240, 'height': 6.2 } person.name → "Arnold" person.height → 6.2 person.wife = 'Maria'; person.wife → 'Maria' person['wife'] → 'Maria' The most confusing thing about objects in JavaScript is that they’re used for so many different things. First, they fill the role of the data structure: hashes/dictionaries (in Python)/ associative arrays. Second, objects are naturally used for JavaScript’s object-oriented programming. Third, JavaScript objects are also the basis for JSON. You can access the properties of an object using the dot notation or bracket notation.
  • 19. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 FUNCTIONS function add(x, y) { return x + y; } add(2,4) → 6 var add = function(x, y) { return x + y; } JavaScript functions are defined with the keyword function and they return a value. Functions can have names, as in the top example, or they can be anonymous.
  • 20. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 BROWSER FUNCTIONS alert('…') confirm('…') prompt('…') console.log('…') console.log is better to use when debugging because alert (1) doesn’t give you any history, (2) you have to click each button. That said, there are times when alert(‘Testing!’) is simply more convenient.
  • 21. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 CONTROL STRUCTURES if (3 > 2) { alert('3 is greater than 2'); } for (var i=0; i < myArray.length; i++) { myArray[i]; } The for loop in JavaScript is a standard C-style for loop. The first statement (here var i=0) sets the starting condition. The second statement (i < myArray.length) sets how long the loop will run--until this condition is false. The third statement (i++) says what will happen at the end of each loop.
  • 22. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 + JQUERY CSS meets JavaScript jQuery is a JavaScript library (intro. 2006) written by John Resig. When learning: great when you can apply something you know to something else. A lot of JS in browser has to do with selecting objects from the DOM. And we already have something to do that...CSS!
  • 23. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 NEW HOTNESS VS. OLD AND BUSTED (But with JavaScript instead of computers) Javascript has been around for awhile. Tutorials on the internet are old. Used to put your Javascript inline with your HTML. onclick...onload...document.writeln(). Like CSS, the current best practice is to separate your Javascript from the HTML. We don’t use onevent anymore. Also, using JavaScript in browsers has often been onerous. To change all the elements with a certain class, you used to write document.getElementsByTagName(‘*’) ... and a bunch of other stuff. But new libraries like jQuery let you do this more efficiently: $(‘.name-of-class’)
  • 24. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 JQUERY Using jQuery involves two steps: • Selects objects from the DOM using CSS selectors. • Do something with the selected elements.
  • 25. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 MAIN JQUERY OPERATIONS • Attributes: Changing existing elements. • Traversing: Moving from selected elements in the DOM to others. • Manipulating: Inserting or removing elements. • Events: Attaching functions to events in the browser. The jQuery Documentation (http://docs.jquery.com), which is well organized and written, uses these names as well. Examples: - Attributes: $(‘h1’).text() gives you the text from the selected elements. $(‘h1’).text(‘New Text Here’) sets the text in the selected elements. - Traversing: Moves from selected elements elsewhere in the DOM. - Manipulating: $(‘p’).after(‘This text will be added after every paragraph’); $ (‘body’).prepend(‘This will appear at the top of the page’) - Events: You select the elements you want to attach an event to and provide an anonymous function: $(‘h2’).click( function() { alert(‘You clicked on an h2’); });
  • 26. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 WEB BROWSER EXTENSIONS Greasemonkey and Jetpack and bears, oh my! A general overview: we’ll be looking at a class of tools that extend the functionality of a web browser, either to change the browser chrome (like the status bar or the menu options) or modify an existing webpage.
  • 27. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 EXTEND WHAT? Browser chrome Page content Page style Page behavior Chrome: an image in the status bar that lets you know when you have new email Content: removing an advertisement or adding a map Style: giving Craiglist any kind of style at all Behavior: make a button
  • 28. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 Greasemonkey Mozilla Jetpack Firefox Extensions Chrome Extensions Relative advantages and disadvantages. The left-hand column is fairly mature compared to the right. The top row is fairly light-weight (for development and installation) than the bottom row. Firefox Extensions have the best performance but are the hardest to develop. We’ll use Greasemonkey here -- it’s easy to develop, easy to install, and fairly widespread. But these others have their advantages -- Jetpack makes it particularly easy to add to the browser’s chrome and Firefox gives you a lot of power that Greasemonkey doesn’t have -- if you want to use one, go for it! But Greasemonkey is a good start for us and development is just like modifying an existing webpage. Anyone know of others? (Safari Saft, IE Activities....)
  • 29. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 GOOD FOR THE BROWSERS GOOD FOR US For the browsers: Let users customize and extend the browser, but keep the core small. For us: Let us prototype website and browser features without building either from scratch.
  • 30. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 LET’S TRY IT To the browser / text editor!
  • 31. INFORMATION ORGANIZATION LAB SEPTEMBER 8, 2009 FOR NEXT WEEK For practice, make sure you can build the Delicious Trailmaker all by yourself. Add a feature to it. Write your first Greasemonkey script. Come with questions next class. Decide on an idea for Project 1. You can find links to help with all of these on the course website at http://courses.ischool.berkeley.edu/i290-4/f09/