Native JavaScript in Hyperion Intelligence Unleashing the Power of Object- Oriented Programming.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
The Web Warrior Guide to Web Design Technologies
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
12-Jun-15 JavaScript Language Fundamentals I. 2 About JavaScript JavaScript is not Java, or even related to Java The original name for JavaScript was.
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.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Information Technology Center Hany Abdelwahab Computer Specialist.
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.
Tutorial 11 Working with Operators and Expressions
JavaScript, Third Edition
JavaScript Part 2 – Page 1 of 35CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: JavaScript Part 2.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 4: Fundamentals of JavaScript 4.1 Capabilities 4.2 Essential Terminology 4.3 Structure of JavaScript Code 4.4 Data and Objects 4.5 Tokens, Operators,
Chapter 3: Data Types and Operators JavaScript - Introductory.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 8 Cookies And Security JavaScript, Third Edition.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Input, Output, and Processing
Objects.  Java Script is an OOP Language  So it allows you to make your own objects and make your own variable types  I will not be going over how.
Using Client-Side Scripts to Enhance Web Applications 1.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Arrays.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
String Manipulation Chapter 15 This chapter explains the String facilities. You have already seen some of the main methods of the String class.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
CS346 Javascript -3 Module 3 JavaScript Variables.
4.4 JavaScript (JS) Deitel Ch. 7, 8, 9, JavaScript & Java: Similarities JS (JavaScript) is case-sensitive Operators –arithmetic: unary +, unary.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Functions and Arrays. Predefined Functions eval(condition) –Evaluates (executes) JavaScript syntax –Eval returns an undefined value parseInt(string) and.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming strings.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Tutorial 11 1 JavaScript Operators and Expressions.
Expressions and Data Types Professor Robin Burke.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Basic Objects. Math Object  Math.cos( x ), x in radians  Math.sqrt ( x )  Math.pow ( x, y )  Math.ceil( x )  etc.
11 JavaScript: Objects.
>> Introduction to JavaScript
Math class Random() method Floor method Top-level parseInt function
Basics of JavaScript Programming Language
SEEM4570 Tutorial 05: JavaScript as OOP
Scope, Objects, Strings, Numbers
Introduction to Scripting
Advanced Programming Behnam Hatami Fall 2017.
Objectives Insert a script element Write JavaScript comments
Chapter 8 JavaScript: Control Statements, Part 2
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
University of Kurdistan
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

Native JavaScript in Hyperion Intelligence Unleashing the Power of Object- Oriented Programming

What is JavaScript? Created in 1995 by Brendan Eich of Netscape as “LiveScript” Interpreted, object-oriented/procedural programming language Extensively used in web pages in conjunction with HTML Event-driven, case-sensitive, ignores extra spaces

How Does Hyperion Intelligence Use JavaScript? Introduced Netscape v1.4 JavaScript interpreter in v6.0 Supports all standard JavaScript commands Used in dashboards, computed items (except in query sections), calculated report fields and document scripts Proprietary object model

Proprietary Object Model Web object model uses objects like window, document, and location Hyperion object model uses objects like Application, ActiveDocument and ActiveSection Properties and methods will vary Core objects such as String, Number and Date will be unchanged

What About “_____”? We will not cover anything proprietary to Hyperion Intelligence We will not cover the basics (syntax, conditional statements, loops, etc.) We will not cover redundancies (for example, the concat() method of a string object) We will not cover advanced topics that would require a separate presentation altogether (for example, regular expressions) We will cover everything else!

Object-Oriented Programming Objects, sub-objects and object collections Methods – – Actions performed on or by an object – Called with parenthesis at the end to allow for the passing of parameters Properties – – Descriptive traits of objects – Sometimes read-only

Other JavaScript Terms Functions: parameters are passed in parenthesis returning a result Statements: cause an action or series of actions Operators: Used for mathematical calculations, value comparisons and shortcuts Constants: Built-in variables (Infinity, NaN, null and undefined)

Functions eval() – evaluates a string of code and (optionally) returns a result eval(“Alert(1)”) //returns no value var x = eval(“10 * 10”) //returns a value of 100

