LING 408/508: Programming for Linguists Lecture 13 October 7 th.

Slides:



Advertisements
Similar presentations
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● / www,histpk.org Hidaya Institute of Science & Technology
Advertisements

Simple Java Forms Dr. Robert L. Probert S.I.T.E., University of Ottawa.
LING 408/508: Programming for Linguists Lecture 12 October 2 nd.
Intro to JavaScript. JavaScript History Client (generally browser-side) language invented at Netscape under the name LiveScript around 1995 Netscape wanted.
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
The DOM tree CS The DOM tree CS380 2 Types of DOM nodes  element nodes (HTML tag)  can have children and/or attributes  text nodes (text in.
/k/k 1212 Cascading Style Sheets Part one Marko Boon
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
SE-2840 Dr. Mark L. Hornick1 jQuery. jQuery is a library of JavaScript functions Helps minimize the amount of JavaScript you have to write in order to:
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Tutorial 6 Creating a Web Form
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Cascade Style Sheet Demo. Cascading Style Sheets Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to.
CSS Statements, media queries, selectors, cascading Web Applications Martin Nečaský Department of Software Engineering, Faculty of Mathematics and Physics,
Day 2 – JavaScript & PHP.  Have the hover effect display an extra image  Add an extra image for each of the tags  In your writeText() function, you.
Chapter 6 Basic forms 1. Forms and query string 2 form : a group of user input (UI) controls that accepts information from the user and sends the information.
CS 174: Web Programming February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Tutorial 6 Creating Tables and CSS Layouts. Objectives Session 6.1 – Create a data table to display and organize data – Modify table properties and layout.
JavaScript Form Validation
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… HTML Lists, Tables and Forms v2.0.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
JavaScript Lecture 6 Rachel A Ober
D2L Notes Be sure to submit your link in the dropbox provided on D2L You can just upload an empty text file if a file upload is required Do not use D2L.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
JAVASCRIPT QUIZ BOWL By: Joseph Lindo. Quiz Bowl Mechanics  Group w/ 5 maximum members  Question is presented at the board  Prepare piece of papers.
CS 174: Web Programming September 30 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
GREP. Whats Grep? Grep is a popular unix program that supports a special programming language for doing regular expressions The grammar in use for software.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
LING 408/508: Programming for Linguists Lecture 14 October 19 th.
LING 408/508: Programming for Linguists
LING 408/508: Programming for Linguists Lecture 12 October 7 th.
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
Word Processor Version.01 EME 4411 Week 5. The Scroll Bars.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Radio Buttons. Input/Form/Radio Group Use the dialog to enter label and values for the radio buttons.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Microsoft Excel 2007 Noris Bt. Ismail Faculty of Information and Communication Technology Tel : (Ext 8408) BCOMP0101.
Tutorial 6 Creating a Web Form
1 Week 8 Final Project Planning & Chapter 6 JavaScript Advanced Web Development IT225 Spring Term 2016 Marymount University School of Business Administration.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Introduction to.
CSE 154 Lecture 17: HTML tables.
Applying CSS to Tables Stylish Tables.
CS 371 Web Application Programming
JavaScript functions.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
CHAPTER FIVE Decision Structures.
Web Programming– UFCFB Lecture 17
CHAPTER FIVE Decision Structures.
Table CSS Create a new CSS called tablestyle.CSS Green Background
Introduction to DOM.
Lecture 25: SQL and HTML tables
In Class Programming BIS1523 – Lecture 11.
© 2015, Mike Murach & Associates, Inc.
PHP.
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
JavaScript Basics Topics Review Important Methods Writing Functions
Make a Heading and sub-headings.
Presentation transcript:

LING 408/508: Programming for Linguists Lecture 13 October 7 th

Administrivia Homework 4 review

Homework 4 Review

15 Puzzle div { font-size: x-large } table { border: medium solid blue } td { border: 1px solid blue; font-size: xx-large; width: 45px; height: 45px; text-align: center; vertical-align: middle } td:hover { background: yellow }

Homework 4 Review var empty_r = 3; var empty_c = 3; function f(e) { if (can_move(e)) { move(e); if (solved()) { msg("Solved!") } } } function msg(s) { document.getElementById("msgline").innerHTML = s } function can_move(e) { var row = e.parentElement.rowIndex; var col = e.cellIndex; return ((row == empty_r && Math.abs(col - empty_c) == 1) || (col == empty_c && Math.abs(row - empty_r) == 1)); }

Homework 4 Review function set_empty(e) { var row = e.parentElement.rowIndex; var col = e.cellIndex; var td = document.getElementById("puzzle").rows[row].cells[col]; td.innerHTML = ""; td.style.border = "initial"; empty_r = row; empty_c = col } function empty_td() { var t = document.getElementById("puzzle"); var tr = t.rows[empty_r]; var td = tr.cells[empty_c]; return td } function move(e) { var empty = empty_td(); empty.innerHTML = e.innerHTML; empty.style.border = "1px solid blue"; set_empty(e) }

Homework 4 Review function random_td() { var row = Math.floor(Math.random() * 4); var col = Math.floor(Math.random() * 4); return document.getElementById("puzzle").rows[row].cells[col]; } function shuffle() { if (typeof shuffle.times == "undefined") { shuffle.times = 100 } for (var i = 0; i < shuffle.times; i++) { var e = random_td(); if (can_move(e)) { move(e) } } shuffle.times += 100; msg(""); }

Homework 4 Review var answer = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; function solved () { for (var i=0; i < answer.length; i++) { if (cell_list[i].innerHTML != answer[i]) { return false } } return true }

Homework 4 Review 15 Puzzle Tiles: Shuffle Reset

Homework 4 Review document.getElementById("puzzle").rows[3].cells[3].style.border = "initial"; var cell_list = document.getElementById("puzzle").getElementsByTagName("td");

Javascript/SVG BMI Last time, we modified our plain Javascript BMI code to incorporate the SVG gauge … – there were one or two problems …

Javascript/SVG BMI Code from last lecture: var gauge; window.onload = function() { gauge = new GaugeSVG({id: "gauge-div", value: 10, min: 10, max: 40, label: "BMI", lowerWarningLimit: 18.5, upperWarningLimit: 25, warningLowerRangeColor: "#eeee00", warningUpperRangeColor: "#ff8800", actionRangeColor: "#ff0000", upperActionLimit: 30, lowerActionLimit: -1}); gauge.gaugeVAL.childNodes[0].textContent = ""; }; function computeBMI(e) { var weight = e.form.weight.value; var height = e.form.height.value; var scalingfactor = e.form.units[0].checked ? : 703; var bmi = weight * scalingfactor / (height * height); var div = document.getElementById("output"); var range; if (bmi < 18.5) { range = "underweight" } else if (bmi < 25) { range = "normal" } else if (bmi < 30) { range = "overweight" } else { range = "obese" } gauge.refresh(bmi.toFixed(2),true); } {property: value, … }

Javascript/SVG BMI Javascript BMI Weight (kg/lbs): Height (cm/ins): kg-cm lbs-ins

Data validation Typically, form data is sent to a webserver. For efficiency: validation can be done using Javascript on the browser side and data sent to the webserver only when validated. Example (we'll use this in later lectures): – – … – BMI example: – make sure weight and height fields contain numeric data when the user clicks the button

Data validation Several possible ways: Use the string.match() method with a regular expression, e.g. /^[0-9\.]+$/, that permits only digits and decimal points – x.match(/^[0-9\.]+$/) or the regular expression test method – /^[0-9\.]+$/.test(x); or convert to 32-bit integer for bitwise or, > 0 and no fractional part after dividing by 1 – ((x | 0) > 0 && x % 1 == 0)

Regular Expressions Regular expressions (regex) are used in many natural language applications to search for and extract patterns. – LING 438/538: Perl regular expressions Javascript has a (relatively simple) regex engine: – Introduction: –