Rodomi pranešimai su žymėmis XMLHttpRequest. Rodyti visus pranešimus
Rodomi pranešimai su žymėmis XMLHttpRequest. Rodyti visus pranešimus

2016 m. kovo 15 d., antradienis

70-480: įvairūs, XMLHttpRequest readyState and status

CSS3 nth-child

The :nth-child(n) selector matches every element that is the nth child, regardless of type, of its parent.
n can be a number, a keyword, or a formula. Pavyzdžiui, li:nth-child(3)  pažymės 3 sąrašo elementą.

Taip pat galite naudoti formulę an+b, kai
a- ciklo skaičius
n- ciklo kintamasis
b- nurodo, kurį elementą pažymėsime

Pavyzdžiui, li:nth-child(10n+3) - pažymės 3 elementą iš kiekvienos 10 elementų grupės. Taigi, jei ul turi 45 elementus, tai bus pažymėti 3, 13, 23, 33 ir 43.

Taip pat galime naudoti odd ir even, kad pažymėtume porinius arba neporinius elementus.

Pavyzdžiui, li:nth-child(odd) pažymi 1, 3, 5, 7 ir t.t.

CSS3 nth-of-type

Raudonai pažymės kiekvieną p elementą, kuris yra antras elementas tėviniam elementui

p:nth-of-type(2)
{
background:#ff0000;
}


JQuery.ajax

contentType (default: 'application/x-www-form-urlencoded; charset=UTF-8')
Type: String
When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.

type (default: 'GET')
Type: String
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

onLine

navigator.onLine savybė grąžina boolean reikšmę, kuri rodo, ar browseris prisijungęs prie interneto, ar ne.


Navigator objektas laiko informaciją apie browser.

XMLHttpRequest


readyState gražiną dabartinio dokumento statusą:
0 - užklausa neinicializuota (request not inicialized);
1 - serverio ryšys nustatytas (server connection established)
2 - užklausa gauta (request received)
3 - užklausa vykdoma (processing request)
4 - užklausa baigta ir atsakymas paruoštas (request finished and response is ready)

status:
100 - continue
200 - standartinis atsakymas sėkmingai HTTP užklausai
300 - rasti keli atsakymai pagal pateiktus duomenis
400 - bloga užklausa

70-480: Įvairūs AJAX

AJAX apibrėžime naudojami autentifikacijai:


password
username

APIs:
XMLHttpRequest
Geolocation - naudojamas geografinei userio pozicijai

Geolocation API


getCurrectPosition - paima dabartinę poziciją
watchPosition -grąžina dabartinę poziciją ir rodo video

Geolocation naudojamas iPhone ir GPS.

http://www.w3schools.com/html/html5_geolocation.asp

Klaidų gaudymo blokas:

try
catch(e)
finally

Draggable elements

Jei norime, kad elementai būtų draggable, reikia pridėti atributą draggable = true

DataTransfer.setData() - siunčia duomenų tipą ir reikšmę tempimui (?)

function drag(ev){
 ev.dataTransfer.setData("text", ev.target.id);
};

onDragOver - nurodo, kur tą reikšmę galima dėti. Elementai negali būti dedami ant kitų elementų, tam naudojama:
event.preventDefault();

Kai elementas padedamas, iškviečiamas metodas onDrop.

function drop(ev){
 ev.preventDefault(); - naršyklė atidaroma default gaudymui (?)
 var data = ev.dataTransfer.getData("Text"); - paimami persiųsti duomenys
 ev.target.appendChild(document.getElementById(data));
};

Prototype


Prototype savybė leidžia pridėti metodus ar savybes objektui.

Pridėti savybę:

function employee(name,jobtitle,born)
{
this.name=name;
this.jobtitle=jobtitle;
this.born=born;
}

var fred=new employee("Fred Flintstone","Caveman",1970);
employee.prototype.salary=null;
fred.salary=20000;

Pridėti metodą:

Customer.prototype.GetCommission() = function()
{
 alert('payroll');
}

http://www.w3schools.com/jsref/jsref_prototype_string.asp