Functions (cont.) isFinite() – returns true if the number is neither positive nor negative infinity var x = isFinite(10) //returns true var x = isFinite(Infinity) //returns false

Functions (cont.) isNaN() – returns true if the parameter is not or cannot become a number var x = isNaN(10) //returns false var x = isNaN(“Adam12”) //returns true var x = isNaN(“1000”) //returns false

Functions (cont.) Number() – converts a non-numeric value to a numeric value var x = Number(“10”) //returns the numeric value 10 String() – converts any value to its string representation var x = String(10) //returns the string value “10”

Statements break – breaks a loop or conditional statement // - comments out a line of code /* - comments out several lines of code (closed with */) continue – opposite of break do{} while() – executes a loop at least once for(){} – executes a loop

Statements (cont.) function(){} – declares a local function if(){} else{} – executes a condition return – returns a value from a function var – declares a local variable while(){} – executes a loop with(){} – declares top level object with(ActiveDocument.Sections[“Query”]){ Name = “MyQuery” }

Statements (cont.) switch(){} – executes a conditional statement with multiple conditions possible switch(x){ case “A” : var y = 1 break case “B” : var y = 2 break default : var y = 3 }

Statements (cont.) try{} catch(){} – attempts to execute a statement in the try{} and executes the catch(){} if an error occurs throw – passes a value to the catch(){}

