aboutsummaryrefslogtreecommitdiff
path: root/index.html
blob: d66fff636dc44bdbd01f1047bfe26b2ac64fabbf (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>color;)</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <style>
      #jstext {
  text-align: center;
  font-size: 900px;
}
}
    </style>
  </head>
  <body>
    
    
     <script>
     let file = "./crates.json"
       
function min(item){
      console.log(item)
        x = document.getElementsByClassName(item)

    //x[i].outerText="\ncontents: [ ... ] <div class='"+item+"'>"; 

    x[0].hidden=!x[0].hidden
    
      }
   function roll(item) {
     fetch(file)
.then(response => {
   return response.json();
})
.then(data => {
       //console.log(data.crates[item].contents[Math.floor(Math.random()*data.crates[item].contents.length)])
      var x = document.getElementById("popup");
  if(x.style.display != "block"){ //anti spam check thingy
    x.style.display = "block";
  
  x.innerHTML="you unboxed:</br></br><code> >> "+(data.crates[item].contents[Math.floor(Math.random()*data.crates[item].contents.length)].color) + (' ( r = '+data.crates[item].contents[Math.floor(Math.random()*data.crates[item].contents.length)].rarity+ " && value = " +data.crates[item].contents[Math.floor(Math.random()*data.crates[item].contents.length)].value + ")</code>").fontsize(1)
  x.style.background=(data.crates[item].contents[Math.floor(Math.random()*data.crates[item].contents.length)].color)
  setTimeout(function() { document.getElementById("popup").style.display = "none"; }, 3000);
  }

})
      
    } 
       fetch(file)
.then(response => {
   return response.json();
})

.then(data => {

    
    console.log(data)
    for(let crate of data.crates){
      document.write("</br>price: "+crate.price)
      document.write("</br>name: "+crate.name)
      document.write("<div onclick='min(\""+data.crates.indexOf(crate)+"\")'</br>contents: [<div class='"+data.crates.indexOf(crate)+"'>")
      for(let item of crate.contents){
        if(item==crate.contents[0]){
        document.write("{color:"+item.color+", rarity:"+item.rarity+", value:"+item.value+"}")
        } else {
        document.write("</br>{color:"+item.color+", rarity:"+item.rarity+", value:"+item.value+"}")
        }
        
      }
      document.write("</br></div>]</div>")
      x = document.getElementsByClassName(data.crates.indexOf(crate))
      x[0].hidden=true
    //x[i].outerText="\ncontents: [ ... ] <div class='"+item+"'>"; 

    
    
      document.write("</br><button onclick='roll("+data.crates.indexOf(crate)+")'>roll</button>")
    //document.write("<p>" + d.crates[0].price + "</p>")
      
      
      }
    
  
  return(0)
  }).then((open)=>{
var number = 5; //just for an example
//------------^ // Not sure but ; is a must in some places.
document.write('<div id = "popup"style="height:50%;position:absolute;width:100%;top:25%;background: #1a1a1a;color:#fff;">null</div>')
  
  var x = document.getElementById("popup");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }



})   
  //

    
    </script>
  

  </body>
</html>