aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4131/lec/lec7big3/RandomPicture.js
blob: b5f4d7316349f759fcfbb7d49a177e8aeeb57472 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var iconImg;

function randImage() {
    var index = Math.floor(Math.random()*7);
    
    var pictures = ["CPE", "EPT", "GPP", "GUI", "PERF", "PORT", "SEO"];
    var descriptions = ["Common Programming Error",
        "Error-Prevention Tip", "Good Programming Practice",
        "Look-and-Feel Observation", "Performance Tip", "Portability Tip",
        "Software Engineering Observation"];
    
    iconImg.src = pictures[index] + ".png";
    iconImg.alt = descriptions[index]; 
}

function start() {
    iconImg = document.getElementById("image");
    iconImg.addEventListener("click", randImage, false);
}

window.addEventListener("load", start);