SlideShare uma empresa Scribd logo
1 de 64
A brief view at client web



                      Markiyan Matsekh
                             Web developer
No, we won’t
HTTP   HTML

CSS     JS
Transport    Content


Appearance   Behavior
Http (HyperText Transfer Protocol) –
is a deal between client and server on
how to deliver data
Http
- Request/Response model
- Stateless
- Operates with text
How to transfer large binary files
       through protocol
  which operates with text?
How to maintain state
in stateless protocol?
How to get updates from server
when all you can do is ask for?
Http methods
-   Get
-   Post
-   Put
-   Delete
-   (few less used)
Time for a small demo
What about security?
Https
- Agree on PreMasterSecret
- Encrypt traffic with it
- Send data safely
Html (HyperText Markup Language) –
is a tool for describing contents with
pre-defined limited set of words
Is a set of rules,
   by which browser
reads this description
<form name="input" action=“your_url"
method="get">
     Text: <input type=“text" name=“text” />
     Radio: <input type="checkbox"
     name=“radio"/>
     <input type="submit" value="Submit" />
</form>




                        Here comes Http
The number of html elements is growing…




Because what really matters nowadays…
Html5 is just a logical step in evolution of web

             ordo ab chao
               After chaos comes order
Css (Cascading Style Sheets) –
is a way of describing how your contents
should look
Css rules priorities
Css rules priorities
        -   #id == 3
        -   .classname == 2
        -   [attr] == 2
        -   el == 1


  Sum = … -> order -> priority = …
