-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.js
52 lines (39 loc) · 1.74 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// function randomImg(){
// var randomNumber = Math.floor(Math.random() * 10) + 1;
// var imgName = "img_" + randomNumber + ".jpg";
// document.getElementById("imageid").src= YOUR_IMG_PATH + "/" + imgName ;
// }
filePath = [];
$.ajax({
type: "GET",
url: "random_image.csv",
dataType: "text",
async: false,
success: function(artCollection) {
filePath = artCollection.split('\n');
// console.log(filePath[0]);
}
});
var randomNumber = [Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,
Math.floor(Math.random() * filePath.length) + 1,];
console.log(randomNumber);
console.log(filePath[randomNumber[0]], filePath[randomNumber[1]],filePath[randomNumber[2]],filePath[randomNumber[3]],
filePath[randomNumber[4]],filePath[randomNumber[5]],filePath[randomNumber[6]],filePath[randomNumber[7]],filePath[randomNumber[8]]);
for (i=1;i < 10; i++)
{
document.getElementById('painting1').innerHTML = i;
console.log("hi");
//"<img src="+filePath[randomNumber[i-1]]+">";
}
// function randomImg(){
// var randomNumber = Math.floor(Math.random() * 12) + 1;
// var imgName = "img_" + randomNumber + ".jpg";
// document.getElementById("greenbox").src= "YOUR_IMG_PATH" + "/" + imgName ;
// }