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

2016 m. kovo 15 d., antradienis

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")


2014 m. sausio 26 d., sekmadienis

JQuery: kaip iškviesti WebService metodą sinchroniškai ir nusiųsti parametrus JSON formatu?

 $.ajax({
                             type: "POST",
                             url: sServiceURL + "/reorderRecord",
                             async: false,
                             data: '{ ordNew:' + JSON.stringify(reOrd) + '}',
                             contentType: "application/json; charset=utf-8",
                             dataType: "json",
                             success: function (msg) {
                                 alert("duomenys perduoti sekmingai");
                             },
                             error: function (xr) {
                                 alert(xr.responseText);
                             }
  });

2014 m. sausio 21 d., antradienis

JQuery: kaip iškviesti webService metodą sinchroniškai?

 window.onbeforeunload = function () {

            var val = false;

            $.ajax({
                type: "POST",
                url: sServiceURL + "/checkRecordsStatus",
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                 
                    if (msg.d == true) {
                        val = true;
                    };

                }

            });

            if (val == true) {
                return 'Turite neišsaugotų testavimo įrašų!';
            }

        };

Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender

        ScriptManager.RegisterStartupScript(Me, Me.GetType, "Service", "sServiceURL='" & VirtualPathUtility.ToAbsolute("~/ServicesPath.asmx") & "';", True)

    End Sub

2013 m. rugsėjo 12 d., ketvirtadienis

Datos formatas pagal lokalią kalbą JavaScript ir ASP.NET

Problema: atnaujinant duomenis su JavaScript, dažnai reikia išlaikyti datos formatą pagal lokalią kalbą.

Sprendimas:

var d = new Date(MeetDate).localeFormat("d"); - JavaScript

< % #  Eval("MeetDate", " { 0 : d } ") % > - ASP.NET

Daugiau: http://www.asp.net/AJAX/Documentation/Live/ClientReference/Global/JavascriptTypeExtensions/DateTypeExt/default.aspx

In Chapter 6: ASP.NET AJAX Localization, on page 289, we have a tip on Data Format Strings. It states that “the data format strings available for the Date and Number types in JavaScript are the same as those that are available in .NET for the DateTime and Double types.” This is incorrect.
The format strings that are allowed for Number types are the following:
  • c or C: Currency
  • p or P: Percentage
  • d or D“: Decimal (# number of digits)
  • n or N“: Numeric (# number of digits after decimal)
- e, f, g, r, x, and custom format strings are not supported
The standard format strings that are allowed for the Date type are the following:
  • d: Short date pattern
  • D: Long date pattern
  • t: Short time pattern
  • T: Long time pattern
  • F: Full date/time pattern (long time)
  • m or M: Month day pattern
  • s: Sortable date/time pattern
  • y or Y: Year month pattern
- the standard format strings: f, F, g, G, O, o, R, r, u, U are not supported. However, custom format strings that use the “mmm”, “yyyy”, “hh”, etc. formats are supported. You can build your own date format string.

http://seejoelprogram.wordpress.com/2008/08/07/supported-number-and-datetime-format-strings-in-aspnet-ajax/




Kaip iš DateTime gauti datos formatą JavaScript'e:

DateAdded: (new Date(parseFloat(result.d[i].auditdate.slice(6, 19)))).localeFormat("d")

čia 6,19 iš DateTime formato nuima pradžią ir pabaigą.