27
Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI

Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Tutorial #2: Javascript and jQuery

2017. 3. 13.

Hyungyu Shin

1

CS374: Introduction to HCI

Page 2: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Team�Formation

• Due�today�11:59pm

• You�SHOULD�form�a�group�of�four�

• If�you�have�not�yet�formed�a�group�of�four,�we’ll�give�a�chance�

• advertise�your�group,�or�

• advertise�yourself

• Please�make�it�at�the�end�of�tutorial�and�submit�the�form

2

Page 3: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Summary�of�Previous�Tutorial

• HTML�for�presenting�structure�of�a�webpage�

• CSS�for�presenting�contents

• Web�browsers�for�interpreting�and�rendering�web�pages�

• Separation�of�presentation�and�content

3

Page 4: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

4https://www.christianheilmann.com/2011/08/15/getting-rusty-we-need-new-best-practices-for-a-different-development-world/

Tutorial #2

Tutorial #1

Page 5: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

5

Student will be able to build the following website on codepen.io

Page 6: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Try�it�!

6

http://codepen.io/hgshin/pen/OpmQdZ/

Page 7: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Javascript

• A�language�to�make�a�web�site�do�something�

• Simply�think�a�web�browser�execute�the�javascript�code

7

Page 8: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Example

• Compute�1�+�…�+�n�and�print�it�on�codepen.io

8

Page 9: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

9

Which action should we implement ?

Page 10: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

10

Which action should we implement ?

1. hover

Page 11: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

11

Which action should we implement ?

1. hover2. click & counting

Page 12: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

12

Which action should we implement ?

1. hover2. click & counting 3. add an option

Page 13: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

13

Which action should we implement ?

1. hover2. click & counting 3. add an option4. sorting5. presenting on the table

Page 14: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

14

Which action should we implement ?

1. hover2. click & counting 3. add an option4. sorting5. presenting on the table

Page 15: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Event

• Events�happens�whenever�interesting�things�take�place�

• Click�/�Mouse�move�

• Typing�keyboard�

• User-generated�event

15

Page 16: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Example

• Raise�an�alert�when�a�user�clicks�a�button

16

Page 17: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Learning�Objective

17

1. hover2. click & counting 3. add an option4. sorting5. presenting on the table

Page 18: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Algorithm

18

When user clicks an option

Page 19: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Algorithm

19

When user clicks an option Increase the count of option

Sort the result

Refresh the result

Refresh the options

Page 20: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Algorithm

20

When user click “add an option” button

Page 21: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Algorithm

21

When user click “add an option” button Add an option with count 1

Refresh the result

Refresh the options

Clear the input box

Page 22: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Summary�of�Algorithm

22

When user clicks an option

Increase the count of option

Sort the result

Refresh the result

Refresh the options

When user click“add an option” button

Add an option with count 1

Refresh the result

Refresh the options

Clear the input box

Page 23: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Let’s�implement�it�!

23

http://shoutkey.com/breeze

Page 24: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

jQuery

• jQuery�is�one�of�the�most�widely�used�javascript�library

• Philosophy�:�write�less,�do�more

24

Page 25: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Let’s�revise�the�code�with�jQuery

25

See whether you really can do more with less code

Page 26: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Summary

• Javascript�

• A�language�to�make�a�web�site�do�something�

• DOM�provides�the�way�to�access�HTML�elements�

• an�HTML�element�is�handled�as�an�object�in�javascript�

• jQuery�

• One�of�the�most�widely�used�javascript�library�

• Google�it�whenever�you�want�to�do�something�!

26

Page 27: Tutorial #2: Javascript and jQuery - KIXLAB · Tutorial #2: Javascript and jQuery 2017. 3. 13. Hyungyu Shin 1 CS374: Introduction to HCI. TeamFormation

Thank�you�for�listening�:D

27

Questions are welcomed

Hyungyu Shin