Statements (cont.) try{ if(x == 1){throw "Error 1"} else if(x == 2){throw "Error 2"} } catch(er){ if(er == "Error 1"){Alert(“Contact SysAdmin")} if(er == "Error 2"){Alert("Please Reload the page")} }

Operators Mathematical + Add/Concatenate ++ Increment += Add/Append - Subtract -- Decrement -= Subtract/Remove / Divide * Multiply % Modulus Comparison == Equal != Not Equal > Greater >= Greater or Equal < Less <= Less or Equal Assignment = Assign

Operators (cont.) Backslash Escaped \’ Quote \” Double Quote \\ Backslash \b Backspace \f Form Feed \n New Line \r Carriage Return \t Tab Logical && And || Or ! Not Special…

Operators (cont.) Question mark & colon – executes a single condition (rowCount > 0) ? var x = “Rows” : var x = “No Rows” new – creates an object function makeBook(title){this.Title = title} var book = new makeBook(“Don Quixote”) Alert(book.Title) //returns “Don Quixote” as a property

Operators (cont.) typeof – returns the type of object var x = typeof(10) // returns “number” var x = typeof(“ABC”) // returns “string” var x = typeof(true) // returns “boolean” var x = typeof(null) // returns “object” Methods & functions return “function”

Operators (cont.) Comma – used to separate multiple values delete – deletes an object, property or array element this – used to refer to the parent object Alert(this.Name) //returns the name of the object used

Objects String Number Date Array Math

String Object The length property returns the string length Methods include charAt(), charCodeAt(), fromCharCode(), indexOf(), lastIndexOf(), slice(), split(), substr(), substring(), toLowerCase(), toUpperCase() We will NOT be discussing regular expressions in this presentation

String Object - Methods String.charAt() – takes 1 argument, returns the character at the index of the argument var x = “AdamFranz” Alert(x.charAt(0)) // returns “A” String.charCodeAt() – takes 1 argument, returns the ASCII value of the character at the index of the argument Alert(x.charCodeAt(0)) // returns 65 (ASCII for “A”)

String Object – Methods (cont.) String.fromCharCode() – builds a character from the ASCII value specified in the argument Alert(String.fromCharCode(65)) // returns “A”

String Object – Methods (cont.) String.indexOf() – takes one or two arguments, returns the index of the first argument in the string (starting from the index of the second argument) Alert(x.indexOf(“a”)) // returns 2 Alert(x.indexOf(“a”, 4)) // returns 6 String.lastIndexOf() – same as above but returning the index of the last instance of the argument

String Object – Methods (cont.) String.slice() – returns a portion of the string between 2 specified indexes Alert(x.slice(1, 3)) // returns “da” String.split() – returns an array from the string being broken on a designated character var y = “A, B” var z = y.split(“,”) Alert(z[0]) // returns “A” Alert(z[1]) // returns “B”

String Object – Methods (cont.) String.substr() – returns a portion of the string starting at the index of the first argument for the length of the second argument (defaults to end of string) Alert(x.substr(2, 2)) // returns “am” String.substring() – basically the same as String.slice()

String Object – Methods (cont.) String.toLowerCase() – returns the string in all lower case Alert(x.toLowerCase()) // returns “adamfranz” String.toUpperCase() – opposite of above Alert(x.toLowerCase()) // returns “ADAMFRANZ”

Number Object Represents a solely numeric value Number.MAX_VALUE = e+308 Number.MIN_VALUE = 5e-324 Number.NaN, Number.NEGATIVE_INFINITY and NUMBER.POSITIVE_INFINITY for comparison purposes

Date Object It is always a good idea to explicitly declare dates before performing any comparisons, calculations or calling any methods var x = new Date(yourDateValue)

Date Object - Methods Date objects have a series of get & set methods used to return or set any specific portion of the date object A get method, such as getFullYear(), returns the year from the date object whereas a set method, such as setFullYear(), sets the year portion of the date to the argument passed A getUTC or setUTC gets or sets according to Universal Time (not discussed)

Date Object – Methods (cont.).getDate().getDay().getFullYear().getHours().getMilliseconds().getMinutes().getMonth()*.getSeconds().setDate().setDay().setFullYear().setHours().setMilliseconds().setMinutes().setMonth()*.setSeconds() * - zero-based, watch out!

Date Object – Methods (cont.) Date.getTimezoneOffset – returns the difference in minutes between local time and Greenwich Mean Time Date.getTime(), Date.parse() and Date.valueof() used to return the number of milliseconds since 1/1/1970

Array Object Contains a series of values of any datatype designated by their array index (starting with zero) The length property will return the total amount of elements in the specified array

Array Object - Methods Array.concat() – joins two or more array objects (passed as arguments) into a single array object (without effecting the original array) Array.join() – converts an array object to a string separated by the character used in the argument (or a comma by default)

Array Object – Methods (cont.) Array.pop() – removes the last element of an array Array.push() – adds an element specified as the argument to the end of an array and returns the new array length Array.shift() – removes and returns the first element of the array

Array Object – Methods (cont.) Array.slice() – Returns a new array from a portion of the original array starting at the index of the first argument and ending at the second (or to the end of the array by default) Array.sort() - re-indexes the array in ascending order by default or in the order provided as an argument in the form of a function

Array Object – Methods (cont.) Array.splice() – used to add, remove or replace elements of an array Array_name.splice(starting_index, how_many_to_remove, replacement_value_1, replacement_value_2, etc.)

Math Object A native object accessible by direct reference without requiring instantiation Used for performing calculations and to access unique mathematical values such as Pi, random numbers, etc. Includes geometrical properties and methods such as Math.tan for calculating Tangent (not discussed)

Math Object - Properties Math.E – Euler’s constant Math.LN10 – Natural logarithm of 10 Math.LN2 – Natural logarithm of 2 Math.LOG10E – Base 10 logarithm E Math.LOG2E – Base 2 logarithm of E Math.Pi – Pi Math.SQRT1_2 – 1 divided by sq. rt. of 2 Math.SQRT2 – Square root of 2

Math Object - Methods Math.abs(x) – returns the absolute value of x Math.ceil(x) – returns x rounded up to nearest whole number Math.exp(x) – returns Euler’s constant to the power of x Math.floor(x) - returns x rounded down to nearest whole number Math.log(x) – returns the natural logarithm (base E) of x

Math Object – Methods (cont.) Math.max(x,y) – returns the greater of x or y Math.min(x,y) – returns the lesser of x or y Math.pow(x,y) – returns x to the power of y Math.random() – returns a pseudo-random number (based on the current time) between 0 and 1 Math.round(x) – returns x rounded off Math.sqrt(x) – returns square root of x

Conclusion JavaScript is a powerful scripting language which extends beyond the Hyperion platform All applicable JavaScript is valid in Hyperion Intelligence JavaScript can be used in dashboards, document scripts, and any computed items (other than in a query) Get out there and get scripting!!!

Helpful Websites - an excellent JavaScript reference sample code and presentations available for download

The End fin