COMP 3540 Advanced Web Design and Programming Term Test III – Winter 2015 Student Name: Student Number: 1. (9 marks) Short answer questions about JavaScript. a) Can you assign a function to a variable? b) Give two different styles to access object properties/methods. c) What object is used for the global scope? d) What kind of bracket is used to create an object? e) Is a function an object? f) How can you create an object prototype? g) What is a function closure? h) What object is used to store data locally within the web browser? i) Which HTTP method should be used to upload a file or files? 2. (4 marks) Short answer questions about PHP. a) What keyword is used for class constructors? b) What operator is used to access object properties and methods? c) How are public and private properties different? d) Which super global variable keeps the information of uploaded files? 3. (4 marks) Write the JavaScript code that creates an object named ‘golf’ that includes Private properties: year, color Public methods: getYear(), getColor(), setYear(), setColor() You should use the module pattern. 4. (2 marks) Here are two objects, apple and banana. function Fruit(name, color) { this.name = name; this.color = color; this.getInfor = function() { return name + ', ' + color; }; } var apple = Fruit('apple', 'red'); var banana = Fruit('banana', 'yellow'); a) You would like to add a new property named ‘origin’ so that the above two objects can use this new property. Give an example how you can do this. You should use just one assignment statement. b) You would like to add a new property named ‘size’ only to ‘apple’, not ‘banana’. Give an example how to do this. 5. (2 marks) The JavaScript code in an iframe needs to change the content of an HTML element in the parent window. The HTML element has an id ‘msg’. The new content is ‘Wow! Amazing technologies’. Show how to change the content of the HTML element in the parent window. 6. (2 marks) Give an example to display the data stored in the local storage. The name of the data is ‘courseName’, and you can use the write() method in document to display the data. 7. (4 marks) Write the HTML code that selects multiple files and uploads them to ‘upload.php’. 8. (4 marks) Write the JavaScript that selects elements in the CSS class ‘panel’ and slides them down when they are clicked. You should use jQuery.