JavaScript –
is a powerful programming language,
embedded into the browsers,
letting us control the behavior of contents
Unobtrusive JavaScript
10 years ago
<body bgcolor=“#000”>
BAD! Now we move styles into separate files
body {
    background-color: #000;
}
Same with javascript. We put him into separate file.
Bad, mixing JavaScript with HTML
<button type="button“
  onclick=“document.getElementById(„photo').style.color='red';“>
Click Me
</button>
<div id=“photo”>I am photo</div>
Unobtrusive JavaScript
<button type="button" id="testButton">
Click Me                                 <-clean HTML
</button>

<script type="text/javascript">
window.onload = init;

function init() {
  document.getElementById('testButton').onclick =
makeItRed;
}
function makeItRed() {
  document.getElementById(„photo').style.color = 'red';
};
</script>
HTTP   HTML

CSS     JS
Transport    Content


Appearance   Behavior
Separation of concerns
Events
• World Wide Web – it’s events that make it all
  happen

1 Set up the user interface.
2 Wait for something interesting to happen.
3 React accordingly.
4 Repeat.
Netscape Event Model (march 1996)
                   DOM Level 0 Event Model
•   Hanlder function is assigned to attribtues on html element (onclick)

    <button id=“button1” value=“I‟m button”
         onclick=“alert(„I‟am clicked‟)” />

    <script type="text/javascript">
      $(function() {
        $(„#button1‟)[0].onfocus = function(event) {
            console.log(„Focused!‟);
        }
      });
    </script>
Across the browsers?
1. IE doesn’t invoke function with ‘event’
   $(„#button1‟)[0].onfocus = function(event) {
      if (!event) event = window.event;
   }

2. IE has event.target instead of event.srcElement:
   var target = (event.target)
       ? event.target : event.srcElement;



$(„#button1‟)[0].onfocus = function(event) {
  if (!event) event = window.event;
  var target = (event.target)
      ? event.target : event.srcElement;
}
Event bubbling
Event bubbling
document.onclick = function(event) {
  alert(event.target.tagName);
}

Events bubbling (propagation)
Browsers:     event.stopPropagation();
IE:       event.cancelBubble = true;
These don’t bubble: focus, blur; change, submit

Events default actions
<form name=“myform” onsubmit=“return false;”></form|>
<a href=“http://www.mysite.com” onclick=“return false;”></a>
Browsers:      event.preventDefault();
IE:       event.returnValue = false;

event.currentTarget – doesn’t work on IE
The DOM Level 2 Event Model (november2000)
function doFirstThing() {
}
function doSecondThing() {
}

addEventListener(eventType, listener, useCapture)

someElement.addEventListener(„click‟, doFirstThing, false);
someElement.addEventListener(„click‟, doSecondThing, false);
// (порядок виконання не гарантується)

IE: attachEvent(eventName, handler); // window.event :(
someElement.attachEvent(„onclick‟, doFirstThing);
someElement.attachEvent(„onclick‟, doSecondThing);
jQuery
What is jQuery?
$(), jQuery() – is function, just another piece of js code. But more
pleasant one

var jQuery = function(selector, context) {
  return new jQuery.fn.init(selector, context);
}
jQuery.fn.init - returns wrapped set
What does jQuery do?
$(selector).action()
<div>Some text</div>
<div class=“winter”>Winter text</div>

<script type=“text/javascript”>
$('div.winter').hide();
// jQuery chaining
$('div.winter').hide().show();

$('div.winter').hide().show().removeClass('winter').addClass('spring');
// same as:
var myDiv = $('div.winter');
myDiv.hide();
myDiv.show();
myDiv.removeClass('winter');
myDiv.addClass('spring');
</script>
CSS, or jQuery selectors
p a { color: green; }
$(“p a”).css(„color‟, „green‟);
$("p:even");
$("tr:nth-child(1)");
$("body > div");
$("a[href$=pdf]");
$("body > div:has(a)");
The jQuery Event Model

$(„img‟).bind(„click‟, function(event) {
    alert(„Image clicked ‟ + $(this).attr(„alt‟));
});

•   Unified way of adding event handlers
•   Easy to add many handlers at once
•   Standard names (click, focus);
•   ‘event’ is always present and in the same form
•   Unified way of canceling and preventing default actions
    (event.preventDefault()) (event.cancelBubble())
Ajax (Asynchronous JavaScript and Xml) –
is a chance to reload the content
without reloading the whole page
Usual Ajax workflow
1. Simple HTTP Get through click
2. Page loads javascript logic for ajax
3. Certain actions lead user to async ajax requests
4. Browser sends request to server without reloading page
5. Server examines that the request is async
6. Server s sends back piece of html or json
7. Client gets response and applies it to page
Ajax lets us use more HTTP then
         <form> element
Don’t forget!

•   Javascript is tricky
•   Javascript is single-threaded
•   Events run it all
•   Use Ajax wisely
•   Use Cookies wisely
And now time for
another demo
Client Web

Mais conteúdo relacionado

Mais procurados

Special Events: Beyond Custom Events
Special Events: Beyond Custom EventsSpecial Events: Beyond Custom Events
Special Events: Beyond Custom Events
Brandon Aaron
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
Scott Messinger
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
OSCON Byrum
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
Pedro Morais
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
Jussi Pohjolainen
 

Mais procurados (20)

Special Events: Beyond Custom Events
Special Events: Beyond Custom EventsSpecial Events: Beyond Custom Events
Special Events: Beyond Custom Events
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
jQuery Mobile with HTML5
jQuery Mobile with HTML5jQuery Mobile with HTML5
jQuery Mobile with HTML5
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
jQuery Mobile: Progressive Enhancement with HTML5
jQuery Mobile: Progressive Enhancement with HTML5jQuery Mobile: Progressive Enhancement with HTML5
jQuery Mobile: Progressive Enhancement with HTML5
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
Js events
Js eventsJs events
Js events
 
Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 
JQuery
JQueryJQuery
JQuery
 
Lec 5
Lec 5Lec 5
Lec 5
 

Destaque

CLIENT SERVER IN OS.ppt
CLIENT SERVER IN OS.pptCLIENT SERVER IN OS.ppt
CLIENT SERVER IN OS.ppt
suman yadav
 
2 08 client-server architecture
2 08 client-server architecture2 08 client-server architecture
2 08 client-server architecture
jit_123
 
Client Server Architecture
Client Server ArchitectureClient Server Architecture
Client Server Architecture
Rence Montanes
 
Clientserver Presentation
Clientserver PresentationClientserver Presentation
Clientserver Presentation
Tuhin_Das
 

Destaque (14)

A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)
 
Web server
Web serverWeb server
Web server
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
 
CLIENT SERVER IN OS.ppt
CLIENT SERVER IN OS.pptCLIENT SERVER IN OS.ppt
CLIENT SERVER IN OS.ppt
 
2 08 client-server architecture
2 08 client-server architecture2 08 client-server architecture
2 08 client-server architecture
 
Client Server Architecture
Client Server ArchitectureClient Server Architecture
Client Server Architecture
 
Application server vs Web Server
Application server vs Web ServerApplication server vs Web Server
Application server vs Web Server
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
Web servers
Web serversWeb servers
Web servers
 
Clientserver Presentation
Clientserver PresentationClientserver Presentation
Clientserver Presentation
 
Web servers
Web serversWeb servers
Web servers
 
Presentation about servers
Presentation about serversPresentation about servers
Presentation about servers
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
 

Semelhante a Client Web

HTML5 and Mobile
HTML5 and MobileHTML5 and Mobile
HTML5 and Mobile
doodoofish
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
Justin Cataldo
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 

Semelhante a Client Web (20)

Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
jQuery
jQueryjQuery
jQuery
 
jQuery
jQueryjQuery
jQuery
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Learning Svelte
Learning SvelteLearning Svelte
Learning Svelte
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
course js day 3
course js day 3course js day 3
course js day 3
 
J query training
J query trainingJ query training
J query training
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQuery
 
Jquery
JqueryJquery
Jquery
 
J query
J queryJ query
J query
 
HTML5 and Mobile
HTML5 and MobileHTML5 and Mobile
HTML5 and Mobile
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 

Mais de Markiyan Matsekh

Mais de Markiyan Matsekh (8)

How we made Apple Watch Tesla App
How we made Apple Watch Tesla AppHow we made Apple Watch Tesla App
How we made Apple Watch Tesla App
 
Wearables Interaction Design
Wearables Interaction DesignWearables Interaction Design
Wearables Interaction Design
 
Wearables: the next level of mobility
Wearables: the next level of mobilityWearables: the next level of mobility
Wearables: the next level of mobility
 
Enterprise Mobility: Getting Trendy
Enterprise Mobility: Getting TrendyEnterprise Mobility: Getting Trendy
Enterprise Mobility: Getting Trendy
 
PhoneGap - What It Actually Is
PhoneGap - What It Actually IsPhoneGap - What It Actually Is
PhoneGap - What It Actually Is
 
Big Mystification Theory
Big Mystification TheoryBig Mystification Theory
Big Mystification Theory
 
Html5 - examples
Html5 - examplesHtml5 - examples
Html5 - examples
 
Html5 - ready yet?(ukr)
Html5 - ready yet?(ukr)Html5 - ready yet?(ukr)
Html5 - ready yet?(ukr)
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Ú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...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 

Client Web

  • 1. A brief view at client web Markiyan Matsekh Web developer
  • 2.
  • 3.
  • 4.
  • 5.
  • 7. HTTP HTML CSS JS
  • 8. Transport Content Appearance Behavior
  • 9.
  • 10. Http (HyperText Transfer Protocol) – is a deal between client and server on how to deliver data
  • 11. Http - Request/Response model - Stateless - Operates with text
  • 12. How to transfer large binary files through protocol which operates with text?
  • 13. How to maintain state in stateless protocol?
  • 14. How to get updates from server when all you can do is ask for?
  • 15. Http methods - Get - Post - Put - Delete - (few less used)
  • 16.
  • 17. Time for a small demo
  • 19. Https - Agree on PreMasterSecret - Encrypt traffic with it - Send data safely
  • 20.
  • 21. Html (HyperText Markup Language) – is a tool for describing contents with pre-defined limited set of words
  • 22. Is a set of rules, by which browser reads this description
  • 23.
  • 24. <form name="input" action=“your_url" method="get"> Text: <input type=“text" name=“text” /> Radio: <input type="checkbox" name=“radio"/> <input type="submit" value="Submit" /> </form> Here comes Http
  • 25. The number of html elements is growing… Because what really matters nowadays…
  • 26.
  • 27.
  • 28. Html5 is just a logical step in evolution of web ordo ab chao After chaos comes order
  • 29.
  • 30. Css (Cascading Style Sheets) – is a way of describing how your contents should look
  • 31.
  • 32.
  • 34. Css rules priorities - #id == 3 - .classname == 2 - [attr] == 2 - el == 1 Sum = … -> order -> priority = …
  • 35.
  • 36.
  • 37. JavaScript – is a powerful programming language, embedded into the browsers, letting us control the behavior of contents
  • 38. Unobtrusive JavaScript 10 years ago <body bgcolor=“#000”> BAD! Now we move styles into separate files body { background-color: #000; } Same with javascript. We put him into separate file.
  • 39. Bad, mixing JavaScript with HTML <button type="button“ onclick=“document.getElementById(„photo').style.color='red';“> Click Me </button> <div id=“photo”>I am photo</div>
  • 40. Unobtrusive JavaScript <button type="button" id="testButton"> Click Me <-clean HTML </button> <script type="text/javascript"> window.onload = init; function init() { document.getElementById('testButton').onclick = makeItRed; } function makeItRed() { document.getElementById(„photo').style.color = 'red'; }; </script>
  • 41. HTTP HTML CSS JS
  • 42. Transport Content Appearance Behavior
  • 44. Events • World Wide Web – it’s events that make it all happen 1 Set up the user interface. 2 Wait for something interesting to happen. 3 React accordingly. 4 Repeat.
  • 45. Netscape Event Model (march 1996) DOM Level 0 Event Model • Hanlder function is assigned to attribtues on html element (onclick) <button id=“button1” value=“I‟m button” onclick=“alert(„I‟am clicked‟)” /> <script type="text/javascript"> $(function() { $(„#button1‟)[0].onfocus = function(event) { console.log(„Focused!‟); } }); </script>
  • 46. Across the browsers? 1. IE doesn’t invoke function with ‘event’ $(„#button1‟)[0].onfocus = function(event) { if (!event) event = window.event; } 2. IE has event.target instead of event.srcElement: var target = (event.target) ? event.target : event.srcElement; $(„#button1‟)[0].onfocus = function(event) { if (!event) event = window.event; var target = (event.target) ? event.target : event.srcElement; }
  • 48. Event bubbling document.onclick = function(event) { alert(event.target.tagName); } Events bubbling (propagation) Browsers: event.stopPropagation(); IE: event.cancelBubble = true; These don’t bubble: focus, blur; change, submit Events default actions <form name=“myform” onsubmit=“return false;”></form|> <a href=“http://www.mysite.com” onclick=“return false;”></a> Browsers: event.preventDefault(); IE: event.returnValue = false; event.currentTarget – doesn’t work on IE
  • 49. The DOM Level 2 Event Model (november2000) function doFirstThing() { } function doSecondThing() { } addEventListener(eventType, listener, useCapture) someElement.addEventListener(„click‟, doFirstThing, false); someElement.addEventListener(„click‟, doSecondThing, false); // (порядок виконання не гарантується) IE: attachEvent(eventName, handler); // window.event :( someElement.attachEvent(„onclick‟, doFirstThing); someElement.attachEvent(„onclick‟, doSecondThing);
  • 51. What is jQuery? $(), jQuery() – is function, just another piece of js code. But more pleasant one var jQuery = function(selector, context) { return new jQuery.fn.init(selector, context); } jQuery.fn.init - returns wrapped set
  • 53.
  • 54. $(selector).action() <div>Some text</div> <div class=“winter”>Winter text</div> <script type=“text/javascript”> $('div.winter').hide(); // jQuery chaining $('div.winter').hide().show(); $('div.winter').hide().show().removeClass('winter').addClass('spring'); // same as: var myDiv = $('div.winter'); myDiv.hide(); myDiv.show(); myDiv.removeClass('winter'); myDiv.addClass('spring'); </script>
  • 55. CSS, or jQuery selectors p a { color: green; } $(“p a”).css(„color‟, „green‟); $("p:even"); $("tr:nth-child(1)"); $("body > div"); $("a[href$=pdf]"); $("body > div:has(a)");
  • 56. The jQuery Event Model $(„img‟).bind(„click‟, function(event) { alert(„Image clicked ‟ + $(this).attr(„alt‟)); }); • Unified way of adding event handlers • Easy to add many handlers at once • Standard names (click, focus); • ‘event’ is always present and in the same form • Unified way of canceling and preventing default actions (event.preventDefault()) (event.cancelBubble())
  • 57.
  • 58. Ajax (Asynchronous JavaScript and Xml) – is a chance to reload the content without reloading the whole page
  • 59. Usual Ajax workflow 1. Simple HTTP Get through click 2. Page loads javascript logic for ajax 3. Certain actions lead user to async ajax requests 4. Browser sends request to server without reloading page 5. Server examines that the request is async 6. Server s sends back piece of html or json 7. Client gets response and applies it to page
  • 60. Ajax lets us use more HTTP then <form> element
  • 61. Don’t forget! • Javascript is tricky • Javascript is single-threaded • Events run it all • Use Ajax wisely • Use Cookies wisely
  • 62.
  • 63. And now time for another demo

Notas do Editor

  1. Intensive development of the web caused too hasty decisions and lack of standards. Later monopolization of the market be IE killed web for years…
  2. You can make add any features to your toy, as long as it conforms standards
  3. You can make add any features to your toy, as long as it conforms standards
  4. These are the 4 main concepts of client web
  5. No questions? Then let me ask you – how do you transfer binary data as text? Big data?And how do you maintain state?
  6. Why? Remember mobile phones boom? And planshets? They all render data as the user got used to, not how we want it to be rendered.
  7. These are the 4 main concepts of client web