Error.prototype

Error.prototype - pristatomas klaidos konstruktorius.


Error prototype turi šias savybes:



https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype

CSS legal color values

Colors in CSS can be specified by the following methods:
  • Hexadecimal colors
  • RGB colors - rgb(red, green, blue), reikšmės nuo 0 iki 255, procentais - 0% iki 100%. PVZ.: rgb(0,0,255) ir rgb(0%,0%,100%).
  • RGBA colors - išplėstas RGB, pridedant alpha savybę: rgba(red, green, blue, alpha). alpha parametras nurodo skaitinę reikšmę nuo 0.0 (visiškai permatoma) ir 1.0 (visiškai nepermatomas).
  • HSL colors - nurodo cilindrinius koordinačių atspalvius, hsl(hue - atspalvis, saturation - sodrumas, lightness - lengvumas). #p1 {background-color:hsl(120,100%,50%);} / * green */
  • HSLA colors - išplėstas HSL, pridedant alpha savybę.
  • Predefined/Cross-browser color names - yra apibrėžta 140 spalvų vardų: http://www.w3schools.com/cssref/css_colornames.asp
Šešioliktainiai spalvų kodai: #RRGGBB, kur RR (red - raudona), GG (green - žalia) and BB (blue - mėlyna). Visos reikšmės gali būti nuo 0 iki FF.

http://www.w3schools.com/cssref/css_colors_legal.asp

Callback gražinti XML duomenis


calback.call(httpRequest.responseXML);

call - naudojamas iškviesti objektą. call([thisObj[, arg1[, arg2[, argN]]}])
responseXML - grąžina duomenis kaip XML duomenis

XMLHttpRequest -leidžia atnaujinti puslapio dalis, neperkraunat puslapio.


input type="email"

SVG - interactive scalable vector graphic

transform - apibrėžia sąrašą transformacijų
setInterval - įvertiną išraišką specialiam intervale (milisekundėmis)

myGraphic.setAttribute("currectScale", 1.5)

JQuery show() vs. visible

$('#btnEdit').show()

$(selector).show(speed,easing,callback)

Su display:none naudoti show()? show(), hide() dirba su display savybe, o ne visibility

Matomi elementai yra tie, kurie:
  • nenurodyta display: none
  • nėra tipo type=hidden
  • plotis ir ilgis nėra 0
  • nėra paslėpto elemento dalis

autocomple

autocomplete atributas nurodo, kad laukas gali būti užpildytas automatiškai???

< input type = 'password' required autocomplete = 'off' />

JQuery pažymėti visus header elementus


$(":header")

CSS text-transform property

p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}

hyphens


hyphens - teksto lygiavimas, kai į eilučių pabaigą žodis dalijamas ir atskiriamas brūkšneliu


 hyphen geriau nei word-break.

CSS3 hyphen veikia nuo Firefox 6 su anglų kalba.

SVG


SVG yra kalba, apibrėžianti 2D grafiką XML.

Canvas SVG
  • Resolution dependent
  • No support for event handlers
  • Poor text rendering capabilities
  • You can save the resulting image as .png or .jpg
  • Well suited for graphic-intensive games
  • Resolution independent
  • Support for event handlers
  • Best suited for applications with large rendering areas (Google Maps)
  • Slow rendering if complex (anything that uses the DOM a lot will be slow)
  • Not suited for game applications

$.ajax settings: accepts, contentType, dataType

accepts - nurodo, kokio tipo atsakymus leidžia grąžinti
contentType - pagal nutylėjimą 'application/x-www-form-urlencoded; charset=UTF-8'
dataType - galimos reikšmės xml, json, script, html



dataFilter - apvalymo, filtravimo funkcija, kad gautume reikiamus "švarų" atsakymą.


getResponseHeader - headerio informacija apie atsakymą, pvz., 

xmlhttp.getResponseHeader("Server")
xmlhttp.getResponseHeader("Content-Type")
xmlhttp.getResponseHeader("Content-Length")
xmlhttp.getResponseHeader("Last-Modified")