basti1012.bplaced.net

Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
    Fragen sie die aktuellen Bitcoin Preise mit dieser Api ab

    Code

                                        
                                    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
    
    
    
    <style>
      body {
      margin-top: 30px;
    }
    
    h1 {
      font-size: 60px;
      margin-bottom: 30px;
    }
    
    .table {
        border-radius: 5px;
        width: 50%;
        margin: 0 auto;
        margin-top: 30px;
        margin-bottom: 30px;
        float: none;
    }
    </style>
    
    <div class="container-fluid">
      <div class="row">
                <div class="col-md-12">
    <h1 class="text-center">Bitcoin Price</h1>
    </div>
      </div>
      <div class="row">
        <div class="col-md-3 col-md-offset-1 col-sm-4">
    <h2 class="text-center usd-price"></h2>
    </div>
            <div class="col-md-4">
    <h2 class="text-center gbp-price"></h2>
    </div>
            <div class="col-md-3 col-sm-4">
    <h2 class="text-center aud-price"></h2>
    </div>
      </div>
      <div class="row">
      <div class="col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1 prices">
      </div>
      </div>
    </div>
    <script>
      $(document).ready(function() {
          $.getJSON("https://blockchain.info/ticker?cors=true", function(json) {
            var html = "";
            var usd = "";
            var gbp = "";
            var aud = "";
            
            html = '<table class="table"><thead><tr><th>Currency</th><th>Price</th></thead><tbody>';
            jQuery.each(json, function(key, val) {
              html += "<tr><td><strong>" + key + "</strong></td><td>" + val["last"] + "</td></tr>"
              
              if (key == "USD"){
                usd += val["last"] + " " + key
              }
              else if (key == "GBP"){
                gbp += val["last"] + " " + key
              }
              else if (key == "AUD"){
                aud += val["last"] + " " + key
              }
            });
            html += "</tbody></table>";
            $(".prices").html(html);
            $(".usd-price").html(usd);
            $(".gbp-price").html(gbp);
            $(".aud-price").html(aud);
        });
    });
    </script>