WML II (“Son of WML”) WML WMLScript. WML - A Quick Review Document structure ,... Text and image controls ...,,..., Navigation controls ,,, Events.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, September 19, 2013 Session 3: JavaScript.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
Java Script Session1 INTRODUCTION.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript for Python Programmers
Introduction to scripting
CST JavaScript Validating Form Data with JavaScript.
1 Introduction to PHP. 2 What is this “PHP” thing? Official description: “PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
WML, WMLS More acronyms than you can shake a stick at!
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Lectured By: Vivek Dimri Assistant Professor, CSE Dept. SET, Sharda University, Gr. Noida.
WAP and WML The Wireless Application Protocol  WAP architecture  WML document structure  WML syntax Basic document syntax Layout Text formatting Images.
JavaScript – Part II Data Types and Operations George Mason University June 3, 2010.
Introduction to Python
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Chapter 4 JavaScript and Dynamic Web pages. Objectives Static Web pages Dynamic Web pages JavaScript Variables Assignments. JavaScript Functions –(prompt(“”,””)
WML What is WML? WML stands for Wireless Markup Language. It is a mark-up language inherited from HTML, but WML is based on XML, so it is much stricter.
Using Client-Side Scripts to Enhance Web Applications 1.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 - Wireless Internet and m- Business Outline 23.1 Introduction 23.2 M-Business 23.3 Identifying.
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
1 Server versus Client-Side Programming Server-SideClient-Side.
WML & WML Script Presented by Kelvin Liu 01/06/2000.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
PHP Form Processing * referenced from
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
OVERVIEW OF CLIENT-SIDE SCRIPTING
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
CHAPTER 10 JAVA SCRIPT.
HTML & teh internets.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Introduction to Scripting
Introduction to JavaScript
Variables and Arithmetic Operations
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Fundamentals of Functional Programming
Tutorial 10: Programming with javascript
JavaScript: Introduction to Scripting
Presentation transcript:

WML II (“Son of WML”) WML WMLScript

WML - A Quick Review Document structure ,... Text and image controls ...,,..., Navigation controls ,,, Events  onenterforward, onenterback, ontimer  ...,... Variables , $(foo)

WML - Examples A minimal WML file Hello world!

WML - Examples Loading an image-- Hello world!

WML - Examples Using a softkey-- Hello world! Hello world!

WML - Examples Using a link-- Hello world! Link to Card 2 Hello world!

WML - Examples Using a timer-- Hello world! Hello world!

WML - Examples Table layout-- Hello world!

WML - Input Revisited Last name : Gender : Female Male Display Welcome, $(salutation) $(name), to my wireless underground volcano lair.

WML - Input Revisited The tag:  Use to record variable user input  name="variable" : required  Can specify format ex: “NNNNN” maps to exactly five digits. “NNaaaa” maps to two digits followed by four letters. The phone won’t accept anything else.  Can specify type=“password” for secure (ie hidden) entry  Can specify maxlength=“...” for the max number of characters of data the user can enter  How the phone chooses to render the input box is up to the phone. Don’t depend on there being, say, a little black box.

WML - Input Revisited The tag:  Use to limit user entry between several possible options  Can be used for links, as well  name="variable” is optional; can just use onpick (below).  multiple=“true” or “false” : allow multiple selections. In the case of multiple selections, the values are stored as a semicolon-delimited list.  value=“...” : sets the default value of the tag’s variable The tag:  Defines a single entry in a  value=“...” determines the value that this option sets for the variable named by the enclosing tag  onpick=“url” : when the user selects this option, links directly to another card or page.  You can also catch “onpick” events from the tag.

WML - Input as Navigation Choose a lair: Volcano Underground Welcome to my wireless volcano lair. Welcome to my wireless underground lair.

WMLScript WMLScript is similiar to JavaScript in function; it allows a more powerful and controllable degree of scripting control than offered by simple WML. WMLScript offers a decent range of string- manipulating and mathematical functions. Each WMLScript file is full of functions. Each function is either local--used only within the file-- or external--accessible from other WMLS and WML files.  To declare a function extern, put the word extern before its declaration.

WMLScript - Functions Within each function, you’ll write WMLScript code. Syntax:  var n = 1; // Declares a variable named ‘n’  n = 2; // Assigns n the value 2  if (n==3)... // Test if n equals 3. // Note that ‘=‘, assignment, is not the // same as ‘==‘, which tests equality.  You’ve got the full set of if-then tests, loops and so on... for (var index = 0; index < 100; index++) { myFunc(index); };

WMLScript - Functions Declaring a function of your own:  Ex: extern function getHello() { return “hello!”; }  Ex: extern function addOne(n) { return n+1; }  Ex: extern function addVals(n, m) { return n+m; }

WMLScript - Functions When you declare a function, it can call other functions: extern function myFunc() { var n = 2;// Initialise n to 2 n = myOtherFunc(n);// Call myOtherFunc() return n; // n is now 4 (n * n) } function myOtherFunc(n)// Note--not extern { return n * n;// Take n and return n squared }

WMLScript - Functions The WMLScript Libraries:  Lang (miscellaneous routines)  Float (real numbers)  String (character string manipulation)  URL (HTTP string routines)  WMLBrowser (browser interraction)  Dialogs (user interraction)  Console (debug output) Each library defines a set of functions that can be called from your code. For details on each library, consult the reference materials online.

WMLScript - Functions A few common standard library routines:  WMLBrowser.getVar( )// gets a var’s value  WMLBrowser.setVar(, )// sets a var’s value  WMLBrowser.refresh()// reload this page  WMLBrowser.go(url)// go to a url  Lang.isInt( )// Test for a number  Lang.parseInt( )// Convert to a number Some common language statements:  if ( ) else  for ( ; ; )...  while ( )...  return ;// Sets the value of // a function call

WMLScript - Calling WMLS from WML Value : $(myVar) Click here to increment the value. extern function increment() { var myVar = WMLBrowser.getVar("myVar"); WMLBrowser.setVar("myVar", myVar + 1); WMLBrowser.refresh(); } What will this code do?

WMLScript - Calling WMLS from WML extern function increment() { var myVar = WMLBrowser.getVar("myVar"); WMLBrowser.setVar("myVar", myVar + 1 ); WMLBrowser.refresh(); } What’s going on here?

WMLScript - What happened back there? Variable types  The problem was that variables in WMLScript don’t have a type associated with them. WMLS doesn’t know whether they’re character strings or numbers.  Since “+” will add two numbers or glue together two strings (1+1=2, but ‘abc’+’def’=‘abcdef’), WMLS just assumed we wanted string concatenation.  To make sure we use integer math, use the Lang library’s toInt() function to force the variable type to an integer: extern function increment() { var myVar = WMLBrowser.getVar("myVar"); if (!Lang.isInt(myVar)) myVar = 0; WMLBrowser.setVar("myVar", Lang.parseInt(myVar) + 1); WMLBrowser.refresh(); }

WMLScript - Initialisation and conditions Initialising a variable in WML: Value : Click here to test the value. The value is $(myOddity).

WMLScript - Initialisation and conditions Testing a value in WMLS: extern function testValue() { var myVar = Lang.parseInt(WMLBrowser.getVar("myVar")); if (((myVar / 2) * 2) == myVar) WMLBrowser.setVar("myOddity", "even"); else WMLBrowser.setVar("myOddity", "odd"); WMLBrowser.refresh(); } And the result:

WMLScript - Recursion “Recursion”  Recursion is the term for when a function calls itself. When you write recursive code, take care : make sure that there’s always a way out!  Ex: In mathematics, the phrase “N factorial” means “if N is some number, then multiply all of the numbers from 1 to N together”. You could say that a little more easily as “if N is some number, then multiply N times N minus one, factorial”. You’ve defined factorial in terms of itself. The shorthand for factorial is !. “N!” is “N factorial”. In other words, N!= N * (N-1)!.

WMLScript - Recursion Recursion - N Factorial (example)  N!: extern function recurseFactorial(n) { if (n > 1) return n * recurseFactorial(n-1); else return n; }  This defines N! in code. When you call recurseFactorial(n), it checks n; if n is greater than one, it calculates (n-1)! and then multiplies n onto the total. Since n-1 must eventually reach 1, eventually we’ll fall out of the loop.  Of course, that’s only true if n >= 1, right?

WMLScript - Recursion Enter N : Click here to find N! ("N factorial"). N! = $(nFact). extern function factorial() { var n = Lang.parseInt(WMLBrowser.getVar(" n")); if (n < 0) n = 0; WMLBrowser.setVar("nFact", recurseFactorial(n)); WMLBrowser.refresh(); } extern function recurseFactorial(n) { if (n > 1) return n * recurseFactorial(n- 1); else return n; }

Bibliography WML Language Reference:  WMLScript Reference:  All code used is available on the J: drive. No variables were harmed in the making of this lecture.