An Introduction to Front-end Web Development Tom Perkins.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Javascript It’s not JAVA. What do these all have in common?
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
The Web Warrior Guide to Web Design Technologies
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
1 Introduction to Human Computer Interaction  Livecode Overview  Based on Livecode User Guide from RunRev Ltd. (2010) 
An Introduction to ASP.NET Web Pages 2 Module 1: Webmatrix Installation and Your First Web Site Tom Perkins.
Written by Matthew Shelley for Professor Wei Shi.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
The Python interpreter CSE 140 University of Washington Michael Ernst.
JavaScript: Functions © by Pearson Education, Inc. All Rights Reserved.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
HTML Hyper Text Markup Language A simple introduction.
Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Active-HDL Interfaces Debugging C Code Course 10.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Browsers © Copyright 2014, Fred McClurg All Rights Reserved.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Imagine Creating Software Without a Single Line of Code!
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Unit 1 – Web Concepts Instructor: Brent Presley.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
Tomcat Setup BCIS 3680 Enterprise Programming. One-Click Tomcat Setup 2  This semester we’ll try to set up Tomcat with a PowerShell script.  Preparation.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
 CSC 215 : Procedural Programming with C C Compilers.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Programming Web Pages with JavaScript
Python’s Modules Noah Black.
Tutorial 10 Programming with JavaScript
3 Things Everyone Knows About Node JS That You Don't
Build Better Apps with MEAN.
Automation with Gwen Introduction.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Cordova & Cordova Plugin Installation and Management
Tutorial 10 Programming with JavaScript
Lecture 12: The Fetch Api and AJAx
Lecture 14: JSON and Web SERVICES
Twitter Bot with NodeJS
The Python interpreter
Interactive Programming vs. Stored Programs
Presentation transcript:

An Introduction to Front-end Web Development Tom Perkins

Disclaimer Examples follow – Pluralsite.com – Learning to Program – Part 1: Getting Started – Scott Allen – Node.js

Programs run inside node.js Node – Easy to install – Can run on Mac, Windows, or Linux First thing to do – Install Node

Node.js Superfast, stand-alone JavaScript interpreter Can function as a web server Easy to install Started from the Command Prompt JavaScript programs run “inside” Node. Two “run modes” – REPL (Loop) – Execute external JavaScript programs

Installing Node Launch any web browser (IE, Chrome, FireFox) Go to nodejs.org Download node Install node (use defaults)

Start Node Search your apps for “node” Select the ”Node.js command prompt” This will open the Command Prompt Window

The Command Prompt Window Run node by typing node at the command prompt

Run node Node runs JavaScript in the REPL loop.

Node’s REPL

REPL Examples To exit Node, type “.exit” at the command prompt (no quotes)

Some Node.js Objects Console – console.log(data) – outputs data to the output device Process – process.argv – returns an array containing command line arguments First element – ‘node’ Second element – name of JavaScript file Next elements – remaining command line arguments

Notes for process.argv() // print process.argv process.argv.forEach(function(val, index, array) { console.log(index + ': ' + val); }); This will generate: $ node process-2.js one two=three four 0: node 1: /Users/mjr/work/node/process-2.js 2: one 3: two=three 4: four

A Simple JavaScript Program Using Functions Running in Node

A Simple JavaScript Program (using functions) Program: \NTPCUG_Node\Functions\ functions.js Code editor: Notepad++ (free download) Steps taken: 1.Create the program in Notepad++ 2.Save the program as functions.js in the folder \NTPCUG_Node\Functions 3.Select the Command Prompt from the Start Menu 4.Enter cd\ntpcug_node\functions 5.Type: node functions.js 6.The program will execute …

A program to simulate the roll of a die and to evaluate that roll: 3, 4, 6 -> Great roll! 1 -> Terrible roll! Otherwise -> Ok roll.

Structured Walkthru: A JavaScript Program employing Functions

A JavaScript Program Demonstrating an Object

A JavaScript Program demonstrating a JavaScript Object

Structured Walkthru: A JavaScript Program using an Object

USING MULTIPLE FILES Objects group related data and behavior into a container called an “object”. To hide complexity – Use objects – Use multiple source code files to build an application A file may contain the definition of one or more objects No limit on number of files in an application

Multiple Files Object.js Program.js (main program – controller) dice.js (code related to rolling dice) Both files in the same folder: \ntpcug_node\multiple

Loading a file Require keyword – used to load a file All properties and methods are hidden by default in a loaded file Inside a called program, you have to explicitly tell node what you want to make available to calling programs Use the node “exports” object to identify what you want to expose Add a “die” property to the exports object – exports.die = die; To gain access to the exported members in the “required” program, place the “required” object into a variable in the calling program – var dice = require(“./dice”); To access the “die” object in the “dice” object – var die = dice.die;

USING MULTIPLE FILES IMPORTANT CONCEPTS: Called program exports object Calling program require keyword Accessing objects w/in called program

Structured Walkthru: Using Multiple Files in Javascript

A MORE COMPLEX FILE STRUCTURE AND INTRODUCTION TO TESTING

A Gradebook Program Given a set of scores for a student (87, 92, 72, 100, etc) calculate the average grade and assign a letter grade. Folder Structure: Gradebook Tests Lib ( application libraries) In c:\ntpcug_node mkdir gradebook In c:\ntpcug_node\gradebook (cd gradebook) mkdir tests mkdir lib

Test-Driven Development Nodeunit – a unit testing package for Node.js Install nodeunit using the NPM (Node Package Manager) – in gradebook: > npm install –g nodeunit Nodeunit looks for tests in the “tests” folder No tests available …

Tests are assertions about the data in a program Tests are written in the gradebook/test folder They require programs in the /gradebook folder

Create a file containing the gradeBook object in the \gradebook\lib folder (grades.js). Create a gradeTests.js file in the \gradebook\tests folder.

gradebook folder (tests folder) gradeTests.js lib folder grades.js (gradebook object)

Write a test first (in testGrades.js) It will fail (no addGrade method, no count) But that’s OK!

Structured Walkthru(s) grades.js – contains gradeBook object gradeTests.js – contains tests (assertions) about methods and properties of gradeBook object program.js – enter test scores from the command prompt line

WEBSITE

Node as a web server Node.js can function as a web server You can build websites and web applications Expressjs is a scaffolding tool It can be used to build a basic website See expressjs.com

Build a website Install expressjs – npm install express Modify website/program.js Start the server –...\website node program.js – Should produce Starting message …

Using any web browser, access localhost:3000 – (server is listening on port 3000) Response indicates root was accessed but site was unable to handle request Use CTRL-C to exit the server …

Modify program.js to handle an empty request on port 3000 Restart the server Access the site at localhost:3000 See response: Add

Pass a number of grades to a different URL Have the server respond with a letter grade – localhost:3000/grade?grades=100,90,80,95 – Query string

Server code to handle request of localhost:3000/grade?grades= … Add

Final result!

FINIS