





















Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!






















La web usability è una progettazione per rendere i siti web facili da usare per gli utenti senza che questi abbiamo competenze specifiche. Per valutare l’usabilità sono state create le dieci euristiche di Nielsen:
Le informazioni devono essere il più chiaro e preciso possibile per eliminare ogni tipo di ambiguità. Le informazioni più importanti devono essere nella giusta posizione al’interno della pagina. Architettura dell’informazione disciplina che permette di organizzare i contenuti in modo semplice e intuitivo per l’utente.
INTRODUZIONE ALLA PROGRAMMAZIONE I computer sono programmabili e svolgono compiti in base alle istruzioni che ricevono. Il calcolatore conosce il LINGUAGGIO MACCHINA che è basato su un ALFABETO BINARIO (0/1). Per facilitare l’interazione con l’utente nascono i LINGUAGGI DI PROGRAMMAZIONE che sono di “alto livello”, hanno una sintassi semplice e vicina al linguaggio dell’uomo. Codice sorgente programma scritto dal programmatore che può essere tradotto in linguaggio macchina con due tecniche:
Algoritmo insieme ordinato di operazioni che descrivono i dati che devono essere utilizzati e determinano la sequenza di azioni elementari che devono essere svolte per risolvere no o più problemi.
Javascript è un linguaggio di scripting orientato agli oggetti e ha due estensioni: lato client e lato server. Per quanto riguarda il lato client, l’interprete di javascript è incorporato del broswer. Javascript interagisce con il HTML attraverso il DOM (Document Object Model) che è una forma di rappresentazione del documento e attraverso il quale si può accedere per modificare i dati del documento HTML. Ha una struttura ad albero. L’oggetto DOCUMENT è quindi molto importante perché è quello che contiene tutti gli altri elementi e identifica una pagina web. Per recuperare gli elementi all’interno di una pagina il DOM ci fornisce due metodi:
Il tag che contiene il codice javascript può essere inserito all’interni della o all’interno del . LE VARIABILI Le variabili contengono dei dati. Example var x = 5; var y = 6; var z = x + y; From the example above, you can expect:
Much Like Algebra In this example, price1, price2, and total, are variables: Example
Strings are written with quotes. You can use single or double quotes: Example var carName = "Volvo XC60"; // Using double quotes var carName = 'Volvo XC60'; // Using single quotes
JavaScript Numbers JavaScript has only one type of numbers. Numbers can be written with, or without decimals: Example var x1 = 34.00; // Written with decimals var x2 = 34; // Written without decimals
JavaScript Booleans Booleans can only have two values: true or false. Example var x = true; var y = false; Booleans are often used in conditional testing.
Undefined In JavaScript, a variable without a value, has the value undefined. The typeof is also undefined. Example var person; // Value is undefined, type is undefined
Null In JavaScript null is "nothing". It is supposed to be something that doesn't exist. Unfortunately, in JavaScript, the data type of null is an object. You can empty an object by setting it to null:
Example var person = null; // Value is null, but type is still an object
2.dati complessi
JavaScript Arrays JavaScript arrays are written with square brackets. Array items are separated by commas. The following code declares (creates) an array called cars, containing three items (car names): Example var cars = ["Saab", "Volvo", "BMW"];
JavaScript Objects JavaScript objects are written with curly braces. Object properties are written as name:value pairs, separated by commas. Example var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
The typeof Operator You can use the JavaScript typeof operator to find the type of a JavaScript variable: Example typeof "John" // Returns string typeof 3.14 // Returns number typeof false // Returns boolean typeof [1,2,3,4] // Returns object typeof {name:'John', age:34} // Returns object
Le funzioni sono molto importanti in Javascript. Sono un blocco di istruzioni al quale viene associato un identificatore.
Le variabili possono essere locali o globali , le prime servono a dichiarare un valore che verrà conservato in memoria per l'utilizzo della funzione o della routine in cui viene dichiarata, le seconde, al contrario, vengono dichiarate all'inizio di un blocco di script e possono essere utilizzate da una molteplicità di funzioni e routine. Vediamo un esempio di variabile locale:
function mia_funzione() { var miaVariabile = 123; alert(miaVariabile); } In questo caso la nostra variabile miaVariabile esiste solo all'interno della funzione. Vediamo adesso un esempio di variabile globale:
var miaVariabile = 123;
function mia_funzione() { alert(miaVariabile); }
JAVASCRIPT OBJECTS Essendo javascript un linguaggio orientato agli oggetti che quindi permetto allo sviluppatore di manipolare i dati che oggetti, questi ultimi hanno delle caratteristiche:
Objects are variables too. But objects can contain many values. This code assigns many values (Fiat, 500, white) to a variable named car: var car = {type:"Fiat", model:500, color:"white"};
Object Properties The name:values pairs (in JavaScript objects) are called properties. var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
Object Methods Methods are actions that can be performed on objects. Methods are stored in properties as function definitions.
Property Property Value firstName John lastName Doe age 50 eyeColor blue fullName function() {return this.firstName + " " + this.lastName;}
Accessing Object Properties You can access object properties in two ways: objectName.propertyName or objectName[propertyName]
Example person.lastName;
Example person["lastName"];
Accessing Object Methods You access an object method with the following syntax: objectName.methodName()
Example name = person.fullName();
If you access the fullName property , without (), it will return the function definition : Example name = person.fullName;
ESEMPI:
Display the result here.
Event Description onchange An HTML element has been changed onclick The user clicks an HTML element onmouseover The user moves the mouse over an HTML element onmouseout The user moves the mouse away from an HTML element onkeydown The user pushes a keyboard key onload The browser has finished loading the page
The Math Object The Math object allows you to perform mathematical tasks. The Math object includes several mathematical methods. One common use of the Math object is to create a random number: Example Math.random(); // returns a random number
Math.random() returns a random number between 0 and 1.
Try it
Math.min() and Math.max() Math.min() and Math.max() can be used to find the lowest or highest value in a list of arguments: Example Math.min(0, 150, 30, 20, -8); // returns -
Example Math.max(0, 150, 30, 20, -8); // returns 150
Math.min() returns the lowest value.
Try it
Un ARRAY è un oggetto complesso che permette di memorizzare all’interno di una variabile un insieme di valori.
Popping and Pushing When you work with arrays, it is easy to remove elements and add new elements. This is what popping and pushing is: Popping items out of an array, or pushing items into an array. The pop() method removes the last element from an array: Example var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop(); // Removes the last element ("Mango") from fruit The push() method adds a new element to an array (at the end): Example var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi"); // Adds a new element ("Kiwi") to fruits
Conditional Statements Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements:
The if Statement Use the if statement to specify a block of JavaScript code to be executed if a condition is true.
Syntax if ( condition ) { block of code to be executed if the condition is true }
Example Make a "Good day" greeting if the hour is less than 18:00:
if (hour < 18) { greeting = "Good day"; } The result of greeting will be: Good day
The else Statement Use the else statement to specify a block of code to be executed if the condition is false. if ( condition ) { block of code to be executed if the condition is true } else { block of code to be executed if the condition is false }
The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed.
Syntax switch( expression ) { case n : code block break; case n : code block break; default: default code block } This is how it works:
i++; }
IL DOM
DOCUMENT OBJECT MODEL, è un modo diverse di visualizzare il documento. È un’interfaccia che permette ai programmi di script di accedere dinamicamento e di modificare lo stile il contenuto e la struttura di un documento HTML. Tutti gli oggetti di un pagina fanno parte dell’OGGETO DOCUMENT. per invocare metodi e proprietà di document è necessario utilizzare la seguente sintassi:
Per “recuperare” o modificare il contenuto di un elemento si usa la proprietà innerHTML. Recupero valori Es. var y =document.getElementById(“titolo”); document.write (y.innerHTML) Es. var x = document.getElementsByTagName(“p”); document.write(x [0].innerHTML) Inserimento valori Es. document.getElementById(“titolo”).innerHTML=”Bla bla”; document.getElementsByTagName(“p”)[0].innerHTML=”Bla bla”
Modificare gli attributi Modificare gli attributi F 09 7La sintassi per modificare il valore degli attributi è la seguente: document.getElementById(id).attributo = nuovo valore Es.
Modificare lo stile Modificare lo stile F 09 7La sintassi per modificare lo stile di un elmento html è la seguente: document.getElementById(id).style.proprietà = nuovo valore Es.
…..
When a user clicks on a button, all
elements will be hidden: Example $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); });
The #id Selector The jQuery #id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element. To find an element with a specific id, write a hash character, followed by the id of the HTML element: $("#test") Example When a user clicks on a button, the element with id="test" will be hidden: Example $(document).ready(function(){ $("button").click(function(){ $("#test").hide(); }); });
The .class Selector The jQuery class selector finds elements with a specific class. To find elements with a specific class, write a period character, followed by the name of the class: $(".test") Example When a user clicks on a button, the elements with class="test" will be hidden: Example
$(document).ready(function(){ $("button").click(function(){ $(".test").hide(); }); });Commonly Used jQuery Event Methods $(document).ready() The $(document).ready() method allows us to execute a function when the document is fully loaded. This event is already explained in the jQuery Syntax chapter. click() The click() method attaches an event handler function to an HTML element. The function is executed when the user clicks on the HTML element. The following example says: When a click event fires on a
element; hide the current
element: Example $("p").click(function(){ $(this).hide(); });
dblclick() The dblclick() method attaches an event handler function to an HTML element. The function is executed when the user double-clicks on the HTML element: Example $("p").dblclick(function(){ $(this).hide(); });
mouseenter() The mouseenter() method attaches an event handler function to an HTML element. The function is executed when the mouse pointer enters the HTML element: Example