LING 408/508: Computational Techniques for Linguists

Slides:



Advertisements
Similar presentations
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything Text Lists Other tables Pictures …
Advertisements

LING 408/508: Programming for Linguists Lecture 12 October 2 nd.
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.
LING 408/508: Programming for Linguists Lecture 13 October 7 th.
JQuery A Javascript Library Hard things made eas(ier) Norman White.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Computer Technology Timpview High School. Columns vs. Rows  Columns run vertically; rows runs horizontally  A cell is where a column and row meet.
Chapter 3 Tables and Page Layout
Computing Concepts Advanced HTML: Tables and Forms.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
HTML. Creating a Table Attributes: border: indicates the border type of the table Value: 0 (no border), 1, 2, etc. cols: indicates the number of columns.
HTML Tables. Start of page where we want to place a table.
Creating Tables in a Web Site.  Define table elements  Describe the steps used to plan, design, and code a table  Create a borderless table to organize.
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.
INTRODUCTORY Tutorial 7 Creating Tables. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Discern the difference between data tables and.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
JS: Document Object Model (DOM)
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… HTML Lists, Tables and Forms v2.0.
JavaScript Lecture 6 Rachel A Ober
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
IS1824: Introduction to Internet Multimedia Lecture 5: Layout in HTML Rob Gleasure
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
CIS234A Lecture 8 Instructor Greg D’Andrea. Review Text Table contains only text, evenly spaced on the Web page in rows and columns uses only standard.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Web Foundations WEDNESDAY, NOVEMBER 20, 2013 LECTURE 32: DREAMWEAVER SLIDE SHOW AND GOOGLE MAP.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
Paper 3 Unit 15 – Web Authoring Software Choices Graphics Exporting Graphics Creating CSS RGB Colour CSS – Body, Table and TD Border Collapse Tables -
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.
1 Creating the Home Page. 2 Creating a Table Table attributes  Two rows and two columns  No border  Left-aligned Change the vertical alignment of the.
LING 408/508: Programming for Linguists Lecture 11 October 5 th.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Positioning Objects with CSS and Tables
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
CSE 154 LECTURE 9: THE DOM TREE. The DOM tree The elements of a page are nested into a tree-like structure of objects the DOM has properties and methods.
XML DOM Week 11 Web site:
HTML Help book. HTML HTML is the programming language used to make web pages for the Internet. HTML stands for Hyper Text Markup Language. HTML is made.
1 The Document Object Model. 2 Objectives You will be able to: Describe the structure of the W3C Document Object Model, or DOM. Use JavaScript to access.
CSE 154 Lecture 17: HTML tables.
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Organizing Content with Lists and Tables
Elements of HTML Web Design – Sec 3-2
CGS 3066: Web Programming and Design Spring 2017
CS 371 Web Application Programming
Positioning Objects with CSS and Tables
JavaScript functions.
CGS 3066: Web Programming and Design Spring 2017
Chapter 5 Introduction to XHTML: Part 2
Microsoft Word: Tables
Document Object Model (DOM): Objects and Collections
Tutorial 6 Creating Dynamic Pages
© 2015, Mike Murach & Associates, Inc.
Creating Tables in a Web Site
LING 408/508: Computational Techniques for Linguists
CSc 337 Lecture 9: The DoM tree.
Principles of Web Design 5th Edition
Make a Heading and sub-headings.
Positioning Objects with CSS and Tables
Presentation transcript:

LING 408/508: Computational Techniques for Linguists Lecture 16

Administrivia Homework 6 due next Monday

Last Time

Let's add an input field HTML: Javascript: <p> Input: <input id="in"> <button onclick="enter()">Enter</button> </p> Javascript: function enter() { var e1 = document.getElementById("c5"); var e2 = document.getElementById("in"); e1.innerHTML = e2.value; }

Let's add a record of the inputs Javascript: e3 = document.createElement("div"); document.getElementsByTagName("body") [0].appendChild(e3); document.createElement(Tag) creates a HTML element. document.getElementsByTagName("body") returns an array of values. The 0th member of the array is the first (and only) body in this document e1.appendChild(e2) adds e2 to e1 as its last child

Document Object Model (DOM) Locating an element: document.getElementById(id) useful if you have named the document element using the id=‘Name’ property document.getElementsByTagName(tag) all document elements of type tag returns an array e.getElementsByTagName(tag) all elements of type tag under el document.getElementsByName(name) useful for elements that support name=‘Name’ (document|e).getElementsByClassName(class) (document|e).querySelector(query) example query ‘BODY > UL > LI’ ‘>’ means immediately dominates returns first matching element (document|e).querySelectorAll(query)

Document Object Model (DOM) New content: document.createElement(tag) tag = ‘div’, ‘p’ etc. creates new DOM element document.createTextNode(text) creates new DOM element of type text For non-HTML elements: document.createElementNS(NS,tag) NS = Namespace URL identifier e.g. http://www.w3.org/2000/svg and tag “rect” (rectangle) Place new_el: e.appendChild(new_el) new_el is inserted as last child of el e.insertBefore(new_el,next_el) new_el inserted as previous sibling of next_el el is common parent e.removeChild(child_el) child_el is deleted el is parent e.replaceChild(new_el,child_el) new_el replaces child_el Old way: document.write(text) document.writeln(text) adds a newline

Document Object Model (DOM) Properties for traversing the DOM: e.childNodes children of element el as an array, e.g. childNodes[0] e.children element nodes only (excludes text nodes) e.firstChild e.lastChild e.parentNode e.nextSibling e.previousSibling Object properties: e.nodeType 1 = element, 3 = text e.nodeName uppercase e.innerHTML for element nodes value is html as text writeable e.nodeValue for text nodes (null: for element nodes)

boxes.html

boxes.html Hover: Click:

Adding a reset button Button tag: Reload page method: <button type="button">Click Me!</button> Reload page method: location is an object that contains information about the current page location.reload() is a method that reloads the page (from the cache)

Homework 6 Tasks/Questions: Write a html/Javascript program that simulates the 15 puzzle. Tasks/Questions: It should bring up a html page that allows the user to manually click on and move the tiles It should be able to initially jumble the tiles Hint: use the Math.random() method from last lecture It should recognize and print a message when the user solves the puzzle Image from wikipedia

Homework 6 Example:

Homework 6 DOM code to locate a specific td by row r (0-3) and col number c (0-3): document.getElementById("puzzle").rows[r].cells[c];

Homework 6 Table layout: table cell: row number: column number: <td onclick="f(this)">..</td> <script> function f(e) { .. code .. } </script> row number: e.parentElement.rowIndex column number: e.cellIndex

Homework 6 <style> td { border: 1px solid blue; width: 30px; height: 30px; text-align: center; vertical-align: middle } td:hover { background: yellow </style> <script> function f(e) { var row = e.parentElement.rowIndex; var col = e.cellIndex; alert("row:" + row + " col:" + col) </script>

Homework 6 You're going to have to do some arithmetic… Table layout: You're going to have to do some arithmetic… Example: suppose the empty cell is row:2 col:1 Which cells can move into the empty cell? Hint: Math.abs(x) might be a useful method

Homework 6 Your goal is to define that function f to simulate moving the tiles: <td onclick="f(this)">1</td> What is the this argument? What can you do with the object? set attribute values, e.g. set content, e.g. e.innerHTML = "3" find row and column numbers (see earlier slides)

Homework 6 Note: the innerHTML property of this TableCell is undefined! i.e. there is no document.getElementById("puzzle").rows[3].cells[3].innerHTML Solution: put a real "space" in there can also use HTML nonbreaking space:   tricky!