Surprise! This week I will have done 2 modules for LIS 4365. This module goes more in depth with using JavaScript and saving images to the web.
My Second JavaScript
I have already made wrote one JavaScript program that had user interaction and if statements, which can be found here. For this one I wanted to write something simple that did not require user interaction. So I took the example code from the module and extended it a little bit to include 4 different greetings based on the time of day. I added the script to my other website, the full script and HTML are at: http://simon-liles.epizy.com/Module4.html
Debugging
For this module I was given some code that needed debugging. Below is the original code.
<!DOCTYPE html>
<html>
<body>
<p id="demo">Display the result here.</p>
<script>
var greeting;
var hour = new Date().getHours();
if (hour < 18) {
greeting = "Good day";
else
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
</script>
</body>
</html>
Code language: HTML, XML (xml)
To fix this code, I add the missing curly braces that belong in the if statement block. Now the code looks like the following.
<!DOCTYPE html>
<html>
<body>
<p id="demo">Display the result here.</p>
<script>
var greeting;
var hour = new Date().getHours();
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
</script>
</body>
</html>
Code language: HTML, XML (xml)
And here is the result of the code running which provides a simple greeting:
Display the result here.
Saving an Image for the Web
The last piece I had to do for this assignment was to use Photoshop to save an image for the Web. For this I used a photo of a sunset I took in Brunswick, Georgia last summer.
The image has lost a lot of its original quality, but most of that was from me downscaling it. Surprisingly it does not have a lot of artifacts in the image like I had mentioned in my previous post. I have found using Adobe Photoshop is not terribly difficult. It seems easy to learn, but is difficult to master.