grctest / Gridcoin-Site

Open source Gridcoin website -- CM's fork
https://github.com/gridcoin-community/Gridcoin-Site/
MIT License
6 stars 8 forks source link

Scripts gathering external website data #18

Closed grctest closed 7 years ago

grctest commented 7 years ago

Could grab:

We need to change the cross site scripting security though & we shouldn't make the website too slow nor tacky/bulky.

Has to be JS, we don't have access to the underlying web server terminal.

startailcoon commented 7 years ago

As soon as I've completed the upgrade of Gridcoinstats I can supply the Gridcoin webpage with API access, trough JS, to the basic functions. This would include functions like latest block number and exchange prices (gathered by gridcoinstats).

Timeframe: 1-2 months

startailcoon commented 7 years ago

Two Public functions that can be used for the webpage for latest Projects status, Active (whitelisted) or Inactive and latest Block information on the chain.

Latest Projects Data: https://www.gridcoinstats.eu/API/api.php?a=getProjectData

Data: Array(
 "active"=>Array(name=>string, url=>string, lastActive=>date),
 "inactive"=>Array(name=>string, url=>string, lastActive=>date)
)

Latest Block Data: https://www.gridcoinstats.eu/API/api.php?a=getLastBlock Data: Array(id=>string, hash=>string, blockTime=>date, blockDiff=>double, totalBlockMinted=>double)

startailcoon commented 7 years ago

Coinmarketcap has a public API for grabbing the latest price feed for Gridcoin. https://api.coinmarketcap.com/v1/ticker/gridcoin/

[
    {
        "id": "gridcoin", 
        "name": "GridCoin", 
        "symbol": "GRC", 
        "rank": "92", 
        "price_usd": "0.0571596", 
        "price_btc": "0.00002416", 
        "24h_volume_usd": "486330.0", 
        "market_cap_usd": "22310121.0", 
        "available_supply": "390312753.0", 
        "total_supply": "390312753.0", 
        "percent_change_1h": "4.06", 
        "percent_change_24h": "-2.65", 
        "percent_change_7d": "-31.33", 
        "last_updated": "1498590012"
    }
]
startailcoon commented 7 years ago

Sample code to get this working with jQuery

    function loadBlocksData() {
      var request = $.ajax({
        url:'https://www.gridcoinstats.eu/API/api.php?a=getLastBlock',
        crossDomain: true,
        dataType: 'json',
      });
      request.done(function(data) {
        $('#blockDataDiv').append('Block ID: ' + data['id'] + ', Block Hash: ' + data['hash'] + ', Time: ' + data['blockTime']);
      });
    }

$(document).ready(function() {
     loadBlockHeaders();
});
grctest commented 7 years ago

This issue has arisen again regarding the slack invite portal being added to the gridcoin website.

barton2526 commented 7 years ago

I can change the cross site scripting file to accommodate these and the slack scripts.

grctest commented 7 years ago

This issue was moved to gridcoin-community/Gridcoin-Site#6